diff --git a/thousandeyes-sdk-administrative/test/conftest.py b/thousandeyes-sdk-administrative/test/conftest.py new file mode 100644 index 00000000..2edba7b3 --- /dev/null +++ b/thousandeyes-sdk-administrative/test/conftest.py @@ -0,0 +1,7 @@ +import sys +from pathlib import Path + +_repo_root = Path(__file__).resolve().parents[2] +_core_test_support = _repo_root / "thousandeyes-sdk-core" / "test" +if str(_core_test_support) not in sys.path: + sys.path.insert(0, str(_core_test_support)) diff --git a/thousandeyes-sdk-administrative/test/integration_test_utils.py b/thousandeyes-sdk-administrative/test/integration_test_utils.py new file mode 100644 index 00000000..34cbcff5 --- /dev/null +++ b/thousandeyes-sdk-administrative/test/integration_test_utils.py @@ -0,0 +1,37 @@ +# coding: utf-8 + +""" + Administrative API + + Manage users, accounts, and account groups in the ThousandEyes platform using the Administrative API. This API provides the following operations to manage your organization: * `/account-groups`: Account groups are used to divide an organization into different sections. These operations can be used to create, retrieve, update and delete account groups. * `/users`: Create, retrieve, update and delete users within an organization. * `/roles`: Create, retrieve and update roles for the current user. * `/permissions`: Retrieve all assignable permissions. Used in the context of modifying roles. * `/audit-user-events`: Retrieve all activity log events. For more information about the administrative models, see [Account Management](https://docs.thousandeyes.com/product-documentation/user-management). + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from thousandeyes_sdk.core.api_client import ApiClient +from thousandeyes_sdk.core.configuration import Configuration +from sdk_test_support.mock_server import ERROR_STATUS_HEADER, OPERATION_ID_HEADER, MockApiServer + +from .mock_manifest import OPERATION_MANIFEST + + +class IntegrationTestBase(unittest.TestCase): + def setUp(self) -> None: + self.server = MockApiServer(OPERATION_MANIFEST) + self.server.start() + configuration = Configuration(host=self.server.base_url, access_token="test-token") + self.api_client = ApiClient(configuration=configuration) + + def tearDown(self) -> None: + self.server.stop() + + def te_headers(self, operation_id: str, error_status=None): + headers = {OPERATION_ID_HEADER: operation_id} + if error_status is not None: + headers[ERROR_STATUS_HEADER] = error_status + return headers diff --git a/thousandeyes-sdk-administrative/test/mock_manifest.py b/thousandeyes-sdk-administrative/test/mock_manifest.py new file mode 100644 index 00000000..bfb0cf8e --- /dev/null +++ b/thousandeyes-sdk-administrative/test/mock_manifest.py @@ -0,0 +1,3252 @@ +# coding: utf-8 + +""" + Administrative API + + Manage users, accounts, and account groups in the ThousandEyes platform using the Administrative API. This API provides the following operations to manage your organization: * `/account-groups`: Account groups are used to divide an organization into different sections. These operations can be used to create, retrieve, update and delete account groups. * `/users`: Create, retrieve, update and delete users within an organization. * `/roles`: Create, retrieve and update roles for the current user. * `/permissions`: Retrieve all assignable permissions. Used in the context of modifying roles. * `/audit-user-events`: Retrieve all activity log events. For more information about the administrative models, see [Account Management](https://docs.thousandeyes.com/product-documentation/user-management). + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json + +from sdk_test_support.mock_server_types import ErrorResponseExpectation, OperationExpectation + +OPERATION_MANIFEST = { + + "create_account_group": OperationExpectation( + operation_id="create_account_group", + method="POST", + path="/account-groups", + path_param_examples={ + }, + success_status=201, + success_body=json.loads(""" + + { + "isCurrentAccountGroup" : true, + "organizationName" : "organizationName", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "accountGroupName" : "Account A", + "isDefaultAccountGroup" : true, + "aid" : "1234", + "orgId" : "12345", + "users" : [ { + "uid" : "235", + "lastLogin" : "2022-07-17T22:00:54Z", + "roles" : [ { + "roleId" : "35", + "name" : "Organization Admin", + "isBuiltin" : true, + "hasManagementPermissions" : true + }, { + "roleId" : "35", + "name" : "Organization Admin", + "isBuiltin" : true, + "hasManagementPermissions" : true + } ], + "name" : "User X", + "email" : "userx@thousandeyes.com", + "dateRegistered" : "2022-07-17T22:00:54Z" + }, { + "uid" : "235", + "lastLogin" : "2022-07-17T22:00:54Z", + "roles" : [ { + "roleId" : "35", + "name" : "Organization Admin", + "isBuiltin" : true, + "hasManagementPermissions" : true + }, { + "roleId" : "35", + "name" : "Organization Admin", + "isBuiltin" : true, + "hasManagementPermissions" : true + } ], + "name" : "User X", + "email" : "userx@thousandeyes.com", + "dateRegistered" : "2022-07-17T22:00:54Z" + } ] + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "accountGroupName" : "My testing account group", + "agents" : [ "105", "719" ] + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "delete_account_group": OperationExpectation( + operation_id="delete_account_group", + method="DELETE", + path="/account-groups/{id}", + path_param_examples={ + "id": '1234', + }, + success_status=204, + success_body=None, + success_content_type="application/json", + request_body_example=None, + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_account_group": OperationExpectation( + operation_id="get_account_group", + method="GET", + path="/account-groups/{id}", + path_param_examples={ + "id": '1234', + }, + success_status=200, + success_body=json.loads(""" + + { + "isCurrentAccountGroup" : true, + "organizationName" : "organizationName", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "accountGroupName" : "Account A", + "isDefaultAccountGroup" : true, + "accountToken" : "accountToken", + "aid" : "1234", + "orgId" : "12345", + "users" : [ { + "uid" : "235", + "lastLogin" : "2022-07-17T22:00:54Z", + "roles" : [ { + "roleId" : "35", + "name" : "Organization Admin", + "isBuiltin" : true, + "hasManagementPermissions" : true + }, { + "roleId" : "35", + "name" : "Organization Admin", + "isBuiltin" : true, + "hasManagementPermissions" : true + } ], + "name" : "User X", + "email" : "userx@thousandeyes.com", + "dateRegistered" : "2022-07-17T22:00:54Z" + }, { + "uid" : "235", + "lastLogin" : "2022-07-17T22:00:54Z", + "roles" : [ { + "roleId" : "35", + "name" : "Organization Admin", + "isBuiltin" : true, + "hasManagementPermissions" : true + }, { + "roleId" : "35", + "name" : "Organization Admin", + "isBuiltin" : true, + "hasManagementPermissions" : true + } ], + "name" : "User X", + "email" : "userx@thousandeyes.com", + "dateRegistered" : "2022-07-17T22:00:54Z" + } ], + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "ipv6Policy" : "force-ipv4", + "prefix" : "99.128.0.0/11", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "hostname" : "thousandeyes.com", + "keepBrowserCache" : true, + "agentState" : "online", + "localResolutionPrefixes" : [ "10.2.3.3/24", "10.2.3.3/24" ], + "serialNumber" : "FOC2218ABCD", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "utilization" : 25, + "testIds" : [ 281474976710706 ], + "clusterMembers" : [ { + "lastSeen" : "2022-07-17T22:00:54Z", + "serialNumber" : "FOC2218ABCD", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "agentState" : "online", + "targetForTests" : "1.1.1.1", + "name" : "Cluster member name", + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "utilization" : 25, + "network" : "AT&T Services, Inc. (AS 7018)", + "memberId" : "10", + "errorDetails" : [ { + "code" : "agent-version-outdated", + "description" : "Agent Version 0.1.1 (latest: 1.0.0)" + }, { + "code" : "agent-version-outdated", + "description" : "Agent Version 0.1.1 (latest: 1.0.0)" + } ] + }, { + "lastSeen" : "2022-07-17T22:00:54Z", + "serialNumber" : "FOC2218ABCD", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "agentState" : "online", + "targetForTests" : "1.1.1.1", + "name" : "Cluster member name", + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "utilization" : 25, + "network" : "AT&T Services, Inc. (AS 7018)", + "memberId" : "10", + "errorDetails" : [ { + "code" : "agent-version-outdated", + "description" : "Agent Version 0.1.1 (latest: 1.0.0)" + }, { + "code" : "agent-version-outdated", + "description" : "Agent Version 0.1.1 (latest: 1.0.0)" + } ] + } ], + "tests" : [ { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + }, { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + } ], + "lastSeen" : "2022-07-17T22:00:54Z", + "createdDate" : "2022-07-17T22:00:54Z", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "interfaceIpMapping" : [ { + "ipAddresses" : [ "73.252.207.219", "2601:646:300:3ae0::b977" ], + "interfaceName" : "wlp4s0" + }, { + "ipAddresses" : [ "73.252.207.219", "2601:646:300:3ae0::b977" ], + "interfaceName" : "wlp4s0" + } ], + "targetForTests" : "1.1.1.1", + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "accountGroups" : [ { + "accountGroupName" : "Account A", + "aid" : "1234" + }, { + "accountGroupName" : "Account A", + "aid" : "1234" + } ], + "verifySslCertificates" : true, + "errorDetails" : [ { + "code" : "agent-version-outdated", + "description" : "Agent Version 0.1.1 (latest: 1.0.0)" + }, { + "code" : "agent-version-outdated", + "description" : "Agent Version 0.1.1 (latest: 1.0.0)" + } ] + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "ipv6Policy" : "force-ipv4", + "prefix" : "99.128.0.0/11", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "hostname" : "thousandeyes.com", + "keepBrowserCache" : true, + "agentState" : "online", + "localResolutionPrefixes" : [ "10.2.3.3/24", "10.2.3.3/24" ], + "serialNumber" : "FOC2218ABCD", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "utilization" : 25, + "testIds" : [ 281474976710706 ], + "clusterMembers" : [ { + "lastSeen" : "2022-07-17T22:00:54Z", + "serialNumber" : "FOC2218ABCD", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "agentState" : "online", + "targetForTests" : "1.1.1.1", + "name" : "Cluster member name", + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "utilization" : 25, + "network" : "AT&T Services, Inc. (AS 7018)", + "memberId" : "10", + "errorDetails" : [ { + "code" : "agent-version-outdated", + "description" : "Agent Version 0.1.1 (latest: 1.0.0)" + }, { + "code" : "agent-version-outdated", + "description" : "Agent Version 0.1.1 (latest: 1.0.0)" + } ] + }, { + "lastSeen" : "2022-07-17T22:00:54Z", + "serialNumber" : "FOC2218ABCD", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "agentState" : "online", + "targetForTests" : "1.1.1.1", + "name" : "Cluster member name", + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "utilization" : 25, + "network" : "AT&T Services, Inc. (AS 7018)", + "memberId" : "10", + "errorDetails" : [ { + "code" : "agent-version-outdated", + "description" : "Agent Version 0.1.1 (latest: 1.0.0)" + }, { + "code" : "agent-version-outdated", + "description" : "Agent Version 0.1.1 (latest: 1.0.0)" + } ] + } ], + "tests" : [ { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + }, { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + } ], + "lastSeen" : "2022-07-17T22:00:54Z", + "createdDate" : "2022-07-17T22:00:54Z", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "interfaceIpMapping" : [ { + "ipAddresses" : [ "73.252.207.219", "2601:646:300:3ae0::b977" ], + "interfaceName" : "wlp4s0" + }, { + "ipAddresses" : [ "73.252.207.219", "2601:646:300:3ae0::b977" ], + "interfaceName" : "wlp4s0" + } ], + "targetForTests" : "1.1.1.1", + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "accountGroups" : [ { + "accountGroupName" : "Account A", + "aid" : "1234" + }, { + "accountGroupName" : "Account A", + "aid" : "1234" + } ], + "verifySslCertificates" : true, + "errorDetails" : [ { + "code" : "agent-version-outdated", + "description" : "Agent Version 0.1.1 (latest: 1.0.0)" + }, { + "code" : "agent-version-outdated", + "description" : "Agent Version 0.1.1 (latest: 1.0.0)" + } ] + } ] + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_account_groups": OperationExpectation( + operation_id="get_account_groups", + method="GET", + path="/account-groups", + path_param_examples={ + }, + success_status=200, + success_body=json.loads(""" + + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "accountGroups" : [ { + "isCurrentAccountGroup" : true, + "organizationName" : "organizationName", + "accountGroupName" : "Account A", + "isDefaultAccountGroup" : true, + "aid" : "1234", + "orgId" : "12345" + }, { + "isCurrentAccountGroup" : true, + "organizationName" : "organizationName", + "accountGroupName" : "Account A", + "isDefaultAccountGroup" : true, + "aid" : "1234", + "orgId" : "12345" + } ] + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "update_account_group": OperationExpectation( + operation_id="update_account_group", + method="PUT", + path="/account-groups/{id}", + path_param_examples={ + "id": '1234', + }, + success_status=200, + success_body=json.loads(""" + + { + "isCurrentAccountGroup" : true, + "organizationName" : "organizationName", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "accountGroupName" : "Account A", + "isDefaultAccountGroup" : true, + "accountToken" : "accountToken", + "aid" : "1234", + "orgId" : "12345", + "users" : [ { + "uid" : "235", + "lastLogin" : "2022-07-17T22:00:54Z", + "roles" : [ { + "roleId" : "35", + "name" : "Organization Admin", + "isBuiltin" : true, + "hasManagementPermissions" : true + }, { + "roleId" : "35", + "name" : "Organization Admin", + "isBuiltin" : true, + "hasManagementPermissions" : true + } ], + "name" : "User X", + "email" : "userx@thousandeyes.com", + "dateRegistered" : "2022-07-17T22:00:54Z" + }, { + "uid" : "235", + "lastLogin" : "2022-07-17T22:00:54Z", + "roles" : [ { + "roleId" : "35", + "name" : "Organization Admin", + "isBuiltin" : true, + "hasManagementPermissions" : true + }, { + "roleId" : "35", + "name" : "Organization Admin", + "isBuiltin" : true, + "hasManagementPermissions" : true + } ], + "name" : "User X", + "email" : "userx@thousandeyes.com", + "dateRegistered" : "2022-07-17T22:00:54Z" + } ], + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "ipv6Policy" : "force-ipv4", + "prefix" : "99.128.0.0/11", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "hostname" : "thousandeyes.com", + "keepBrowserCache" : true, + "agentState" : "online", + "localResolutionPrefixes" : [ "10.2.3.3/24", "10.2.3.3/24" ], + "serialNumber" : "FOC2218ABCD", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "utilization" : 25, + "testIds" : [ 281474976710706 ], + "clusterMembers" : [ { + "lastSeen" : "2022-07-17T22:00:54Z", + "serialNumber" : "FOC2218ABCD", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "agentState" : "online", + "targetForTests" : "1.1.1.1", + "name" : "Cluster member name", + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "utilization" : 25, + "network" : "AT&T Services, Inc. (AS 7018)", + "memberId" : "10", + "errorDetails" : [ { + "code" : "agent-version-outdated", + "description" : "Agent Version 0.1.1 (latest: 1.0.0)" + }, { + "code" : "agent-version-outdated", + "description" : "Agent Version 0.1.1 (latest: 1.0.0)" + } ] + }, { + "lastSeen" : "2022-07-17T22:00:54Z", + "serialNumber" : "FOC2218ABCD", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "agentState" : "online", + "targetForTests" : "1.1.1.1", + "name" : "Cluster member name", + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "utilization" : 25, + "network" : "AT&T Services, Inc. (AS 7018)", + "memberId" : "10", + "errorDetails" : [ { + "code" : "agent-version-outdated", + "description" : "Agent Version 0.1.1 (latest: 1.0.0)" + }, { + "code" : "agent-version-outdated", + "description" : "Agent Version 0.1.1 (latest: 1.0.0)" + } ] + } ], + "tests" : [ { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + }, { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + } ], + "lastSeen" : "2022-07-17T22:00:54Z", + "createdDate" : "2022-07-17T22:00:54Z", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "interfaceIpMapping" : [ { + "ipAddresses" : [ "73.252.207.219", "2601:646:300:3ae0::b977" ], + "interfaceName" : "wlp4s0" + }, { + "ipAddresses" : [ "73.252.207.219", "2601:646:300:3ae0::b977" ], + "interfaceName" : "wlp4s0" + } ], + "targetForTests" : "1.1.1.1", + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "accountGroups" : [ { + "accountGroupName" : "Account A", + "aid" : "1234" + }, { + "accountGroupName" : "Account A", + "aid" : "1234" + } ], + "verifySslCertificates" : true, + "errorDetails" : [ { + "code" : "agent-version-outdated", + "description" : "Agent Version 0.1.1 (latest: 1.0.0)" + }, { + "code" : "agent-version-outdated", + "description" : "Agent Version 0.1.1 (latest: 1.0.0)" + } ] + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "ipv6Policy" : "force-ipv4", + "prefix" : "99.128.0.0/11", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "hostname" : "thousandeyes.com", + "keepBrowserCache" : true, + "agentState" : "online", + "localResolutionPrefixes" : [ "10.2.3.3/24", "10.2.3.3/24" ], + "serialNumber" : "FOC2218ABCD", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "utilization" : 25, + "testIds" : [ 281474976710706 ], + "clusterMembers" : [ { + "lastSeen" : "2022-07-17T22:00:54Z", + "serialNumber" : "FOC2218ABCD", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "agentState" : "online", + "targetForTests" : "1.1.1.1", + "name" : "Cluster member name", + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "utilization" : 25, + "network" : "AT&T Services, Inc. (AS 7018)", + "memberId" : "10", + "errorDetails" : [ { + "code" : "agent-version-outdated", + "description" : "Agent Version 0.1.1 (latest: 1.0.0)" + }, { + "code" : "agent-version-outdated", + "description" : "Agent Version 0.1.1 (latest: 1.0.0)" + } ] + }, { + "lastSeen" : "2022-07-17T22:00:54Z", + "serialNumber" : "FOC2218ABCD", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "agentState" : "online", + "targetForTests" : "1.1.1.1", + "name" : "Cluster member name", + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "utilization" : 25, + "network" : "AT&T Services, Inc. (AS 7018)", + "memberId" : "10", + "errorDetails" : [ { + "code" : "agent-version-outdated", + "description" : "Agent Version 0.1.1 (latest: 1.0.0)" + }, { + "code" : "agent-version-outdated", + "description" : "Agent Version 0.1.1 (latest: 1.0.0)" + } ] + } ], + "tests" : [ { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + }, { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + } ], + "lastSeen" : "2022-07-17T22:00:54Z", + "createdDate" : "2022-07-17T22:00:54Z", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "interfaceIpMapping" : [ { + "ipAddresses" : [ "73.252.207.219", "2601:646:300:3ae0::b977" ], + "interfaceName" : "wlp4s0" + }, { + "ipAddresses" : [ "73.252.207.219", "2601:646:300:3ae0::b977" ], + "interfaceName" : "wlp4s0" + } ], + "targetForTests" : "1.1.1.1", + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "accountGroups" : [ { + "accountGroupName" : "Account A", + "aid" : "1234" + }, { + "accountGroupName" : "Account A", + "aid" : "1234" + } ], + "verifySslCertificates" : true, + "errorDetails" : [ { + "code" : "agent-version-outdated", + "description" : "Agent Version 0.1.1 (latest: 1.0.0)" + }, { + "code" : "agent-version-outdated", + "description" : "Agent Version 0.1.1 (latest: 1.0.0)" + } ] + } ] + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "accountGroupName" : "My testing account group", + "agents" : [ "105", "719" ] + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_permissions": OperationExpectation( + operation_id="get_permissions", + method="GET", + path="/permissions", + path_param_examples={ + }, + success_status=200, + success_body=json.loads(""" + + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "permissions" : [ { + "label" : "View reports", + "permissionId" : "1", + "isManagementPermission" : true, + "permission" : "REPORT_READ" + }, { + "label" : "View snapshots", + "permissionId" : "51", + "isManagementPermission" : false, + "permission" : "REPORT_SNAPSHOTS_READ" + } ] + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "create_role": OperationExpectation( + operation_id="create_role", + method="POST", + path="/roles", + path_param_examples={ + }, + success_status=201, + success_body=json.loads(""" + + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "roleId" : "35", + "permissions" : [ { + "label" : "View reports", + "permissionId" : "1", + "isManagementPermission" : true, + "permission" : "REPORT_READ" + }, { + "label" : "View snapshots", + "permissionId" : "51", + "isManagementPermission" : false, + "permission" : "REPORT_SNAPSHOTS_READ" + } ], + "name" : "Organization Admin", + "isBuiltin" : true + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "permissions" : [ "56", "315" ], + "name" : "Organization Admin" + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "delete_role": OperationExpectation( + operation_id="delete_role", + method="DELETE", + path="/roles/{id}", + path_param_examples={ + "id": '23', + }, + success_status=204, + success_body=None, + success_content_type="application/json", + request_body_example=None, + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_role": OperationExpectation( + operation_id="get_role", + method="GET", + path="/roles/{id}", + path_param_examples={ + "id": '23', + }, + success_status=200, + success_body=json.loads(""" + + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "roleId" : "35", + "permissions" : [ { + "label" : "View reports", + "permissionId" : "1", + "isManagementPermission" : true, + "permission" : "REPORT_READ" + }, { + "label" : "View snapshots", + "permissionId" : "51", + "isManagementPermission" : false, + "permission" : "REPORT_SNAPSHOTS_READ" + } ], + "name" : "Organization Admin", + "isBuiltin" : true + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_roles": OperationExpectation( + operation_id="get_roles", + method="GET", + path="/roles", + path_param_examples={ + }, + success_status=200, + success_body=json.loads(""" + + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "roles" : [ { + "roleId" : "35", + "name" : "Organization Admin", + "isBuiltin" : true, + "hasManagementPermissions" : true + }, { + "roleId" : "35", + "name" : "Organization Admin", + "isBuiltin" : true, + "hasManagementPermissions" : true + } ] + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "update_role": OperationExpectation( + operation_id="update_role", + method="PUT", + path="/roles/{id}", + path_param_examples={ + "id": '23', + }, + success_status=200, + success_body=json.loads(""" + + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "roleId" : "35", + "permissions" : [ { + "label" : "View reports", + "permissionId" : "1", + "isManagementPermission" : true, + "permission" : "REPORT_READ" + }, { + "label" : "View snapshots", + "permissionId" : "51", + "isManagementPermission" : false, + "permission" : "REPORT_SNAPSHOTS_READ" + } ], + "name" : "Organization Admin", + "isBuiltin" : true + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "permissions" : [ "56", "315" ], + "name" : "Organization Admin" + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_user_events": OperationExpectation( + operation_id="get_user_events", + method="GET", + path="/audit-user-events", + path_param_examples={ + }, + success_status=200, + success_body=json.loads(""" + + { + "endDate" : "2022-07-18T22:00:54Z", + "_links" : { + "next" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "previous" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "auditEvents" : [ { + "accountGroupName" : "API Sandbox", + "aid" : "1234", + "date" : "2020-07-17T21:54:54Z", + "event" : "Report created.", + "ipAddress" : "99.128.0.0/11", + "uid" : "1234", + "user" : "API Sandbox User (noreply@thousandeyes.com)", + "resources" : [ { + "name" : "My New report", + "type" : "reportTitle" + }, { + "name" : "Other Report", + "type" : "testName" + } ] + }, { + "accountGroupName" : "API Sandbox", + "aid" : "1234", + "date" : "2020-07-17T22:00:54Z", + "event" : "Login failed.", + "ipAddress" : "99.128.0.0/11", + "uid" : "1234", + "user" : "API Sandbox User (noreply@thousandeyes.com)" + } ], + "startDate" : "2022-07-17T22:00:54Z" + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "create_user": OperationExpectation( + operation_id="create_user", + method="POST", + path="/users", + path_param_examples={ + }, + success_status=201, + success_body=json.loads(""" + + { + "loginAccountGroup" : { + "accountGroupName" : "Account A", + "aid" : "1234" + }, + "uid" : "245", + "allAccountGroupRoles" : [ { + "roleId" : "35", + "name" : "Organization Admin", + "isBuiltin" : true, + "hasManagementPermissions" : true + }, { + "roleId" : "35", + "name" : "Organization Admin", + "isBuiltin" : true, + "hasManagementPermissions" : true + } ], + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "accountGroupRoles" : [ { + "roles" : [ { + "roleId" : "35", + "name" : "Organization Admin", + "isBuiltin" : true, + "hasManagementPermissions" : true + }, { + "roleId" : "35", + "name" : "Organization Admin", + "isBuiltin" : true, + "hasManagementPermissions" : true + } ], + "accountGroup" : { + "accountGroupName" : "Account A", + "aid" : "1234" + } + }, { + "roles" : [ { + "roleId" : "35", + "name" : "Organization Admin", + "isBuiltin" : true, + "hasManagementPermissions" : true + }, { + "roleId" : "35", + "name" : "Organization Admin", + "isBuiltin" : true, + "hasManagementPermissions" : true + } ], + "accountGroup" : { + "accountGroupName" : "Account A", + "aid" : "1234" + } + } ], + "name" : "User X", + "email" : "userx@thousandeyes.com", + "dateRegistered" : "2020-07-17T22:00:54Z" + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "loginAccountGroupId" : "691", + "accountGroupRoles" : [ { + "roleIds" : [ "57", "1140" ], + "accountGroupId" : "315" + }, { + "roleIds" : [ "57", "1140" ], + "accountGroupId" : "315" + } ], + "name" : "User X", + "allAccountGroupRoleIds" : [ "57", "1140" ], + "email" : "userx@thousandeyes.com" + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "delete_user": OperationExpectation( + operation_id="delete_user", + method="DELETE", + path="/users/{id}", + path_param_examples={ + "id": '1234', + }, + success_status=204, + success_body=None, + success_content_type="application/json", + request_body_example=None, + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_current_user": OperationExpectation( + operation_id="get_current_user", + method="GET", + path="/users/current", + path_param_examples={ + }, + success_status=200, + success_body=json.loads(""" + + { + "loginAccountGroup" : { + "accountGroupName" : "Account A", + "aid" : "1234" + }, + "uid" : "245", + "lastLogin" : "2022-07-17T22:00:54Z", + "allAccountGroupRoles" : [ { + "roleId" : "35", + "name" : "Organization Admin", + "isBuiltin" : true, + "hasManagementPermissions" : true + }, { + "roleId" : "35", + "name" : "Organization Admin", + "isBuiltin" : true, + "hasManagementPermissions" : true + } ], + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "accountGroupRoles" : [ { + "roles" : [ { + "roleId" : "35", + "name" : "Organization Admin", + "isBuiltin" : true, + "hasManagementPermissions" : true + }, { + "roleId" : "35", + "name" : "Organization Admin", + "isBuiltin" : true, + "hasManagementPermissions" : true + } ], + "accountGroup" : { + "accountGroupName" : "Account A", + "aid" : "1234" + } + }, { + "roles" : [ { + "roleId" : "35", + "name" : "Organization Admin", + "isBuiltin" : true, + "hasManagementPermissions" : true + }, { + "roleId" : "35", + "name" : "Organization Admin", + "isBuiltin" : true, + "hasManagementPermissions" : true + } ], + "accountGroup" : { + "accountGroupName" : "Account A", + "aid" : "1234" + } + } ], + "name" : "User X", + "email" : "userx@thousandeyes.com", + "dateRegistered" : "2020-07-17T22:00:54Z" + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_user": OperationExpectation( + operation_id="get_user", + method="GET", + path="/users/{id}", + path_param_examples={ + "id": '1234', + }, + success_status=200, + success_body=json.loads(""" + + { + "loginAccountGroup" : { + "accountGroupName" : "Account A", + "aid" : "1234" + }, + "uid" : "245", + "lastLogin" : "2022-07-17T22:00:54Z", + "allAccountGroupRoles" : [ { + "roleId" : "35", + "name" : "Organization Admin", + "isBuiltin" : true, + "hasManagementPermissions" : true + }, { + "roleId" : "35", + "name" : "Organization Admin", + "isBuiltin" : true, + "hasManagementPermissions" : true + } ], + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "accountGroupRoles" : [ { + "roles" : [ { + "roleId" : "35", + "name" : "Organization Admin", + "isBuiltin" : true, + "hasManagementPermissions" : true + }, { + "roleId" : "35", + "name" : "Organization Admin", + "isBuiltin" : true, + "hasManagementPermissions" : true + } ], + "accountGroup" : { + "accountGroupName" : "Account A", + "aid" : "1234" + } + }, { + "roles" : [ { + "roleId" : "35", + "name" : "Organization Admin", + "isBuiltin" : true, + "hasManagementPermissions" : true + }, { + "roleId" : "35", + "name" : "Organization Admin", + "isBuiltin" : true, + "hasManagementPermissions" : true + } ], + "accountGroup" : { + "accountGroupName" : "Account A", + "aid" : "1234" + } + } ], + "name" : "User X", + "email" : "userx@thousandeyes.com", + "dateRegistered" : "2020-07-17T22:00:54Z" + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_users": OperationExpectation( + operation_id="get_users", + method="GET", + path="/users", + path_param_examples={ + }, + success_status=200, + success_body=json.loads(""" + + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "users" : [ { + "loginAccountGroup" : { + "accountGroupName" : "Account A", + "aid" : "1234" + }, + "uid" : "245", + "lastLogin" : "2022-07-17T22:00:54Z", + "name" : "User X", + "email" : "userx@thousandeyes.com", + "dateRegistered" : "2020-07-17T22:00:54Z" + }, { + "loginAccountGroup" : { + "accountGroupName" : "Account A", + "aid" : "1234" + }, + "uid" : "245", + "lastLogin" : "2022-07-17T22:00:54Z", + "name" : "User X", + "email" : "userx@thousandeyes.com", + "dateRegistered" : "2020-07-17T22:00:54Z" + } ] + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "update_user": OperationExpectation( + operation_id="update_user", + method="PUT", + path="/users/{id}", + path_param_examples={ + "id": '1234', + }, + success_status=200, + success_body=json.loads(""" + + { + "loginAccountGroup" : { + "accountGroupName" : "Account A", + "aid" : "1234" + }, + "uid" : "245", + "lastLogin" : "2022-07-17T22:00:54Z", + "allAccountGroupRoles" : [ { + "roleId" : "35", + "name" : "Organization Admin", + "isBuiltin" : true, + "hasManagementPermissions" : true + }, { + "roleId" : "35", + "name" : "Organization Admin", + "isBuiltin" : true, + "hasManagementPermissions" : true + } ], + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "accountGroupRoles" : [ { + "roles" : [ { + "roleId" : "35", + "name" : "Organization Admin", + "isBuiltin" : true, + "hasManagementPermissions" : true + }, { + "roleId" : "35", + "name" : "Organization Admin", + "isBuiltin" : true, + "hasManagementPermissions" : true + } ], + "accountGroup" : { + "accountGroupName" : "Account A", + "aid" : "1234" + } + }, { + "roles" : [ { + "roleId" : "35", + "name" : "Organization Admin", + "isBuiltin" : true, + "hasManagementPermissions" : true + }, { + "roleId" : "35", + "name" : "Organization Admin", + "isBuiltin" : true, + "hasManagementPermissions" : true + } ], + "accountGroup" : { + "accountGroupName" : "Account A", + "aid" : "1234" + } + } ], + "name" : "User X", + "email" : "userx@thousandeyes.com", + "dateRegistered" : "2020-07-17T22:00:54Z" + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "loginAccountGroupId" : "691", + "accountGroupRoles" : [ { + "roleIds" : [ "57", "1140" ], + "accountGroupId" : "315" + }, { + "roleIds" : [ "57", "1140" ], + "accountGroupId" : "315" + } ], + "name" : "User X", + "allAccountGroupRoleIds" : [ "57", "1140" ], + "email" : "userx@thousandeyes.com" + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + +} diff --git a/thousandeyes-sdk-administrative/test/test_account_groups_api_integration.py b/thousandeyes-sdk-administrative/test/test_account_groups_api_integration.py new file mode 100644 index 00000000..f30b9f77 --- /dev/null +++ b/thousandeyes-sdk-administrative/test/test_account_groups_api_integration.py @@ -0,0 +1,1820 @@ +# coding: utf-8 + +""" + Administrative API + + Manage users, accounts, and account groups in the ThousandEyes platform using the Administrative API. This API provides the following operations to manage your organization: * `/account-groups`: Account groups are used to divide an organization into different sections. These operations can be used to create, retrieve, update and delete account groups. * `/users`: Create, retrieve, update and delete users within an organization. * `/roles`: Create, retrieve and update roles for the current user. * `/permissions`: Retrieve all assignable permissions. Used in the context of modifying roles. * `/audit-user-events`: Retrieve all activity log events. For more information about the administrative models, see [Account Management](https://docs.thousandeyes.com/product-documentation/user-management). + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.administrative.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.administrative.api.account_groups_api import AccountGroupsApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestAccountGroupsApiIntegration(IntegrationTestBase): + """AccountGroupsApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = AccountGroupsApi(self.api_client) + + + def test_create_account_group_happy_path(self) -> None: + """Integration test for create_account_group success path""" + request_body_json = """ + + { + "accountGroupName" : "My testing account group", + "agents" : [ "105", "719" ] + } + + """ + account_group_request = thousandeyes_sdk.administrative.models.AccountGroupRequest.from_json(request_body_json) + response_body_json = """ + { + "isCurrentAccountGroup" : true, + "organizationName" : "organizationName", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "accountGroupName" : "Account A", + "isDefaultAccountGroup" : true, + "aid" : "1234", + "orgId" : "12345", + "users" : [ { + "uid" : "235", + "lastLogin" : "2022-07-17T22:00:54Z", + "roles" : [ { + "roleId" : "35", + "name" : "Organization Admin", + "isBuiltin" : true, + "hasManagementPermissions" : true + }, { + "roleId" : "35", + "name" : "Organization Admin", + "isBuiltin" : true, + "hasManagementPermissions" : true + } ], + "name" : "User X", + "email" : "userx@thousandeyes.com", + "dateRegistered" : "2022-07-17T22:00:54Z" + }, { + "uid" : "235", + "lastLogin" : "2022-07-17T22:00:54Z", + "roles" : [ { + "roleId" : "35", + "name" : "Organization Admin", + "isBuiltin" : true, + "hasManagementPermissions" : true + }, { + "roleId" : "35", + "name" : "Organization Admin", + "isBuiltin" : true, + "hasManagementPermissions" : true + } ], + "name" : "User X", + "email" : "userx@thousandeyes.com", + "dateRegistered" : "2022-07-17T22:00:54Z" + } ] + } + """ + expected_response = json.loads(response_body_json) + response = self.api.create_account_group( + + account_group_request=account_group_request, + + _headers=self.te_headers("create_account_group"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_create_account_group_error_400(self) -> None: + """Integration test for create_account_group error path (HTTP 400)""" + request_body_json = """ + + { + "accountGroupName" : "My testing account group", + "agents" : [ "105", "719" ] + } + + """ + account_group_request = thousandeyes_sdk.administrative.models.AccountGroupRequest.from_json(request_body_json) + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.create_account_group( + + account_group_request=account_group_request, + + _headers=self.te_headers("create_account_group", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_account_group_error_401(self) -> None: + """Integration test for create_account_group error path (HTTP 401)""" + request_body_json = """ + + { + "accountGroupName" : "My testing account group", + "agents" : [ "105", "719" ] + } + + """ + account_group_request = thousandeyes_sdk.administrative.models.AccountGroupRequest.from_json(request_body_json) + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.create_account_group( + + account_group_request=account_group_request, + + _headers=self.te_headers("create_account_group", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_account_group_error_403(self) -> None: + """Integration test for create_account_group error path (HTTP 403)""" + request_body_json = """ + + { + "accountGroupName" : "My testing account group", + "agents" : [ "105", "719" ] + } + + """ + account_group_request = thousandeyes_sdk.administrative.models.AccountGroupRequest.from_json(request_body_json) + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.create_account_group( + + account_group_request=account_group_request, + + _headers=self.te_headers("create_account_group", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_account_group_error_404(self) -> None: + """Integration test for create_account_group error path (HTTP 404)""" + request_body_json = """ + + { + "accountGroupName" : "My testing account group", + "agents" : [ "105", "719" ] + } + + """ + account_group_request = thousandeyes_sdk.administrative.models.AccountGroupRequest.from_json(request_body_json) + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.create_account_group( + + account_group_request=account_group_request, + + _headers=self.te_headers("create_account_group", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_account_group_error_429(self) -> None: + """Integration test for create_account_group error path (HTTP 429)""" + request_body_json = """ + + { + "accountGroupName" : "My testing account group", + "agents" : [ "105", "719" ] + } + + """ + account_group_request = thousandeyes_sdk.administrative.models.AccountGroupRequest.from_json(request_body_json) + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.create_account_group( + + account_group_request=account_group_request, + + _headers=self.te_headers("create_account_group", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_account_group_error_500(self) -> None: + """Integration test for create_account_group error path (HTTP 500)""" + request_body_json = """ + + { + "accountGroupName" : "My testing account group", + "agents" : [ "105", "719" ] + } + + """ + account_group_request = thousandeyes_sdk.administrative.models.AccountGroupRequest.from_json(request_body_json) + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.create_account_group( + + account_group_request=account_group_request, + + _headers=self.te_headers("create_account_group", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_delete_account_group_happy_path(self) -> None: + """Integration test for delete_account_group success path""" + id = '1234' + response = self.api.delete_account_group_with_http_info( + + id=id, + + _headers=self.te_headers("delete_account_group"), + ) + self.assertEqual(204, response.status_code) + self.assertIsNone(response.data) + + + def test_delete_account_group_error_400(self) -> None: + """Integration test for delete_account_group error path (HTTP 400)""" + id = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.delete_account_group( + + id=id, + + _headers=self.te_headers("delete_account_group", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_account_group_error_401(self) -> None: + """Integration test for delete_account_group error path (HTTP 401)""" + id = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.delete_account_group( + + id=id, + + _headers=self.te_headers("delete_account_group", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_account_group_error_403(self) -> None: + """Integration test for delete_account_group error path (HTTP 403)""" + id = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.delete_account_group( + + id=id, + + _headers=self.te_headers("delete_account_group", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_account_group_error_404(self) -> None: + """Integration test for delete_account_group error path (HTTP 404)""" + id = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.delete_account_group( + + id=id, + + _headers=self.te_headers("delete_account_group", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_account_group_error_429(self) -> None: + """Integration test for delete_account_group error path (HTTP 429)""" + id = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.delete_account_group( + + id=id, + + _headers=self.te_headers("delete_account_group", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_account_group_error_500(self) -> None: + """Integration test for delete_account_group error path (HTTP 500)""" + id = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.delete_account_group( + + id=id, + + _headers=self.te_headers("delete_account_group", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_account_group_happy_path(self) -> None: + """Integration test for get_account_group success path""" + id = '1234' + response_body_json = """ + { + "isCurrentAccountGroup" : true, + "organizationName" : "organizationName", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "accountGroupName" : "Account A", + "isDefaultAccountGroup" : true, + "accountToken" : "accountToken", + "aid" : "1234", + "orgId" : "12345", + "users" : [ { + "uid" : "235", + "lastLogin" : "2022-07-17T22:00:54Z", + "roles" : [ { + "roleId" : "35", + "name" : "Organization Admin", + "isBuiltin" : true, + "hasManagementPermissions" : true + }, { + "roleId" : "35", + "name" : "Organization Admin", + "isBuiltin" : true, + "hasManagementPermissions" : true + } ], + "name" : "User X", + "email" : "userx@thousandeyes.com", + "dateRegistered" : "2022-07-17T22:00:54Z" + }, { + "uid" : "235", + "lastLogin" : "2022-07-17T22:00:54Z", + "roles" : [ { + "roleId" : "35", + "name" : "Organization Admin", + "isBuiltin" : true, + "hasManagementPermissions" : true + }, { + "roleId" : "35", + "name" : "Organization Admin", + "isBuiltin" : true, + "hasManagementPermissions" : true + } ], + "name" : "User X", + "email" : "userx@thousandeyes.com", + "dateRegistered" : "2022-07-17T22:00:54Z" + } ], + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "ipv6Policy" : "force-ipv4", + "prefix" : "99.128.0.0/11", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "hostname" : "thousandeyes.com", + "keepBrowserCache" : true, + "agentState" : "online", + "localResolutionPrefixes" : [ "10.2.3.3/24", "10.2.3.3/24" ], + "serialNumber" : "FOC2218ABCD", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "utilization" : 25, + "testIds" : [ 281474976710706 ], + "clusterMembers" : [ { + "lastSeen" : "2022-07-17T22:00:54Z", + "serialNumber" : "FOC2218ABCD", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "agentState" : "online", + "targetForTests" : "1.1.1.1", + "name" : "Cluster member name", + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "utilization" : 25, + "network" : "AT&T Services, Inc. (AS 7018)", + "memberId" : "10", + "errorDetails" : [ { + "code" : "agent-version-outdated", + "description" : "Agent Version 0.1.1 (latest: 1.0.0)" + }, { + "code" : "agent-version-outdated", + "description" : "Agent Version 0.1.1 (latest: 1.0.0)" + } ] + }, { + "lastSeen" : "2022-07-17T22:00:54Z", + "serialNumber" : "FOC2218ABCD", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "agentState" : "online", + "targetForTests" : "1.1.1.1", + "name" : "Cluster member name", + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "utilization" : 25, + "network" : "AT&T Services, Inc. (AS 7018)", + "memberId" : "10", + "errorDetails" : [ { + "code" : "agent-version-outdated", + "description" : "Agent Version 0.1.1 (latest: 1.0.0)" + }, { + "code" : "agent-version-outdated", + "description" : "Agent Version 0.1.1 (latest: 1.0.0)" + } ] + } ], + "tests" : [ { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + }, { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + } ], + "lastSeen" : "2022-07-17T22:00:54Z", + "createdDate" : "2022-07-17T22:00:54Z", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "interfaceIpMapping" : [ { + "ipAddresses" : [ "73.252.207.219", "2601:646:300:3ae0::b977" ], + "interfaceName" : "wlp4s0" + }, { + "ipAddresses" : [ "73.252.207.219", "2601:646:300:3ae0::b977" ], + "interfaceName" : "wlp4s0" + } ], + "targetForTests" : "1.1.1.1", + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "accountGroups" : [ { + "accountGroupName" : "Account A", + "aid" : "1234" + }, { + "accountGroupName" : "Account A", + "aid" : "1234" + } ], + "verifySslCertificates" : true, + "errorDetails" : [ { + "code" : "agent-version-outdated", + "description" : "Agent Version 0.1.1 (latest: 1.0.0)" + }, { + "code" : "agent-version-outdated", + "description" : "Agent Version 0.1.1 (latest: 1.0.0)" + } ] + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "ipv6Policy" : "force-ipv4", + "prefix" : "99.128.0.0/11", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "hostname" : "thousandeyes.com", + "keepBrowserCache" : true, + "agentState" : "online", + "localResolutionPrefixes" : [ "10.2.3.3/24", "10.2.3.3/24" ], + "serialNumber" : "FOC2218ABCD", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "utilization" : 25, + "testIds" : [ 281474976710706 ], + "clusterMembers" : [ { + "lastSeen" : "2022-07-17T22:00:54Z", + "serialNumber" : "FOC2218ABCD", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "agentState" : "online", + "targetForTests" : "1.1.1.1", + "name" : "Cluster member name", + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "utilization" : 25, + "network" : "AT&T Services, Inc. (AS 7018)", + "memberId" : "10", + "errorDetails" : [ { + "code" : "agent-version-outdated", + "description" : "Agent Version 0.1.1 (latest: 1.0.0)" + }, { + "code" : "agent-version-outdated", + "description" : "Agent Version 0.1.1 (latest: 1.0.0)" + } ] + }, { + "lastSeen" : "2022-07-17T22:00:54Z", + "serialNumber" : "FOC2218ABCD", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "agentState" : "online", + "targetForTests" : "1.1.1.1", + "name" : "Cluster member name", + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "utilization" : 25, + "network" : "AT&T Services, Inc. (AS 7018)", + "memberId" : "10", + "errorDetails" : [ { + "code" : "agent-version-outdated", + "description" : "Agent Version 0.1.1 (latest: 1.0.0)" + }, { + "code" : "agent-version-outdated", + "description" : "Agent Version 0.1.1 (latest: 1.0.0)" + } ] + } ], + "tests" : [ { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + }, { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + } ], + "lastSeen" : "2022-07-17T22:00:54Z", + "createdDate" : "2022-07-17T22:00:54Z", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "interfaceIpMapping" : [ { + "ipAddresses" : [ "73.252.207.219", "2601:646:300:3ae0::b977" ], + "interfaceName" : "wlp4s0" + }, { + "ipAddresses" : [ "73.252.207.219", "2601:646:300:3ae0::b977" ], + "interfaceName" : "wlp4s0" + } ], + "targetForTests" : "1.1.1.1", + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "accountGroups" : [ { + "accountGroupName" : "Account A", + "aid" : "1234" + }, { + "accountGroupName" : "Account A", + "aid" : "1234" + } ], + "verifySslCertificates" : true, + "errorDetails" : [ { + "code" : "agent-version-outdated", + "description" : "Agent Version 0.1.1 (latest: 1.0.0)" + }, { + "code" : "agent-version-outdated", + "description" : "Agent Version 0.1.1 (latest: 1.0.0)" + } ] + } ] + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_account_group( + + id=id, + + _headers=self.te_headers("get_account_group"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_account_group_error_400(self) -> None: + """Integration test for get_account_group error path (HTTP 400)""" + id = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.get_account_group( + + id=id, + + _headers=self.te_headers("get_account_group", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_account_group_error_401(self) -> None: + """Integration test for get_account_group error path (HTTP 401)""" + id = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_account_group( + + id=id, + + _headers=self.te_headers("get_account_group", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_account_group_error_403(self) -> None: + """Integration test for get_account_group error path (HTTP 403)""" + id = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_account_group( + + id=id, + + _headers=self.te_headers("get_account_group", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_account_group_error_404(self) -> None: + """Integration test for get_account_group error path (HTTP 404)""" + id = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_account_group( + + id=id, + + _headers=self.te_headers("get_account_group", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_account_group_error_429(self) -> None: + """Integration test for get_account_group error path (HTTP 429)""" + id = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_account_group( + + id=id, + + _headers=self.te_headers("get_account_group", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_account_group_error_500(self) -> None: + """Integration test for get_account_group error path (HTTP 500)""" + id = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_account_group( + + id=id, + + _headers=self.te_headers("get_account_group", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_account_groups_happy_path(self) -> None: + """Integration test for get_account_groups success path""" + response_body_json = """ + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "accountGroups" : [ { + "isCurrentAccountGroup" : true, + "organizationName" : "organizationName", + "accountGroupName" : "Account A", + "isDefaultAccountGroup" : true, + "aid" : "1234", + "orgId" : "12345" + }, { + "isCurrentAccountGroup" : true, + "organizationName" : "organizationName", + "accountGroupName" : "Account A", + "isDefaultAccountGroup" : true, + "aid" : "1234", + "orgId" : "12345" + } ] + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_account_groups( + + _headers=self.te_headers("get_account_groups"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_account_groups_error_400(self) -> None: + """Integration test for get_account_groups error path (HTTP 400)""" + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.get_account_groups( + + _headers=self.te_headers("get_account_groups", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_account_groups_error_401(self) -> None: + """Integration test for get_account_groups error path (HTTP 401)""" + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_account_groups( + + _headers=self.te_headers("get_account_groups", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_account_groups_error_403(self) -> None: + """Integration test for get_account_groups error path (HTTP 403)""" + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_account_groups( + + _headers=self.te_headers("get_account_groups", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_account_groups_error_404(self) -> None: + """Integration test for get_account_groups error path (HTTP 404)""" + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_account_groups( + + _headers=self.te_headers("get_account_groups", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_account_groups_error_429(self) -> None: + """Integration test for get_account_groups error path (HTTP 429)""" + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_account_groups( + + _headers=self.te_headers("get_account_groups", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_account_groups_error_500(self) -> None: + """Integration test for get_account_groups error path (HTTP 500)""" + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_account_groups( + + _headers=self.te_headers("get_account_groups", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_update_account_group_happy_path(self) -> None: + """Integration test for update_account_group success path""" + request_body_json = """ + + { + "accountGroupName" : "My testing account group", + "agents" : [ "105", "719" ] + } + + """ + account_group_request = thousandeyes_sdk.administrative.models.AccountGroupRequest.from_json(request_body_json) + id = '1234' + response_body_json = """ + { + "isCurrentAccountGroup" : true, + "organizationName" : "organizationName", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "accountGroupName" : "Account A", + "isDefaultAccountGroup" : true, + "accountToken" : "accountToken", + "aid" : "1234", + "orgId" : "12345", + "users" : [ { + "uid" : "235", + "lastLogin" : "2022-07-17T22:00:54Z", + "roles" : [ { + "roleId" : "35", + "name" : "Organization Admin", + "isBuiltin" : true, + "hasManagementPermissions" : true + }, { + "roleId" : "35", + "name" : "Organization Admin", + "isBuiltin" : true, + "hasManagementPermissions" : true + } ], + "name" : "User X", + "email" : "userx@thousandeyes.com", + "dateRegistered" : "2022-07-17T22:00:54Z" + }, { + "uid" : "235", + "lastLogin" : "2022-07-17T22:00:54Z", + "roles" : [ { + "roleId" : "35", + "name" : "Organization Admin", + "isBuiltin" : true, + "hasManagementPermissions" : true + }, { + "roleId" : "35", + "name" : "Organization Admin", + "isBuiltin" : true, + "hasManagementPermissions" : true + } ], + "name" : "User X", + "email" : "userx@thousandeyes.com", + "dateRegistered" : "2022-07-17T22:00:54Z" + } ], + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "ipv6Policy" : "force-ipv4", + "prefix" : "99.128.0.0/11", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "hostname" : "thousandeyes.com", + "keepBrowserCache" : true, + "agentState" : "online", + "localResolutionPrefixes" : [ "10.2.3.3/24", "10.2.3.3/24" ], + "serialNumber" : "FOC2218ABCD", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "utilization" : 25, + "testIds" : [ 281474976710706 ], + "clusterMembers" : [ { + "lastSeen" : "2022-07-17T22:00:54Z", + "serialNumber" : "FOC2218ABCD", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "agentState" : "online", + "targetForTests" : "1.1.1.1", + "name" : "Cluster member name", + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "utilization" : 25, + "network" : "AT&T Services, Inc. (AS 7018)", + "memberId" : "10", + "errorDetails" : [ { + "code" : "agent-version-outdated", + "description" : "Agent Version 0.1.1 (latest: 1.0.0)" + }, { + "code" : "agent-version-outdated", + "description" : "Agent Version 0.1.1 (latest: 1.0.0)" + } ] + }, { + "lastSeen" : "2022-07-17T22:00:54Z", + "serialNumber" : "FOC2218ABCD", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "agentState" : "online", + "targetForTests" : "1.1.1.1", + "name" : "Cluster member name", + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "utilization" : 25, + "network" : "AT&T Services, Inc. (AS 7018)", + "memberId" : "10", + "errorDetails" : [ { + "code" : "agent-version-outdated", + "description" : "Agent Version 0.1.1 (latest: 1.0.0)" + }, { + "code" : "agent-version-outdated", + "description" : "Agent Version 0.1.1 (latest: 1.0.0)" + } ] + } ], + "tests" : [ { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + }, { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + } ], + "lastSeen" : "2022-07-17T22:00:54Z", + "createdDate" : "2022-07-17T22:00:54Z", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "interfaceIpMapping" : [ { + "ipAddresses" : [ "73.252.207.219", "2601:646:300:3ae0::b977" ], + "interfaceName" : "wlp4s0" + }, { + "ipAddresses" : [ "73.252.207.219", "2601:646:300:3ae0::b977" ], + "interfaceName" : "wlp4s0" + } ], + "targetForTests" : "1.1.1.1", + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "accountGroups" : [ { + "accountGroupName" : "Account A", + "aid" : "1234" + }, { + "accountGroupName" : "Account A", + "aid" : "1234" + } ], + "verifySslCertificates" : true, + "errorDetails" : [ { + "code" : "agent-version-outdated", + "description" : "Agent Version 0.1.1 (latest: 1.0.0)" + }, { + "code" : "agent-version-outdated", + "description" : "Agent Version 0.1.1 (latest: 1.0.0)" + } ] + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "ipv6Policy" : "force-ipv4", + "prefix" : "99.128.0.0/11", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "hostname" : "thousandeyes.com", + "keepBrowserCache" : true, + "agentState" : "online", + "localResolutionPrefixes" : [ "10.2.3.3/24", "10.2.3.3/24" ], + "serialNumber" : "FOC2218ABCD", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "utilization" : 25, + "testIds" : [ 281474976710706 ], + "clusterMembers" : [ { + "lastSeen" : "2022-07-17T22:00:54Z", + "serialNumber" : "FOC2218ABCD", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "agentState" : "online", + "targetForTests" : "1.1.1.1", + "name" : "Cluster member name", + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "utilization" : 25, + "network" : "AT&T Services, Inc. (AS 7018)", + "memberId" : "10", + "errorDetails" : [ { + "code" : "agent-version-outdated", + "description" : "Agent Version 0.1.1 (latest: 1.0.0)" + }, { + "code" : "agent-version-outdated", + "description" : "Agent Version 0.1.1 (latest: 1.0.0)" + } ] + }, { + "lastSeen" : "2022-07-17T22:00:54Z", + "serialNumber" : "FOC2218ABCD", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "agentState" : "online", + "targetForTests" : "1.1.1.1", + "name" : "Cluster member name", + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "utilization" : 25, + "network" : "AT&T Services, Inc. (AS 7018)", + "memberId" : "10", + "errorDetails" : [ { + "code" : "agent-version-outdated", + "description" : "Agent Version 0.1.1 (latest: 1.0.0)" + }, { + "code" : "agent-version-outdated", + "description" : "Agent Version 0.1.1 (latest: 1.0.0)" + } ] + } ], + "tests" : [ { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + }, { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + } ], + "lastSeen" : "2022-07-17T22:00:54Z", + "createdDate" : "2022-07-17T22:00:54Z", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "interfaceIpMapping" : [ { + "ipAddresses" : [ "73.252.207.219", "2601:646:300:3ae0::b977" ], + "interfaceName" : "wlp4s0" + }, { + "ipAddresses" : [ "73.252.207.219", "2601:646:300:3ae0::b977" ], + "interfaceName" : "wlp4s0" + } ], + "targetForTests" : "1.1.1.1", + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "accountGroups" : [ { + "accountGroupName" : "Account A", + "aid" : "1234" + }, { + "accountGroupName" : "Account A", + "aid" : "1234" + } ], + "verifySslCertificates" : true, + "errorDetails" : [ { + "code" : "agent-version-outdated", + "description" : "Agent Version 0.1.1 (latest: 1.0.0)" + }, { + "code" : "agent-version-outdated", + "description" : "Agent Version 0.1.1 (latest: 1.0.0)" + } ] + } ] + } + """ + expected_response = json.loads(response_body_json) + response = self.api.update_account_group( + + id=id, + + account_group_request=account_group_request, + + _headers=self.te_headers("update_account_group"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_update_account_group_error_400(self) -> None: + """Integration test for update_account_group error path (HTTP 400)""" + request_body_json = """ + + { + "accountGroupName" : "My testing account group", + "agents" : [ "105", "719" ] + } + + """ + account_group_request = thousandeyes_sdk.administrative.models.AccountGroupRequest.from_json(request_body_json) + id = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.update_account_group( + + id=id, + + account_group_request=account_group_request, + + _headers=self.te_headers("update_account_group", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_account_group_error_401(self) -> None: + """Integration test for update_account_group error path (HTTP 401)""" + request_body_json = """ + + { + "accountGroupName" : "My testing account group", + "agents" : [ "105", "719" ] + } + + """ + account_group_request = thousandeyes_sdk.administrative.models.AccountGroupRequest.from_json(request_body_json) + id = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.update_account_group( + + id=id, + + account_group_request=account_group_request, + + _headers=self.te_headers("update_account_group", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_account_group_error_403(self) -> None: + """Integration test for update_account_group error path (HTTP 403)""" + request_body_json = """ + + { + "accountGroupName" : "My testing account group", + "agents" : [ "105", "719" ] + } + + """ + account_group_request = thousandeyes_sdk.administrative.models.AccountGroupRequest.from_json(request_body_json) + id = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.update_account_group( + + id=id, + + account_group_request=account_group_request, + + _headers=self.te_headers("update_account_group", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_account_group_error_404(self) -> None: + """Integration test for update_account_group error path (HTTP 404)""" + request_body_json = """ + + { + "accountGroupName" : "My testing account group", + "agents" : [ "105", "719" ] + } + + """ + account_group_request = thousandeyes_sdk.administrative.models.AccountGroupRequest.from_json(request_body_json) + id = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.update_account_group( + + id=id, + + account_group_request=account_group_request, + + _headers=self.te_headers("update_account_group", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_account_group_error_429(self) -> None: + """Integration test for update_account_group error path (HTTP 429)""" + request_body_json = """ + + { + "accountGroupName" : "My testing account group", + "agents" : [ "105", "719" ] + } + + """ + account_group_request = thousandeyes_sdk.administrative.models.AccountGroupRequest.from_json(request_body_json) + id = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.update_account_group( + + id=id, + + account_group_request=account_group_request, + + _headers=self.te_headers("update_account_group", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_account_group_error_500(self) -> None: + """Integration test for update_account_group error path (HTTP 500)""" + request_body_json = """ + + { + "accountGroupName" : "My testing account group", + "agents" : [ "105", "719" ] + } + + """ + account_group_request = thousandeyes_sdk.administrative.models.AccountGroupRequest.from_json(request_body_json) + id = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.update_account_group( + + id=id, + + account_group_request=account_group_request, + + _headers=self.te_headers("update_account_group", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-administrative/test/test_permissions_api_integration.py b/thousandeyes-sdk-administrative/test/test_permissions_api_integration.py new file mode 100644 index 00000000..cb461ad6 --- /dev/null +++ b/thousandeyes-sdk-administrative/test/test_permissions_api_integration.py @@ -0,0 +1,233 @@ +# coding: utf-8 + +""" + Administrative API + + Manage users, accounts, and account groups in the ThousandEyes platform using the Administrative API. This API provides the following operations to manage your organization: * `/account-groups`: Account groups are used to divide an organization into different sections. These operations can be used to create, retrieve, update and delete account groups. * `/users`: Create, retrieve, update and delete users within an organization. * `/roles`: Create, retrieve and update roles for the current user. * `/permissions`: Retrieve all assignable permissions. Used in the context of modifying roles. * `/audit-user-events`: Retrieve all activity log events. For more information about the administrative models, see [Account Management](https://docs.thousandeyes.com/product-documentation/user-management). + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.administrative.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.administrative.api.permissions_api import PermissionsApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestPermissionsApiIntegration(IntegrationTestBase): + """PermissionsApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = PermissionsApi(self.api_client) + + + def test_get_permissions_happy_path(self) -> None: + """Integration test for get_permissions success path""" + aid = '1234' + response_body_json = """ + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "permissions" : [ { + "label" : "View reports", + "permissionId" : "1", + "isManagementPermission" : true, + "permission" : "REPORT_READ" + }, { + "label" : "View snapshots", + "permissionId" : "51", + "isManagementPermission" : false, + "permission" : "REPORT_SNAPSHOTS_READ" + } ] + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_permissions( + + aid=aid, + + _headers=self.te_headers("get_permissions"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_permissions_error_400(self) -> None: + """Integration test for get_permissions error path (HTTP 400)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.get_permissions( + + aid=aid, + + _headers=self.te_headers("get_permissions", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_permissions_error_401(self) -> None: + """Integration test for get_permissions error path (HTTP 401)""" + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_permissions( + + aid=aid, + + _headers=self.te_headers("get_permissions", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_permissions_error_403(self) -> None: + """Integration test for get_permissions error path (HTTP 403)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_permissions( + + aid=aid, + + _headers=self.te_headers("get_permissions", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_permissions_error_404(self) -> None: + """Integration test for get_permissions error path (HTTP 404)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_permissions( + + aid=aid, + + _headers=self.te_headers("get_permissions", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_permissions_error_429(self) -> None: + """Integration test for get_permissions error path (HTTP 429)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_permissions( + + aid=aid, + + _headers=self.te_headers("get_permissions", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_permissions_error_500(self) -> None: + """Integration test for get_permissions error path (HTTP 500)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_permissions( + + aid=aid, + + _headers=self.te_headers("get_permissions", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-administrative/test/test_roles_api_integration.py b/thousandeyes-sdk-administrative/test/test_roles_api_integration.py new file mode 100644 index 00000000..f79e5a8d --- /dev/null +++ b/thousandeyes-sdk-administrative/test/test_roles_api_integration.py @@ -0,0 +1,1224 @@ +# coding: utf-8 + +""" + Administrative API + + Manage users, accounts, and account groups in the ThousandEyes platform using the Administrative API. This API provides the following operations to manage your organization: * `/account-groups`: Account groups are used to divide an organization into different sections. These operations can be used to create, retrieve, update and delete account groups. * `/users`: Create, retrieve, update and delete users within an organization. * `/roles`: Create, retrieve and update roles for the current user. * `/permissions`: Retrieve all assignable permissions. Used in the context of modifying roles. * `/audit-user-events`: Retrieve all activity log events. For more information about the administrative models, see [Account Management](https://docs.thousandeyes.com/product-documentation/user-management). + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.administrative.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.administrative.api.roles_api import RolesApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestRolesApiIntegration(IntegrationTestBase): + """RolesApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = RolesApi(self.api_client) + + + def test_create_role_happy_path(self) -> None: + """Integration test for create_role success path""" + request_body_json = """ + + { + "permissions" : [ "56", "315" ], + "name" : "Organization Admin" + } + + """ + role_request_body = thousandeyes_sdk.administrative.models.RoleRequestBody.from_json(request_body_json) + aid = '1234' + response_body_json = """ + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "roleId" : "35", + "permissions" : [ { + "label" : "View reports", + "permissionId" : "1", + "isManagementPermission" : true, + "permission" : "REPORT_READ" + }, { + "label" : "View snapshots", + "permissionId" : "51", + "isManagementPermission" : false, + "permission" : "REPORT_SNAPSHOTS_READ" + } ], + "name" : "Organization Admin", + "isBuiltin" : true + } + """ + expected_response = json.loads(response_body_json) + response = self.api.create_role( + + role_request_body=role_request_body, + + aid=aid, + + _headers=self.te_headers("create_role"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_create_role_error_400(self) -> None: + """Integration test for create_role error path (HTTP 400)""" + request_body_json = """ + + { + "permissions" : [ "56", "315" ], + "name" : "Organization Admin" + } + + """ + role_request_body = thousandeyes_sdk.administrative.models.RoleRequestBody.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.create_role( + + role_request_body=role_request_body, + + aid=aid, + + _headers=self.te_headers("create_role", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_role_error_401(self) -> None: + """Integration test for create_role error path (HTTP 401)""" + request_body_json = """ + + { + "permissions" : [ "56", "315" ], + "name" : "Organization Admin" + } + + """ + role_request_body = thousandeyes_sdk.administrative.models.RoleRequestBody.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.create_role( + + role_request_body=role_request_body, + + aid=aid, + + _headers=self.te_headers("create_role", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_role_error_403(self) -> None: + """Integration test for create_role error path (HTTP 403)""" + request_body_json = """ + + { + "permissions" : [ "56", "315" ], + "name" : "Organization Admin" + } + + """ + role_request_body = thousandeyes_sdk.administrative.models.RoleRequestBody.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.create_role( + + role_request_body=role_request_body, + + aid=aid, + + _headers=self.te_headers("create_role", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_role_error_404(self) -> None: + """Integration test for create_role error path (HTTP 404)""" + request_body_json = """ + + { + "permissions" : [ "56", "315" ], + "name" : "Organization Admin" + } + + """ + role_request_body = thousandeyes_sdk.administrative.models.RoleRequestBody.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.create_role( + + role_request_body=role_request_body, + + aid=aid, + + _headers=self.te_headers("create_role", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_role_error_429(self) -> None: + """Integration test for create_role error path (HTTP 429)""" + request_body_json = """ + + { + "permissions" : [ "56", "315" ], + "name" : "Organization Admin" + } + + """ + role_request_body = thousandeyes_sdk.administrative.models.RoleRequestBody.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.create_role( + + role_request_body=role_request_body, + + aid=aid, + + _headers=self.te_headers("create_role", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_role_error_500(self) -> None: + """Integration test for create_role error path (HTTP 500)""" + request_body_json = """ + + { + "permissions" : [ "56", "315" ], + "name" : "Organization Admin" + } + + """ + role_request_body = thousandeyes_sdk.administrative.models.RoleRequestBody.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.create_role( + + role_request_body=role_request_body, + + aid=aid, + + _headers=self.te_headers("create_role", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_delete_role_happy_path(self) -> None: + """Integration test for delete_role success path""" + id = '23' + aid = '1234' + response = self.api.delete_role_with_http_info( + + id=id, + + aid=aid, + + _headers=self.te_headers("delete_role"), + ) + self.assertEqual(204, response.status_code) + self.assertIsNone(response.data) + + + def test_delete_role_error_400(self) -> None: + """Integration test for delete_role error path (HTTP 400)""" + id = '23' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.delete_role( + + id=id, + + aid=aid, + + _headers=self.te_headers("delete_role", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_role_error_401(self) -> None: + """Integration test for delete_role error path (HTTP 401)""" + id = '23' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.delete_role( + + id=id, + + aid=aid, + + _headers=self.te_headers("delete_role", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_role_error_403(self) -> None: + """Integration test for delete_role error path (HTTP 403)""" + id = '23' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.delete_role( + + id=id, + + aid=aid, + + _headers=self.te_headers("delete_role", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_role_error_404(self) -> None: + """Integration test for delete_role error path (HTTP 404)""" + id = '23' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.delete_role( + + id=id, + + aid=aid, + + _headers=self.te_headers("delete_role", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_role_error_429(self) -> None: + """Integration test for delete_role error path (HTTP 429)""" + id = '23' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.delete_role( + + id=id, + + aid=aid, + + _headers=self.te_headers("delete_role", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_role_error_500(self) -> None: + """Integration test for delete_role error path (HTTP 500)""" + id = '23' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.delete_role( + + id=id, + + aid=aid, + + _headers=self.te_headers("delete_role", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_role_happy_path(self) -> None: + """Integration test for get_role success path""" + id = '23' + aid = '1234' + response_body_json = """ + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "roleId" : "35", + "permissions" : [ { + "label" : "View reports", + "permissionId" : "1", + "isManagementPermission" : true, + "permission" : "REPORT_READ" + }, { + "label" : "View snapshots", + "permissionId" : "51", + "isManagementPermission" : false, + "permission" : "REPORT_SNAPSHOTS_READ" + } ], + "name" : "Organization Admin", + "isBuiltin" : true + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_role( + + id=id, + + aid=aid, + + _headers=self.te_headers("get_role"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_role_error_400(self) -> None: + """Integration test for get_role error path (HTTP 400)""" + id = '23' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.get_role( + + id=id, + + aid=aid, + + _headers=self.te_headers("get_role", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_role_error_401(self) -> None: + """Integration test for get_role error path (HTTP 401)""" + id = '23' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_role( + + id=id, + + aid=aid, + + _headers=self.te_headers("get_role", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_role_error_403(self) -> None: + """Integration test for get_role error path (HTTP 403)""" + id = '23' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_role( + + id=id, + + aid=aid, + + _headers=self.te_headers("get_role", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_role_error_404(self) -> None: + """Integration test for get_role error path (HTTP 404)""" + id = '23' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_role( + + id=id, + + aid=aid, + + _headers=self.te_headers("get_role", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_role_error_429(self) -> None: + """Integration test for get_role error path (HTTP 429)""" + id = '23' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_role( + + id=id, + + aid=aid, + + _headers=self.te_headers("get_role", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_role_error_500(self) -> None: + """Integration test for get_role error path (HTTP 500)""" + id = '23' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_role( + + id=id, + + aid=aid, + + _headers=self.te_headers("get_role", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_roles_happy_path(self) -> None: + """Integration test for get_roles success path""" + aid = '1234' + response_body_json = """ + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "roles" : [ { + "roleId" : "35", + "name" : "Organization Admin", + "isBuiltin" : true, + "hasManagementPermissions" : true + }, { + "roleId" : "35", + "name" : "Organization Admin", + "isBuiltin" : true, + "hasManagementPermissions" : true + } ] + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_roles( + + aid=aid, + + _headers=self.te_headers("get_roles"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_roles_error_400(self) -> None: + """Integration test for get_roles error path (HTTP 400)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.get_roles( + + aid=aid, + + _headers=self.te_headers("get_roles", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_roles_error_401(self) -> None: + """Integration test for get_roles error path (HTTP 401)""" + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_roles( + + aid=aid, + + _headers=self.te_headers("get_roles", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_roles_error_403(self) -> None: + """Integration test for get_roles error path (HTTP 403)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_roles( + + aid=aid, + + _headers=self.te_headers("get_roles", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_roles_error_404(self) -> None: + """Integration test for get_roles error path (HTTP 404)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_roles( + + aid=aid, + + _headers=self.te_headers("get_roles", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_roles_error_429(self) -> None: + """Integration test for get_roles error path (HTTP 429)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_roles( + + aid=aid, + + _headers=self.te_headers("get_roles", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_roles_error_500(self) -> None: + """Integration test for get_roles error path (HTTP 500)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_roles( + + aid=aid, + + _headers=self.te_headers("get_roles", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_update_role_happy_path(self) -> None: + """Integration test for update_role success path""" + request_body_json = """ + + { + "permissions" : [ "56", "315" ], + "name" : "Organization Admin" + } + + """ + role_request_body = thousandeyes_sdk.administrative.models.RoleRequestBody.from_json(request_body_json) + id = '23' + aid = '1234' + response_body_json = """ + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "roleId" : "35", + "permissions" : [ { + "label" : "View reports", + "permissionId" : "1", + "isManagementPermission" : true, + "permission" : "REPORT_READ" + }, { + "label" : "View snapshots", + "permissionId" : "51", + "isManagementPermission" : false, + "permission" : "REPORT_SNAPSHOTS_READ" + } ], + "name" : "Organization Admin", + "isBuiltin" : true + } + """ + expected_response = json.loads(response_body_json) + response = self.api.update_role( + + id=id, + + role_request_body=role_request_body, + + aid=aid, + + _headers=self.te_headers("update_role"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_update_role_error_400(self) -> None: + """Integration test for update_role error path (HTTP 400)""" + request_body_json = """ + + { + "permissions" : [ "56", "315" ], + "name" : "Organization Admin" + } + + """ + role_request_body = thousandeyes_sdk.administrative.models.RoleRequestBody.from_json(request_body_json) + id = '23' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.update_role( + + id=id, + + role_request_body=role_request_body, + + aid=aid, + + _headers=self.te_headers("update_role", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_role_error_401(self) -> None: + """Integration test for update_role error path (HTTP 401)""" + request_body_json = """ + + { + "permissions" : [ "56", "315" ], + "name" : "Organization Admin" + } + + """ + role_request_body = thousandeyes_sdk.administrative.models.RoleRequestBody.from_json(request_body_json) + id = '23' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.update_role( + + id=id, + + role_request_body=role_request_body, + + aid=aid, + + _headers=self.te_headers("update_role", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_role_error_403(self) -> None: + """Integration test for update_role error path (HTTP 403)""" + request_body_json = """ + + { + "permissions" : [ "56", "315" ], + "name" : "Organization Admin" + } + + """ + role_request_body = thousandeyes_sdk.administrative.models.RoleRequestBody.from_json(request_body_json) + id = '23' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.update_role( + + id=id, + + role_request_body=role_request_body, + + aid=aid, + + _headers=self.te_headers("update_role", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_role_error_404(self) -> None: + """Integration test for update_role error path (HTTP 404)""" + request_body_json = """ + + { + "permissions" : [ "56", "315" ], + "name" : "Organization Admin" + } + + """ + role_request_body = thousandeyes_sdk.administrative.models.RoleRequestBody.from_json(request_body_json) + id = '23' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.update_role( + + id=id, + + role_request_body=role_request_body, + + aid=aid, + + _headers=self.te_headers("update_role", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_role_error_429(self) -> None: + """Integration test for update_role error path (HTTP 429)""" + request_body_json = """ + + { + "permissions" : [ "56", "315" ], + "name" : "Organization Admin" + } + + """ + role_request_body = thousandeyes_sdk.administrative.models.RoleRequestBody.from_json(request_body_json) + id = '23' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.update_role( + + id=id, + + role_request_body=role_request_body, + + aid=aid, + + _headers=self.te_headers("update_role", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_role_error_500(self) -> None: + """Integration test for update_role error path (HTTP 500)""" + request_body_json = """ + + { + "permissions" : [ "56", "315" ], + "name" : "Organization Admin" + } + + """ + role_request_body = thousandeyes_sdk.administrative.models.RoleRequestBody.from_json(request_body_json) + id = '23' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.update_role( + + id=id, + + role_request_body=role_request_body, + + aid=aid, + + _headers=self.te_headers("update_role", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-administrative/test/test_user_events_api_integration.py b/thousandeyes-sdk-administrative/test/test_user_events_api_integration.py new file mode 100644 index 00000000..908d363f --- /dev/null +++ b/thousandeyes-sdk-administrative/test/test_user_events_api_integration.py @@ -0,0 +1,373 @@ +# coding: utf-8 + +""" + Administrative API + + Manage users, accounts, and account groups in the ThousandEyes platform using the Administrative API. This API provides the following operations to manage your organization: * `/account-groups`: Account groups are used to divide an organization into different sections. These operations can be used to create, retrieve, update and delete account groups. * `/users`: Create, retrieve, update and delete users within an organization. * `/roles`: Create, retrieve and update roles for the current user. * `/permissions`: Retrieve all assignable permissions. Used in the context of modifying roles. * `/audit-user-events`: Retrieve all activity log events. For more information about the administrative models, see [Account Management](https://docs.thousandeyes.com/product-documentation/user-management). + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.administrative.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.administrative.api.user_events_api import UserEventsApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestUserEventsApiIntegration(IntegrationTestBase): + """UserEventsApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = UserEventsApi(self.api_client) + + + def test_get_user_events_happy_path(self) -> None: + """Integration test for get_user_events success path""" + aid = '1234' + use_all_permitted_aids = False + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + response_body_json = """ + { + "endDate" : "2022-07-18T22:00:54Z", + "_links" : { + "next" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "previous" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "auditEvents" : [ { + "accountGroupName" : "API Sandbox", + "aid" : "1234", + "date" : "2020-07-17T21:54:54Z", + "event" : "Report created.", + "ipAddress" : "99.128.0.0/11", + "uid" : "1234", + "user" : "API Sandbox User (noreply@thousandeyes.com)", + "resources" : [ { + "name" : "My New report", + "type" : "reportTitle" + }, { + "name" : "Other Report", + "type" : "testName" + } ] + }, { + "accountGroupName" : "API Sandbox", + "aid" : "1234", + "date" : "2020-07-17T22:00:54Z", + "event" : "Login failed.", + "ipAddress" : "99.128.0.0/11", + "uid" : "1234", + "user" : "API Sandbox User (noreply@thousandeyes.com)" + } ], + "startDate" : "2022-07-17T22:00:54Z" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_user_events( + + aid=aid, + + use_all_permitted_aids=use_all_permitted_aids, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_user_events"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_user_events_error_400(self) -> None: + """Integration test for get_user_events error path (HTTP 400)""" + aid = '1234' + use_all_permitted_aids = False + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.get_user_events( + + aid=aid, + + use_all_permitted_aids=use_all_permitted_aids, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_user_events", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_user_events_error_401(self) -> None: + """Integration test for get_user_events error path (HTTP 401)""" + aid = '1234' + use_all_permitted_aids = False + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_user_events( + + aid=aid, + + use_all_permitted_aids=use_all_permitted_aids, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_user_events", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_user_events_error_403(self) -> None: + """Integration test for get_user_events error path (HTTP 403)""" + aid = '1234' + use_all_permitted_aids = False + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_user_events( + + aid=aid, + + use_all_permitted_aids=use_all_permitted_aids, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_user_events", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_user_events_error_404(self) -> None: + """Integration test for get_user_events error path (HTTP 404)""" + aid = '1234' + use_all_permitted_aids = False + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_user_events( + + aid=aid, + + use_all_permitted_aids=use_all_permitted_aids, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_user_events", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_user_events_error_429(self) -> None: + """Integration test for get_user_events error path (HTTP 429)""" + aid = '1234' + use_all_permitted_aids = False + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_user_events( + + aid=aid, + + use_all_permitted_aids=use_all_permitted_aids, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_user_events", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_user_events_error_500(self) -> None: + """Integration test for get_user_events error path (HTTP 500)""" + aid = '1234' + use_all_permitted_aids = False + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_user_events( + + aid=aid, + + use_all_permitted_aids=use_all_permitted_aids, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_user_events", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-administrative/test/test_users_api_integration.py b/thousandeyes-sdk-administrative/test/test_users_api_integration.py new file mode 100644 index 00000000..c1a0b9d2 --- /dev/null +++ b/thousandeyes-sdk-administrative/test/test_users_api_integration.py @@ -0,0 +1,1695 @@ +# coding: utf-8 + +""" + Administrative API + + Manage users, accounts, and account groups in the ThousandEyes platform using the Administrative API. This API provides the following operations to manage your organization: * `/account-groups`: Account groups are used to divide an organization into different sections. These operations can be used to create, retrieve, update and delete account groups. * `/users`: Create, retrieve, update and delete users within an organization. * `/roles`: Create, retrieve and update roles for the current user. * `/permissions`: Retrieve all assignable permissions. Used in the context of modifying roles. * `/audit-user-events`: Retrieve all activity log events. For more information about the administrative models, see [Account Management](https://docs.thousandeyes.com/product-documentation/user-management). + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.administrative.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.administrative.api.users_api import UsersApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestUsersApiIntegration(IntegrationTestBase): + """UsersApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = UsersApi(self.api_client) + + + def test_create_user_happy_path(self) -> None: + """Integration test for create_user success path""" + request_body_json = """ + + { + "loginAccountGroupId" : "691", + "accountGroupRoles" : [ { + "roleIds" : [ "57", "1140" ], + "accountGroupId" : "315" + }, { + "roleIds" : [ "57", "1140" ], + "accountGroupId" : "315" + } ], + "name" : "User X", + "allAccountGroupRoleIds" : [ "57", "1140" ], + "email" : "userx@thousandeyes.com" + } + + """ + user_request = thousandeyes_sdk.administrative.models.UserRequest.from_json(request_body_json) + aid = '1234' + response_body_json = """ + { + "loginAccountGroup" : { + "accountGroupName" : "Account A", + "aid" : "1234" + }, + "uid" : "245", + "allAccountGroupRoles" : [ { + "roleId" : "35", + "name" : "Organization Admin", + "isBuiltin" : true, + "hasManagementPermissions" : true + }, { + "roleId" : "35", + "name" : "Organization Admin", + "isBuiltin" : true, + "hasManagementPermissions" : true + } ], + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "accountGroupRoles" : [ { + "roles" : [ { + "roleId" : "35", + "name" : "Organization Admin", + "isBuiltin" : true, + "hasManagementPermissions" : true + }, { + "roleId" : "35", + "name" : "Organization Admin", + "isBuiltin" : true, + "hasManagementPermissions" : true + } ], + "accountGroup" : { + "accountGroupName" : "Account A", + "aid" : "1234" + } + }, { + "roles" : [ { + "roleId" : "35", + "name" : "Organization Admin", + "isBuiltin" : true, + "hasManagementPermissions" : true + }, { + "roleId" : "35", + "name" : "Organization Admin", + "isBuiltin" : true, + "hasManagementPermissions" : true + } ], + "accountGroup" : { + "accountGroupName" : "Account A", + "aid" : "1234" + } + } ], + "name" : "User X", + "email" : "userx@thousandeyes.com", + "dateRegistered" : "2020-07-17T22:00:54Z" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.create_user( + + user_request=user_request, + + aid=aid, + + _headers=self.te_headers("create_user"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_create_user_error_400(self) -> None: + """Integration test for create_user error path (HTTP 400)""" + request_body_json = """ + + { + "loginAccountGroupId" : "691", + "accountGroupRoles" : [ { + "roleIds" : [ "57", "1140" ], + "accountGroupId" : "315" + }, { + "roleIds" : [ "57", "1140" ], + "accountGroupId" : "315" + } ], + "name" : "User X", + "allAccountGroupRoleIds" : [ "57", "1140" ], + "email" : "userx@thousandeyes.com" + } + + """ + user_request = thousandeyes_sdk.administrative.models.UserRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.create_user( + + user_request=user_request, + + aid=aid, + + _headers=self.te_headers("create_user", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_user_error_401(self) -> None: + """Integration test for create_user error path (HTTP 401)""" + request_body_json = """ + + { + "loginAccountGroupId" : "691", + "accountGroupRoles" : [ { + "roleIds" : [ "57", "1140" ], + "accountGroupId" : "315" + }, { + "roleIds" : [ "57", "1140" ], + "accountGroupId" : "315" + } ], + "name" : "User X", + "allAccountGroupRoleIds" : [ "57", "1140" ], + "email" : "userx@thousandeyes.com" + } + + """ + user_request = thousandeyes_sdk.administrative.models.UserRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.create_user( + + user_request=user_request, + + aid=aid, + + _headers=self.te_headers("create_user", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_user_error_403(self) -> None: + """Integration test for create_user error path (HTTP 403)""" + request_body_json = """ + + { + "loginAccountGroupId" : "691", + "accountGroupRoles" : [ { + "roleIds" : [ "57", "1140" ], + "accountGroupId" : "315" + }, { + "roleIds" : [ "57", "1140" ], + "accountGroupId" : "315" + } ], + "name" : "User X", + "allAccountGroupRoleIds" : [ "57", "1140" ], + "email" : "userx@thousandeyes.com" + } + + """ + user_request = thousandeyes_sdk.administrative.models.UserRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.create_user( + + user_request=user_request, + + aid=aid, + + _headers=self.te_headers("create_user", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_user_error_404(self) -> None: + """Integration test for create_user error path (HTTP 404)""" + request_body_json = """ + + { + "loginAccountGroupId" : "691", + "accountGroupRoles" : [ { + "roleIds" : [ "57", "1140" ], + "accountGroupId" : "315" + }, { + "roleIds" : [ "57", "1140" ], + "accountGroupId" : "315" + } ], + "name" : "User X", + "allAccountGroupRoleIds" : [ "57", "1140" ], + "email" : "userx@thousandeyes.com" + } + + """ + user_request = thousandeyes_sdk.administrative.models.UserRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.create_user( + + user_request=user_request, + + aid=aid, + + _headers=self.te_headers("create_user", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_user_error_429(self) -> None: + """Integration test for create_user error path (HTTP 429)""" + request_body_json = """ + + { + "loginAccountGroupId" : "691", + "accountGroupRoles" : [ { + "roleIds" : [ "57", "1140" ], + "accountGroupId" : "315" + }, { + "roleIds" : [ "57", "1140" ], + "accountGroupId" : "315" + } ], + "name" : "User X", + "allAccountGroupRoleIds" : [ "57", "1140" ], + "email" : "userx@thousandeyes.com" + } + + """ + user_request = thousandeyes_sdk.administrative.models.UserRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.create_user( + + user_request=user_request, + + aid=aid, + + _headers=self.te_headers("create_user", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_user_error_500(self) -> None: + """Integration test for create_user error path (HTTP 500)""" + request_body_json = """ + + { + "loginAccountGroupId" : "691", + "accountGroupRoles" : [ { + "roleIds" : [ "57", "1140" ], + "accountGroupId" : "315" + }, { + "roleIds" : [ "57", "1140" ], + "accountGroupId" : "315" + } ], + "name" : "User X", + "allAccountGroupRoleIds" : [ "57", "1140" ], + "email" : "userx@thousandeyes.com" + } + + """ + user_request = thousandeyes_sdk.administrative.models.UserRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.create_user( + + user_request=user_request, + + aid=aid, + + _headers=self.te_headers("create_user", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_delete_user_happy_path(self) -> None: + """Integration test for delete_user success path""" + id = '1234' + aid = '1234' + response = self.api.delete_user_with_http_info( + + id=id, + + aid=aid, + + _headers=self.te_headers("delete_user"), + ) + self.assertEqual(204, response.status_code) + self.assertIsNone(response.data) + + + def test_delete_user_error_400(self) -> None: + """Integration test for delete_user error path (HTTP 400)""" + id = '1234' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.delete_user( + + id=id, + + aid=aid, + + _headers=self.te_headers("delete_user", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_user_error_401(self) -> None: + """Integration test for delete_user error path (HTTP 401)""" + id = '1234' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.delete_user( + + id=id, + + aid=aid, + + _headers=self.te_headers("delete_user", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_user_error_403(self) -> None: + """Integration test for delete_user error path (HTTP 403)""" + id = '1234' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.delete_user( + + id=id, + + aid=aid, + + _headers=self.te_headers("delete_user", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_user_error_404(self) -> None: + """Integration test for delete_user error path (HTTP 404)""" + id = '1234' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.delete_user( + + id=id, + + aid=aid, + + _headers=self.te_headers("delete_user", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_user_error_429(self) -> None: + """Integration test for delete_user error path (HTTP 429)""" + id = '1234' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.delete_user( + + id=id, + + aid=aid, + + _headers=self.te_headers("delete_user", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_user_error_500(self) -> None: + """Integration test for delete_user error path (HTTP 500)""" + id = '1234' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.delete_user( + + id=id, + + aid=aid, + + _headers=self.te_headers("delete_user", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_current_user_happy_path(self) -> None: + """Integration test for get_current_user success path""" + response_body_json = """ + { + "loginAccountGroup" : { + "accountGroupName" : "Account A", + "aid" : "1234" + }, + "uid" : "245", + "lastLogin" : "2022-07-17T22:00:54Z", + "allAccountGroupRoles" : [ { + "roleId" : "35", + "name" : "Organization Admin", + "isBuiltin" : true, + "hasManagementPermissions" : true + }, { + "roleId" : "35", + "name" : "Organization Admin", + "isBuiltin" : true, + "hasManagementPermissions" : true + } ], + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "accountGroupRoles" : [ { + "roles" : [ { + "roleId" : "35", + "name" : "Organization Admin", + "isBuiltin" : true, + "hasManagementPermissions" : true + }, { + "roleId" : "35", + "name" : "Organization Admin", + "isBuiltin" : true, + "hasManagementPermissions" : true + } ], + "accountGroup" : { + "accountGroupName" : "Account A", + "aid" : "1234" + } + }, { + "roles" : [ { + "roleId" : "35", + "name" : "Organization Admin", + "isBuiltin" : true, + "hasManagementPermissions" : true + }, { + "roleId" : "35", + "name" : "Organization Admin", + "isBuiltin" : true, + "hasManagementPermissions" : true + } ], + "accountGroup" : { + "accountGroupName" : "Account A", + "aid" : "1234" + } + } ], + "name" : "User X", + "email" : "userx@thousandeyes.com", + "dateRegistered" : "2020-07-17T22:00:54Z" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_current_user( + + _headers=self.te_headers("get_current_user"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_current_user_error_400(self) -> None: + """Integration test for get_current_user error path (HTTP 400)""" + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.get_current_user( + + _headers=self.te_headers("get_current_user", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_current_user_error_401(self) -> None: + """Integration test for get_current_user error path (HTTP 401)""" + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_current_user( + + _headers=self.te_headers("get_current_user", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_current_user_error_403(self) -> None: + """Integration test for get_current_user error path (HTTP 403)""" + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_current_user( + + _headers=self.te_headers("get_current_user", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_current_user_error_404(self) -> None: + """Integration test for get_current_user error path (HTTP 404)""" + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_current_user( + + _headers=self.te_headers("get_current_user", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_current_user_error_429(self) -> None: + """Integration test for get_current_user error path (HTTP 429)""" + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_current_user( + + _headers=self.te_headers("get_current_user", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_current_user_error_500(self) -> None: + """Integration test for get_current_user error path (HTTP 500)""" + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_current_user( + + _headers=self.te_headers("get_current_user", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_user_happy_path(self) -> None: + """Integration test for get_user success path""" + id = '1234' + aid = '1234' + response_body_json = """ + { + "loginAccountGroup" : { + "accountGroupName" : "Account A", + "aid" : "1234" + }, + "uid" : "245", + "lastLogin" : "2022-07-17T22:00:54Z", + "allAccountGroupRoles" : [ { + "roleId" : "35", + "name" : "Organization Admin", + "isBuiltin" : true, + "hasManagementPermissions" : true + }, { + "roleId" : "35", + "name" : "Organization Admin", + "isBuiltin" : true, + "hasManagementPermissions" : true + } ], + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "accountGroupRoles" : [ { + "roles" : [ { + "roleId" : "35", + "name" : "Organization Admin", + "isBuiltin" : true, + "hasManagementPermissions" : true + }, { + "roleId" : "35", + "name" : "Organization Admin", + "isBuiltin" : true, + "hasManagementPermissions" : true + } ], + "accountGroup" : { + "accountGroupName" : "Account A", + "aid" : "1234" + } + }, { + "roles" : [ { + "roleId" : "35", + "name" : "Organization Admin", + "isBuiltin" : true, + "hasManagementPermissions" : true + }, { + "roleId" : "35", + "name" : "Organization Admin", + "isBuiltin" : true, + "hasManagementPermissions" : true + } ], + "accountGroup" : { + "accountGroupName" : "Account A", + "aid" : "1234" + } + } ], + "name" : "User X", + "email" : "userx@thousandeyes.com", + "dateRegistered" : "2020-07-17T22:00:54Z" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_user( + + id=id, + + aid=aid, + + _headers=self.te_headers("get_user"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_user_error_400(self) -> None: + """Integration test for get_user error path (HTTP 400)""" + id = '1234' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.get_user( + + id=id, + + aid=aid, + + _headers=self.te_headers("get_user", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_user_error_401(self) -> None: + """Integration test for get_user error path (HTTP 401)""" + id = '1234' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_user( + + id=id, + + aid=aid, + + _headers=self.te_headers("get_user", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_user_error_403(self) -> None: + """Integration test for get_user error path (HTTP 403)""" + id = '1234' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_user( + + id=id, + + aid=aid, + + _headers=self.te_headers("get_user", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_user_error_404(self) -> None: + """Integration test for get_user error path (HTTP 404)""" + id = '1234' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_user( + + id=id, + + aid=aid, + + _headers=self.te_headers("get_user", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_user_error_429(self) -> None: + """Integration test for get_user error path (HTTP 429)""" + id = '1234' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_user( + + id=id, + + aid=aid, + + _headers=self.te_headers("get_user", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_user_error_500(self) -> None: + """Integration test for get_user error path (HTTP 500)""" + id = '1234' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_user( + + id=id, + + aid=aid, + + _headers=self.te_headers("get_user", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_users_happy_path(self) -> None: + """Integration test for get_users success path""" + aid = '1234' + response_body_json = """ + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "users" : [ { + "loginAccountGroup" : { + "accountGroupName" : "Account A", + "aid" : "1234" + }, + "uid" : "245", + "lastLogin" : "2022-07-17T22:00:54Z", + "name" : "User X", + "email" : "userx@thousandeyes.com", + "dateRegistered" : "2020-07-17T22:00:54Z" + }, { + "loginAccountGroup" : { + "accountGroupName" : "Account A", + "aid" : "1234" + }, + "uid" : "245", + "lastLogin" : "2022-07-17T22:00:54Z", + "name" : "User X", + "email" : "userx@thousandeyes.com", + "dateRegistered" : "2020-07-17T22:00:54Z" + } ] + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_users( + + aid=aid, + + _headers=self.te_headers("get_users"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_users_error_400(self) -> None: + """Integration test for get_users error path (HTTP 400)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.get_users( + + aid=aid, + + _headers=self.te_headers("get_users", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_users_error_401(self) -> None: + """Integration test for get_users error path (HTTP 401)""" + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_users( + + aid=aid, + + _headers=self.te_headers("get_users", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_users_error_403(self) -> None: + """Integration test for get_users error path (HTTP 403)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_users( + + aid=aid, + + _headers=self.te_headers("get_users", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_users_error_404(self) -> None: + """Integration test for get_users error path (HTTP 404)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_users( + + aid=aid, + + _headers=self.te_headers("get_users", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_users_error_429(self) -> None: + """Integration test for get_users error path (HTTP 429)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_users( + + aid=aid, + + _headers=self.te_headers("get_users", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_users_error_500(self) -> None: + """Integration test for get_users error path (HTTP 500)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_users( + + aid=aid, + + _headers=self.te_headers("get_users", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_update_user_happy_path(self) -> None: + """Integration test for update_user success path""" + request_body_json = """ + + { + "loginAccountGroupId" : "691", + "accountGroupRoles" : [ { + "roleIds" : [ "57", "1140" ], + "accountGroupId" : "315" + }, { + "roleIds" : [ "57", "1140" ], + "accountGroupId" : "315" + } ], + "name" : "User X", + "allAccountGroupRoleIds" : [ "57", "1140" ], + "email" : "userx@thousandeyes.com" + } + + """ + user_request = thousandeyes_sdk.administrative.models.UserRequest.from_json(request_body_json) + id = '1234' + aid = '1234' + response_body_json = """ + { + "loginAccountGroup" : { + "accountGroupName" : "Account A", + "aid" : "1234" + }, + "uid" : "245", + "lastLogin" : "2022-07-17T22:00:54Z", + "allAccountGroupRoles" : [ { + "roleId" : "35", + "name" : "Organization Admin", + "isBuiltin" : true, + "hasManagementPermissions" : true + }, { + "roleId" : "35", + "name" : "Organization Admin", + "isBuiltin" : true, + "hasManagementPermissions" : true + } ], + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "accountGroupRoles" : [ { + "roles" : [ { + "roleId" : "35", + "name" : "Organization Admin", + "isBuiltin" : true, + "hasManagementPermissions" : true + }, { + "roleId" : "35", + "name" : "Organization Admin", + "isBuiltin" : true, + "hasManagementPermissions" : true + } ], + "accountGroup" : { + "accountGroupName" : "Account A", + "aid" : "1234" + } + }, { + "roles" : [ { + "roleId" : "35", + "name" : "Organization Admin", + "isBuiltin" : true, + "hasManagementPermissions" : true + }, { + "roleId" : "35", + "name" : "Organization Admin", + "isBuiltin" : true, + "hasManagementPermissions" : true + } ], + "accountGroup" : { + "accountGroupName" : "Account A", + "aid" : "1234" + } + } ], + "name" : "User X", + "email" : "userx@thousandeyes.com", + "dateRegistered" : "2020-07-17T22:00:54Z" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.update_user( + + id=id, + + user_request=user_request, + + aid=aid, + + _headers=self.te_headers("update_user"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_update_user_error_400(self) -> None: + """Integration test for update_user error path (HTTP 400)""" + request_body_json = """ + + { + "loginAccountGroupId" : "691", + "accountGroupRoles" : [ { + "roleIds" : [ "57", "1140" ], + "accountGroupId" : "315" + }, { + "roleIds" : [ "57", "1140" ], + "accountGroupId" : "315" + } ], + "name" : "User X", + "allAccountGroupRoleIds" : [ "57", "1140" ], + "email" : "userx@thousandeyes.com" + } + + """ + user_request = thousandeyes_sdk.administrative.models.UserRequest.from_json(request_body_json) + id = '1234' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.update_user( + + id=id, + + user_request=user_request, + + aid=aid, + + _headers=self.te_headers("update_user", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_user_error_401(self) -> None: + """Integration test for update_user error path (HTTP 401)""" + request_body_json = """ + + { + "loginAccountGroupId" : "691", + "accountGroupRoles" : [ { + "roleIds" : [ "57", "1140" ], + "accountGroupId" : "315" + }, { + "roleIds" : [ "57", "1140" ], + "accountGroupId" : "315" + } ], + "name" : "User X", + "allAccountGroupRoleIds" : [ "57", "1140" ], + "email" : "userx@thousandeyes.com" + } + + """ + user_request = thousandeyes_sdk.administrative.models.UserRequest.from_json(request_body_json) + id = '1234' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.update_user( + + id=id, + + user_request=user_request, + + aid=aid, + + _headers=self.te_headers("update_user", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_user_error_403(self) -> None: + """Integration test for update_user error path (HTTP 403)""" + request_body_json = """ + + { + "loginAccountGroupId" : "691", + "accountGroupRoles" : [ { + "roleIds" : [ "57", "1140" ], + "accountGroupId" : "315" + }, { + "roleIds" : [ "57", "1140" ], + "accountGroupId" : "315" + } ], + "name" : "User X", + "allAccountGroupRoleIds" : [ "57", "1140" ], + "email" : "userx@thousandeyes.com" + } + + """ + user_request = thousandeyes_sdk.administrative.models.UserRequest.from_json(request_body_json) + id = '1234' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.update_user( + + id=id, + + user_request=user_request, + + aid=aid, + + _headers=self.te_headers("update_user", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_user_error_404(self) -> None: + """Integration test for update_user error path (HTTP 404)""" + request_body_json = """ + + { + "loginAccountGroupId" : "691", + "accountGroupRoles" : [ { + "roleIds" : [ "57", "1140" ], + "accountGroupId" : "315" + }, { + "roleIds" : [ "57", "1140" ], + "accountGroupId" : "315" + } ], + "name" : "User X", + "allAccountGroupRoleIds" : [ "57", "1140" ], + "email" : "userx@thousandeyes.com" + } + + """ + user_request = thousandeyes_sdk.administrative.models.UserRequest.from_json(request_body_json) + id = '1234' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.update_user( + + id=id, + + user_request=user_request, + + aid=aid, + + _headers=self.te_headers("update_user", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_user_error_429(self) -> None: + """Integration test for update_user error path (HTTP 429)""" + request_body_json = """ + + { + "loginAccountGroupId" : "691", + "accountGroupRoles" : [ { + "roleIds" : [ "57", "1140" ], + "accountGroupId" : "315" + }, { + "roleIds" : [ "57", "1140" ], + "accountGroupId" : "315" + } ], + "name" : "User X", + "allAccountGroupRoleIds" : [ "57", "1140" ], + "email" : "userx@thousandeyes.com" + } + + """ + user_request = thousandeyes_sdk.administrative.models.UserRequest.from_json(request_body_json) + id = '1234' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.update_user( + + id=id, + + user_request=user_request, + + aid=aid, + + _headers=self.te_headers("update_user", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_user_error_500(self) -> None: + """Integration test for update_user error path (HTTP 500)""" + request_body_json = """ + + { + "loginAccountGroupId" : "691", + "accountGroupRoles" : [ { + "roleIds" : [ "57", "1140" ], + "accountGroupId" : "315" + }, { + "roleIds" : [ "57", "1140" ], + "accountGroupId" : "315" + } ], + "name" : "User X", + "allAccountGroupRoleIds" : [ "57", "1140" ], + "email" : "userx@thousandeyes.com" + } + + """ + user_request = thousandeyes_sdk.administrative.models.UserRequest.from_json(request_body_json) + id = '1234' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.update_user( + + id=id, + + user_request=user_request, + + aid=aid, + + _headers=self.te_headers("update_user", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-administrative/test/test_utils.py b/thousandeyes-sdk-administrative/test/test_utils.py index 930528d9..37913f62 100644 --- a/thousandeyes-sdk-administrative/test/test_utils.py +++ b/thousandeyes-sdk-administrative/test/test_utils.py @@ -2,15 +2,36 @@ import json import unittest +from typing import Any from pydantic import BaseModel +def _project_onto_constructed(expected: Any, constructed: Any) -> Any: + """Keep only example fields that appear in the constructed model output.""" + if isinstance(constructed, dict): + if not isinstance(expected, dict): + return expected + return { + key: _project_onto_constructed(expected.get(key), value) + for key, value in constructed.items() + } + if isinstance(constructed, list): + if not isinstance(expected, list): + return expected + return [ + _project_onto_constructed(expected[index], value) + for index, value in enumerate(constructed) + ] + return expected + + def assert_constructed_model_matches_example_json(model: BaseModel, loaded_json: dict): test_case = unittest.TestCase() test_case.maxDiff = None test_case.assertIsNotNone(model) constructed_json = json.loads(model.to_json()) - sorted_loaded_json = json.dumps(loaded_json, sort_keys=True) + projected_loaded_json = _project_onto_constructed(loaded_json, constructed_json) + sorted_loaded_json = json.dumps(projected_loaded_json, sort_keys=True) sorted_constructed_json = json.dumps(constructed_json, sort_keys=True) test_case.assertEqual(sorted_loaded_json, sorted_constructed_json) diff --git a/thousandeyes-sdk-agents/test/conftest.py b/thousandeyes-sdk-agents/test/conftest.py new file mode 100644 index 00000000..2edba7b3 --- /dev/null +++ b/thousandeyes-sdk-agents/test/conftest.py @@ -0,0 +1,7 @@ +import sys +from pathlib import Path + +_repo_root = Path(__file__).resolve().parents[2] +_core_test_support = _repo_root / "thousandeyes-sdk-core" / "test" +if str(_core_test_support) not in sys.path: + sys.path.insert(0, str(_core_test_support)) diff --git a/thousandeyes-sdk-agents/test/integration_test_utils.py b/thousandeyes-sdk-agents/test/integration_test_utils.py new file mode 100644 index 00000000..7813e966 --- /dev/null +++ b/thousandeyes-sdk-agents/test/integration_test_utils.py @@ -0,0 +1,37 @@ +# coding: utf-8 + +""" + Agents API + + ## Overview Manage Cloud and Enterprise Agents available to your account in ThousandEyes. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from thousandeyes_sdk.core.api_client import ApiClient +from thousandeyes_sdk.core.configuration import Configuration +from sdk_test_support.mock_server import ERROR_STATUS_HEADER, OPERATION_ID_HEADER, MockApiServer + +from .mock_manifest import OPERATION_MANIFEST + + +class IntegrationTestBase(unittest.TestCase): + def setUp(self) -> None: + self.server = MockApiServer(OPERATION_MANIFEST) + self.server.start() + configuration = Configuration(host=self.server.base_url, access_token="test-token") + self.api_client = ApiClient(configuration=configuration) + + def tearDown(self) -> None: + self.server.stop() + + def te_headers(self, operation_id: str, error_status=None): + headers = {OPERATION_ID_HEADER: operation_id} + if error_status is not None: + headers[ERROR_STATUS_HEADER] = error_status + return headers diff --git a/thousandeyes-sdk-agents/test/mock_manifest.py b/thousandeyes-sdk-agents/test/mock_manifest.py new file mode 100644 index 00000000..2007d92e --- /dev/null +++ b/thousandeyes-sdk-agents/test/mock_manifest.py @@ -0,0 +1,2459 @@ +# coding: utf-8 + +""" + Agents API + + ## Overview Manage Cloud and Enterprise Agents available to your account in ThousandEyes. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json + +from sdk_test_support.mock_server_types import ErrorResponseExpectation, OperationExpectation + +OPERATION_MANIFEST = { + + "get_agents_proxies": OperationExpectation( + operation_id="get_agents_proxies", + method="GET", + path="/agents/proxies", + path_param_examples={ + }, + success_status=200, + success_body=json.loads(""" + + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "agentProxies" : [ { + "password" : "**********", + "isLocalConfigured" : true, + "name" : "Test Proxy - Auth Type - BASIC", + "location" : "proxy.thousandeyes.com:3128", + "lastModified" : "2022-07-17T22:00:54Z", + "authType" : "basic", + "type" : "static", + "aid" : "1234", + "bypassList" : [ "10.0.0.0/16", "*.thousandeyes.com" ], + "user" : "user1", + "proxyId" : "281474976710706" + }, { + "password" : "**********", + "isLocalConfigured" : true, + "name" : "Test Proxy - Auth Type - BASIC", + "location" : "proxy.thousandeyes.com:3128", + "lastModified" : "2022-07-17T22:00:54Z", + "authType" : "basic", + "type" : "static", + "aid" : "1234", + "bypassList" : [ "10.0.0.0/16", "*.thousandeyes.com" ], + "user" : "user1", + "proxyId" : "281474976710706" + } ] + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_agents_notification_rule": OperationExpectation( + operation_id="get_agents_notification_rule", + method="GET", + path="/agents/notification-rules/{notificationRuleId}", + path_param_examples={ + "notificationRuleId": '281474976710706', + }, + success_status=200, + success_body=json.loads(""" + + { + "isDefault" : false, + "expression" : "((lastContact >= 30 min))", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "ruleName" : "Default Agent Offline Notification", + "ruleId" : "281474976710706", + "notifications" : { + "thirdParty" : [ { + "integrationType" : "slack", + "integrationName" : "integrationSlack1", + "authToken" : "0VqDYEpidpHVAK397x8PBsmZ", + "channel" : "#slackChannel", + "integrationId" : "wb-78", + "authMethod" : "Basic", + "authUser" : "user123", + "target" : "https://hooks.slack.com/services/asd/0VqDYEpidpHVAK397x8PBsmZ" + }, { + "integrationType" : "slack", + "integrationName" : "integrationSlack1", + "authToken" : "0VqDYEpidpHVAK397x8PBsmZ", + "channel" : "#slackChannel", + "integrationId" : "wb-78", + "authMethod" : "Basic", + "authUser" : "user123", + "target" : "https://hooks.slack.com/services/asd/0VqDYEpidpHVAK397x8PBsmZ" + } ], + "webhook" : [ { + "integrationType" : "slack", + "integrationName" : "integrationSlack1", + "authToken" : "0VqDYEpidpHVAK397x8PBsmZ", + "channel" : "#slackChannel", + "integrationId" : "wb-78", + "authMethod" : "Basic", + "authUser" : "user123", + "target" : "https://hooks.slack.com/services/asd/0VqDYEpidpHVAK397x8PBsmZ" + }, { + "integrationType" : "slack", + "integrationName" : "integrationSlack1", + "authToken" : "0VqDYEpidpHVAK397x8PBsmZ", + "channel" : "#slackChannel", + "integrationId" : "wb-78", + "authMethod" : "Basic", + "authUser" : "user123", + "target" : "https://hooks.slack.com/services/asd/0VqDYEpidpHVAK397x8PBsmZ" + } ], + "email" : { + "recipients" : [ "user1@thousandeyes.com", "user2@cisco.com" ], + "message" : "This test is failing, check as soon as possible." + } + }, + "notifyOnClear" : true, + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ] + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_agents_notification_rules": OperationExpectation( + operation_id="get_agents_notification_rules", + method="GET", + path="/agents/notification-rules", + path_param_examples={ + }, + success_status=200, + success_body=json.loads(""" + + { + "agentAlertRules" : [ { + "ruleId" : "281474976710706", + "ruleName" : "Default Agent Offline Notification", + "expression" : "((lastContact >= 30 min))", + "notifyOnClear" : true, + "isDefault" : false + }, { + "ruleId" : "281474976710709", + "ruleName" : "Test Rule", + "expression" : "((lastContact >= 40 min))", + "notifyOnClear" : true, + "isDefault" : true + } ], + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "delete_agent": OperationExpectation( + operation_id="delete_agent", + method="DELETE", + path="/agents/{agentId}", + path_param_examples={ + "agentId": '281474976710706', + }, + success_status=204, + success_body=None, + success_content_type="application/json", + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_agent": OperationExpectation( + operation_id="get_agent", + method="GET", + path="/agents/{agentId}", + path_param_examples={ + "agentId": '281474976710706', + }, + success_status=200, + success_body=json.loads(""" + + { + "agentId" : "281474976710706", + "agentType" : "cloud", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "labels" : [ { + "labelId" : "11", + "name" : "Label name" + }, { + "labelId" : "11", + "name" : "Label name" + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "tests" : [ { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + }, { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + } ], + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_agents": OperationExpectation( + operation_id="get_agents", + method="GET", + path="/agents", + path_param_examples={ + }, + success_status=200, + success_body=json.loads(""" + + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ] + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "update_agent": OperationExpectation( + operation_id="update_agent", + method="PUT", + path="/agents/{agentId}", + path_param_examples={ + "agentId": '281474976710706', + }, + success_status=200, + success_body=json.loads(""" + + { + "agentId" : "281474976710706", + "agentType" : "cloud", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "labels" : [ { + "labelId" : "11", + "name" : "Label name" + }, { + "labelId" : "11", + "name" : "Label name" + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "tests" : [ { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + }, { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + } ], + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "localResolutionPrefixes" : [ "10.2.3.3/24", "10.2.3.3/25" ], + "tests" : [ "12313145", "12345" ], + "ipv6Policy" : "force-ipv4", + "keepBrowserCache" : true, + "targetForTests" : "1.1.1.1", + "agentName" : "thousandeyes-stg-va-254", + "enabled" : true, + "accountGroups" : [ "1234", "1" ] + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "assign_agent_to_cluster": OperationExpectation( + operation_id="assign_agent_to_cluster", + method="POST", + path="/agents/{agentId}/cluster/assign", + path_param_examples={ + "agentId": '281474976710706', + }, + success_status=200, + success_body=json.loads(""" + + { + "agentId" : "281474976710706", + "agentType" : "cloud", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "labels" : [ { + "labelId" : "11", + "name" : "Label name" + }, { + "labelId" : "11", + "name" : "Label name" + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "tests" : [ { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + }, { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + } ], + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "agents" : [ "281474976710706" ] + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "unassign_agent_from_cluster": OperationExpectation( + operation_id="unassign_agent_from_cluster", + method="POST", + path="/agents/{agentId}/cluster/unassign", + path_param_examples={ + "agentId": '281474976710706', + }, + success_status=200, + success_body=json.loads(""" + + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ] + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "members" : [ "281474976710706" ] + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_agents_local_problems": OperationExpectation( + operation_id="get_agents_local_problems", + method="GET", + path="/agents/local-problems", + path_param_examples={ + }, + success_status=200, + success_body=json.loads(""" + + { + "endDate" : "2022-07-18T22:00:54Z", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "localProblems" : [ { + "duration" : 480, + "agent" : { + "agentId" : "281474976710706", + "agentName" : "thousandeyes-stg-va-254", + "location" : "San Francisco Bay Area", + "countryId" : "US" + }, + "endDate" : "2026-05-18T03:22:00Z", + "active" : false, + "startDate" : "2026-05-18T03:14:00Z" + }, { + "duration" : 480, + "agent" : { + "agentId" : "281474976710706", + "agentName" : "thousandeyes-stg-va-254", + "location" : "San Francisco Bay Area", + "countryId" : "US" + }, + "endDate" : "2026-05-18T03:22:00Z", + "active" : false, + "startDate" : "2026-05-18T03:14:00Z" + } ], + "startDate" : "2022-07-17T22:00:54Z" + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "assign_tests": OperationExpectation( + operation_id="assign_tests", + method="POST", + path="/agents/{agentId}/tests/assign", + path_param_examples={ + "agentId": '281474976710706', + }, + success_status=200, + success_body=json.loads(""" + + { + "agentId" : "281474976710706", + "agentType" : "cloud", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "labels" : [ { + "labelId" : "11", + "name" : "Label name" + }, { + "labelId" : "11", + "name" : "Label name" + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "tests" : [ { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + }, { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + } ], + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "testIds" : [ "281474976710706" ] + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "overwrite_tests": OperationExpectation( + operation_id="overwrite_tests", + method="POST", + path="/agents/{agentId}/tests/override", + path_param_examples={ + "agentId": '281474976710706', + }, + success_status=200, + success_body=json.loads(""" + + { + "agentId" : "281474976710706", + "agentType" : "cloud", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "labels" : [ { + "labelId" : "11", + "name" : "Label name" + }, { + "labelId" : "11", + "name" : "Label name" + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "tests" : [ { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + }, { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + } ], + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "testIds" : [ "281474976710706" ] + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "unassign_tests": OperationExpectation( + operation_id="unassign_tests", + method="POST", + path="/agents/{agentId}/tests/unassign", + path_param_examples={ + "agentId": '281474976710706', + }, + success_status=200, + success_body=json.loads(""" + + { + "agentId" : "281474976710706", + "agentType" : "cloud", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "labels" : [ { + "labelId" : "11", + "name" : "Label name" + }, { + "labelId" : "11", + "name" : "Label name" + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "tests" : [ { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + }, { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + } ], + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "testIds" : [ "281474976710706" ] + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + +} diff --git a/thousandeyes-sdk-agents/test/test_agent_proxies_api_integration.py b/thousandeyes-sdk-agents/test/test_agent_proxies_api_integration.py new file mode 100644 index 00000000..c49fe42e --- /dev/null +++ b/thousandeyes-sdk-agents/test/test_agent_proxies_api_integration.py @@ -0,0 +1,238 @@ +# coding: utf-8 + +""" + Agents API + + ## Overview Manage Cloud and Enterprise Agents available to your account in ThousandEyes. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.agents.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.agents.api.agent_proxies_api import AgentProxiesApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestAgentProxiesApiIntegration(IntegrationTestBase): + """AgentProxiesApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = AgentProxiesApi(self.api_client) + + + def test_get_agents_proxies_happy_path(self) -> None: + """Integration test for get_agents_proxies success path""" + aid = '1234' + response_body_json = """ + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "agentProxies" : [ { + "password" : "**********", + "isLocalConfigured" : true, + "name" : "Test Proxy - Auth Type - BASIC", + "location" : "proxy.thousandeyes.com:3128", + "lastModified" : "2022-07-17T22:00:54Z", + "authType" : "basic", + "type" : "static", + "aid" : "1234", + "bypassList" : [ "10.0.0.0/16", "*.thousandeyes.com" ], + "user" : "user1", + "proxyId" : "281474976710706" + }, { + "password" : "**********", + "isLocalConfigured" : true, + "name" : "Test Proxy - Auth Type - BASIC", + "location" : "proxy.thousandeyes.com:3128", + "lastModified" : "2022-07-17T22:00:54Z", + "authType" : "basic", + "type" : "static", + "aid" : "1234", + "bypassList" : [ "10.0.0.0/16", "*.thousandeyes.com" ], + "user" : "user1", + "proxyId" : "281474976710706" + } ] + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_agents_proxies( + + aid=aid, + + _headers=self.te_headers("get_agents_proxies"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_agents_proxies_error_401(self) -> None: + """Integration test for get_agents_proxies error path (HTTP 401)""" + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_agents_proxies( + + aid=aid, + + _headers=self.te_headers("get_agents_proxies", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_agents_proxies_error_403(self) -> None: + """Integration test for get_agents_proxies error path (HTTP 403)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_agents_proxies( + + aid=aid, + + _headers=self.te_headers("get_agents_proxies", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_agents_proxies_error_404(self) -> None: + """Integration test for get_agents_proxies error path (HTTP 404)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_agents_proxies( + + aid=aid, + + _headers=self.te_headers("get_agents_proxies", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_agents_proxies_error_429(self) -> None: + """Integration test for get_agents_proxies error path (HTTP 429)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_agents_proxies( + + aid=aid, + + _headers=self.te_headers("get_agents_proxies", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_agents_proxies_error_500(self) -> None: + """Integration test for get_agents_proxies error path (HTTP 500)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_agents_proxies( + + aid=aid, + + _headers=self.te_headers("get_agents_proxies", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_agents_proxies_error_502(self) -> None: + """Integration test for get_agents_proxies error path (HTTP 502)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.get_agents_proxies( + + aid=aid, + + _headers=self.te_headers("get_agents_proxies", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-agents/test/test_cloud_and_enterprise_agent_notification_rules_api_integration.py b/thousandeyes-sdk-agents/test/test_cloud_and_enterprise_agent_notification_rules_api_integration.py new file mode 100644 index 00000000..f3e5a4a0 --- /dev/null +++ b/thousandeyes-sdk-agents/test/test_cloud_and_enterprise_agent_notification_rules_api_integration.py @@ -0,0 +1,517 @@ +# coding: utf-8 + +""" + Agents API + + ## Overview Manage Cloud and Enterprise Agents available to your account in ThousandEyes. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.agents.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.agents.api.cloud_and_enterprise_agent_notification_rules_api import CloudAndEnterpriseAgentNotificationRulesApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestCloudAndEnterpriseAgentNotificationRulesApiIntegration(IntegrationTestBase): + """CloudAndEnterpriseAgentNotificationRulesApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = CloudAndEnterpriseAgentNotificationRulesApi(self.api_client) + + + def test_get_agents_notification_rule_happy_path(self) -> None: + """Integration test for get_agents_notification_rule success path""" + notification_rule_id = '281474976710706' + aid = '1234' + response_body_json = """ + { + "isDefault" : false, + "expression" : "((lastContact >= 30 min))", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "ruleName" : "Default Agent Offline Notification", + "ruleId" : "281474976710706", + "notifications" : { + "thirdParty" : [ { + "integrationType" : "slack", + "integrationName" : "integrationSlack1", + "authToken" : "0VqDYEpidpHVAK397x8PBsmZ", + "channel" : "#slackChannel", + "integrationId" : "wb-78", + "authMethod" : "Basic", + "authUser" : "user123", + "target" : "https://hooks.slack.com/services/asd/0VqDYEpidpHVAK397x8PBsmZ" + }, { + "integrationType" : "slack", + "integrationName" : "integrationSlack1", + "authToken" : "0VqDYEpidpHVAK397x8PBsmZ", + "channel" : "#slackChannel", + "integrationId" : "wb-78", + "authMethod" : "Basic", + "authUser" : "user123", + "target" : "https://hooks.slack.com/services/asd/0VqDYEpidpHVAK397x8PBsmZ" + } ], + "webhook" : [ { + "integrationType" : "slack", + "integrationName" : "integrationSlack1", + "authToken" : "0VqDYEpidpHVAK397x8PBsmZ", + "channel" : "#slackChannel", + "integrationId" : "wb-78", + "authMethod" : "Basic", + "authUser" : "user123", + "target" : "https://hooks.slack.com/services/asd/0VqDYEpidpHVAK397x8PBsmZ" + }, { + "integrationType" : "slack", + "integrationName" : "integrationSlack1", + "authToken" : "0VqDYEpidpHVAK397x8PBsmZ", + "channel" : "#slackChannel", + "integrationId" : "wb-78", + "authMethod" : "Basic", + "authUser" : "user123", + "target" : "https://hooks.slack.com/services/asd/0VqDYEpidpHVAK397x8PBsmZ" + } ], + "email" : { + "recipients" : [ "user1@thousandeyes.com", "user2@cisco.com" ], + "message" : "This test is failing, check as soon as possible." + } + }, + "notifyOnClear" : true, + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ] + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_agents_notification_rule( + + notification_rule_id=notification_rule_id, + + aid=aid, + + _headers=self.te_headers("get_agents_notification_rule"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_agents_notification_rule_error_401(self) -> None: + """Integration test for get_agents_notification_rule error path (HTTP 401)""" + notification_rule_id = '281474976710706' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_agents_notification_rule( + + notification_rule_id=notification_rule_id, + + aid=aid, + + _headers=self.te_headers("get_agents_notification_rule", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_agents_notification_rule_error_403(self) -> None: + """Integration test for get_agents_notification_rule error path (HTTP 403)""" + notification_rule_id = '281474976710706' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_agents_notification_rule( + + notification_rule_id=notification_rule_id, + + aid=aid, + + _headers=self.te_headers("get_agents_notification_rule", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_agents_notification_rule_error_404(self) -> None: + """Integration test for get_agents_notification_rule error path (HTTP 404)""" + notification_rule_id = '281474976710706' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_agents_notification_rule( + + notification_rule_id=notification_rule_id, + + aid=aid, + + _headers=self.te_headers("get_agents_notification_rule", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_agents_notification_rule_error_429(self) -> None: + """Integration test for get_agents_notification_rule error path (HTTP 429)""" + notification_rule_id = '281474976710706' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_agents_notification_rule( + + notification_rule_id=notification_rule_id, + + aid=aid, + + _headers=self.te_headers("get_agents_notification_rule", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_agents_notification_rule_error_500(self) -> None: + """Integration test for get_agents_notification_rule error path (HTTP 500)""" + notification_rule_id = '281474976710706' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_agents_notification_rule( + + notification_rule_id=notification_rule_id, + + aid=aid, + + _headers=self.te_headers("get_agents_notification_rule", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_agents_notification_rule_error_502(self) -> None: + """Integration test for get_agents_notification_rule error path (HTTP 502)""" + notification_rule_id = '281474976710706' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.get_agents_notification_rule( + + notification_rule_id=notification_rule_id, + + aid=aid, + + _headers=self.te_headers("get_agents_notification_rule", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_agents_notification_rules_happy_path(self) -> None: + """Integration test for get_agents_notification_rules success path""" + aid = '1234' + response_body_json = """ + { + "agentAlertRules" : [ { + "ruleId" : "281474976710706", + "ruleName" : "Default Agent Offline Notification", + "expression" : "((lastContact >= 30 min))", + "notifyOnClear" : true, + "isDefault" : false + }, { + "ruleId" : "281474976710709", + "ruleName" : "Test Rule", + "expression" : "((lastContact >= 40 min))", + "notifyOnClear" : true, + "isDefault" : true + } ], + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_agents_notification_rules( + + aid=aid, + + _headers=self.te_headers("get_agents_notification_rules"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_agents_notification_rules_error_401(self) -> None: + """Integration test for get_agents_notification_rules error path (HTTP 401)""" + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_agents_notification_rules( + + aid=aid, + + _headers=self.te_headers("get_agents_notification_rules", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_agents_notification_rules_error_403(self) -> None: + """Integration test for get_agents_notification_rules error path (HTTP 403)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_agents_notification_rules( + + aid=aid, + + _headers=self.te_headers("get_agents_notification_rules", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_agents_notification_rules_error_404(self) -> None: + """Integration test for get_agents_notification_rules error path (HTTP 404)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_agents_notification_rules( + + aid=aid, + + _headers=self.te_headers("get_agents_notification_rules", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_agents_notification_rules_error_429(self) -> None: + """Integration test for get_agents_notification_rules error path (HTTP 429)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_agents_notification_rules( + + aid=aid, + + _headers=self.te_headers("get_agents_notification_rules", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_agents_notification_rules_error_500(self) -> None: + """Integration test for get_agents_notification_rules error path (HTTP 500)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_agents_notification_rules( + + aid=aid, + + _headers=self.te_headers("get_agents_notification_rules", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_agents_notification_rules_error_502(self) -> None: + """Integration test for get_agents_notification_rules error path (HTTP 502)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.get_agents_notification_rules( + + aid=aid, + + _headers=self.te_headers("get_agents_notification_rules", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-agents/test/test_cloud_and_enterprise_agents_api_integration.py b/thousandeyes-sdk-agents/test/test_cloud_and_enterprise_agents_api_integration.py new file mode 100644 index 00000000..92c940db --- /dev/null +++ b/thousandeyes-sdk-agents/test/test_cloud_and_enterprise_agents_api_integration.py @@ -0,0 +1,1250 @@ +# coding: utf-8 + +""" + Agents API + + ## Overview Manage Cloud and Enterprise Agents available to your account in ThousandEyes. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.agents.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.agents.api.cloud_and_enterprise_agents_api import CloudAndEnterpriseAgentsApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestCloudAndEnterpriseAgentsApiIntegration(IntegrationTestBase): + """CloudAndEnterpriseAgentsApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = CloudAndEnterpriseAgentsApi(self.api_client) + + + def test_delete_agent_happy_path(self) -> None: + """Integration test for delete_agent success path""" + agent_id = '281474976710706' + aid = '1234' + response = self.api.delete_agent_with_http_info( + + agent_id=agent_id, + + aid=aid, + + _headers=self.te_headers("delete_agent"), + ) + self.assertEqual(204, response.status_code) + self.assertIsNone(response.data) + + + def test_delete_agent_error_401(self) -> None: + """Integration test for delete_agent error path (HTTP 401)""" + agent_id = '281474976710706' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.delete_agent( + + agent_id=agent_id, + + aid=aid, + + _headers=self.te_headers("delete_agent", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_agent_error_403(self) -> None: + """Integration test for delete_agent error path (HTTP 403)""" + agent_id = '281474976710706' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.delete_agent( + + agent_id=agent_id, + + aid=aid, + + _headers=self.te_headers("delete_agent", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_agent_error_404(self) -> None: + """Integration test for delete_agent error path (HTTP 404)""" + agent_id = '281474976710706' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.delete_agent( + + agent_id=agent_id, + + aid=aid, + + _headers=self.te_headers("delete_agent", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_agent_error_429(self) -> None: + """Integration test for delete_agent error path (HTTP 429)""" + agent_id = '281474976710706' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.delete_agent( + + agent_id=agent_id, + + aid=aid, + + _headers=self.te_headers("delete_agent", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_agent_error_500(self) -> None: + """Integration test for delete_agent error path (HTTP 500)""" + agent_id = '281474976710706' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.delete_agent( + + agent_id=agent_id, + + aid=aid, + + _headers=self.te_headers("delete_agent", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_agent_error_502(self) -> None: + """Integration test for delete_agent error path (HTTP 502)""" + agent_id = '281474976710706' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.delete_agent( + + agent_id=agent_id, + + aid=aid, + + _headers=self.te_headers("delete_agent", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_agent_happy_path(self) -> None: + """Integration test for get_agent success path""" + agent_id = '281474976710706' + aid = '1234' + response_body_json = """ + { + "agentId" : "281474976710706", + "agentType" : "cloud", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "labels" : [ { + "labelId" : "11", + "name" : "Label name" + }, { + "labelId" : "11", + "name" : "Label name" + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "tests" : [ { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + }, { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + } ], + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_agent( + + agent_id=agent_id, + + aid=aid, + + _headers=self.te_headers("get_agent"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_agent_error_401(self) -> None: + """Integration test for get_agent error path (HTTP 401)""" + agent_id = '281474976710706' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_agent( + + agent_id=agent_id, + + aid=aid, + + _headers=self.te_headers("get_agent", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_agent_error_403(self) -> None: + """Integration test for get_agent error path (HTTP 403)""" + agent_id = '281474976710706' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_agent( + + agent_id=agent_id, + + aid=aid, + + _headers=self.te_headers("get_agent", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_agent_error_404(self) -> None: + """Integration test for get_agent error path (HTTP 404)""" + agent_id = '281474976710706' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_agent( + + agent_id=agent_id, + + aid=aid, + + _headers=self.te_headers("get_agent", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_agent_error_429(self) -> None: + """Integration test for get_agent error path (HTTP 429)""" + agent_id = '281474976710706' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_agent( + + agent_id=agent_id, + + aid=aid, + + _headers=self.te_headers("get_agent", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_agent_error_500(self) -> None: + """Integration test for get_agent error path (HTTP 500)""" + agent_id = '281474976710706' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_agent( + + agent_id=agent_id, + + aid=aid, + + _headers=self.te_headers("get_agent", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_agent_error_502(self) -> None: + """Integration test for get_agent error path (HTTP 502)""" + agent_id = '281474976710706' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.get_agent( + + agent_id=agent_id, + + aid=aid, + + _headers=self.te_headers("get_agent", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_agents_happy_path(self) -> None: + """Integration test for get_agents success path""" + aid = '1234' + labels = ['[\"myCustomLabeledAgent\"]'] + tag_keys = ['tag_keys_example'] + response_body_json = """ + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ] + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_agents( + + aid=aid, + + labels=labels, + + tag_keys=tag_keys, + + _headers=self.te_headers("get_agents"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_agents_error_401(self) -> None: + """Integration test for get_agents error path (HTTP 401)""" + aid = '1234' + labels = ['[\"myCustomLabeledAgent\"]'] + tag_keys = ['tag_keys_example'] + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_agents( + + aid=aid, + + labels=labels, + + tag_keys=tag_keys, + + _headers=self.te_headers("get_agents", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_agents_error_403(self) -> None: + """Integration test for get_agents error path (HTTP 403)""" + aid = '1234' + labels = ['[\"myCustomLabeledAgent\"]'] + tag_keys = ['tag_keys_example'] + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_agents( + + aid=aid, + + labels=labels, + + tag_keys=tag_keys, + + _headers=self.te_headers("get_agents", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_agents_error_404(self) -> None: + """Integration test for get_agents error path (HTTP 404)""" + aid = '1234' + labels = ['[\"myCustomLabeledAgent\"]'] + tag_keys = ['tag_keys_example'] + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_agents( + + aid=aid, + + labels=labels, + + tag_keys=tag_keys, + + _headers=self.te_headers("get_agents", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_agents_error_429(self) -> None: + """Integration test for get_agents error path (HTTP 429)""" + aid = '1234' + labels = ['[\"myCustomLabeledAgent\"]'] + tag_keys = ['tag_keys_example'] + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_agents( + + aid=aid, + + labels=labels, + + tag_keys=tag_keys, + + _headers=self.te_headers("get_agents", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_agents_error_500(self) -> None: + """Integration test for get_agents error path (HTTP 500)""" + aid = '1234' + labels = ['[\"myCustomLabeledAgent\"]'] + tag_keys = ['tag_keys_example'] + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_agents( + + aid=aid, + + labels=labels, + + tag_keys=tag_keys, + + _headers=self.te_headers("get_agents", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_agents_error_502(self) -> None: + """Integration test for get_agents error path (HTTP 502)""" + aid = '1234' + labels = ['[\"myCustomLabeledAgent\"]'] + tag_keys = ['tag_keys_example'] + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.get_agents( + + aid=aid, + + labels=labels, + + tag_keys=tag_keys, + + _headers=self.te_headers("get_agents", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_update_agent_happy_path(self) -> None: + """Integration test for update_agent success path""" + request_body_json = """ + + { + "localResolutionPrefixes" : [ "10.2.3.3/24", "10.2.3.3/25" ], + "tests" : [ "12313145", "12345" ], + "ipv6Policy" : "force-ipv4", + "keepBrowserCache" : true, + "targetForTests" : "1.1.1.1", + "agentName" : "thousandeyes-stg-va-254", + "enabled" : true, + "accountGroups" : [ "1234", "1" ] + } + + """ + agent_request = thousandeyes_sdk.agents.models.AgentRequest.from_json(request_body_json) + agent_id = '281474976710706' + aid = '1234' + response_body_json = """ + { + "agentId" : "281474976710706", + "agentType" : "cloud", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "labels" : [ { + "labelId" : "11", + "name" : "Label name" + }, { + "labelId" : "11", + "name" : "Label name" + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "tests" : [ { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + }, { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + } ], + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } + """ + expected_response = json.loads(response_body_json) + response = self.api.update_agent( + + agent_id=agent_id, + + agent_request=agent_request, + + aid=aid, + + _headers=self.te_headers("update_agent"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_update_agent_error_400(self) -> None: + """Integration test for update_agent error path (HTTP 400)""" + request_body_json = """ + + { + "localResolutionPrefixes" : [ "10.2.3.3/24", "10.2.3.3/25" ], + "tests" : [ "12313145", "12345" ], + "ipv6Policy" : "force-ipv4", + "keepBrowserCache" : true, + "targetForTests" : "1.1.1.1", + "agentName" : "thousandeyes-stg-va-254", + "enabled" : true, + "accountGroups" : [ "1234", "1" ] + } + + """ + agent_request = thousandeyes_sdk.agents.models.AgentRequest.from_json(request_body_json) + agent_id = '281474976710706' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.update_agent( + + agent_id=agent_id, + + agent_request=agent_request, + + aid=aid, + + _headers=self.te_headers("update_agent", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_agent_error_401(self) -> None: + """Integration test for update_agent error path (HTTP 401)""" + request_body_json = """ + + { + "localResolutionPrefixes" : [ "10.2.3.3/24", "10.2.3.3/25" ], + "tests" : [ "12313145", "12345" ], + "ipv6Policy" : "force-ipv4", + "keepBrowserCache" : true, + "targetForTests" : "1.1.1.1", + "agentName" : "thousandeyes-stg-va-254", + "enabled" : true, + "accountGroups" : [ "1234", "1" ] + } + + """ + agent_request = thousandeyes_sdk.agents.models.AgentRequest.from_json(request_body_json) + agent_id = '281474976710706' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.update_agent( + + agent_id=agent_id, + + agent_request=agent_request, + + aid=aid, + + _headers=self.te_headers("update_agent", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_agent_error_403(self) -> None: + """Integration test for update_agent error path (HTTP 403)""" + request_body_json = """ + + { + "localResolutionPrefixes" : [ "10.2.3.3/24", "10.2.3.3/25" ], + "tests" : [ "12313145", "12345" ], + "ipv6Policy" : "force-ipv4", + "keepBrowserCache" : true, + "targetForTests" : "1.1.1.1", + "agentName" : "thousandeyes-stg-va-254", + "enabled" : true, + "accountGroups" : [ "1234", "1" ] + } + + """ + agent_request = thousandeyes_sdk.agents.models.AgentRequest.from_json(request_body_json) + agent_id = '281474976710706' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.update_agent( + + agent_id=agent_id, + + agent_request=agent_request, + + aid=aid, + + _headers=self.te_headers("update_agent", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_agent_error_404(self) -> None: + """Integration test for update_agent error path (HTTP 404)""" + request_body_json = """ + + { + "localResolutionPrefixes" : [ "10.2.3.3/24", "10.2.3.3/25" ], + "tests" : [ "12313145", "12345" ], + "ipv6Policy" : "force-ipv4", + "keepBrowserCache" : true, + "targetForTests" : "1.1.1.1", + "agentName" : "thousandeyes-stg-va-254", + "enabled" : true, + "accountGroups" : [ "1234", "1" ] + } + + """ + agent_request = thousandeyes_sdk.agents.models.AgentRequest.from_json(request_body_json) + agent_id = '281474976710706' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.update_agent( + + agent_id=agent_id, + + agent_request=agent_request, + + aid=aid, + + _headers=self.te_headers("update_agent", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_agent_error_429(self) -> None: + """Integration test for update_agent error path (HTTP 429)""" + request_body_json = """ + + { + "localResolutionPrefixes" : [ "10.2.3.3/24", "10.2.3.3/25" ], + "tests" : [ "12313145", "12345" ], + "ipv6Policy" : "force-ipv4", + "keepBrowserCache" : true, + "targetForTests" : "1.1.1.1", + "agentName" : "thousandeyes-stg-va-254", + "enabled" : true, + "accountGroups" : [ "1234", "1" ] + } + + """ + agent_request = thousandeyes_sdk.agents.models.AgentRequest.from_json(request_body_json) + agent_id = '281474976710706' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.update_agent( + + agent_id=agent_id, + + agent_request=agent_request, + + aid=aid, + + _headers=self.te_headers("update_agent", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_agent_error_500(self) -> None: + """Integration test for update_agent error path (HTTP 500)""" + request_body_json = """ + + { + "localResolutionPrefixes" : [ "10.2.3.3/24", "10.2.3.3/25" ], + "tests" : [ "12313145", "12345" ], + "ipv6Policy" : "force-ipv4", + "keepBrowserCache" : true, + "targetForTests" : "1.1.1.1", + "agentName" : "thousandeyes-stg-va-254", + "enabled" : true, + "accountGroups" : [ "1234", "1" ] + } + + """ + agent_request = thousandeyes_sdk.agents.models.AgentRequest.from_json(request_body_json) + agent_id = '281474976710706' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.update_agent( + + agent_id=agent_id, + + agent_request=agent_request, + + aid=aid, + + _headers=self.te_headers("update_agent", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_agent_error_502(self) -> None: + """Integration test for update_agent error path (HTTP 502)""" + request_body_json = """ + + { + "localResolutionPrefixes" : [ "10.2.3.3/24", "10.2.3.3/25" ], + "tests" : [ "12313145", "12345" ], + "ipv6Policy" : "force-ipv4", + "keepBrowserCache" : true, + "targetForTests" : "1.1.1.1", + "agentName" : "thousandeyes-stg-va-254", + "enabled" : true, + "accountGroups" : [ "1234", "1" ] + } + + """ + agent_request = thousandeyes_sdk.agents.models.AgentRequest.from_json(request_body_json) + agent_id = '281474976710706' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.update_agent( + + agent_id=agent_id, + + agent_request=agent_request, + + aid=aid, + + _headers=self.te_headers("update_agent", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-agents/test/test_enterprise_agent_cluster_api_integration.py b/thousandeyes-sdk-agents/test/test_enterprise_agent_cluster_api_integration.py new file mode 100644 index 00000000..b734cdc2 --- /dev/null +++ b/thousandeyes-sdk-agents/test/test_enterprise_agent_cluster_api_integration.py @@ -0,0 +1,809 @@ +# coding: utf-8 + +""" + Agents API + + ## Overview Manage Cloud and Enterprise Agents available to your account in ThousandEyes. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.agents.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.agents.api.enterprise_agent_cluster_api import EnterpriseAgentClusterApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestEnterpriseAgentClusterApiIntegration(IntegrationTestBase): + """EnterpriseAgentClusterApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = EnterpriseAgentClusterApi(self.api_client) + + + def test_assign_agent_to_cluster_happy_path(self) -> None: + """Integration test for assign_agent_to_cluster success path""" + request_body_json = """ + + { + "agents" : [ "281474976710706" ] + } + + """ + agent_cluster_assign_request = thousandeyes_sdk.agents.models.AgentClusterAssignRequest.from_json(request_body_json) + agent_id = '281474976710706' + aid = '1234' + response_body_json = """ + { + "agentId" : "281474976710706", + "agentType" : "cloud", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "labels" : [ { + "labelId" : "11", + "name" : "Label name" + }, { + "labelId" : "11", + "name" : "Label name" + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "tests" : [ { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + }, { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + } ], + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } + """ + expected_response = json.loads(response_body_json) + response = self.api.assign_agent_to_cluster( + + agent_id=agent_id, + + agent_cluster_assign_request=agent_cluster_assign_request, + + aid=aid, + + _headers=self.te_headers("assign_agent_to_cluster"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_assign_agent_to_cluster_error_400(self) -> None: + """Integration test for assign_agent_to_cluster error path (HTTP 400)""" + request_body_json = """ + + { + "agents" : [ "281474976710706" ] + } + + """ + agent_cluster_assign_request = thousandeyes_sdk.agents.models.AgentClusterAssignRequest.from_json(request_body_json) + agent_id = '281474976710706' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.assign_agent_to_cluster( + + agent_id=agent_id, + + agent_cluster_assign_request=agent_cluster_assign_request, + + aid=aid, + + _headers=self.te_headers("assign_agent_to_cluster", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_assign_agent_to_cluster_error_401(self) -> None: + """Integration test for assign_agent_to_cluster error path (HTTP 401)""" + request_body_json = """ + + { + "agents" : [ "281474976710706" ] + } + + """ + agent_cluster_assign_request = thousandeyes_sdk.agents.models.AgentClusterAssignRequest.from_json(request_body_json) + agent_id = '281474976710706' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.assign_agent_to_cluster( + + agent_id=agent_id, + + agent_cluster_assign_request=agent_cluster_assign_request, + + aid=aid, + + _headers=self.te_headers("assign_agent_to_cluster", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_assign_agent_to_cluster_error_403(self) -> None: + """Integration test for assign_agent_to_cluster error path (HTTP 403)""" + request_body_json = """ + + { + "agents" : [ "281474976710706" ] + } + + """ + agent_cluster_assign_request = thousandeyes_sdk.agents.models.AgentClusterAssignRequest.from_json(request_body_json) + agent_id = '281474976710706' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.assign_agent_to_cluster( + + agent_id=agent_id, + + agent_cluster_assign_request=agent_cluster_assign_request, + + aid=aid, + + _headers=self.te_headers("assign_agent_to_cluster", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_assign_agent_to_cluster_error_404(self) -> None: + """Integration test for assign_agent_to_cluster error path (HTTP 404)""" + request_body_json = """ + + { + "agents" : [ "281474976710706" ] + } + + """ + agent_cluster_assign_request = thousandeyes_sdk.agents.models.AgentClusterAssignRequest.from_json(request_body_json) + agent_id = '281474976710706' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.assign_agent_to_cluster( + + agent_id=agent_id, + + agent_cluster_assign_request=agent_cluster_assign_request, + + aid=aid, + + _headers=self.te_headers("assign_agent_to_cluster", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_assign_agent_to_cluster_error_429(self) -> None: + """Integration test for assign_agent_to_cluster error path (HTTP 429)""" + request_body_json = """ + + { + "agents" : [ "281474976710706" ] + } + + """ + agent_cluster_assign_request = thousandeyes_sdk.agents.models.AgentClusterAssignRequest.from_json(request_body_json) + agent_id = '281474976710706' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.assign_agent_to_cluster( + + agent_id=agent_id, + + agent_cluster_assign_request=agent_cluster_assign_request, + + aid=aid, + + _headers=self.te_headers("assign_agent_to_cluster", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_assign_agent_to_cluster_error_500(self) -> None: + """Integration test for assign_agent_to_cluster error path (HTTP 500)""" + request_body_json = """ + + { + "agents" : [ "281474976710706" ] + } + + """ + agent_cluster_assign_request = thousandeyes_sdk.agents.models.AgentClusterAssignRequest.from_json(request_body_json) + agent_id = '281474976710706' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.assign_agent_to_cluster( + + agent_id=agent_id, + + agent_cluster_assign_request=agent_cluster_assign_request, + + aid=aid, + + _headers=self.te_headers("assign_agent_to_cluster", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_assign_agent_to_cluster_error_502(self) -> None: + """Integration test for assign_agent_to_cluster error path (HTTP 502)""" + request_body_json = """ + + { + "agents" : [ "281474976710706" ] + } + + """ + agent_cluster_assign_request = thousandeyes_sdk.agents.models.AgentClusterAssignRequest.from_json(request_body_json) + agent_id = '281474976710706' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.assign_agent_to_cluster( + + agent_id=agent_id, + + agent_cluster_assign_request=agent_cluster_assign_request, + + aid=aid, + + _headers=self.te_headers("assign_agent_to_cluster", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_unassign_agent_from_cluster_happy_path(self) -> None: + """Integration test for unassign_agent_from_cluster success path""" + request_body_json = """ + + { + "members" : [ "281474976710706" ] + } + + """ + agent_cluster_unassign_request = thousandeyes_sdk.agents.models.AgentClusterUnassignRequest.from_json(request_body_json) + agent_id = '281474976710706' + aid = '1234' + response_body_json = """ + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ] + } + """ + expected_response = json.loads(response_body_json) + response = self.api.unassign_agent_from_cluster( + + agent_id=agent_id, + + agent_cluster_unassign_request=agent_cluster_unassign_request, + + aid=aid, + + _headers=self.te_headers("unassign_agent_from_cluster"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_unassign_agent_from_cluster_error_400(self) -> None: + """Integration test for unassign_agent_from_cluster error path (HTTP 400)""" + request_body_json = """ + + { + "members" : [ "281474976710706" ] + } + + """ + agent_cluster_unassign_request = thousandeyes_sdk.agents.models.AgentClusterUnassignRequest.from_json(request_body_json) + agent_id = '281474976710706' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.unassign_agent_from_cluster( + + agent_id=agent_id, + + agent_cluster_unassign_request=agent_cluster_unassign_request, + + aid=aid, + + _headers=self.te_headers("unassign_agent_from_cluster", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_unassign_agent_from_cluster_error_401(self) -> None: + """Integration test for unassign_agent_from_cluster error path (HTTP 401)""" + request_body_json = """ + + { + "members" : [ "281474976710706" ] + } + + """ + agent_cluster_unassign_request = thousandeyes_sdk.agents.models.AgentClusterUnassignRequest.from_json(request_body_json) + agent_id = '281474976710706' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.unassign_agent_from_cluster( + + agent_id=agent_id, + + agent_cluster_unassign_request=agent_cluster_unassign_request, + + aid=aid, + + _headers=self.te_headers("unassign_agent_from_cluster", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_unassign_agent_from_cluster_error_403(self) -> None: + """Integration test for unassign_agent_from_cluster error path (HTTP 403)""" + request_body_json = """ + + { + "members" : [ "281474976710706" ] + } + + """ + agent_cluster_unassign_request = thousandeyes_sdk.agents.models.AgentClusterUnassignRequest.from_json(request_body_json) + agent_id = '281474976710706' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.unassign_agent_from_cluster( + + agent_id=agent_id, + + agent_cluster_unassign_request=agent_cluster_unassign_request, + + aid=aid, + + _headers=self.te_headers("unassign_agent_from_cluster", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_unassign_agent_from_cluster_error_404(self) -> None: + """Integration test for unassign_agent_from_cluster error path (HTTP 404)""" + request_body_json = """ + + { + "members" : [ "281474976710706" ] + } + + """ + agent_cluster_unassign_request = thousandeyes_sdk.agents.models.AgentClusterUnassignRequest.from_json(request_body_json) + agent_id = '281474976710706' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.unassign_agent_from_cluster( + + agent_id=agent_id, + + agent_cluster_unassign_request=agent_cluster_unassign_request, + + aid=aid, + + _headers=self.te_headers("unassign_agent_from_cluster", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_unassign_agent_from_cluster_error_429(self) -> None: + """Integration test for unassign_agent_from_cluster error path (HTTP 429)""" + request_body_json = """ + + { + "members" : [ "281474976710706" ] + } + + """ + agent_cluster_unassign_request = thousandeyes_sdk.agents.models.AgentClusterUnassignRequest.from_json(request_body_json) + agent_id = '281474976710706' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.unassign_agent_from_cluster( + + agent_id=agent_id, + + agent_cluster_unassign_request=agent_cluster_unassign_request, + + aid=aid, + + _headers=self.te_headers("unassign_agent_from_cluster", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_unassign_agent_from_cluster_error_500(self) -> None: + """Integration test for unassign_agent_from_cluster error path (HTTP 500)""" + request_body_json = """ + + { + "members" : [ "281474976710706" ] + } + + """ + agent_cluster_unassign_request = thousandeyes_sdk.agents.models.AgentClusterUnassignRequest.from_json(request_body_json) + agent_id = '281474976710706' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.unassign_agent_from_cluster( + + agent_id=agent_id, + + agent_cluster_unassign_request=agent_cluster_unassign_request, + + aid=aid, + + _headers=self.te_headers("unassign_agent_from_cluster", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_unassign_agent_from_cluster_error_502(self) -> None: + """Integration test for unassign_agent_from_cluster error path (HTTP 502)""" + request_body_json = """ + + { + "members" : [ "281474976710706" ] + } + + """ + agent_cluster_unassign_request = thousandeyes_sdk.agents.models.AgentClusterUnassignRequest.from_json(request_body_json) + agent_id = '281474976710706' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.unassign_agent_from_cluster( + + agent_id=agent_id, + + agent_cluster_unassign_request=agent_cluster_unassign_request, + + aid=aid, + + _headers=self.te_headers("unassign_agent_from_cluster", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-agents/test/test_local_problems_api_integration.py b/thousandeyes-sdk-agents/test/test_local_problems_api_integration.py new file mode 100644 index 00000000..bd908a0b --- /dev/null +++ b/thousandeyes-sdk-agents/test/test_local_problems_api_integration.py @@ -0,0 +1,344 @@ +# coding: utf-8 + +""" + Agents API + + ## Overview Manage Cloud and Enterprise Agents available to your account in ThousandEyes. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.agents.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.agents.api.local_problems_api import LocalProblemsApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestLocalProblemsApiIntegration(IntegrationTestBase): + """LocalProblemsApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = LocalProblemsApi(self.api_client) + + + def test_get_agents_local_problems_happy_path(self) -> None: + """Integration test for get_agents_local_problems success path""" + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + response_body_json = """ + { + "endDate" : "2022-07-18T22:00:54Z", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "localProblems" : [ { + "duration" : 480, + "agent" : { + "agentId" : "281474976710706", + "agentName" : "thousandeyes-stg-va-254", + "location" : "San Francisco Bay Area", + "countryId" : "US" + }, + "endDate" : "2026-05-18T03:22:00Z", + "active" : false, + "startDate" : "2026-05-18T03:14:00Z" + }, { + "duration" : 480, + "agent" : { + "agentId" : "281474976710706", + "agentName" : "thousandeyes-stg-va-254", + "location" : "San Francisco Bay Area", + "countryId" : "US" + }, + "endDate" : "2026-05-18T03:22:00Z", + "active" : false, + "startDate" : "2026-05-18T03:14:00Z" + } ], + "startDate" : "2022-07-17T22:00:54Z" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_agents_local_problems( + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + _headers=self.te_headers("get_agents_local_problems"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_agents_local_problems_error_400(self) -> None: + """Integration test for get_agents_local_problems error path (HTTP 400)""" + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.get_agents_local_problems( + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + _headers=self.te_headers("get_agents_local_problems", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_agents_local_problems_error_401(self) -> None: + """Integration test for get_agents_local_problems error path (HTTP 401)""" + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_agents_local_problems( + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + _headers=self.te_headers("get_agents_local_problems", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_agents_local_problems_error_403(self) -> None: + """Integration test for get_agents_local_problems error path (HTTP 403)""" + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_agents_local_problems( + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + _headers=self.te_headers("get_agents_local_problems", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_agents_local_problems_error_404(self) -> None: + """Integration test for get_agents_local_problems error path (HTTP 404)""" + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_agents_local_problems( + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + _headers=self.te_headers("get_agents_local_problems", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_agents_local_problems_error_429(self) -> None: + """Integration test for get_agents_local_problems error path (HTTP 429)""" + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_agents_local_problems( + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + _headers=self.te_headers("get_agents_local_problems", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_agents_local_problems_error_500(self) -> None: + """Integration test for get_agents_local_problems error path (HTTP 500)""" + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_agents_local_problems( + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + _headers=self.te_headers("get_agents_local_problems", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_agents_local_problems_error_502(self) -> None: + """Integration test for get_agents_local_problems error path (HTTP 502)""" + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.get_agents_local_problems( + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + _headers=self.te_headers("get_agents_local_problems", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-agents/test/test_tests_assignment_on_agents_api_integration.py b/thousandeyes-sdk-agents/test/test_tests_assignment_on_agents_api_integration.py new file mode 100644 index 00000000..d6898248 --- /dev/null +++ b/thousandeyes-sdk-agents/test/test_tests_assignment_on_agents_api_integration.py @@ -0,0 +1,1280 @@ +# coding: utf-8 + +""" + Agents API + + ## Overview Manage Cloud and Enterprise Agents available to your account in ThousandEyes. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.agents.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.agents.api.tests_assignment_on_agents_api import TestsAssignmentOnAgentsApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestTestsAssignmentOnAgentsApiIntegration(IntegrationTestBase): + """TestsAssignmentOnAgentsApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = TestsAssignmentOnAgentsApi(self.api_client) + + + def test_assign_tests_happy_path(self) -> None: + """Integration test for assign_tests success path""" + request_body_json = """ + + { + "testIds" : [ "281474976710706" ] + } + + """ + agent_tests_assign_request = thousandeyes_sdk.agents.models.AgentTestsAssignRequest.from_json(request_body_json) + agent_id = '281474976710706' + aid = '1234' + response_body_json = """ + { + "agentId" : "281474976710706", + "agentType" : "cloud", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "labels" : [ { + "labelId" : "11", + "name" : "Label name" + }, { + "labelId" : "11", + "name" : "Label name" + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "tests" : [ { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + }, { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + } ], + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } + """ + expected_response = json.loads(response_body_json) + response = self.api.assign_tests( + + agent_id=agent_id, + + agent_tests_assign_request=agent_tests_assign_request, + + aid=aid, + + _headers=self.te_headers("assign_tests"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_assign_tests_error_400(self) -> None: + """Integration test for assign_tests error path (HTTP 400)""" + request_body_json = """ + + { + "testIds" : [ "281474976710706" ] + } + + """ + agent_tests_assign_request = thousandeyes_sdk.agents.models.AgentTestsAssignRequest.from_json(request_body_json) + agent_id = '281474976710706' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.assign_tests( + + agent_id=agent_id, + + agent_tests_assign_request=agent_tests_assign_request, + + aid=aid, + + _headers=self.te_headers("assign_tests", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_assign_tests_error_401(self) -> None: + """Integration test for assign_tests error path (HTTP 401)""" + request_body_json = """ + + { + "testIds" : [ "281474976710706" ] + } + + """ + agent_tests_assign_request = thousandeyes_sdk.agents.models.AgentTestsAssignRequest.from_json(request_body_json) + agent_id = '281474976710706' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.assign_tests( + + agent_id=agent_id, + + agent_tests_assign_request=agent_tests_assign_request, + + aid=aid, + + _headers=self.te_headers("assign_tests", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_assign_tests_error_403(self) -> None: + """Integration test for assign_tests error path (HTTP 403)""" + request_body_json = """ + + { + "testIds" : [ "281474976710706" ] + } + + """ + agent_tests_assign_request = thousandeyes_sdk.agents.models.AgentTestsAssignRequest.from_json(request_body_json) + agent_id = '281474976710706' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.assign_tests( + + agent_id=agent_id, + + agent_tests_assign_request=agent_tests_assign_request, + + aid=aid, + + _headers=self.te_headers("assign_tests", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_assign_tests_error_404(self) -> None: + """Integration test for assign_tests error path (HTTP 404)""" + request_body_json = """ + + { + "testIds" : [ "281474976710706" ] + } + + """ + agent_tests_assign_request = thousandeyes_sdk.agents.models.AgentTestsAssignRequest.from_json(request_body_json) + agent_id = '281474976710706' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.assign_tests( + + agent_id=agent_id, + + agent_tests_assign_request=agent_tests_assign_request, + + aid=aid, + + _headers=self.te_headers("assign_tests", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_assign_tests_error_429(self) -> None: + """Integration test for assign_tests error path (HTTP 429)""" + request_body_json = """ + + { + "testIds" : [ "281474976710706" ] + } + + """ + agent_tests_assign_request = thousandeyes_sdk.agents.models.AgentTestsAssignRequest.from_json(request_body_json) + agent_id = '281474976710706' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.assign_tests( + + agent_id=agent_id, + + agent_tests_assign_request=agent_tests_assign_request, + + aid=aid, + + _headers=self.te_headers("assign_tests", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_assign_tests_error_500(self) -> None: + """Integration test for assign_tests error path (HTTP 500)""" + request_body_json = """ + + { + "testIds" : [ "281474976710706" ] + } + + """ + agent_tests_assign_request = thousandeyes_sdk.agents.models.AgentTestsAssignRequest.from_json(request_body_json) + agent_id = '281474976710706' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.assign_tests( + + agent_id=agent_id, + + agent_tests_assign_request=agent_tests_assign_request, + + aid=aid, + + _headers=self.te_headers("assign_tests", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_assign_tests_error_502(self) -> None: + """Integration test for assign_tests error path (HTTP 502)""" + request_body_json = """ + + { + "testIds" : [ "281474976710706" ] + } + + """ + agent_tests_assign_request = thousandeyes_sdk.agents.models.AgentTestsAssignRequest.from_json(request_body_json) + agent_id = '281474976710706' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.assign_tests( + + agent_id=agent_id, + + agent_tests_assign_request=agent_tests_assign_request, + + aid=aid, + + _headers=self.te_headers("assign_tests", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_overwrite_tests_happy_path(self) -> None: + """Integration test for overwrite_tests success path""" + request_body_json = """ + + { + "testIds" : [ "281474976710706" ] + } + + """ + agent_tests_assign_request = thousandeyes_sdk.agents.models.AgentTestsAssignRequest.from_json(request_body_json) + agent_id = '281474976710706' + aid = '1234' + response_body_json = """ + { + "agentId" : "281474976710706", + "agentType" : "cloud", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "labels" : [ { + "labelId" : "11", + "name" : "Label name" + }, { + "labelId" : "11", + "name" : "Label name" + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "tests" : [ { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + }, { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + } ], + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } + """ + expected_response = json.loads(response_body_json) + response = self.api.overwrite_tests( + + agent_id=agent_id, + + agent_tests_assign_request=agent_tests_assign_request, + + aid=aid, + + _headers=self.te_headers("overwrite_tests"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_overwrite_tests_error_400(self) -> None: + """Integration test for overwrite_tests error path (HTTP 400)""" + request_body_json = """ + + { + "testIds" : [ "281474976710706" ] + } + + """ + agent_tests_assign_request = thousandeyes_sdk.agents.models.AgentTestsAssignRequest.from_json(request_body_json) + agent_id = '281474976710706' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.overwrite_tests( + + agent_id=agent_id, + + agent_tests_assign_request=agent_tests_assign_request, + + aid=aid, + + _headers=self.te_headers("overwrite_tests", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_overwrite_tests_error_401(self) -> None: + """Integration test for overwrite_tests error path (HTTP 401)""" + request_body_json = """ + + { + "testIds" : [ "281474976710706" ] + } + + """ + agent_tests_assign_request = thousandeyes_sdk.agents.models.AgentTestsAssignRequest.from_json(request_body_json) + agent_id = '281474976710706' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.overwrite_tests( + + agent_id=agent_id, + + agent_tests_assign_request=agent_tests_assign_request, + + aid=aid, + + _headers=self.te_headers("overwrite_tests", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_overwrite_tests_error_403(self) -> None: + """Integration test for overwrite_tests error path (HTTP 403)""" + request_body_json = """ + + { + "testIds" : [ "281474976710706" ] + } + + """ + agent_tests_assign_request = thousandeyes_sdk.agents.models.AgentTestsAssignRequest.from_json(request_body_json) + agent_id = '281474976710706' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.overwrite_tests( + + agent_id=agent_id, + + agent_tests_assign_request=agent_tests_assign_request, + + aid=aid, + + _headers=self.te_headers("overwrite_tests", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_overwrite_tests_error_404(self) -> None: + """Integration test for overwrite_tests error path (HTTP 404)""" + request_body_json = """ + + { + "testIds" : [ "281474976710706" ] + } + + """ + agent_tests_assign_request = thousandeyes_sdk.agents.models.AgentTestsAssignRequest.from_json(request_body_json) + agent_id = '281474976710706' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.overwrite_tests( + + agent_id=agent_id, + + agent_tests_assign_request=agent_tests_assign_request, + + aid=aid, + + _headers=self.te_headers("overwrite_tests", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_overwrite_tests_error_429(self) -> None: + """Integration test for overwrite_tests error path (HTTP 429)""" + request_body_json = """ + + { + "testIds" : [ "281474976710706" ] + } + + """ + agent_tests_assign_request = thousandeyes_sdk.agents.models.AgentTestsAssignRequest.from_json(request_body_json) + agent_id = '281474976710706' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.overwrite_tests( + + agent_id=agent_id, + + agent_tests_assign_request=agent_tests_assign_request, + + aid=aid, + + _headers=self.te_headers("overwrite_tests", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_overwrite_tests_error_500(self) -> None: + """Integration test for overwrite_tests error path (HTTP 500)""" + request_body_json = """ + + { + "testIds" : [ "281474976710706" ] + } + + """ + agent_tests_assign_request = thousandeyes_sdk.agents.models.AgentTestsAssignRequest.from_json(request_body_json) + agent_id = '281474976710706' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.overwrite_tests( + + agent_id=agent_id, + + agent_tests_assign_request=agent_tests_assign_request, + + aid=aid, + + _headers=self.te_headers("overwrite_tests", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_overwrite_tests_error_502(self) -> None: + """Integration test for overwrite_tests error path (HTTP 502)""" + request_body_json = """ + + { + "testIds" : [ "281474976710706" ] + } + + """ + agent_tests_assign_request = thousandeyes_sdk.agents.models.AgentTestsAssignRequest.from_json(request_body_json) + agent_id = '281474976710706' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.overwrite_tests( + + agent_id=agent_id, + + agent_tests_assign_request=agent_tests_assign_request, + + aid=aid, + + _headers=self.te_headers("overwrite_tests", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_unassign_tests_happy_path(self) -> None: + """Integration test for unassign_tests success path""" + request_body_json = """ + + { + "testIds" : [ "281474976710706" ] + } + + """ + agent_tests_assign_request = thousandeyes_sdk.agents.models.AgentTestsAssignRequest.from_json(request_body_json) + agent_id = '281474976710706' + aid = '1234' + response_body_json = """ + { + "agentId" : "281474976710706", + "agentType" : "cloud", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "labels" : [ { + "labelId" : "11", + "name" : "Label name" + }, { + "labelId" : "11", + "name" : "Label name" + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "tests" : [ { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + }, { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + } ], + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } + """ + expected_response = json.loads(response_body_json) + response = self.api.unassign_tests( + + agent_id=agent_id, + + agent_tests_assign_request=agent_tests_assign_request, + + aid=aid, + + _headers=self.te_headers("unassign_tests"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_unassign_tests_error_400(self) -> None: + """Integration test for unassign_tests error path (HTTP 400)""" + request_body_json = """ + + { + "testIds" : [ "281474976710706" ] + } + + """ + agent_tests_assign_request = thousandeyes_sdk.agents.models.AgentTestsAssignRequest.from_json(request_body_json) + agent_id = '281474976710706' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.unassign_tests( + + agent_id=agent_id, + + agent_tests_assign_request=agent_tests_assign_request, + + aid=aid, + + _headers=self.te_headers("unassign_tests", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_unassign_tests_error_401(self) -> None: + """Integration test for unassign_tests error path (HTTP 401)""" + request_body_json = """ + + { + "testIds" : [ "281474976710706" ] + } + + """ + agent_tests_assign_request = thousandeyes_sdk.agents.models.AgentTestsAssignRequest.from_json(request_body_json) + agent_id = '281474976710706' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.unassign_tests( + + agent_id=agent_id, + + agent_tests_assign_request=agent_tests_assign_request, + + aid=aid, + + _headers=self.te_headers("unassign_tests", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_unassign_tests_error_403(self) -> None: + """Integration test for unassign_tests error path (HTTP 403)""" + request_body_json = """ + + { + "testIds" : [ "281474976710706" ] + } + + """ + agent_tests_assign_request = thousandeyes_sdk.agents.models.AgentTestsAssignRequest.from_json(request_body_json) + agent_id = '281474976710706' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.unassign_tests( + + agent_id=agent_id, + + agent_tests_assign_request=agent_tests_assign_request, + + aid=aid, + + _headers=self.te_headers("unassign_tests", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_unassign_tests_error_404(self) -> None: + """Integration test for unassign_tests error path (HTTP 404)""" + request_body_json = """ + + { + "testIds" : [ "281474976710706" ] + } + + """ + agent_tests_assign_request = thousandeyes_sdk.agents.models.AgentTestsAssignRequest.from_json(request_body_json) + agent_id = '281474976710706' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.unassign_tests( + + agent_id=agent_id, + + agent_tests_assign_request=agent_tests_assign_request, + + aid=aid, + + _headers=self.te_headers("unassign_tests", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_unassign_tests_error_429(self) -> None: + """Integration test for unassign_tests error path (HTTP 429)""" + request_body_json = """ + + { + "testIds" : [ "281474976710706" ] + } + + """ + agent_tests_assign_request = thousandeyes_sdk.agents.models.AgentTestsAssignRequest.from_json(request_body_json) + agent_id = '281474976710706' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.unassign_tests( + + agent_id=agent_id, + + agent_tests_assign_request=agent_tests_assign_request, + + aid=aid, + + _headers=self.te_headers("unassign_tests", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_unassign_tests_error_500(self) -> None: + """Integration test for unassign_tests error path (HTTP 500)""" + request_body_json = """ + + { + "testIds" : [ "281474976710706" ] + } + + """ + agent_tests_assign_request = thousandeyes_sdk.agents.models.AgentTestsAssignRequest.from_json(request_body_json) + agent_id = '281474976710706' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.unassign_tests( + + agent_id=agent_id, + + agent_tests_assign_request=agent_tests_assign_request, + + aid=aid, + + _headers=self.te_headers("unassign_tests", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_unassign_tests_error_502(self) -> None: + """Integration test for unassign_tests error path (HTTP 502)""" + request_body_json = """ + + { + "testIds" : [ "281474976710706" ] + } + + """ + agent_tests_assign_request = thousandeyes_sdk.agents.models.AgentTestsAssignRequest.from_json(request_body_json) + agent_id = '281474976710706' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.unassign_tests( + + agent_id=agent_id, + + agent_tests_assign_request=agent_tests_assign_request, + + aid=aid, + + _headers=self.te_headers("unassign_tests", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-agents/test/test_utils.py b/thousandeyes-sdk-agents/test/test_utils.py index 930528d9..37913f62 100644 --- a/thousandeyes-sdk-agents/test/test_utils.py +++ b/thousandeyes-sdk-agents/test/test_utils.py @@ -2,15 +2,36 @@ import json import unittest +from typing import Any from pydantic import BaseModel +def _project_onto_constructed(expected: Any, constructed: Any) -> Any: + """Keep only example fields that appear in the constructed model output.""" + if isinstance(constructed, dict): + if not isinstance(expected, dict): + return expected + return { + key: _project_onto_constructed(expected.get(key), value) + for key, value in constructed.items() + } + if isinstance(constructed, list): + if not isinstance(expected, list): + return expected + return [ + _project_onto_constructed(expected[index], value) + for index, value in enumerate(constructed) + ] + return expected + + def assert_constructed_model_matches_example_json(model: BaseModel, loaded_json: dict): test_case = unittest.TestCase() test_case.maxDiff = None test_case.assertIsNotNone(model) constructed_json = json.loads(model.to_json()) - sorted_loaded_json = json.dumps(loaded_json, sort_keys=True) + projected_loaded_json = _project_onto_constructed(loaded_json, constructed_json) + sorted_loaded_json = json.dumps(projected_loaded_json, sort_keys=True) sorted_constructed_json = json.dumps(constructed_json, sort_keys=True) test_case.assertEqual(sorted_loaded_json, sorted_constructed_json) diff --git a/thousandeyes-sdk-alerts/test/conftest.py b/thousandeyes-sdk-alerts/test/conftest.py new file mode 100644 index 00000000..2edba7b3 --- /dev/null +++ b/thousandeyes-sdk-alerts/test/conftest.py @@ -0,0 +1,7 @@ +import sys +from pathlib import Path + +_repo_root = Path(__file__).resolve().parents[2] +_core_test_support = _repo_root / "thousandeyes-sdk-core" / "test" +if str(_core_test_support) not in sys.path: + sys.path.insert(0, str(_core_test_support)) diff --git a/thousandeyes-sdk-alerts/test/integration_test_utils.py b/thousandeyes-sdk-alerts/test/integration_test_utils.py new file mode 100644 index 00000000..24b37d08 --- /dev/null +++ b/thousandeyes-sdk-alerts/test/integration_test_utils.py @@ -0,0 +1,37 @@ +# coding: utf-8 + +""" + Alerts API + + **Note:** API operations for the creation or retrieval of API, Page Load, or Web-Transaction alert rules are not available for ThousandEyes for Government instance. You can manage the following alert functionalities on the ThousandEyes platform using the Alerts API: * **Alerts**: Retrieve alert details. Alerts are assigned to tests through alert rules. * **Alert Rules**: Conditions that you configure in order to highlight or be notified of events of interest in your ThousandEyes tests. When an alert rule’s conditions are met, the associated alert is triggered and the alert becomes active. It remains active until the alert is cleared. Alert rules are reusable across multiple tests.. * **Alert Suppression Windows**: Suppress alerts for tests during periods such as planned maintenance. Windows can be one-time events or recurring events to handle periodic occurrences such as monthly downtime for maintenance. For more information about the alerts, see [Alerts](https://docs.thousandeyes.com/product-documentation/alerts). + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from thousandeyes_sdk.core.api_client import ApiClient +from thousandeyes_sdk.core.configuration import Configuration +from sdk_test_support.mock_server import ERROR_STATUS_HEADER, OPERATION_ID_HEADER, MockApiServer + +from .mock_manifest import OPERATION_MANIFEST + + +class IntegrationTestBase(unittest.TestCase): + def setUp(self) -> None: + self.server = MockApiServer(OPERATION_MANIFEST) + self.server.start() + configuration = Configuration(host=self.server.base_url, access_token="test-token") + self.api_client = ApiClient(configuration=configuration) + + def tearDown(self) -> None: + self.server.stop() + + def te_headers(self, operation_id: str, error_status=None): + headers = {OPERATION_ID_HEADER: operation_id} + if error_status is not None: + headers[ERROR_STATUS_HEADER] = error_status + return headers diff --git a/thousandeyes-sdk-alerts/test/mock_manifest.py b/thousandeyes-sdk-alerts/test/mock_manifest.py new file mode 100644 index 00000000..b1d811c7 --- /dev/null +++ b/thousandeyes-sdk-alerts/test/mock_manifest.py @@ -0,0 +1,2247 @@ +# coding: utf-8 + +""" + Alerts API + + **Note:** API operations for the creation or retrieval of API, Page Load, or Web-Transaction alert rules are not available for ThousandEyes for Government instance. You can manage the following alert functionalities on the ThousandEyes platform using the Alerts API: * **Alerts**: Retrieve alert details. Alerts are assigned to tests through alert rules. * **Alert Rules**: Conditions that you configure in order to highlight or be notified of events of interest in your ThousandEyes tests. When an alert rule’s conditions are met, the associated alert is triggered and the alert becomes active. It remains active until the alert is cleared. Alert rules are reusable across multiple tests.. * **Alert Suppression Windows**: Suppress alerts for tests during periods such as planned maintenance. Windows can be one-time events or recurring events to handle periodic occurrences such as monthly downtime for maintenance. For more information about the alerts, see [Alerts](https://docs.thousandeyes.com/product-documentation/alerts). + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json + +from sdk_test_support.mock_server_types import ErrorResponseExpectation, OperationExpectation + +OPERATION_MANIFEST = { + + "create_alert_rule": OperationExpectation( + operation_id="create_alert_rule", + method="POST", + path="/alerts/rules", + path_param_examples={ + }, + success_status=201, + success_body=json.loads(""" + + { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "includeCoveredPrefixes" : true, + "visitedSitesFilter" : [ "app.thousandeyes.com" ], + "description" : "A rule description string", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "alertGroupType" : "endpoint", + "notifyOnClear" : true, + "testIds" : [ "281474976710706", "271659" ], + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "endpointAgentIds" : [ "281474976710706", "281474976710706" ], + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "endpointLabelIds" : [ "123456", "123456" ], + "minimumSources" : 10, + "ruleId" : "127094", + "notifications" : { + "thirdParty" : [ { + "integrationType" : "slack", + "integrationId" : "sl-101" + }, { + "integrationType" : "slack", + "integrationId" : "sl-101" + } ], + "webhook" : [ { + "integrationType" : "webhook", + "integrationName" : "My webhook", + "integrationId" : "wb-201", + "target" : "https://example.com/test/webhooks/notifications" + }, { + "integrationType" : "webhook", + "integrationName" : "My webhook", + "integrationId" : "wb-201", + "target" : "https://example.com/test/webhooks/notifications" + } ], + "email" : { + "recipients" : [ "noreply@thousandeyes.com" ], + "message" : "Notification message" + }, + "customWebhook" : [ { + "integrationType" : "custom-webhook", + "integrationName" : "My webhook", + "integrationId" : "6e069ae9-8537-4120-b988-61bf8e0d8b87", + "target" : "https://example.com/test/webhooks/notifications" + }, { + "integrationType" : "custom-webhook", + "integrationName" : "My webhook", + "integrationId" : "6e069ae9-8537-4120-b988-61bf8e0d8b87", + "target" : "https://example.com/test/webhooks/notifications" + } ] + }, + "direction" : "to-target" + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "includeCoveredPrefixes" : true, + "visitedSitesFilter" : [ "app.thousandeyes.com" ], + "description" : "A rule description string", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "alertGroupType" : "endpoint", + "notifyOnClear" : true, + "testIds" : [ "281474976710706", "271659" ], + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "endpointAgentIds" : [ "281474976710706", "281474976710706" ], + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "endpointLabelIds" : [ "123456", "123456" ], + "minimumSources" : 10, + "ruleId" : "127094", + "notifications" : { + "thirdParty" : [ { + "integrationType" : "slack", + "integrationId" : "sl-101" + }, { + "integrationType" : "slack", + "integrationId" : "sl-101" + } ], + "webhook" : [ { + "integrationType" : "webhook", + "integrationName" : "My webhook", + "integrationId" : "wb-201", + "target" : "https://example.com/test/webhooks/notifications" + }, { + "integrationType" : "webhook", + "integrationName" : "My webhook", + "integrationId" : "wb-201", + "target" : "https://example.com/test/webhooks/notifications" + } ], + "email" : { + "recipients" : [ "noreply@thousandeyes.com" ], + "message" : "Notification message" + }, + "customWebhook" : [ { + "integrationType" : "custom-webhook", + "integrationName" : "My webhook", + "integrationId" : "6e069ae9-8537-4120-b988-61bf8e0d8b87", + "target" : "https://example.com/test/webhooks/notifications" + }, { + "integrationType" : "custom-webhook", + "integrationName" : "My webhook", + "integrationId" : "6e069ae9-8537-4120-b988-61bf8e0d8b87", + "target" : "https://example.com/test/webhooks/notifications" + } ] + }, + "direction" : "to-target" + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "delete_alert_rule": OperationExpectation( + operation_id="delete_alert_rule", + method="DELETE", + path="/alerts/rules/{ruleId}", + path_param_examples={ + "ruleId": '127094', + }, + success_status=204, + success_body=None, + success_content_type="application/json", + request_body_example=None, + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_alert_rule": OperationExpectation( + operation_id="get_alert_rule", + method="GET", + path="/alerts/rules/{ruleId}", + path_param_examples={ + "ruleId": '127094', + }, + success_status=200, + success_body=json.loads(""" + + { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "includeCoveredPrefixes" : true, + "visitedSitesFilter" : [ "app.thousandeyes.com" ], + "description" : "A rule description string", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "alertGroupType" : "endpoint", + "notifyOnClear" : true, + "testIds" : [ "281474976710706", "271659" ], + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "endpointAgentIds" : [ "281474976710706", "281474976710706" ], + "tests" : [ { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + }, { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + } ], + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "endpointLabelIds" : [ "123456", "123456" ], + "minimumSources" : 10, + "ruleId" : "127094", + "notifications" : { + "thirdParty" : [ { + "integrationType" : "slack", + "integrationId" : "sl-101" + }, { + "integrationType" : "slack", + "integrationId" : "sl-101" + } ], + "webhook" : [ { + "integrationType" : "webhook", + "integrationName" : "My webhook", + "integrationId" : "wb-201", + "target" : "https://example.com/test/webhooks/notifications" + }, { + "integrationType" : "webhook", + "integrationName" : "My webhook", + "integrationId" : "wb-201", + "target" : "https://example.com/test/webhooks/notifications" + } ], + "email" : { + "recipients" : [ "noreply@thousandeyes.com" ], + "message" : "Notification message" + }, + "customWebhook" : [ { + "integrationType" : "custom-webhook", + "integrationName" : "My webhook", + "integrationId" : "6e069ae9-8537-4120-b988-61bf8e0d8b87", + "target" : "https://example.com/test/webhooks/notifications" + }, { + "integrationType" : "custom-webhook", + "integrationName" : "My webhook", + "integrationId" : "6e069ae9-8537-4120-b988-61bf8e0d8b87", + "target" : "https://example.com/test/webhooks/notifications" + } ] + }, + "direction" : "to-target" + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_alerts_rules": OperationExpectation( + operation_id="get_alerts_rules", + method="GET", + path="/alerts/rules", + path_param_examples={ + }, + success_status=200, + success_body=json.loads(""" + + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "includeCoveredPrefixes" : true, + "visitedSitesFilter" : [ "app.thousandeyes.com" ], + "description" : "A rule description string", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "alertGroupType" : "endpoint", + "notifyOnClear" : true, + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "endpointAgentIds" : [ "281474976710706", "281474976710706" ], + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "endpointLabelIds" : [ "123456", "123456" ], + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + }, { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "includeCoveredPrefixes" : true, + "visitedSitesFilter" : [ "app.thousandeyes.com" ], + "description" : "A rule description string", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "alertGroupType" : "endpoint", + "notifyOnClear" : true, + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "endpointAgentIds" : [ "281474976710706", "281474976710706" ], + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "endpointLabelIds" : [ "123456", "123456" ], + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + } ] + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "update_alert_rule": OperationExpectation( + operation_id="update_alert_rule", + method="PUT", + path="/alerts/rules/{ruleId}", + path_param_examples={ + "ruleId": '127094', + }, + success_status=200, + success_body=json.loads(""" + + { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "includeCoveredPrefixes" : true, + "visitedSitesFilter" : [ "app.thousandeyes.com" ], + "description" : "A rule description string", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "alertGroupType" : "endpoint", + "notifyOnClear" : true, + "testIds" : [ "281474976710706", "271659" ], + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "endpointAgentIds" : [ "281474976710706", "281474976710706" ], + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "endpointLabelIds" : [ "123456", "123456" ], + "minimumSources" : 10, + "ruleId" : "127094", + "notifications" : { + "thirdParty" : [ { + "integrationType" : "slack", + "integrationId" : "sl-101" + }, { + "integrationType" : "slack", + "integrationId" : "sl-101" + } ], + "webhook" : [ { + "integrationType" : "webhook", + "integrationName" : "My webhook", + "integrationId" : "wb-201", + "target" : "https://example.com/test/webhooks/notifications" + }, { + "integrationType" : "webhook", + "integrationName" : "My webhook", + "integrationId" : "wb-201", + "target" : "https://example.com/test/webhooks/notifications" + } ], + "email" : { + "recipients" : [ "noreply@thousandeyes.com" ], + "message" : "Notification message" + }, + "customWebhook" : [ { + "integrationType" : "custom-webhook", + "integrationName" : "My webhook", + "integrationId" : "6e069ae9-8537-4120-b988-61bf8e0d8b87", + "target" : "https://example.com/test/webhooks/notifications" + }, { + "integrationType" : "custom-webhook", + "integrationName" : "My webhook", + "integrationId" : "6e069ae9-8537-4120-b988-61bf8e0d8b87", + "target" : "https://example.com/test/webhooks/notifications" + } ] + }, + "direction" : "to-target" + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "includeCoveredPrefixes" : true, + "visitedSitesFilter" : [ "app.thousandeyes.com" ], + "description" : "A rule description string", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "alertGroupType" : "endpoint", + "notifyOnClear" : true, + "testIds" : [ "281474976710706", "271659" ], + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "endpointAgentIds" : [ "281474976710706", "281474976710706" ], + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "endpointLabelIds" : [ "123456", "123456" ], + "minimumSources" : 10, + "ruleId" : "127094", + "notifications" : { + "thirdParty" : [ { + "integrationType" : "slack", + "integrationId" : "sl-101" + }, { + "integrationType" : "slack", + "integrationId" : "sl-101" + } ], + "webhook" : [ { + "integrationType" : "webhook", + "integrationName" : "My webhook", + "integrationId" : "wb-201", + "target" : "https://example.com/test/webhooks/notifications" + }, { + "integrationType" : "webhook", + "integrationName" : "My webhook", + "integrationId" : "wb-201", + "target" : "https://example.com/test/webhooks/notifications" + } ], + "email" : { + "recipients" : [ "noreply@thousandeyes.com" ], + "message" : "Notification message" + }, + "customWebhook" : [ { + "integrationType" : "custom-webhook", + "integrationName" : "My webhook", + "integrationId" : "6e069ae9-8537-4120-b988-61bf8e0d8b87", + "target" : "https://example.com/test/webhooks/notifications" + }, { + "integrationType" : "custom-webhook", + "integrationName" : "My webhook", + "integrationId" : "6e069ae9-8537-4120-b988-61bf8e0d8b87", + "target" : "https://example.com/test/webhooks/notifications" + } ] + }, + "direction" : "to-target" + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "create_alert_suppression_window": OperationExpectation( + operation_id="create_alert_suppression_window", + method="POST", + path="/alert-suppression-windows", + path_param_examples={ + }, + success_status=201, + success_body=json.loads(""" + + { + "duration" : 0, + "alertSuppressionWindowId" : "2411", + "tests" : [ { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + }, { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + } ], + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isEnabled" : false, + "repeat" : { + "intervalType" : "day", + "intervalLength" : 2, + "type" : "week", + "daysOfWeek" : [ "sun", "sun" ] + }, + "endRepeat" : { + "date" : "2017-07-01", + "count" : 3, + "type" : "never" + }, + "name" : "Monthly maintenance", + "startDate" : "2017-07-01T05:00:00Z", + "status" : "ended" + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "duration" : 0, + "testIds" : [ "71687", "71687" ], + "alertSuppressionWindowId" : "2411", + "isEnabled" : false, + "repeat" : { + "intervalType" : "day", + "intervalLength" : 2, + "type" : "week", + "daysOfWeek" : [ "sun", "sun" ] + }, + "endRepeat" : { + "date" : "2017-07-01", + "count" : 3, + "type" : "never" + }, + "name" : "Monthly maintenance", + "startDate" : "2017-07-01T05:00:00Z", + "status" : "ended" + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "delete_alert_suppression_window": OperationExpectation( + operation_id="delete_alert_suppression_window", + method="DELETE", + path="/alert-suppression-windows/{windowId}", + path_param_examples={ + "windowId": '2411', + }, + success_status=204, + success_body=None, + success_content_type="application/json", + request_body_example=None, + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_alert_suppression_window": OperationExpectation( + operation_id="get_alert_suppression_window", + method="GET", + path="/alert-suppression-windows/{windowId}", + path_param_examples={ + "windowId": '2411', + }, + success_status=200, + success_body=json.loads(""" + + { + "duration" : 0, + "alertSuppressionWindowId" : "2411", + "tests" : [ { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + }, { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + } ], + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isEnabled" : false, + "repeat" : { + "intervalType" : "day", + "intervalLength" : 2, + "type" : "week", + "daysOfWeek" : [ "sun", "sun" ] + }, + "endRepeat" : { + "date" : "2017-07-01", + "count" : 3, + "type" : "never" + }, + "name" : "Monthly maintenance", + "startDate" : "2017-07-01T05:00:00Z", + "status" : "ended" + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_alert_suppression_windows": OperationExpectation( + operation_id="get_alert_suppression_windows", + method="GET", + path="/alert-suppression-windows", + path_param_examples={ + }, + success_status=200, + success_body=json.loads(""" + + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertSuppressionWindows" : [ { + "duration" : 0, + "alertSuppressionWindowId" : "2411", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isEnabled" : false, + "repeat" : { + "intervalType" : "day", + "intervalLength" : 2, + "type" : "week", + "daysOfWeek" : [ "sun", "sun" ] + }, + "endRepeat" : { + "date" : "2017-07-01", + "count" : 3, + "type" : "never" + }, + "name" : "Monthly maintenance", + "startDate" : "2017-07-01T05:00:00Z", + "status" : "ended" + }, { + "duration" : 0, + "alertSuppressionWindowId" : "2411", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isEnabled" : false, + "repeat" : { + "intervalType" : "day", + "intervalLength" : 2, + "type" : "week", + "daysOfWeek" : [ "sun", "sun" ] + }, + "endRepeat" : { + "date" : "2017-07-01", + "count" : 3, + "type" : "never" + }, + "name" : "Monthly maintenance", + "startDate" : "2017-07-01T05:00:00Z", + "status" : "ended" + } ] + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "update_alert_suppression_window": OperationExpectation( + operation_id="update_alert_suppression_window", + method="PUT", + path="/alert-suppression-windows/{windowId}", + path_param_examples={ + "windowId": '2411', + }, + success_status=200, + success_body=json.loads(""" + + { + "duration" : 0, + "alertSuppressionWindowId" : "2411", + "tests" : [ { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + }, { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + } ], + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isEnabled" : false, + "repeat" : { + "intervalType" : "day", + "intervalLength" : 2, + "type" : "week", + "daysOfWeek" : [ "sun", "sun" ] + }, + "endRepeat" : { + "date" : "2017-07-01", + "count" : 3, + "type" : "never" + }, + "name" : "Monthly maintenance", + "startDate" : "2017-07-01T05:00:00Z", + "status" : "ended" + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "duration" : 0, + "testIds" : [ "71687", "71687" ], + "alertSuppressionWindowId" : "2411", + "isEnabled" : false, + "repeat" : { + "intervalType" : "day", + "intervalLength" : 2, + "type" : "week", + "daysOfWeek" : [ "sun", "sun" ] + }, + "endRepeat" : { + "date" : "2017-07-01", + "count" : 3, + "type" : "never" + }, + "name" : "Monthly maintenance", + "startDate" : "2017-07-01T05:00:00Z", + "status" : "ended" + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_alert": OperationExpectation( + operation_id="get_alert", + method="GET", + path="/alerts/{alertId}", + path_param_examples={ + "alertId": 'e9c3bf02-a48c-4aa8-9e5f-898800d6f569', + }, + success_status=200, + success_body=json.loads(""" + + { + "severity" : "major", + "alertType" : "http-server", + "endDate" : "2022-07-18T22:00:54Z", + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "test" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "rule" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertSeverity" : "major", + "duration" : 60, + "violationCount" : 2, + "_embedded" : { + "asn" : { + "name" : "Cisco Webex LLC", + "id" : "13445", + "type" : "asn" + } + }, + "meta" : { + "version" : 1 + }, + "details" : [ { + "name" : "Bucharest, Romania", + "start" : { + "metrics" : "metrics" + }, + "end" : { + "metrics" : "metrics" + }, + "id" : "3379", + "state" : "trigger", + "type" : "cea_agent" + }, { + "name" : "Bucharest, Romania", + "start" : { + "metrics" : "metrics" + }, + "end" : { + "metrics" : "metrics" + }, + "id" : "3379", + "state" : "trigger", + "type" : "cea_agent" + } ], + "id" : "e9c3bf02-a48c-4aa8-9e5f-898800d6f569", + "suppressed" : false, + "state" : "trigger", + "alertState" : "trigger", + "startDate" : "2022-07-17T22:00:54Z" + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_alerts": OperationExpectation( + operation_id="get_alerts", + method="GET", + path="/alerts", + path_param_examples={ + }, + success_status=200, + success_body=json.loads(""" + + { + "alerts" : [ { + "severity" : "MAJOR", + "alertType" : "http-server", + "endDate" : "2022-07-18T22:00:54Z", + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "test" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "rule" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "apiLinks" : [ { + "key" : "" + }, { + "key" : "" + } ], + "alertSeverity" : "major", + "dateEnd" : "2020-04-23 13:43:16", + "duration" : 60, + "violationCount" : 2, + "dateStart" : "2020-04-23 13:43:16", + "meta" : { + "version" : 1 + }, + "id" : "e9c3bf02-a48c-4aa8-9e5f-898800d6f569", + "suppressed" : false, + "alertId" : "e9c3bf02-a48c-4aa8-9e5f-898800d6f569", + "state" : "ACTIVE", + "ruleId" : 127094, + "permalink" : "https://app.thousandeyes.com/alerts/list?__a=75&alertId=2783&agentId=12", + "alertState" : "trigger", + "startDate" : "2022-07-17T22:00:54Z", + "alertRuleId" : "127094" + }, { + "severity" : "MAJOR", + "alertType" : "http-server", + "endDate" : "2022-07-18T22:00:54Z", + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "test" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "rule" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "apiLinks" : [ { + "key" : "" + }, { + "key" : "" + } ], + "alertSeverity" : "major", + "dateEnd" : "2020-04-23 13:43:16", + "duration" : 60, + "violationCount" : 2, + "dateStart" : "2020-04-23 13:43:16", + "meta" : { + "version" : 1 + }, + "id" : "e9c3bf02-a48c-4aa8-9e5f-898800d6f569", + "suppressed" : false, + "alertId" : "e9c3bf02-a48c-4aa8-9e5f-898800d6f569", + "state" : "ACTIVE", + "ruleId" : 127094, + "permalink" : "https://app.thousandeyes.com/alerts/list?__a=75&alertId=2783&agentId=12", + "alertState" : "trigger", + "startDate" : "2022-07-17T22:00:54Z", + "alertRuleId" : "127094" + } ], + "_links" : { + "next" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "previous" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + +} diff --git a/thousandeyes-sdk-alerts/test/test_alert_rules_api_integration.py b/thousandeyes-sdk-alerts/test/test_alert_rules_api_integration.py new file mode 100644 index 00000000..5e96180d --- /dev/null +++ b/thousandeyes-sdk-alerts/test/test_alert_rules_api_integration.py @@ -0,0 +1,2130 @@ +# coding: utf-8 + +""" + Alerts API + + **Note:** API operations for the creation or retrieval of API, Page Load, or Web-Transaction alert rules are not available for ThousandEyes for Government instance. You can manage the following alert functionalities on the ThousandEyes platform using the Alerts API: * **Alerts**: Retrieve alert details. Alerts are assigned to tests through alert rules. * **Alert Rules**: Conditions that you configure in order to highlight or be notified of events of interest in your ThousandEyes tests. When an alert rule’s conditions are met, the associated alert is triggered and the alert becomes active. It remains active until the alert is cleared. Alert rules are reusable across multiple tests.. * **Alert Suppression Windows**: Suppress alerts for tests during periods such as planned maintenance. Windows can be one-time events or recurring events to handle periodic occurrences such as monthly downtime for maintenance. For more information about the alerts, see [Alerts](https://docs.thousandeyes.com/product-documentation/alerts). + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.alerts.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.alerts.api.alert_rules_api import AlertRulesApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestAlertRulesApiIntegration(IntegrationTestBase): + """AlertRulesApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = AlertRulesApi(self.api_client) + + + def test_create_alert_rule_happy_path(self) -> None: + """Integration test for create_alert_rule success path""" + request_body_json = """ + + { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "includeCoveredPrefixes" : true, + "visitedSitesFilter" : [ "app.thousandeyes.com" ], + "description" : "A rule description string", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "alertGroupType" : "endpoint", + "notifyOnClear" : true, + "testIds" : [ "281474976710706", "271659" ], + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "endpointAgentIds" : [ "281474976710706", "281474976710706" ], + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "endpointLabelIds" : [ "123456", "123456" ], + "minimumSources" : 10, + "ruleId" : "127094", + "notifications" : { + "thirdParty" : [ { + "integrationType" : "slack", + "integrationId" : "sl-101" + }, { + "integrationType" : "slack", + "integrationId" : "sl-101" + } ], + "webhook" : [ { + "integrationType" : "webhook", + "integrationName" : "My webhook", + "integrationId" : "wb-201", + "target" : "https://example.com/test/webhooks/notifications" + }, { + "integrationType" : "webhook", + "integrationName" : "My webhook", + "integrationId" : "wb-201", + "target" : "https://example.com/test/webhooks/notifications" + } ], + "email" : { + "recipients" : [ "noreply@thousandeyes.com" ], + "message" : "Notification message" + }, + "customWebhook" : [ { + "integrationType" : "custom-webhook", + "integrationName" : "My webhook", + "integrationId" : "6e069ae9-8537-4120-b988-61bf8e0d8b87", + "target" : "https://example.com/test/webhooks/notifications" + }, { + "integrationType" : "custom-webhook", + "integrationName" : "My webhook", + "integrationId" : "6e069ae9-8537-4120-b988-61bf8e0d8b87", + "target" : "https://example.com/test/webhooks/notifications" + } ] + }, + "direction" : "to-target" + } + + """ + rule_detail_update = thousandeyes_sdk.alerts.models.RuleDetailUpdate.from_json(request_body_json) + aid = '1234' + response_body_json = """ + { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "includeCoveredPrefixes" : true, + "visitedSitesFilter" : [ "app.thousandeyes.com" ], + "description" : "A rule description string", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "alertGroupType" : "endpoint", + "notifyOnClear" : true, + "testIds" : [ "281474976710706", "271659" ], + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "endpointAgentIds" : [ "281474976710706", "281474976710706" ], + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "endpointLabelIds" : [ "123456", "123456" ], + "minimumSources" : 10, + "ruleId" : "127094", + "notifications" : { + "thirdParty" : [ { + "integrationType" : "slack", + "integrationId" : "sl-101" + }, { + "integrationType" : "slack", + "integrationId" : "sl-101" + } ], + "webhook" : [ { + "integrationType" : "webhook", + "integrationName" : "My webhook", + "integrationId" : "wb-201", + "target" : "https://example.com/test/webhooks/notifications" + }, { + "integrationType" : "webhook", + "integrationName" : "My webhook", + "integrationId" : "wb-201", + "target" : "https://example.com/test/webhooks/notifications" + } ], + "email" : { + "recipients" : [ "noreply@thousandeyes.com" ], + "message" : "Notification message" + }, + "customWebhook" : [ { + "integrationType" : "custom-webhook", + "integrationName" : "My webhook", + "integrationId" : "6e069ae9-8537-4120-b988-61bf8e0d8b87", + "target" : "https://example.com/test/webhooks/notifications" + }, { + "integrationType" : "custom-webhook", + "integrationName" : "My webhook", + "integrationId" : "6e069ae9-8537-4120-b988-61bf8e0d8b87", + "target" : "https://example.com/test/webhooks/notifications" + } ] + }, + "direction" : "to-target" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.create_alert_rule( + + rule_detail_update=rule_detail_update, + + aid=aid, + + _headers=self.te_headers("create_alert_rule"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_create_alert_rule_error_400(self) -> None: + """Integration test for create_alert_rule error path (HTTP 400)""" + request_body_json = """ + + { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "includeCoveredPrefixes" : true, + "visitedSitesFilter" : [ "app.thousandeyes.com" ], + "description" : "A rule description string", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "alertGroupType" : "endpoint", + "notifyOnClear" : true, + "testIds" : [ "281474976710706", "271659" ], + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "endpointAgentIds" : [ "281474976710706", "281474976710706" ], + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "endpointLabelIds" : [ "123456", "123456" ], + "minimumSources" : 10, + "ruleId" : "127094", + "notifications" : { + "thirdParty" : [ { + "integrationType" : "slack", + "integrationId" : "sl-101" + }, { + "integrationType" : "slack", + "integrationId" : "sl-101" + } ], + "webhook" : [ { + "integrationType" : "webhook", + "integrationName" : "My webhook", + "integrationId" : "wb-201", + "target" : "https://example.com/test/webhooks/notifications" + }, { + "integrationType" : "webhook", + "integrationName" : "My webhook", + "integrationId" : "wb-201", + "target" : "https://example.com/test/webhooks/notifications" + } ], + "email" : { + "recipients" : [ "noreply@thousandeyes.com" ], + "message" : "Notification message" + }, + "customWebhook" : [ { + "integrationType" : "custom-webhook", + "integrationName" : "My webhook", + "integrationId" : "6e069ae9-8537-4120-b988-61bf8e0d8b87", + "target" : "https://example.com/test/webhooks/notifications" + }, { + "integrationType" : "custom-webhook", + "integrationName" : "My webhook", + "integrationId" : "6e069ae9-8537-4120-b988-61bf8e0d8b87", + "target" : "https://example.com/test/webhooks/notifications" + } ] + }, + "direction" : "to-target" + } + + """ + rule_detail_update = thousandeyes_sdk.alerts.models.RuleDetailUpdate.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.create_alert_rule( + + rule_detail_update=rule_detail_update, + + aid=aid, + + _headers=self.te_headers("create_alert_rule", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_alert_rule_error_401(self) -> None: + """Integration test for create_alert_rule error path (HTTP 401)""" + request_body_json = """ + + { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "includeCoveredPrefixes" : true, + "visitedSitesFilter" : [ "app.thousandeyes.com" ], + "description" : "A rule description string", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "alertGroupType" : "endpoint", + "notifyOnClear" : true, + "testIds" : [ "281474976710706", "271659" ], + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "endpointAgentIds" : [ "281474976710706", "281474976710706" ], + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "endpointLabelIds" : [ "123456", "123456" ], + "minimumSources" : 10, + "ruleId" : "127094", + "notifications" : { + "thirdParty" : [ { + "integrationType" : "slack", + "integrationId" : "sl-101" + }, { + "integrationType" : "slack", + "integrationId" : "sl-101" + } ], + "webhook" : [ { + "integrationType" : "webhook", + "integrationName" : "My webhook", + "integrationId" : "wb-201", + "target" : "https://example.com/test/webhooks/notifications" + }, { + "integrationType" : "webhook", + "integrationName" : "My webhook", + "integrationId" : "wb-201", + "target" : "https://example.com/test/webhooks/notifications" + } ], + "email" : { + "recipients" : [ "noreply@thousandeyes.com" ], + "message" : "Notification message" + }, + "customWebhook" : [ { + "integrationType" : "custom-webhook", + "integrationName" : "My webhook", + "integrationId" : "6e069ae9-8537-4120-b988-61bf8e0d8b87", + "target" : "https://example.com/test/webhooks/notifications" + }, { + "integrationType" : "custom-webhook", + "integrationName" : "My webhook", + "integrationId" : "6e069ae9-8537-4120-b988-61bf8e0d8b87", + "target" : "https://example.com/test/webhooks/notifications" + } ] + }, + "direction" : "to-target" + } + + """ + rule_detail_update = thousandeyes_sdk.alerts.models.RuleDetailUpdate.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.create_alert_rule( + + rule_detail_update=rule_detail_update, + + aid=aid, + + _headers=self.te_headers("create_alert_rule", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_alert_rule_error_403(self) -> None: + """Integration test for create_alert_rule error path (HTTP 403)""" + request_body_json = """ + + { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "includeCoveredPrefixes" : true, + "visitedSitesFilter" : [ "app.thousandeyes.com" ], + "description" : "A rule description string", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "alertGroupType" : "endpoint", + "notifyOnClear" : true, + "testIds" : [ "281474976710706", "271659" ], + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "endpointAgentIds" : [ "281474976710706", "281474976710706" ], + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "endpointLabelIds" : [ "123456", "123456" ], + "minimumSources" : 10, + "ruleId" : "127094", + "notifications" : { + "thirdParty" : [ { + "integrationType" : "slack", + "integrationId" : "sl-101" + }, { + "integrationType" : "slack", + "integrationId" : "sl-101" + } ], + "webhook" : [ { + "integrationType" : "webhook", + "integrationName" : "My webhook", + "integrationId" : "wb-201", + "target" : "https://example.com/test/webhooks/notifications" + }, { + "integrationType" : "webhook", + "integrationName" : "My webhook", + "integrationId" : "wb-201", + "target" : "https://example.com/test/webhooks/notifications" + } ], + "email" : { + "recipients" : [ "noreply@thousandeyes.com" ], + "message" : "Notification message" + }, + "customWebhook" : [ { + "integrationType" : "custom-webhook", + "integrationName" : "My webhook", + "integrationId" : "6e069ae9-8537-4120-b988-61bf8e0d8b87", + "target" : "https://example.com/test/webhooks/notifications" + }, { + "integrationType" : "custom-webhook", + "integrationName" : "My webhook", + "integrationId" : "6e069ae9-8537-4120-b988-61bf8e0d8b87", + "target" : "https://example.com/test/webhooks/notifications" + } ] + }, + "direction" : "to-target" + } + + """ + rule_detail_update = thousandeyes_sdk.alerts.models.RuleDetailUpdate.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.create_alert_rule( + + rule_detail_update=rule_detail_update, + + aid=aid, + + _headers=self.te_headers("create_alert_rule", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_alert_rule_error_404(self) -> None: + """Integration test for create_alert_rule error path (HTTP 404)""" + request_body_json = """ + + { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "includeCoveredPrefixes" : true, + "visitedSitesFilter" : [ "app.thousandeyes.com" ], + "description" : "A rule description string", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "alertGroupType" : "endpoint", + "notifyOnClear" : true, + "testIds" : [ "281474976710706", "271659" ], + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "endpointAgentIds" : [ "281474976710706", "281474976710706" ], + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "endpointLabelIds" : [ "123456", "123456" ], + "minimumSources" : 10, + "ruleId" : "127094", + "notifications" : { + "thirdParty" : [ { + "integrationType" : "slack", + "integrationId" : "sl-101" + }, { + "integrationType" : "slack", + "integrationId" : "sl-101" + } ], + "webhook" : [ { + "integrationType" : "webhook", + "integrationName" : "My webhook", + "integrationId" : "wb-201", + "target" : "https://example.com/test/webhooks/notifications" + }, { + "integrationType" : "webhook", + "integrationName" : "My webhook", + "integrationId" : "wb-201", + "target" : "https://example.com/test/webhooks/notifications" + } ], + "email" : { + "recipients" : [ "noreply@thousandeyes.com" ], + "message" : "Notification message" + }, + "customWebhook" : [ { + "integrationType" : "custom-webhook", + "integrationName" : "My webhook", + "integrationId" : "6e069ae9-8537-4120-b988-61bf8e0d8b87", + "target" : "https://example.com/test/webhooks/notifications" + }, { + "integrationType" : "custom-webhook", + "integrationName" : "My webhook", + "integrationId" : "6e069ae9-8537-4120-b988-61bf8e0d8b87", + "target" : "https://example.com/test/webhooks/notifications" + } ] + }, + "direction" : "to-target" + } + + """ + rule_detail_update = thousandeyes_sdk.alerts.models.RuleDetailUpdate.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.create_alert_rule( + + rule_detail_update=rule_detail_update, + + aid=aid, + + _headers=self.te_headers("create_alert_rule", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_alert_rule_error_429(self) -> None: + """Integration test for create_alert_rule error path (HTTP 429)""" + request_body_json = """ + + { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "includeCoveredPrefixes" : true, + "visitedSitesFilter" : [ "app.thousandeyes.com" ], + "description" : "A rule description string", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "alertGroupType" : "endpoint", + "notifyOnClear" : true, + "testIds" : [ "281474976710706", "271659" ], + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "endpointAgentIds" : [ "281474976710706", "281474976710706" ], + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "endpointLabelIds" : [ "123456", "123456" ], + "minimumSources" : 10, + "ruleId" : "127094", + "notifications" : { + "thirdParty" : [ { + "integrationType" : "slack", + "integrationId" : "sl-101" + }, { + "integrationType" : "slack", + "integrationId" : "sl-101" + } ], + "webhook" : [ { + "integrationType" : "webhook", + "integrationName" : "My webhook", + "integrationId" : "wb-201", + "target" : "https://example.com/test/webhooks/notifications" + }, { + "integrationType" : "webhook", + "integrationName" : "My webhook", + "integrationId" : "wb-201", + "target" : "https://example.com/test/webhooks/notifications" + } ], + "email" : { + "recipients" : [ "noreply@thousandeyes.com" ], + "message" : "Notification message" + }, + "customWebhook" : [ { + "integrationType" : "custom-webhook", + "integrationName" : "My webhook", + "integrationId" : "6e069ae9-8537-4120-b988-61bf8e0d8b87", + "target" : "https://example.com/test/webhooks/notifications" + }, { + "integrationType" : "custom-webhook", + "integrationName" : "My webhook", + "integrationId" : "6e069ae9-8537-4120-b988-61bf8e0d8b87", + "target" : "https://example.com/test/webhooks/notifications" + } ] + }, + "direction" : "to-target" + } + + """ + rule_detail_update = thousandeyes_sdk.alerts.models.RuleDetailUpdate.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.create_alert_rule( + + rule_detail_update=rule_detail_update, + + aid=aid, + + _headers=self.te_headers("create_alert_rule", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_alert_rule_error_500(self) -> None: + """Integration test for create_alert_rule error path (HTTP 500)""" + request_body_json = """ + + { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "includeCoveredPrefixes" : true, + "visitedSitesFilter" : [ "app.thousandeyes.com" ], + "description" : "A rule description string", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "alertGroupType" : "endpoint", + "notifyOnClear" : true, + "testIds" : [ "281474976710706", "271659" ], + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "endpointAgentIds" : [ "281474976710706", "281474976710706" ], + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "endpointLabelIds" : [ "123456", "123456" ], + "minimumSources" : 10, + "ruleId" : "127094", + "notifications" : { + "thirdParty" : [ { + "integrationType" : "slack", + "integrationId" : "sl-101" + }, { + "integrationType" : "slack", + "integrationId" : "sl-101" + } ], + "webhook" : [ { + "integrationType" : "webhook", + "integrationName" : "My webhook", + "integrationId" : "wb-201", + "target" : "https://example.com/test/webhooks/notifications" + }, { + "integrationType" : "webhook", + "integrationName" : "My webhook", + "integrationId" : "wb-201", + "target" : "https://example.com/test/webhooks/notifications" + } ], + "email" : { + "recipients" : [ "noreply@thousandeyes.com" ], + "message" : "Notification message" + }, + "customWebhook" : [ { + "integrationType" : "custom-webhook", + "integrationName" : "My webhook", + "integrationId" : "6e069ae9-8537-4120-b988-61bf8e0d8b87", + "target" : "https://example.com/test/webhooks/notifications" + }, { + "integrationType" : "custom-webhook", + "integrationName" : "My webhook", + "integrationId" : "6e069ae9-8537-4120-b988-61bf8e0d8b87", + "target" : "https://example.com/test/webhooks/notifications" + } ] + }, + "direction" : "to-target" + } + + """ + rule_detail_update = thousandeyes_sdk.alerts.models.RuleDetailUpdate.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.create_alert_rule( + + rule_detail_update=rule_detail_update, + + aid=aid, + + _headers=self.te_headers("create_alert_rule", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_delete_alert_rule_happy_path(self) -> None: + """Integration test for delete_alert_rule success path""" + rule_id = '127094' + aid = '1234' + response = self.api.delete_alert_rule_with_http_info( + + rule_id=rule_id, + + aid=aid, + + _headers=self.te_headers("delete_alert_rule"), + ) + self.assertEqual(204, response.status_code) + self.assertIsNone(response.data) + + + def test_delete_alert_rule_error_400(self) -> None: + """Integration test for delete_alert_rule error path (HTTP 400)""" + rule_id = '127094' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.delete_alert_rule( + + rule_id=rule_id, + + aid=aid, + + _headers=self.te_headers("delete_alert_rule", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_alert_rule_error_401(self) -> None: + """Integration test for delete_alert_rule error path (HTTP 401)""" + rule_id = '127094' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.delete_alert_rule( + + rule_id=rule_id, + + aid=aid, + + _headers=self.te_headers("delete_alert_rule", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_alert_rule_error_403(self) -> None: + """Integration test for delete_alert_rule error path (HTTP 403)""" + rule_id = '127094' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.delete_alert_rule( + + rule_id=rule_id, + + aid=aid, + + _headers=self.te_headers("delete_alert_rule", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_alert_rule_error_404(self) -> None: + """Integration test for delete_alert_rule error path (HTTP 404)""" + rule_id = '127094' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.delete_alert_rule( + + rule_id=rule_id, + + aid=aid, + + _headers=self.te_headers("delete_alert_rule", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_alert_rule_error_429(self) -> None: + """Integration test for delete_alert_rule error path (HTTP 429)""" + rule_id = '127094' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.delete_alert_rule( + + rule_id=rule_id, + + aid=aid, + + _headers=self.te_headers("delete_alert_rule", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_alert_rule_error_500(self) -> None: + """Integration test for delete_alert_rule error path (HTTP 500)""" + rule_id = '127094' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.delete_alert_rule( + + rule_id=rule_id, + + aid=aid, + + _headers=self.te_headers("delete_alert_rule", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_alert_rule_happy_path(self) -> None: + """Integration test for get_alert_rule success path""" + rule_id = '127094' + aid = '1234' + response_body_json = """ + { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "includeCoveredPrefixes" : true, + "visitedSitesFilter" : [ "app.thousandeyes.com" ], + "description" : "A rule description string", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "alertGroupType" : "endpoint", + "notifyOnClear" : true, + "testIds" : [ "281474976710706", "271659" ], + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "endpointAgentIds" : [ "281474976710706", "281474976710706" ], + "tests" : [ { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + }, { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + } ], + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "endpointLabelIds" : [ "123456", "123456" ], + "minimumSources" : 10, + "ruleId" : "127094", + "notifications" : { + "thirdParty" : [ { + "integrationType" : "slack", + "integrationId" : "sl-101" + }, { + "integrationType" : "slack", + "integrationId" : "sl-101" + } ], + "webhook" : [ { + "integrationType" : "webhook", + "integrationName" : "My webhook", + "integrationId" : "wb-201", + "target" : "https://example.com/test/webhooks/notifications" + }, { + "integrationType" : "webhook", + "integrationName" : "My webhook", + "integrationId" : "wb-201", + "target" : "https://example.com/test/webhooks/notifications" + } ], + "email" : { + "recipients" : [ "noreply@thousandeyes.com" ], + "message" : "Notification message" + }, + "customWebhook" : [ { + "integrationType" : "custom-webhook", + "integrationName" : "My webhook", + "integrationId" : "6e069ae9-8537-4120-b988-61bf8e0d8b87", + "target" : "https://example.com/test/webhooks/notifications" + }, { + "integrationType" : "custom-webhook", + "integrationName" : "My webhook", + "integrationId" : "6e069ae9-8537-4120-b988-61bf8e0d8b87", + "target" : "https://example.com/test/webhooks/notifications" + } ] + }, + "direction" : "to-target" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_alert_rule( + + rule_id=rule_id, + + aid=aid, + + _headers=self.te_headers("get_alert_rule"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_alert_rule_error_401(self) -> None: + """Integration test for get_alert_rule error path (HTTP 401)""" + rule_id = '127094' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_alert_rule( + + rule_id=rule_id, + + aid=aid, + + _headers=self.te_headers("get_alert_rule", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_alert_rule_error_403(self) -> None: + """Integration test for get_alert_rule error path (HTTP 403)""" + rule_id = '127094' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_alert_rule( + + rule_id=rule_id, + + aid=aid, + + _headers=self.te_headers("get_alert_rule", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_alert_rule_error_404(self) -> None: + """Integration test for get_alert_rule error path (HTTP 404)""" + rule_id = '127094' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_alert_rule( + + rule_id=rule_id, + + aid=aid, + + _headers=self.te_headers("get_alert_rule", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_alert_rule_error_429(self) -> None: + """Integration test for get_alert_rule error path (HTTP 429)""" + rule_id = '127094' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_alert_rule( + + rule_id=rule_id, + + aid=aid, + + _headers=self.te_headers("get_alert_rule", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_alert_rule_error_500(self) -> None: + """Integration test for get_alert_rule error path (HTTP 500)""" + rule_id = '127094' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_alert_rule( + + rule_id=rule_id, + + aid=aid, + + _headers=self.te_headers("get_alert_rule", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_alerts_rules_happy_path(self) -> None: + """Integration test for get_alerts_rules success path""" + aid = '1234' + response_body_json = """ + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "includeCoveredPrefixes" : true, + "visitedSitesFilter" : [ "app.thousandeyes.com" ], + "description" : "A rule description string", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "alertGroupType" : "endpoint", + "notifyOnClear" : true, + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "endpointAgentIds" : [ "281474976710706", "281474976710706" ], + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "endpointLabelIds" : [ "123456", "123456" ], + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + }, { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "includeCoveredPrefixes" : true, + "visitedSitesFilter" : [ "app.thousandeyes.com" ], + "description" : "A rule description string", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "alertGroupType" : "endpoint", + "notifyOnClear" : true, + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "endpointAgentIds" : [ "281474976710706", "281474976710706" ], + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "endpointLabelIds" : [ "123456", "123456" ], + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + } ] + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_alerts_rules( + + aid=aid, + + _headers=self.te_headers("get_alerts_rules"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_alerts_rules_error_401(self) -> None: + """Integration test for get_alerts_rules error path (HTTP 401)""" + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_alerts_rules( + + aid=aid, + + _headers=self.te_headers("get_alerts_rules", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_alerts_rules_error_403(self) -> None: + """Integration test for get_alerts_rules error path (HTTP 403)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_alerts_rules( + + aid=aid, + + _headers=self.te_headers("get_alerts_rules", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_alerts_rules_error_404(self) -> None: + """Integration test for get_alerts_rules error path (HTTP 404)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_alerts_rules( + + aid=aid, + + _headers=self.te_headers("get_alerts_rules", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_alerts_rules_error_429(self) -> None: + """Integration test for get_alerts_rules error path (HTTP 429)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_alerts_rules( + + aid=aid, + + _headers=self.te_headers("get_alerts_rules", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_alerts_rules_error_500(self) -> None: + """Integration test for get_alerts_rules error path (HTTP 500)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_alerts_rules( + + aid=aid, + + _headers=self.te_headers("get_alerts_rules", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_update_alert_rule_happy_path(self) -> None: + """Integration test for update_alert_rule success path""" + request_body_json = """ + + { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "includeCoveredPrefixes" : true, + "visitedSitesFilter" : [ "app.thousandeyes.com" ], + "description" : "A rule description string", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "alertGroupType" : "endpoint", + "notifyOnClear" : true, + "testIds" : [ "281474976710706", "271659" ], + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "endpointAgentIds" : [ "281474976710706", "281474976710706" ], + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "endpointLabelIds" : [ "123456", "123456" ], + "minimumSources" : 10, + "ruleId" : "127094", + "notifications" : { + "thirdParty" : [ { + "integrationType" : "slack", + "integrationId" : "sl-101" + }, { + "integrationType" : "slack", + "integrationId" : "sl-101" + } ], + "webhook" : [ { + "integrationType" : "webhook", + "integrationName" : "My webhook", + "integrationId" : "wb-201", + "target" : "https://example.com/test/webhooks/notifications" + }, { + "integrationType" : "webhook", + "integrationName" : "My webhook", + "integrationId" : "wb-201", + "target" : "https://example.com/test/webhooks/notifications" + } ], + "email" : { + "recipients" : [ "noreply@thousandeyes.com" ], + "message" : "Notification message" + }, + "customWebhook" : [ { + "integrationType" : "custom-webhook", + "integrationName" : "My webhook", + "integrationId" : "6e069ae9-8537-4120-b988-61bf8e0d8b87", + "target" : "https://example.com/test/webhooks/notifications" + }, { + "integrationType" : "custom-webhook", + "integrationName" : "My webhook", + "integrationId" : "6e069ae9-8537-4120-b988-61bf8e0d8b87", + "target" : "https://example.com/test/webhooks/notifications" + } ] + }, + "direction" : "to-target" + } + + """ + rule_detail_update = thousandeyes_sdk.alerts.models.RuleDetailUpdate.from_json(request_body_json) + rule_id = '127094' + aid = '1234' + response_body_json = """ + { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "includeCoveredPrefixes" : true, + "visitedSitesFilter" : [ "app.thousandeyes.com" ], + "description" : "A rule description string", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "alertGroupType" : "endpoint", + "notifyOnClear" : true, + "testIds" : [ "281474976710706", "271659" ], + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "endpointAgentIds" : [ "281474976710706", "281474976710706" ], + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "endpointLabelIds" : [ "123456", "123456" ], + "minimumSources" : 10, + "ruleId" : "127094", + "notifications" : { + "thirdParty" : [ { + "integrationType" : "slack", + "integrationId" : "sl-101" + }, { + "integrationType" : "slack", + "integrationId" : "sl-101" + } ], + "webhook" : [ { + "integrationType" : "webhook", + "integrationName" : "My webhook", + "integrationId" : "wb-201", + "target" : "https://example.com/test/webhooks/notifications" + }, { + "integrationType" : "webhook", + "integrationName" : "My webhook", + "integrationId" : "wb-201", + "target" : "https://example.com/test/webhooks/notifications" + } ], + "email" : { + "recipients" : [ "noreply@thousandeyes.com" ], + "message" : "Notification message" + }, + "customWebhook" : [ { + "integrationType" : "custom-webhook", + "integrationName" : "My webhook", + "integrationId" : "6e069ae9-8537-4120-b988-61bf8e0d8b87", + "target" : "https://example.com/test/webhooks/notifications" + }, { + "integrationType" : "custom-webhook", + "integrationName" : "My webhook", + "integrationId" : "6e069ae9-8537-4120-b988-61bf8e0d8b87", + "target" : "https://example.com/test/webhooks/notifications" + } ] + }, + "direction" : "to-target" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.update_alert_rule( + + rule_id=rule_id, + + rule_detail_update=rule_detail_update, + + aid=aid, + + _headers=self.te_headers("update_alert_rule"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_update_alert_rule_error_400(self) -> None: + """Integration test for update_alert_rule error path (HTTP 400)""" + request_body_json = """ + + { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "includeCoveredPrefixes" : true, + "visitedSitesFilter" : [ "app.thousandeyes.com" ], + "description" : "A rule description string", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "alertGroupType" : "endpoint", + "notifyOnClear" : true, + "testIds" : [ "281474976710706", "271659" ], + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "endpointAgentIds" : [ "281474976710706", "281474976710706" ], + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "endpointLabelIds" : [ "123456", "123456" ], + "minimumSources" : 10, + "ruleId" : "127094", + "notifications" : { + "thirdParty" : [ { + "integrationType" : "slack", + "integrationId" : "sl-101" + }, { + "integrationType" : "slack", + "integrationId" : "sl-101" + } ], + "webhook" : [ { + "integrationType" : "webhook", + "integrationName" : "My webhook", + "integrationId" : "wb-201", + "target" : "https://example.com/test/webhooks/notifications" + }, { + "integrationType" : "webhook", + "integrationName" : "My webhook", + "integrationId" : "wb-201", + "target" : "https://example.com/test/webhooks/notifications" + } ], + "email" : { + "recipients" : [ "noreply@thousandeyes.com" ], + "message" : "Notification message" + }, + "customWebhook" : [ { + "integrationType" : "custom-webhook", + "integrationName" : "My webhook", + "integrationId" : "6e069ae9-8537-4120-b988-61bf8e0d8b87", + "target" : "https://example.com/test/webhooks/notifications" + }, { + "integrationType" : "custom-webhook", + "integrationName" : "My webhook", + "integrationId" : "6e069ae9-8537-4120-b988-61bf8e0d8b87", + "target" : "https://example.com/test/webhooks/notifications" + } ] + }, + "direction" : "to-target" + } + + """ + rule_detail_update = thousandeyes_sdk.alerts.models.RuleDetailUpdate.from_json(request_body_json) + rule_id = '127094' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.update_alert_rule( + + rule_id=rule_id, + + rule_detail_update=rule_detail_update, + + aid=aid, + + _headers=self.te_headers("update_alert_rule", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_alert_rule_error_401(self) -> None: + """Integration test for update_alert_rule error path (HTTP 401)""" + request_body_json = """ + + { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "includeCoveredPrefixes" : true, + "visitedSitesFilter" : [ "app.thousandeyes.com" ], + "description" : "A rule description string", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "alertGroupType" : "endpoint", + "notifyOnClear" : true, + "testIds" : [ "281474976710706", "271659" ], + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "endpointAgentIds" : [ "281474976710706", "281474976710706" ], + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "endpointLabelIds" : [ "123456", "123456" ], + "minimumSources" : 10, + "ruleId" : "127094", + "notifications" : { + "thirdParty" : [ { + "integrationType" : "slack", + "integrationId" : "sl-101" + }, { + "integrationType" : "slack", + "integrationId" : "sl-101" + } ], + "webhook" : [ { + "integrationType" : "webhook", + "integrationName" : "My webhook", + "integrationId" : "wb-201", + "target" : "https://example.com/test/webhooks/notifications" + }, { + "integrationType" : "webhook", + "integrationName" : "My webhook", + "integrationId" : "wb-201", + "target" : "https://example.com/test/webhooks/notifications" + } ], + "email" : { + "recipients" : [ "noreply@thousandeyes.com" ], + "message" : "Notification message" + }, + "customWebhook" : [ { + "integrationType" : "custom-webhook", + "integrationName" : "My webhook", + "integrationId" : "6e069ae9-8537-4120-b988-61bf8e0d8b87", + "target" : "https://example.com/test/webhooks/notifications" + }, { + "integrationType" : "custom-webhook", + "integrationName" : "My webhook", + "integrationId" : "6e069ae9-8537-4120-b988-61bf8e0d8b87", + "target" : "https://example.com/test/webhooks/notifications" + } ] + }, + "direction" : "to-target" + } + + """ + rule_detail_update = thousandeyes_sdk.alerts.models.RuleDetailUpdate.from_json(request_body_json) + rule_id = '127094' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.update_alert_rule( + + rule_id=rule_id, + + rule_detail_update=rule_detail_update, + + aid=aid, + + _headers=self.te_headers("update_alert_rule", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_alert_rule_error_403(self) -> None: + """Integration test for update_alert_rule error path (HTTP 403)""" + request_body_json = """ + + { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "includeCoveredPrefixes" : true, + "visitedSitesFilter" : [ "app.thousandeyes.com" ], + "description" : "A rule description string", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "alertGroupType" : "endpoint", + "notifyOnClear" : true, + "testIds" : [ "281474976710706", "271659" ], + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "endpointAgentIds" : [ "281474976710706", "281474976710706" ], + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "endpointLabelIds" : [ "123456", "123456" ], + "minimumSources" : 10, + "ruleId" : "127094", + "notifications" : { + "thirdParty" : [ { + "integrationType" : "slack", + "integrationId" : "sl-101" + }, { + "integrationType" : "slack", + "integrationId" : "sl-101" + } ], + "webhook" : [ { + "integrationType" : "webhook", + "integrationName" : "My webhook", + "integrationId" : "wb-201", + "target" : "https://example.com/test/webhooks/notifications" + }, { + "integrationType" : "webhook", + "integrationName" : "My webhook", + "integrationId" : "wb-201", + "target" : "https://example.com/test/webhooks/notifications" + } ], + "email" : { + "recipients" : [ "noreply@thousandeyes.com" ], + "message" : "Notification message" + }, + "customWebhook" : [ { + "integrationType" : "custom-webhook", + "integrationName" : "My webhook", + "integrationId" : "6e069ae9-8537-4120-b988-61bf8e0d8b87", + "target" : "https://example.com/test/webhooks/notifications" + }, { + "integrationType" : "custom-webhook", + "integrationName" : "My webhook", + "integrationId" : "6e069ae9-8537-4120-b988-61bf8e0d8b87", + "target" : "https://example.com/test/webhooks/notifications" + } ] + }, + "direction" : "to-target" + } + + """ + rule_detail_update = thousandeyes_sdk.alerts.models.RuleDetailUpdate.from_json(request_body_json) + rule_id = '127094' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.update_alert_rule( + + rule_id=rule_id, + + rule_detail_update=rule_detail_update, + + aid=aid, + + _headers=self.te_headers("update_alert_rule", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_alert_rule_error_404(self) -> None: + """Integration test for update_alert_rule error path (HTTP 404)""" + request_body_json = """ + + { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "includeCoveredPrefixes" : true, + "visitedSitesFilter" : [ "app.thousandeyes.com" ], + "description" : "A rule description string", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "alertGroupType" : "endpoint", + "notifyOnClear" : true, + "testIds" : [ "281474976710706", "271659" ], + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "endpointAgentIds" : [ "281474976710706", "281474976710706" ], + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "endpointLabelIds" : [ "123456", "123456" ], + "minimumSources" : 10, + "ruleId" : "127094", + "notifications" : { + "thirdParty" : [ { + "integrationType" : "slack", + "integrationId" : "sl-101" + }, { + "integrationType" : "slack", + "integrationId" : "sl-101" + } ], + "webhook" : [ { + "integrationType" : "webhook", + "integrationName" : "My webhook", + "integrationId" : "wb-201", + "target" : "https://example.com/test/webhooks/notifications" + }, { + "integrationType" : "webhook", + "integrationName" : "My webhook", + "integrationId" : "wb-201", + "target" : "https://example.com/test/webhooks/notifications" + } ], + "email" : { + "recipients" : [ "noreply@thousandeyes.com" ], + "message" : "Notification message" + }, + "customWebhook" : [ { + "integrationType" : "custom-webhook", + "integrationName" : "My webhook", + "integrationId" : "6e069ae9-8537-4120-b988-61bf8e0d8b87", + "target" : "https://example.com/test/webhooks/notifications" + }, { + "integrationType" : "custom-webhook", + "integrationName" : "My webhook", + "integrationId" : "6e069ae9-8537-4120-b988-61bf8e0d8b87", + "target" : "https://example.com/test/webhooks/notifications" + } ] + }, + "direction" : "to-target" + } + + """ + rule_detail_update = thousandeyes_sdk.alerts.models.RuleDetailUpdate.from_json(request_body_json) + rule_id = '127094' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.update_alert_rule( + + rule_id=rule_id, + + rule_detail_update=rule_detail_update, + + aid=aid, + + _headers=self.te_headers("update_alert_rule", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_alert_rule_error_429(self) -> None: + """Integration test for update_alert_rule error path (HTTP 429)""" + request_body_json = """ + + { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "includeCoveredPrefixes" : true, + "visitedSitesFilter" : [ "app.thousandeyes.com" ], + "description" : "A rule description string", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "alertGroupType" : "endpoint", + "notifyOnClear" : true, + "testIds" : [ "281474976710706", "271659" ], + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "endpointAgentIds" : [ "281474976710706", "281474976710706" ], + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "endpointLabelIds" : [ "123456", "123456" ], + "minimumSources" : 10, + "ruleId" : "127094", + "notifications" : { + "thirdParty" : [ { + "integrationType" : "slack", + "integrationId" : "sl-101" + }, { + "integrationType" : "slack", + "integrationId" : "sl-101" + } ], + "webhook" : [ { + "integrationType" : "webhook", + "integrationName" : "My webhook", + "integrationId" : "wb-201", + "target" : "https://example.com/test/webhooks/notifications" + }, { + "integrationType" : "webhook", + "integrationName" : "My webhook", + "integrationId" : "wb-201", + "target" : "https://example.com/test/webhooks/notifications" + } ], + "email" : { + "recipients" : [ "noreply@thousandeyes.com" ], + "message" : "Notification message" + }, + "customWebhook" : [ { + "integrationType" : "custom-webhook", + "integrationName" : "My webhook", + "integrationId" : "6e069ae9-8537-4120-b988-61bf8e0d8b87", + "target" : "https://example.com/test/webhooks/notifications" + }, { + "integrationType" : "custom-webhook", + "integrationName" : "My webhook", + "integrationId" : "6e069ae9-8537-4120-b988-61bf8e0d8b87", + "target" : "https://example.com/test/webhooks/notifications" + } ] + }, + "direction" : "to-target" + } + + """ + rule_detail_update = thousandeyes_sdk.alerts.models.RuleDetailUpdate.from_json(request_body_json) + rule_id = '127094' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.update_alert_rule( + + rule_id=rule_id, + + rule_detail_update=rule_detail_update, + + aid=aid, + + _headers=self.te_headers("update_alert_rule", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_alert_rule_error_500(self) -> None: + """Integration test for update_alert_rule error path (HTTP 500)""" + request_body_json = """ + + { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "includeCoveredPrefixes" : true, + "visitedSitesFilter" : [ "app.thousandeyes.com" ], + "description" : "A rule description string", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "alertGroupType" : "endpoint", + "notifyOnClear" : true, + "testIds" : [ "281474976710706", "271659" ], + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "endpointAgentIds" : [ "281474976710706", "281474976710706" ], + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "endpointLabelIds" : [ "123456", "123456" ], + "minimumSources" : 10, + "ruleId" : "127094", + "notifications" : { + "thirdParty" : [ { + "integrationType" : "slack", + "integrationId" : "sl-101" + }, { + "integrationType" : "slack", + "integrationId" : "sl-101" + } ], + "webhook" : [ { + "integrationType" : "webhook", + "integrationName" : "My webhook", + "integrationId" : "wb-201", + "target" : "https://example.com/test/webhooks/notifications" + }, { + "integrationType" : "webhook", + "integrationName" : "My webhook", + "integrationId" : "wb-201", + "target" : "https://example.com/test/webhooks/notifications" + } ], + "email" : { + "recipients" : [ "noreply@thousandeyes.com" ], + "message" : "Notification message" + }, + "customWebhook" : [ { + "integrationType" : "custom-webhook", + "integrationName" : "My webhook", + "integrationId" : "6e069ae9-8537-4120-b988-61bf8e0d8b87", + "target" : "https://example.com/test/webhooks/notifications" + }, { + "integrationType" : "custom-webhook", + "integrationName" : "My webhook", + "integrationId" : "6e069ae9-8537-4120-b988-61bf8e0d8b87", + "target" : "https://example.com/test/webhooks/notifications" + } ] + }, + "direction" : "to-target" + } + + """ + rule_detail_update = thousandeyes_sdk.alerts.models.RuleDetailUpdate.from_json(request_body_json) + rule_id = '127094' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.update_alert_rule( + + rule_id=rule_id, + + rule_detail_update=rule_detail_update, + + aid=aid, + + _headers=self.te_headers("update_alert_rule", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-alerts/test/test_alert_suppression_windows_api_integration.py b/thousandeyes-sdk-alerts/test/test_alert_suppression_windows_api_integration.py new file mode 100644 index 00000000..382665c5 --- /dev/null +++ b/thousandeyes-sdk-alerts/test/test_alert_suppression_windows_api_integration.py @@ -0,0 +1,1625 @@ +# coding: utf-8 + +""" + Alerts API + + **Note:** API operations for the creation or retrieval of API, Page Load, or Web-Transaction alert rules are not available for ThousandEyes for Government instance. You can manage the following alert functionalities on the ThousandEyes platform using the Alerts API: * **Alerts**: Retrieve alert details. Alerts are assigned to tests through alert rules. * **Alert Rules**: Conditions that you configure in order to highlight or be notified of events of interest in your ThousandEyes tests. When an alert rule’s conditions are met, the associated alert is triggered and the alert becomes active. It remains active until the alert is cleared. Alert rules are reusable across multiple tests.. * **Alert Suppression Windows**: Suppress alerts for tests during periods such as planned maintenance. Windows can be one-time events or recurring events to handle periodic occurrences such as monthly downtime for maintenance. For more information about the alerts, see [Alerts](https://docs.thousandeyes.com/product-documentation/alerts). + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.alerts.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.alerts.api.alert_suppression_windows_api import AlertSuppressionWindowsApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestAlertSuppressionWindowsApiIntegration(IntegrationTestBase): + """AlertSuppressionWindowsApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = AlertSuppressionWindowsApi(self.api_client) + + + def test_create_alert_suppression_window_happy_path(self) -> None: + """Integration test for create_alert_suppression_window success path""" + request_body_json = """ + + { + "duration" : 0, + "testIds" : [ "71687", "71687" ], + "alertSuppressionWindowId" : "2411", + "isEnabled" : false, + "repeat" : { + "intervalType" : "day", + "intervalLength" : 2, + "type" : "week", + "daysOfWeek" : [ "sun", "sun" ] + }, + "endRepeat" : { + "date" : "2017-07-01", + "count" : 3, + "type" : "never" + }, + "name" : "Monthly maintenance", + "startDate" : "2017-07-01T05:00:00Z", + "status" : "ended" + } + + """ + alert_suppression_window_request = thousandeyes_sdk.alerts.models.AlertSuppressionWindowRequest.from_json(request_body_json) + aid = '1234' + response_body_json = """ + { + "duration" : 0, + "alertSuppressionWindowId" : "2411", + "tests" : [ { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + }, { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + } ], + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isEnabled" : false, + "repeat" : { + "intervalType" : "day", + "intervalLength" : 2, + "type" : "week", + "daysOfWeek" : [ "sun", "sun" ] + }, + "endRepeat" : { + "date" : "2017-07-01", + "count" : 3, + "type" : "never" + }, + "name" : "Monthly maintenance", + "startDate" : "2017-07-01T05:00:00Z", + "status" : "ended" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.create_alert_suppression_window( + + alert_suppression_window_request=alert_suppression_window_request, + + aid=aid, + + _headers=self.te_headers("create_alert_suppression_window"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_create_alert_suppression_window_error_400(self) -> None: + """Integration test for create_alert_suppression_window error path (HTTP 400)""" + request_body_json = """ + + { + "duration" : 0, + "testIds" : [ "71687", "71687" ], + "alertSuppressionWindowId" : "2411", + "isEnabled" : false, + "repeat" : { + "intervalType" : "day", + "intervalLength" : 2, + "type" : "week", + "daysOfWeek" : [ "sun", "sun" ] + }, + "endRepeat" : { + "date" : "2017-07-01", + "count" : 3, + "type" : "never" + }, + "name" : "Monthly maintenance", + "startDate" : "2017-07-01T05:00:00Z", + "status" : "ended" + } + + """ + alert_suppression_window_request = thousandeyes_sdk.alerts.models.AlertSuppressionWindowRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.create_alert_suppression_window( + + alert_suppression_window_request=alert_suppression_window_request, + + aid=aid, + + _headers=self.te_headers("create_alert_suppression_window", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_alert_suppression_window_error_401(self) -> None: + """Integration test for create_alert_suppression_window error path (HTTP 401)""" + request_body_json = """ + + { + "duration" : 0, + "testIds" : [ "71687", "71687" ], + "alertSuppressionWindowId" : "2411", + "isEnabled" : false, + "repeat" : { + "intervalType" : "day", + "intervalLength" : 2, + "type" : "week", + "daysOfWeek" : [ "sun", "sun" ] + }, + "endRepeat" : { + "date" : "2017-07-01", + "count" : 3, + "type" : "never" + }, + "name" : "Monthly maintenance", + "startDate" : "2017-07-01T05:00:00Z", + "status" : "ended" + } + + """ + alert_suppression_window_request = thousandeyes_sdk.alerts.models.AlertSuppressionWindowRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.create_alert_suppression_window( + + alert_suppression_window_request=alert_suppression_window_request, + + aid=aid, + + _headers=self.te_headers("create_alert_suppression_window", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_alert_suppression_window_error_403(self) -> None: + """Integration test for create_alert_suppression_window error path (HTTP 403)""" + request_body_json = """ + + { + "duration" : 0, + "testIds" : [ "71687", "71687" ], + "alertSuppressionWindowId" : "2411", + "isEnabled" : false, + "repeat" : { + "intervalType" : "day", + "intervalLength" : 2, + "type" : "week", + "daysOfWeek" : [ "sun", "sun" ] + }, + "endRepeat" : { + "date" : "2017-07-01", + "count" : 3, + "type" : "never" + }, + "name" : "Monthly maintenance", + "startDate" : "2017-07-01T05:00:00Z", + "status" : "ended" + } + + """ + alert_suppression_window_request = thousandeyes_sdk.alerts.models.AlertSuppressionWindowRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.create_alert_suppression_window( + + alert_suppression_window_request=alert_suppression_window_request, + + aid=aid, + + _headers=self.te_headers("create_alert_suppression_window", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_alert_suppression_window_error_404(self) -> None: + """Integration test for create_alert_suppression_window error path (HTTP 404)""" + request_body_json = """ + + { + "duration" : 0, + "testIds" : [ "71687", "71687" ], + "alertSuppressionWindowId" : "2411", + "isEnabled" : false, + "repeat" : { + "intervalType" : "day", + "intervalLength" : 2, + "type" : "week", + "daysOfWeek" : [ "sun", "sun" ] + }, + "endRepeat" : { + "date" : "2017-07-01", + "count" : 3, + "type" : "never" + }, + "name" : "Monthly maintenance", + "startDate" : "2017-07-01T05:00:00Z", + "status" : "ended" + } + + """ + alert_suppression_window_request = thousandeyes_sdk.alerts.models.AlertSuppressionWindowRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.create_alert_suppression_window( + + alert_suppression_window_request=alert_suppression_window_request, + + aid=aid, + + _headers=self.te_headers("create_alert_suppression_window", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_alert_suppression_window_error_429(self) -> None: + """Integration test for create_alert_suppression_window error path (HTTP 429)""" + request_body_json = """ + + { + "duration" : 0, + "testIds" : [ "71687", "71687" ], + "alertSuppressionWindowId" : "2411", + "isEnabled" : false, + "repeat" : { + "intervalType" : "day", + "intervalLength" : 2, + "type" : "week", + "daysOfWeek" : [ "sun", "sun" ] + }, + "endRepeat" : { + "date" : "2017-07-01", + "count" : 3, + "type" : "never" + }, + "name" : "Monthly maintenance", + "startDate" : "2017-07-01T05:00:00Z", + "status" : "ended" + } + + """ + alert_suppression_window_request = thousandeyes_sdk.alerts.models.AlertSuppressionWindowRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.create_alert_suppression_window( + + alert_suppression_window_request=alert_suppression_window_request, + + aid=aid, + + _headers=self.te_headers("create_alert_suppression_window", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_alert_suppression_window_error_500(self) -> None: + """Integration test for create_alert_suppression_window error path (HTTP 500)""" + request_body_json = """ + + { + "duration" : 0, + "testIds" : [ "71687", "71687" ], + "alertSuppressionWindowId" : "2411", + "isEnabled" : false, + "repeat" : { + "intervalType" : "day", + "intervalLength" : 2, + "type" : "week", + "daysOfWeek" : [ "sun", "sun" ] + }, + "endRepeat" : { + "date" : "2017-07-01", + "count" : 3, + "type" : "never" + }, + "name" : "Monthly maintenance", + "startDate" : "2017-07-01T05:00:00Z", + "status" : "ended" + } + + """ + alert_suppression_window_request = thousandeyes_sdk.alerts.models.AlertSuppressionWindowRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.create_alert_suppression_window( + + alert_suppression_window_request=alert_suppression_window_request, + + aid=aid, + + _headers=self.te_headers("create_alert_suppression_window", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_delete_alert_suppression_window_happy_path(self) -> None: + """Integration test for delete_alert_suppression_window success path""" + window_id = '2411' + aid = '1234' + response = self.api.delete_alert_suppression_window_with_http_info( + + window_id=window_id, + + aid=aid, + + _headers=self.te_headers("delete_alert_suppression_window"), + ) + self.assertEqual(204, response.status_code) + self.assertIsNone(response.data) + + + def test_delete_alert_suppression_window_error_400(self) -> None: + """Integration test for delete_alert_suppression_window error path (HTTP 400)""" + window_id = '2411' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.delete_alert_suppression_window( + + window_id=window_id, + + aid=aid, + + _headers=self.te_headers("delete_alert_suppression_window", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_alert_suppression_window_error_401(self) -> None: + """Integration test for delete_alert_suppression_window error path (HTTP 401)""" + window_id = '2411' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.delete_alert_suppression_window( + + window_id=window_id, + + aid=aid, + + _headers=self.te_headers("delete_alert_suppression_window", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_alert_suppression_window_error_403(self) -> None: + """Integration test for delete_alert_suppression_window error path (HTTP 403)""" + window_id = '2411' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.delete_alert_suppression_window( + + window_id=window_id, + + aid=aid, + + _headers=self.te_headers("delete_alert_suppression_window", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_alert_suppression_window_error_404(self) -> None: + """Integration test for delete_alert_suppression_window error path (HTTP 404)""" + window_id = '2411' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.delete_alert_suppression_window( + + window_id=window_id, + + aid=aid, + + _headers=self.te_headers("delete_alert_suppression_window", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_alert_suppression_window_error_429(self) -> None: + """Integration test for delete_alert_suppression_window error path (HTTP 429)""" + window_id = '2411' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.delete_alert_suppression_window( + + window_id=window_id, + + aid=aid, + + _headers=self.te_headers("delete_alert_suppression_window", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_alert_suppression_window_error_500(self) -> None: + """Integration test for delete_alert_suppression_window error path (HTTP 500)""" + window_id = '2411' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.delete_alert_suppression_window( + + window_id=window_id, + + aid=aid, + + _headers=self.te_headers("delete_alert_suppression_window", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_alert_suppression_window_happy_path(self) -> None: + """Integration test for get_alert_suppression_window success path""" + window_id = '2411' + aid = '1234' + response_body_json = """ + { + "duration" : 0, + "alertSuppressionWindowId" : "2411", + "tests" : [ { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + }, { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + } ], + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isEnabled" : false, + "repeat" : { + "intervalType" : "day", + "intervalLength" : 2, + "type" : "week", + "daysOfWeek" : [ "sun", "sun" ] + }, + "endRepeat" : { + "date" : "2017-07-01", + "count" : 3, + "type" : "never" + }, + "name" : "Monthly maintenance", + "startDate" : "2017-07-01T05:00:00Z", + "status" : "ended" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_alert_suppression_window( + + window_id=window_id, + + aid=aid, + + _headers=self.te_headers("get_alert_suppression_window"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_alert_suppression_window_error_401(self) -> None: + """Integration test for get_alert_suppression_window error path (HTTP 401)""" + window_id = '2411' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_alert_suppression_window( + + window_id=window_id, + + aid=aid, + + _headers=self.te_headers("get_alert_suppression_window", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_alert_suppression_window_error_403(self) -> None: + """Integration test for get_alert_suppression_window error path (HTTP 403)""" + window_id = '2411' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_alert_suppression_window( + + window_id=window_id, + + aid=aid, + + _headers=self.te_headers("get_alert_suppression_window", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_alert_suppression_window_error_404(self) -> None: + """Integration test for get_alert_suppression_window error path (HTTP 404)""" + window_id = '2411' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_alert_suppression_window( + + window_id=window_id, + + aid=aid, + + _headers=self.te_headers("get_alert_suppression_window", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_alert_suppression_window_error_429(self) -> None: + """Integration test for get_alert_suppression_window error path (HTTP 429)""" + window_id = '2411' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_alert_suppression_window( + + window_id=window_id, + + aid=aid, + + _headers=self.te_headers("get_alert_suppression_window", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_alert_suppression_window_error_500(self) -> None: + """Integration test for get_alert_suppression_window error path (HTTP 500)""" + window_id = '2411' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_alert_suppression_window( + + window_id=window_id, + + aid=aid, + + _headers=self.te_headers("get_alert_suppression_window", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_alert_suppression_windows_happy_path(self) -> None: + """Integration test for get_alert_suppression_windows success path""" + aid = '1234' + response_body_json = """ + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertSuppressionWindows" : [ { + "duration" : 0, + "alertSuppressionWindowId" : "2411", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isEnabled" : false, + "repeat" : { + "intervalType" : "day", + "intervalLength" : 2, + "type" : "week", + "daysOfWeek" : [ "sun", "sun" ] + }, + "endRepeat" : { + "date" : "2017-07-01", + "count" : 3, + "type" : "never" + }, + "name" : "Monthly maintenance", + "startDate" : "2017-07-01T05:00:00Z", + "status" : "ended" + }, { + "duration" : 0, + "alertSuppressionWindowId" : "2411", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isEnabled" : false, + "repeat" : { + "intervalType" : "day", + "intervalLength" : 2, + "type" : "week", + "daysOfWeek" : [ "sun", "sun" ] + }, + "endRepeat" : { + "date" : "2017-07-01", + "count" : 3, + "type" : "never" + }, + "name" : "Monthly maintenance", + "startDate" : "2017-07-01T05:00:00Z", + "status" : "ended" + } ] + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_alert_suppression_windows( + + aid=aid, + + _headers=self.te_headers("get_alert_suppression_windows"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_alert_suppression_windows_error_401(self) -> None: + """Integration test for get_alert_suppression_windows error path (HTTP 401)""" + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_alert_suppression_windows( + + aid=aid, + + _headers=self.te_headers("get_alert_suppression_windows", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_alert_suppression_windows_error_403(self) -> None: + """Integration test for get_alert_suppression_windows error path (HTTP 403)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_alert_suppression_windows( + + aid=aid, + + _headers=self.te_headers("get_alert_suppression_windows", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_alert_suppression_windows_error_404(self) -> None: + """Integration test for get_alert_suppression_windows error path (HTTP 404)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_alert_suppression_windows( + + aid=aid, + + _headers=self.te_headers("get_alert_suppression_windows", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_alert_suppression_windows_error_429(self) -> None: + """Integration test for get_alert_suppression_windows error path (HTTP 429)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_alert_suppression_windows( + + aid=aid, + + _headers=self.te_headers("get_alert_suppression_windows", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_alert_suppression_windows_error_500(self) -> None: + """Integration test for get_alert_suppression_windows error path (HTTP 500)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_alert_suppression_windows( + + aid=aid, + + _headers=self.te_headers("get_alert_suppression_windows", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_update_alert_suppression_window_happy_path(self) -> None: + """Integration test for update_alert_suppression_window success path""" + request_body_json = """ + + { + "duration" : 0, + "testIds" : [ "71687", "71687" ], + "alertSuppressionWindowId" : "2411", + "isEnabled" : false, + "repeat" : { + "intervalType" : "day", + "intervalLength" : 2, + "type" : "week", + "daysOfWeek" : [ "sun", "sun" ] + }, + "endRepeat" : { + "date" : "2017-07-01", + "count" : 3, + "type" : "never" + }, + "name" : "Monthly maintenance", + "startDate" : "2017-07-01T05:00:00Z", + "status" : "ended" + } + + """ + alert_suppression_window_request = thousandeyes_sdk.alerts.models.AlertSuppressionWindowRequest.from_json(request_body_json) + window_id = '2411' + aid = '1234' + response_body_json = """ + { + "duration" : 0, + "alertSuppressionWindowId" : "2411", + "tests" : [ { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + }, { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + } ], + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isEnabled" : false, + "repeat" : { + "intervalType" : "day", + "intervalLength" : 2, + "type" : "week", + "daysOfWeek" : [ "sun", "sun" ] + }, + "endRepeat" : { + "date" : "2017-07-01", + "count" : 3, + "type" : "never" + }, + "name" : "Monthly maintenance", + "startDate" : "2017-07-01T05:00:00Z", + "status" : "ended" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.update_alert_suppression_window( + + window_id=window_id, + + alert_suppression_window_request=alert_suppression_window_request, + + aid=aid, + + _headers=self.te_headers("update_alert_suppression_window"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_update_alert_suppression_window_error_400(self) -> None: + """Integration test for update_alert_suppression_window error path (HTTP 400)""" + request_body_json = """ + + { + "duration" : 0, + "testIds" : [ "71687", "71687" ], + "alertSuppressionWindowId" : "2411", + "isEnabled" : false, + "repeat" : { + "intervalType" : "day", + "intervalLength" : 2, + "type" : "week", + "daysOfWeek" : [ "sun", "sun" ] + }, + "endRepeat" : { + "date" : "2017-07-01", + "count" : 3, + "type" : "never" + }, + "name" : "Monthly maintenance", + "startDate" : "2017-07-01T05:00:00Z", + "status" : "ended" + } + + """ + alert_suppression_window_request = thousandeyes_sdk.alerts.models.AlertSuppressionWindowRequest.from_json(request_body_json) + window_id = '2411' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.update_alert_suppression_window( + + window_id=window_id, + + alert_suppression_window_request=alert_suppression_window_request, + + aid=aid, + + _headers=self.te_headers("update_alert_suppression_window", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_alert_suppression_window_error_401(self) -> None: + """Integration test for update_alert_suppression_window error path (HTTP 401)""" + request_body_json = """ + + { + "duration" : 0, + "testIds" : [ "71687", "71687" ], + "alertSuppressionWindowId" : "2411", + "isEnabled" : false, + "repeat" : { + "intervalType" : "day", + "intervalLength" : 2, + "type" : "week", + "daysOfWeek" : [ "sun", "sun" ] + }, + "endRepeat" : { + "date" : "2017-07-01", + "count" : 3, + "type" : "never" + }, + "name" : "Monthly maintenance", + "startDate" : "2017-07-01T05:00:00Z", + "status" : "ended" + } + + """ + alert_suppression_window_request = thousandeyes_sdk.alerts.models.AlertSuppressionWindowRequest.from_json(request_body_json) + window_id = '2411' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.update_alert_suppression_window( + + window_id=window_id, + + alert_suppression_window_request=alert_suppression_window_request, + + aid=aid, + + _headers=self.te_headers("update_alert_suppression_window", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_alert_suppression_window_error_403(self) -> None: + """Integration test for update_alert_suppression_window error path (HTTP 403)""" + request_body_json = """ + + { + "duration" : 0, + "testIds" : [ "71687", "71687" ], + "alertSuppressionWindowId" : "2411", + "isEnabled" : false, + "repeat" : { + "intervalType" : "day", + "intervalLength" : 2, + "type" : "week", + "daysOfWeek" : [ "sun", "sun" ] + }, + "endRepeat" : { + "date" : "2017-07-01", + "count" : 3, + "type" : "never" + }, + "name" : "Monthly maintenance", + "startDate" : "2017-07-01T05:00:00Z", + "status" : "ended" + } + + """ + alert_suppression_window_request = thousandeyes_sdk.alerts.models.AlertSuppressionWindowRequest.from_json(request_body_json) + window_id = '2411' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.update_alert_suppression_window( + + window_id=window_id, + + alert_suppression_window_request=alert_suppression_window_request, + + aid=aid, + + _headers=self.te_headers("update_alert_suppression_window", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_alert_suppression_window_error_404(self) -> None: + """Integration test for update_alert_suppression_window error path (HTTP 404)""" + request_body_json = """ + + { + "duration" : 0, + "testIds" : [ "71687", "71687" ], + "alertSuppressionWindowId" : "2411", + "isEnabled" : false, + "repeat" : { + "intervalType" : "day", + "intervalLength" : 2, + "type" : "week", + "daysOfWeek" : [ "sun", "sun" ] + }, + "endRepeat" : { + "date" : "2017-07-01", + "count" : 3, + "type" : "never" + }, + "name" : "Monthly maintenance", + "startDate" : "2017-07-01T05:00:00Z", + "status" : "ended" + } + + """ + alert_suppression_window_request = thousandeyes_sdk.alerts.models.AlertSuppressionWindowRequest.from_json(request_body_json) + window_id = '2411' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.update_alert_suppression_window( + + window_id=window_id, + + alert_suppression_window_request=alert_suppression_window_request, + + aid=aid, + + _headers=self.te_headers("update_alert_suppression_window", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_alert_suppression_window_error_429(self) -> None: + """Integration test for update_alert_suppression_window error path (HTTP 429)""" + request_body_json = """ + + { + "duration" : 0, + "testIds" : [ "71687", "71687" ], + "alertSuppressionWindowId" : "2411", + "isEnabled" : false, + "repeat" : { + "intervalType" : "day", + "intervalLength" : 2, + "type" : "week", + "daysOfWeek" : [ "sun", "sun" ] + }, + "endRepeat" : { + "date" : "2017-07-01", + "count" : 3, + "type" : "never" + }, + "name" : "Monthly maintenance", + "startDate" : "2017-07-01T05:00:00Z", + "status" : "ended" + } + + """ + alert_suppression_window_request = thousandeyes_sdk.alerts.models.AlertSuppressionWindowRequest.from_json(request_body_json) + window_id = '2411' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.update_alert_suppression_window( + + window_id=window_id, + + alert_suppression_window_request=alert_suppression_window_request, + + aid=aid, + + _headers=self.te_headers("update_alert_suppression_window", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_alert_suppression_window_error_500(self) -> None: + """Integration test for update_alert_suppression_window error path (HTTP 500)""" + request_body_json = """ + + { + "duration" : 0, + "testIds" : [ "71687", "71687" ], + "alertSuppressionWindowId" : "2411", + "isEnabled" : false, + "repeat" : { + "intervalType" : "day", + "intervalLength" : 2, + "type" : "week", + "daysOfWeek" : [ "sun", "sun" ] + }, + "endRepeat" : { + "date" : "2017-07-01", + "count" : 3, + "type" : "never" + }, + "name" : "Monthly maintenance", + "startDate" : "2017-07-01T05:00:00Z", + "status" : "ended" + } + + """ + alert_suppression_window_request = thousandeyes_sdk.alerts.models.AlertSuppressionWindowRequest.from_json(request_body_json) + window_id = '2411' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.update_alert_suppression_window( + + window_id=window_id, + + alert_suppression_window_request=alert_suppression_window_request, + + aid=aid, + + _headers=self.te_headers("update_alert_suppression_window", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-alerts/test/test_alerts_api_integration.py b/thousandeyes-sdk-alerts/test/test_alerts_api_integration.py new file mode 100644 index 00000000..7d0bc39d --- /dev/null +++ b/thousandeyes-sdk-alerts/test/test_alerts_api_integration.py @@ -0,0 +1,680 @@ +# coding: utf-8 + +""" + Alerts API + + **Note:** API operations for the creation or retrieval of API, Page Load, or Web-Transaction alert rules are not available for ThousandEyes for Government instance. You can manage the following alert functionalities on the ThousandEyes platform using the Alerts API: * **Alerts**: Retrieve alert details. Alerts are assigned to tests through alert rules. * **Alert Rules**: Conditions that you configure in order to highlight or be notified of events of interest in your ThousandEyes tests. When an alert rule’s conditions are met, the associated alert is triggered and the alert becomes active. It remains active until the alert is cleared. Alert rules are reusable across multiple tests.. * **Alert Suppression Windows**: Suppress alerts for tests during periods such as planned maintenance. Windows can be one-time events or recurring events to handle periodic occurrences such as monthly downtime for maintenance. For more information about the alerts, see [Alerts](https://docs.thousandeyes.com/product-documentation/alerts). + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.alerts.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.alerts.api.alerts_api import AlertsApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestAlertsApiIntegration(IntegrationTestBase): + """AlertsApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = AlertsApi(self.api_client) + + + def test_get_alert_happy_path(self) -> None: + """Integration test for get_alert success path""" + alert_id = 'e9c3bf02-a48c-4aa8-9e5f-898800d6f569' + aid = '1234' + response_body_json = """ + { + "severity" : "major", + "alertType" : "http-server", + "endDate" : "2022-07-18T22:00:54Z", + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "test" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "rule" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertSeverity" : "major", + "duration" : 60, + "violationCount" : 2, + "_embedded" : { + "asn" : { + "name" : "Cisco Webex LLC", + "id" : "13445", + "type" : "asn" + } + }, + "meta" : { + "version" : 1 + }, + "details" : [ { + "name" : "Bucharest, Romania", + "start" : { + "metrics" : "metrics" + }, + "end" : { + "metrics" : "metrics" + }, + "id" : "3379", + "state" : "trigger", + "type" : "cea_agent" + }, { + "name" : "Bucharest, Romania", + "start" : { + "metrics" : "metrics" + }, + "end" : { + "metrics" : "metrics" + }, + "id" : "3379", + "state" : "trigger", + "type" : "cea_agent" + } ], + "id" : "e9c3bf02-a48c-4aa8-9e5f-898800d6f569", + "suppressed" : false, + "state" : "trigger", + "alertState" : "trigger", + "startDate" : "2022-07-17T22:00:54Z" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_alert( + + alert_id=alert_id, + + aid=aid, + + _headers=self.te_headers("get_alert"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_alert_error_401(self) -> None: + """Integration test for get_alert error path (HTTP 401)""" + alert_id = 'e9c3bf02-a48c-4aa8-9e5f-898800d6f569' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_alert( + + alert_id=alert_id, + + aid=aid, + + _headers=self.te_headers("get_alert", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_alert_error_403(self) -> None: + """Integration test for get_alert error path (HTTP 403)""" + alert_id = 'e9c3bf02-a48c-4aa8-9e5f-898800d6f569' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_alert( + + alert_id=alert_id, + + aid=aid, + + _headers=self.te_headers("get_alert", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_alert_error_404(self) -> None: + """Integration test for get_alert error path (HTTP 404)""" + alert_id = 'e9c3bf02-a48c-4aa8-9e5f-898800d6f569' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_alert( + + alert_id=alert_id, + + aid=aid, + + _headers=self.te_headers("get_alert", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_alert_error_429(self) -> None: + """Integration test for get_alert error path (HTTP 429)""" + alert_id = 'e9c3bf02-a48c-4aa8-9e5f-898800d6f569' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_alert( + + alert_id=alert_id, + + aid=aid, + + _headers=self.te_headers("get_alert", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_alert_error_500(self) -> None: + """Integration test for get_alert error path (HTTP 500)""" + alert_id = 'e9c3bf02-a48c-4aa8-9e5f-898800d6f569' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_alert( + + alert_id=alert_id, + + aid=aid, + + _headers=self.te_headers("get_alert", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_alerts_happy_path(self) -> None: + """Integration test for get_alerts success path""" + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + max = 5 + cursor = 'cursor_example' + response_body_json = """ + { + "alerts" : [ { + "severity" : "MAJOR", + "alertType" : "http-server", + "endDate" : "2022-07-18T22:00:54Z", + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "test" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "rule" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "apiLinks" : [ { + "key" : "" + }, { + "key" : "" + } ], + "alertSeverity" : "major", + "dateEnd" : "2020-04-23 13:43:16", + "duration" : 60, + "violationCount" : 2, + "dateStart" : "2020-04-23 13:43:16", + "meta" : { + "version" : 1 + }, + "id" : "e9c3bf02-a48c-4aa8-9e5f-898800d6f569", + "suppressed" : false, + "alertId" : "e9c3bf02-a48c-4aa8-9e5f-898800d6f569", + "state" : "ACTIVE", + "ruleId" : 127094, + "permalink" : "https://app.thousandeyes.com/alerts/list?__a=75&alertId=2783&agentId=12", + "alertState" : "trigger", + "startDate" : "2022-07-17T22:00:54Z", + "alertRuleId" : "127094" + }, { + "severity" : "MAJOR", + "alertType" : "http-server", + "endDate" : "2022-07-18T22:00:54Z", + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "test" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "rule" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "apiLinks" : [ { + "key" : "" + }, { + "key" : "" + } ], + "alertSeverity" : "major", + "dateEnd" : "2020-04-23 13:43:16", + "duration" : 60, + "violationCount" : 2, + "dateStart" : "2020-04-23 13:43:16", + "meta" : { + "version" : 1 + }, + "id" : "e9c3bf02-a48c-4aa8-9e5f-898800d6f569", + "suppressed" : false, + "alertId" : "e9c3bf02-a48c-4aa8-9e5f-898800d6f569", + "state" : "ACTIVE", + "ruleId" : 127094, + "permalink" : "https://app.thousandeyes.com/alerts/list?__a=75&alertId=2783&agentId=12", + "alertState" : "trigger", + "startDate" : "2022-07-17T22:00:54Z", + "alertRuleId" : "127094" + } ], + "_links" : { + "next" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "previous" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_alerts( + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + max=max, + + cursor=cursor, + + _headers=self.te_headers("get_alerts"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_alerts_error_401(self) -> None: + """Integration test for get_alerts error path (HTTP 401)""" + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + max = 5 + cursor = 'cursor_example' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_alerts( + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + max=max, + + cursor=cursor, + + _headers=self.te_headers("get_alerts", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_alerts_error_403(self) -> None: + """Integration test for get_alerts error path (HTTP 403)""" + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + max = 5 + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_alerts( + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + max=max, + + cursor=cursor, + + _headers=self.te_headers("get_alerts", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_alerts_error_404(self) -> None: + """Integration test for get_alerts error path (HTTP 404)""" + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + max = 5 + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_alerts( + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + max=max, + + cursor=cursor, + + _headers=self.te_headers("get_alerts", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_alerts_error_429(self) -> None: + """Integration test for get_alerts error path (HTTP 429)""" + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + max = 5 + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_alerts( + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + max=max, + + cursor=cursor, + + _headers=self.te_headers("get_alerts", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_alerts_error_500(self) -> None: + """Integration test for get_alerts error path (HTTP 500)""" + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + max = 5 + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_alerts( + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + max=max, + + cursor=cursor, + + _headers=self.te_headers("get_alerts", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-alerts/test/test_utils.py b/thousandeyes-sdk-alerts/test/test_utils.py index 930528d9..37913f62 100644 --- a/thousandeyes-sdk-alerts/test/test_utils.py +++ b/thousandeyes-sdk-alerts/test/test_utils.py @@ -2,15 +2,36 @@ import json import unittest +from typing import Any from pydantic import BaseModel +def _project_onto_constructed(expected: Any, constructed: Any) -> Any: + """Keep only example fields that appear in the constructed model output.""" + if isinstance(constructed, dict): + if not isinstance(expected, dict): + return expected + return { + key: _project_onto_constructed(expected.get(key), value) + for key, value in constructed.items() + } + if isinstance(constructed, list): + if not isinstance(expected, list): + return expected + return [ + _project_onto_constructed(expected[index], value) + for index, value in enumerate(constructed) + ] + return expected + + def assert_constructed_model_matches_example_json(model: BaseModel, loaded_json: dict): test_case = unittest.TestCase() test_case.maxDiff = None test_case.assertIsNotNone(model) constructed_json = json.loads(model.to_json()) - sorted_loaded_json = json.dumps(loaded_json, sort_keys=True) + projected_loaded_json = _project_onto_constructed(loaded_json, constructed_json) + sorted_loaded_json = json.dumps(projected_loaded_json, sort_keys=True) sorted_constructed_json = json.dumps(constructed_json, sort_keys=True) test_case.assertEqual(sorted_loaded_json, sorted_constructed_json) diff --git a/thousandeyes-sdk-bgp-monitors/test/test_utils.py b/thousandeyes-sdk-bgp-monitors/test/test_utils.py index 930528d9..37913f62 100644 --- a/thousandeyes-sdk-bgp-monitors/test/test_utils.py +++ b/thousandeyes-sdk-bgp-monitors/test/test_utils.py @@ -2,15 +2,36 @@ import json import unittest +from typing import Any from pydantic import BaseModel +def _project_onto_constructed(expected: Any, constructed: Any) -> Any: + """Keep only example fields that appear in the constructed model output.""" + if isinstance(constructed, dict): + if not isinstance(expected, dict): + return expected + return { + key: _project_onto_constructed(expected.get(key), value) + for key, value in constructed.items() + } + if isinstance(constructed, list): + if not isinstance(expected, list): + return expected + return [ + _project_onto_constructed(expected[index], value) + for index, value in enumerate(constructed) + ] + return expected + + def assert_constructed_model_matches_example_json(model: BaseModel, loaded_json: dict): test_case = unittest.TestCase() test_case.maxDiff = None test_case.assertIsNotNone(model) constructed_json = json.loads(model.to_json()) - sorted_loaded_json = json.dumps(loaded_json, sort_keys=True) + projected_loaded_json = _project_onto_constructed(loaded_json, constructed_json) + sorted_loaded_json = json.dumps(projected_loaded_json, sort_keys=True) sorted_constructed_json = json.dumps(constructed_json, sort_keys=True) test_case.assertEqual(sorted_loaded_json, sorted_constructed_json) diff --git a/thousandeyes-sdk-connectors/test/conftest.py b/thousandeyes-sdk-connectors/test/conftest.py new file mode 100644 index 00000000..2edba7b3 --- /dev/null +++ b/thousandeyes-sdk-connectors/test/conftest.py @@ -0,0 +1,7 @@ +import sys +from pathlib import Path + +_repo_root = Path(__file__).resolve().parents[2] +_core_test_support = _repo_root / "thousandeyes-sdk-core" / "test" +if str(_core_test_support) not in sys.path: + sys.path.insert(0, str(_core_test_support)) diff --git a/thousandeyes-sdk-connectors/test/integration_test_utils.py b/thousandeyes-sdk-connectors/test/integration_test_utils.py new file mode 100644 index 00000000..c05e4aa3 --- /dev/null +++ b/thousandeyes-sdk-connectors/test/integration_test_utils.py @@ -0,0 +1,37 @@ +# coding: utf-8 + +""" + Integrations API + + **Note:** The Webhook Operations APIs are not available for ThousandEyes for Government instance. Manage connectors and operations. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from thousandeyes_sdk.core.api_client import ApiClient +from thousandeyes_sdk.core.configuration import Configuration +from sdk_test_support.mock_server import ERROR_STATUS_HEADER, OPERATION_ID_HEADER, MockApiServer + +from .mock_manifest import OPERATION_MANIFEST + + +class IntegrationTestBase(unittest.TestCase): + def setUp(self) -> None: + self.server = MockApiServer(OPERATION_MANIFEST) + self.server.start() + configuration = Configuration(host=self.server.base_url, access_token="test-token") + self.api_client = ApiClient(configuration=configuration) + + def tearDown(self) -> None: + self.server.stop() + + def te_headers(self, operation_id: str, error_status=None): + headers = {OPERATION_ID_HEADER: operation_id} + if error_status is not None: + headers[ERROR_STATUS_HEADER] = error_status + return headers diff --git a/thousandeyes-sdk-connectors/test/mock_manifest.py b/thousandeyes-sdk-connectors/test/mock_manifest.py new file mode 100644 index 00000000..8ed9fbdb --- /dev/null +++ b/thousandeyes-sdk-connectors/test/mock_manifest.py @@ -0,0 +1,3021 @@ +# coding: utf-8 + +""" + Integrations API + + **Note:** The Webhook Operations APIs are not available for ThousandEyes for Government instance. Manage connectors and operations. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json + +from sdk_test_support.mock_server_types import ErrorResponseExpectation, OperationExpectation + +OPERATION_MANIFEST = { + + "create_credential_vault_operation": OperationExpectation( + operation_id="create_credential_vault_operation", + method="POST", + path="/operations/credential-vault", + path_param_examples={ + }, + success_status=201, + success_body=json.loads(""" + + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "My operation", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "type" : "webhook", + "secrets" : [ { + "secretKey" : "secret/key", + "name" : "secret_name", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf" + }, { + "secretKey" : "secret/key", + "name" : "secret_name", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf" + } ], + "status" : "pending" + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "My operation", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "type" : "webhook", + "secrets" : [ { + "secretKey" : "secret/key", + "name" : "secret_name", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf" + }, { + "secretKey" : "secret/key", + "name" : "secret_name", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf" + } ], + "status" : "pending" + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "delete_credential_vault_operation": OperationExpectation( + operation_id="delete_credential_vault_operation", + method="DELETE", + path="/operations/credential-vault/{id}", + path_param_examples={ + "id": 'cb1b8033-ea2d-4e9b-a920-fe87850693cf', + }, + success_status=204, + success_body=None, + success_content_type="application/json", + request_body_example=None, + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_credential_vault_operation": OperationExpectation( + operation_id="get_credential_vault_operation", + method="GET", + path="/operations/credential-vault/{id}", + path_param_examples={ + "id": 'cb1b8033-ea2d-4e9b-a920-fe87850693cf', + }, + success_status=200, + success_body=json.loads(""" + + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "My operation", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "type" : "webhook", + "secrets" : [ { + "secretKey" : "secret/key", + "name" : "secret_name", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf" + }, { + "secretKey" : "secret/key", + "name" : "secret_name", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf" + } ], + "status" : "pending" + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_credential_vault_operations": OperationExpectation( + operation_id="get_credential_vault_operations", + method="GET", + path="/operations/credential-vault", + path_param_examples={ + }, + success_status=200, + success_body=json.loads(""" + + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "items" : [ { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "My operation", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "type" : "webhook", + "secrets" : [ { + "secretKey" : "secret/key", + "name" : "secret_name", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf" + }, { + "secretKey" : "secret/key", + "name" : "secret_name", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf" + } ], + "status" : "pending" + }, { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "My operation", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "type" : "webhook", + "secrets" : [ { + "secretKey" : "secret/key", + "name" : "secret_name", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf" + }, { + "secretKey" : "secret/key", + "name" : "secret_name", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf" + } ], + "status" : "pending" + } ] + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "update_credential_vault_operation": OperationExpectation( + operation_id="update_credential_vault_operation", + method="PUT", + path="/operations/credential-vault/{id}", + path_param_examples={ + "id": 'cb1b8033-ea2d-4e9b-a920-fe87850693cf', + }, + success_status=200, + success_body=json.loads(""" + + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "My operation", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "type" : "webhook", + "secrets" : [ { + "secretKey" : "secret/key", + "name" : "secret_name", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf" + }, { + "secretKey" : "secret/key", + "name" : "secret_name", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf" + } ], + "status" : "pending" + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "My operation", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "type" : "webhook", + "secrets" : [ { + "secretKey" : "secret/key", + "name" : "secret_name", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf" + }, { + "secretKey" : "secret/key", + "name" : "secret_name", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf" + } ], + "status" : "pending" + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "create_conjur_connector": OperationExpectation( + operation_id="create_conjur_connector", + method="POST", + path="/connectors/conjur", + path_param_examples={ + }, + success_status=201, + success_body=json.loads(""" + + { + "lastModifiedDate" : 1770293655756, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "Cisco Slack", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "type" : "generic", + "account" : "My CyberArk Account", + "target" : "https://eval.conjur.org/secrets", + "authentication" : { + "apiKey" : "abc123", + "hostId" : "host1", + "type" : "basic" + } + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "lastModifiedDate" : 1770293655756, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "Cisco Slack", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "type" : "generic", + "account" : "My CyberArk Account", + "target" : "https://eval.conjur.org/secrets", + "authentication" : { + "apiKey" : "abc123", + "hostId" : "host1", + "type" : "basic" + } + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "delete_conjur_connector": OperationExpectation( + operation_id="delete_conjur_connector", + method="DELETE", + path="/connectors/conjur/{id}", + path_param_examples={ + "id": 'cb1b8033-ea2d-4e9b-a920-fe87850693cf', + }, + success_status=204, + success_body=None, + success_content_type="application/json", + request_body_example=None, + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_conjur_connector": OperationExpectation( + operation_id="get_conjur_connector", + method="GET", + path="/connectors/conjur/{id}", + path_param_examples={ + "id": 'cb1b8033-ea2d-4e9b-a920-fe87850693cf', + }, + success_status=200, + success_body=json.loads(""" + + { + "lastModifiedDate" : 1770293655756, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "Cisco Slack", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "type" : "generic", + "account" : "My CyberArk Account", + "target" : "https://eval.conjur.org/secrets", + "authentication" : { + "apiKey" : "abc123", + "hostId" : "host1", + "type" : "basic" + } + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_conjur_connector_operations": OperationExpectation( + operation_id="get_conjur_connector_operations", + method="GET", + path="/connectors/conjur/{id}/operations", + path_param_examples={ + "id": 'cb1b8033-ea2d-4e9b-a920-fe87850693cf', + }, + success_status=200, + success_body=json.loads(""" + + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "items" : [ "ca39314d-eb4f-496f-9435-b5d20b1bfbff", "ca39314d-eb4f-496f-9435-b5d20b1bfbff" ] + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_conjur_connectors": OperationExpectation( + operation_id="get_conjur_connectors", + method="GET", + path="/connectors/conjur", + path_param_examples={ + }, + success_status=200, + success_body=json.loads(""" + + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "items" : [ { + "lastModifiedDate" : 1770293655756, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "Cisco Slack", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "type" : "generic", + "account" : "My CyberArk Account", + "target" : "https://eval.conjur.org/secrets", + "authentication" : { + "apiKey" : "abc123", + "hostId" : "host1", + "type" : "basic" + } + }, { + "lastModifiedDate" : 1770293655756, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "Cisco Slack", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "type" : "generic", + "account" : "My CyberArk Account", + "target" : "https://eval.conjur.org/secrets", + "authentication" : { + "apiKey" : "abc123", + "hostId" : "host1", + "type" : "basic" + } + } ] + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "update_conjur_connector": OperationExpectation( + operation_id="update_conjur_connector", + method="PUT", + path="/connectors/conjur/{id}", + path_param_examples={ + "id": 'cb1b8033-ea2d-4e9b-a920-fe87850693cf', + }, + success_status=200, + success_body=json.loads(""" + + { + "lastModifiedDate" : 1770293655756, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "Cisco Slack", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "type" : "generic", + "account" : "My CyberArk Account", + "target" : "https://eval.conjur.org/secrets", + "authentication" : { + "apiKey" : "abc123", + "hostId" : "host1", + "type" : "basic" + } + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "lastModifiedDate" : 1770293655756, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "Cisco Slack", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "type" : "generic", + "account" : "My CyberArk Account", + "target" : "https://eval.conjur.org/secrets", + "authentication" : { + "apiKey" : "abc123", + "hostId" : "host1", + "type" : "basic" + } + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "create_generic_connector": OperationExpectation( + operation_id="create_generic_connector", + method="POST", + path="/connectors/generic", + path_param_examples={ + }, + success_status=201, + success_body=json.loads(""" + + { + "headers" : [ { + "name" : "Content-Type", + "value" : "application/json" + }, { + "name" : "Content-Type", + "value" : "application/json" + } ], + "lastModifiedDate" : 1770293655756, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "Cisco Slack", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "type" : "generic", + "target" : "https://hooks.slack.com/services/abc/xyz", + "authentication" : { + "password" : "abc123", + "type" : "basic", + "username" : "user1" + } + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "headers" : [ { + "name" : "Content-Type", + "value" : "application/json" + }, { + "name" : "Content-Type", + "value" : "application/json" + } ], + "lastModifiedDate" : 1770293655756, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "Cisco Slack", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "type" : "generic", + "target" : "https://hooks.slack.com/services/abc/xyz", + "authentication" : { + "password" : "abc123", + "type" : "basic", + "username" : "user1" + } + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "delete_generic_connector": OperationExpectation( + operation_id="delete_generic_connector", + method="DELETE", + path="/connectors/generic/{id}", + path_param_examples={ + "id": 'cb1b8033-ea2d-4e9b-a920-fe87850693cf', + }, + success_status=204, + success_body=None, + success_content_type="application/json", + request_body_example=None, + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_generic_connector": OperationExpectation( + operation_id="get_generic_connector", + method="GET", + path="/connectors/generic/{id}", + path_param_examples={ + "id": 'cb1b8033-ea2d-4e9b-a920-fe87850693cf', + }, + success_status=200, + success_body=json.loads(""" + + { + "headers" : [ { + "name" : "Content-Type", + "value" : "application/json" + }, { + "name" : "Content-Type", + "value" : "application/json" + } ], + "lastModifiedDate" : 1770293655756, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "Cisco Slack", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "type" : "generic", + "target" : "https://hooks.slack.com/services/abc/xyz", + "authentication" : { + "password" : "abc123", + "type" : "basic", + "username" : "user1" + } + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_generic_connectors": OperationExpectation( + operation_id="get_generic_connectors", + method="GET", + path="/connectors/generic", + path_param_examples={ + }, + success_status=200, + success_body=json.loads(""" + + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "items" : [ { + "headers" : [ { + "name" : "Content-Type", + "value" : "application/json" + }, { + "name" : "Content-Type", + "value" : "application/json" + } ], + "lastModifiedDate" : 1770293655756, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "Cisco Slack", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "type" : "generic", + "target" : "https://hooks.slack.com/services/abc/xyz", + "authentication" : { + "password" : "abc123", + "type" : "basic", + "username" : "user1" + } + }, { + "headers" : [ { + "name" : "Content-Type", + "value" : "application/json" + }, { + "name" : "Content-Type", + "value" : "application/json" + } ], + "lastModifiedDate" : 1770293655756, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "Cisco Slack", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "type" : "generic", + "target" : "https://hooks.slack.com/services/abc/xyz", + "authentication" : { + "password" : "abc123", + "type" : "basic", + "username" : "user1" + } + } ] + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "list_generic_connector_operations": OperationExpectation( + operation_id="list_generic_connector_operations", + method="GET", + path="/connectors/generic/{id}/operations", + path_param_examples={ + "id": 'cb1b8033-ea2d-4e9b-a920-fe87850693cf', + }, + success_status=200, + success_body=json.loads(""" + + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "items" : [ "ca39314d-eb4f-496f-9435-b5d20b1bfbff", "ca39314d-eb4f-496f-9435-b5d20b1bfbff" ] + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "update_generic_connector": OperationExpectation( + operation_id="update_generic_connector", + method="PUT", + path="/connectors/generic/{id}", + path_param_examples={ + "id": 'cb1b8033-ea2d-4e9b-a920-fe87850693cf', + }, + success_status=200, + success_body=json.loads(""" + + { + "headers" : [ { + "name" : "Content-Type", + "value" : "application/json" + }, { + "name" : "Content-Type", + "value" : "application/json" + } ], + "lastModifiedDate" : 1770293655756, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "Cisco Slack", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "type" : "generic", + "target" : "https://hooks.slack.com/services/abc/xyz", + "authentication" : { + "password" : "abc123", + "type" : "basic", + "username" : "user1" + } + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "headers" : [ { + "name" : "Content-Type", + "value" : "application/json" + }, { + "name" : "Content-Type", + "value" : "application/json" + } ], + "lastModifiedDate" : 1770293655756, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "Cisco Slack", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "type" : "generic", + "target" : "https://hooks.slack.com/services/abc/xyz", + "authentication" : { + "password" : "abc123", + "type" : "basic", + "username" : "user1" + } + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_operation_connectors": OperationExpectation( + operation_id="get_operation_connectors", + method="GET", + path="/operations/{type}/{id}/connectors", + path_param_examples={ + "type": 'webhooks', + "id": 'cb1b8033-ea2d-4e9b-a920-fe87850693cf', + }, + success_status=200, + success_body=json.loads(""" + + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "items" : [ "ca39314d-eb4f-496f-9435-b5d20b1bfbff", "ca39314d-eb4f-496f-9435-b5d20b1bfbff" ] + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "create_webhook_operation": OperationExpectation( + operation_id="create_webhook_operation", + method="POST", + path="/operations/webhooks", + path_param_examples={ + }, + success_status=201, + success_body=json.loads(""" + + { + "path" : "/custom/path", + "headers" : [ { + "name" : "Content-Type", + "value" : "application/json" + }, { + "name" : "Content-Type", + "value" : "application/json" + } ], + "payload" : "{\\"property1\\": {{numericVar}}, \\"property2\\": \\"{{stringVar}}\\"}", + "queryParams" : "{\\"queryParam1\\":\\"{{stringVar}}\\"}", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "My operation", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "category" : "alerts", + "type" : "webhook", + "enabled" : true, + "status" : "pending" + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "path" : "/custom/path", + "headers" : [ { + "name" : "Content-Type", + "value" : "application/json" + }, { + "name" : "Content-Type", + "value" : "application/json" + } ], + "payload" : "{\\"property1\\": {{numericVar}}, \\"property2\\": \\"{{stringVar}}\\"}", + "queryParams" : "{\\"queryParam1\\":\\"{{stringVar}}\\"}", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "My operation", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "category" : "alerts", + "type" : "webhook", + "enabled" : true, + "status" : "pending" + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "delete_webhook_operation": OperationExpectation( + operation_id="delete_webhook_operation", + method="DELETE", + path="/operations/webhooks/{id}", + path_param_examples={ + "id": 'cb1b8033-ea2d-4e9b-a920-fe87850693cf', + }, + success_status=204, + success_body=None, + success_content_type="application/json", + request_body_example=None, + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_webhook_operation": OperationExpectation( + operation_id="get_webhook_operation", + method="GET", + path="/operations/webhooks/{id}", + path_param_examples={ + "id": 'cb1b8033-ea2d-4e9b-a920-fe87850693cf', + }, + success_status=200, + success_body=json.loads(""" + + { + "path" : "/custom/path", + "headers" : [ { + "name" : "Content-Type", + "value" : "application/json" + }, { + "name" : "Content-Type", + "value" : "application/json" + } ], + "payload" : "{\\"property1\\": {{numericVar}}, \\"property2\\": \\"{{stringVar}}\\"}", + "queryParams" : "{\\"queryParam1\\":\\"{{stringVar}}\\"}", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "My operation", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "category" : "alerts", + "type" : "webhook", + "enabled" : true, + "status" : "pending" + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_webhook_operations": OperationExpectation( + operation_id="get_webhook_operations", + method="GET", + path="/operations/webhooks", + path_param_examples={ + }, + success_status=200, + success_body=json.loads(""" + + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "items" : [ { + "path" : "/custom/path", + "headers" : [ { + "name" : "Content-Type", + "value" : "application/json" + }, { + "name" : "Content-Type", + "value" : "application/json" + } ], + "payload" : "{\\"property1\\": {{numericVar}}, \\"property2\\": \\"{{stringVar}}\\"}", + "queryParams" : "{\\"queryParam1\\":\\"{{stringVar}}\\"}", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "My operation", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "category" : "alerts", + "type" : "webhook", + "enabled" : true, + "status" : "pending" + }, { + "path" : "/custom/path", + "headers" : [ { + "name" : "Content-Type", + "value" : "application/json" + }, { + "name" : "Content-Type", + "value" : "application/json" + } ], + "payload" : "{\\"property1\\": {{numericVar}}, \\"property2\\": \\"{{stringVar}}\\"}", + "queryParams" : "{\\"queryParam1\\":\\"{{stringVar}}\\"}", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "My operation", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "category" : "alerts", + "type" : "webhook", + "enabled" : true, + "status" : "pending" + } ] + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "update_webhook_operation": OperationExpectation( + operation_id="update_webhook_operation", + method="PUT", + path="/operations/webhooks/{id}", + path_param_examples={ + "id": 'cb1b8033-ea2d-4e9b-a920-fe87850693cf', + }, + success_status=200, + success_body=json.loads(""" + + { + "path" : "/custom/path", + "headers" : [ { + "name" : "Content-Type", + "value" : "application/json" + }, { + "name" : "Content-Type", + "value" : "application/json" + } ], + "payload" : "{\\"property1\\": {{numericVar}}, \\"property2\\": \\"{{stringVar}}\\"}", + "queryParams" : "{\\"queryParam1\\":\\"{{stringVar}}\\"}", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "My operation", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "category" : "alerts", + "type" : "webhook", + "enabled" : true, + "status" : "pending" + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "path" : "/custom/path", + "headers" : [ { + "name" : "Content-Type", + "value" : "application/json" + }, { + "name" : "Content-Type", + "value" : "application/json" + } ], + "payload" : "{\\"property1\\": {{numericVar}}, \\"property2\\": \\"{{stringVar}}\\"}", + "queryParams" : "{\\"queryParam1\\":\\"{{stringVar}}\\"}", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "My operation", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "category" : "alerts", + "type" : "webhook", + "enabled" : true, + "status" : "pending" + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + +} diff --git a/thousandeyes-sdk-connectors/test/test_credential_vault_operations_api_integration.py b/thousandeyes-sdk-connectors/test/test_credential_vault_operations_api_integration.py new file mode 100644 index 00000000..c487bb72 --- /dev/null +++ b/thousandeyes-sdk-connectors/test/test_credential_vault_operations_api_integration.py @@ -0,0 +1,1401 @@ +# coding: utf-8 + +""" + Integrations API + + **Note:** The Webhook Operations APIs are not available for ThousandEyes for Government instance. Manage connectors and operations. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.connectors.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.connectors.api.credential_vault_operations_api import CredentialVaultOperationsApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestCredentialVaultOperationsApiIntegration(IntegrationTestBase): + """CredentialVaultOperationsApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = CredentialVaultOperationsApi(self.api_client) + + + def test_create_credential_vault_operation_happy_path(self) -> None: + """Integration test for create_credential_vault_operation success path""" + request_body_json = """ + + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "My operation", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "type" : "webhook", + "secrets" : [ { + "secretKey" : "secret/key", + "name" : "secret_name", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf" + }, { + "secretKey" : "secret/key", + "name" : "secret_name", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf" + } ], + "status" : "pending" + } + + """ + credential_vault_operation = thousandeyes_sdk.connectors.models.CredentialVaultOperation.from_json(request_body_json) + aid = '1234' + response_body_json = """ + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "My operation", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "type" : "webhook", + "secrets" : [ { + "secretKey" : "secret/key", + "name" : "secret_name", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf" + }, { + "secretKey" : "secret/key", + "name" : "secret_name", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf" + } ], + "status" : "pending" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.create_credential_vault_operation( + + credential_vault_operation=credential_vault_operation, + + aid=aid, + + _headers=self.te_headers("create_credential_vault_operation"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_create_credential_vault_operation_error_400(self) -> None: + """Integration test for create_credential_vault_operation error path (HTTP 400)""" + request_body_json = """ + + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "My operation", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "type" : "webhook", + "secrets" : [ { + "secretKey" : "secret/key", + "name" : "secret_name", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf" + }, { + "secretKey" : "secret/key", + "name" : "secret_name", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf" + } ], + "status" : "pending" + } + + """ + credential_vault_operation = thousandeyes_sdk.connectors.models.CredentialVaultOperation.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.create_credential_vault_operation( + + credential_vault_operation=credential_vault_operation, + + aid=aid, + + _headers=self.te_headers("create_credential_vault_operation", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_credential_vault_operation_error_401(self) -> None: + """Integration test for create_credential_vault_operation error path (HTTP 401)""" + request_body_json = """ + + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "My operation", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "type" : "webhook", + "secrets" : [ { + "secretKey" : "secret/key", + "name" : "secret_name", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf" + }, { + "secretKey" : "secret/key", + "name" : "secret_name", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf" + } ], + "status" : "pending" + } + + """ + credential_vault_operation = thousandeyes_sdk.connectors.models.CredentialVaultOperation.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.create_credential_vault_operation( + + credential_vault_operation=credential_vault_operation, + + aid=aid, + + _headers=self.te_headers("create_credential_vault_operation", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_credential_vault_operation_error_403(self) -> None: + """Integration test for create_credential_vault_operation error path (HTTP 403)""" + request_body_json = """ + + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "My operation", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "type" : "webhook", + "secrets" : [ { + "secretKey" : "secret/key", + "name" : "secret_name", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf" + }, { + "secretKey" : "secret/key", + "name" : "secret_name", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf" + } ], + "status" : "pending" + } + + """ + credential_vault_operation = thousandeyes_sdk.connectors.models.CredentialVaultOperation.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.create_credential_vault_operation( + + credential_vault_operation=credential_vault_operation, + + aid=aid, + + _headers=self.te_headers("create_credential_vault_operation", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_credential_vault_operation_error_404(self) -> None: + """Integration test for create_credential_vault_operation error path (HTTP 404)""" + request_body_json = """ + + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "My operation", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "type" : "webhook", + "secrets" : [ { + "secretKey" : "secret/key", + "name" : "secret_name", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf" + }, { + "secretKey" : "secret/key", + "name" : "secret_name", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf" + } ], + "status" : "pending" + } + + """ + credential_vault_operation = thousandeyes_sdk.connectors.models.CredentialVaultOperation.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.create_credential_vault_operation( + + credential_vault_operation=credential_vault_operation, + + aid=aid, + + _headers=self.te_headers("create_credential_vault_operation", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_credential_vault_operation_error_500(self) -> None: + """Integration test for create_credential_vault_operation error path (HTTP 500)""" + request_body_json = """ + + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "My operation", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "type" : "webhook", + "secrets" : [ { + "secretKey" : "secret/key", + "name" : "secret_name", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf" + }, { + "secretKey" : "secret/key", + "name" : "secret_name", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf" + } ], + "status" : "pending" + } + + """ + credential_vault_operation = thousandeyes_sdk.connectors.models.CredentialVaultOperation.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.create_credential_vault_operation( + + credential_vault_operation=credential_vault_operation, + + aid=aid, + + _headers=self.te_headers("create_credential_vault_operation", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_delete_credential_vault_operation_happy_path(self) -> None: + """Integration test for delete_credential_vault_operation success path""" + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + confirm_disabled_objects = False + aid = '1234' + response = self.api.delete_credential_vault_operation_with_http_info( + + id=id, + + confirm_disabled_objects=confirm_disabled_objects, + + aid=aid, + + _headers=self.te_headers("delete_credential_vault_operation"), + ) + self.assertEqual(204, response.status_code) + self.assertIsNone(response.data) + + + def test_delete_credential_vault_operation_error_400(self) -> None: + """Integration test for delete_credential_vault_operation error path (HTTP 400)""" + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + confirm_disabled_objects = False + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.delete_credential_vault_operation( + + id=id, + + confirm_disabled_objects=confirm_disabled_objects, + + aid=aid, + + _headers=self.te_headers("delete_credential_vault_operation", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_credential_vault_operation_error_401(self) -> None: + """Integration test for delete_credential_vault_operation error path (HTTP 401)""" + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + confirm_disabled_objects = False + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.delete_credential_vault_operation( + + id=id, + + confirm_disabled_objects=confirm_disabled_objects, + + aid=aid, + + _headers=self.te_headers("delete_credential_vault_operation", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_credential_vault_operation_error_403(self) -> None: + """Integration test for delete_credential_vault_operation error path (HTTP 403)""" + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + confirm_disabled_objects = False + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.delete_credential_vault_operation( + + id=id, + + confirm_disabled_objects=confirm_disabled_objects, + + aid=aid, + + _headers=self.te_headers("delete_credential_vault_operation", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_credential_vault_operation_error_404(self) -> None: + """Integration test for delete_credential_vault_operation error path (HTTP 404)""" + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + confirm_disabled_objects = False + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.delete_credential_vault_operation( + + id=id, + + confirm_disabled_objects=confirm_disabled_objects, + + aid=aid, + + _headers=self.te_headers("delete_credential_vault_operation", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_credential_vault_operation_error_500(self) -> None: + """Integration test for delete_credential_vault_operation error path (HTTP 500)""" + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + confirm_disabled_objects = False + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.delete_credential_vault_operation( + + id=id, + + confirm_disabled_objects=confirm_disabled_objects, + + aid=aid, + + _headers=self.te_headers("delete_credential_vault_operation", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_credential_vault_operation_happy_path(self) -> None: + """Integration test for get_credential_vault_operation success path""" + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + aid = '1234' + response_body_json = """ + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "My operation", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "type" : "webhook", + "secrets" : [ { + "secretKey" : "secret/key", + "name" : "secret_name", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf" + }, { + "secretKey" : "secret/key", + "name" : "secret_name", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf" + } ], + "status" : "pending" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_credential_vault_operation( + + id=id, + + aid=aid, + + _headers=self.te_headers("get_credential_vault_operation"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_credential_vault_operation_error_400(self) -> None: + """Integration test for get_credential_vault_operation error path (HTTP 400)""" + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.get_credential_vault_operation( + + id=id, + + aid=aid, + + _headers=self.te_headers("get_credential_vault_operation", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_credential_vault_operation_error_401(self) -> None: + """Integration test for get_credential_vault_operation error path (HTTP 401)""" + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_credential_vault_operation( + + id=id, + + aid=aid, + + _headers=self.te_headers("get_credential_vault_operation", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_credential_vault_operation_error_403(self) -> None: + """Integration test for get_credential_vault_operation error path (HTTP 403)""" + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_credential_vault_operation( + + id=id, + + aid=aid, + + _headers=self.te_headers("get_credential_vault_operation", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_credential_vault_operation_error_404(self) -> None: + """Integration test for get_credential_vault_operation error path (HTTP 404)""" + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_credential_vault_operation( + + id=id, + + aid=aid, + + _headers=self.te_headers("get_credential_vault_operation", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_credential_vault_operation_error_500(self) -> None: + """Integration test for get_credential_vault_operation error path (HTTP 500)""" + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_credential_vault_operation( + + id=id, + + aid=aid, + + _headers=self.te_headers("get_credential_vault_operation", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_credential_vault_operations_happy_path(self) -> None: + """Integration test for get_credential_vault_operations success path""" + aid = '1234' + response_body_json = """ + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "items" : [ { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "My operation", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "type" : "webhook", + "secrets" : [ { + "secretKey" : "secret/key", + "name" : "secret_name", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf" + }, { + "secretKey" : "secret/key", + "name" : "secret_name", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf" + } ], + "status" : "pending" + }, { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "My operation", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "type" : "webhook", + "secrets" : [ { + "secretKey" : "secret/key", + "name" : "secret_name", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf" + }, { + "secretKey" : "secret/key", + "name" : "secret_name", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf" + } ], + "status" : "pending" + } ] + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_credential_vault_operations( + + aid=aid, + + _headers=self.te_headers("get_credential_vault_operations"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_credential_vault_operations_error_400(self) -> None: + """Integration test for get_credential_vault_operations error path (HTTP 400)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.get_credential_vault_operations( + + aid=aid, + + _headers=self.te_headers("get_credential_vault_operations", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_credential_vault_operations_error_401(self) -> None: + """Integration test for get_credential_vault_operations error path (HTTP 401)""" + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_credential_vault_operations( + + aid=aid, + + _headers=self.te_headers("get_credential_vault_operations", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_credential_vault_operations_error_403(self) -> None: + """Integration test for get_credential_vault_operations error path (HTTP 403)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_credential_vault_operations( + + aid=aid, + + _headers=self.te_headers("get_credential_vault_operations", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_credential_vault_operations_error_404(self) -> None: + """Integration test for get_credential_vault_operations error path (HTTP 404)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_credential_vault_operations( + + aid=aid, + + _headers=self.te_headers("get_credential_vault_operations", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_credential_vault_operations_error_500(self) -> None: + """Integration test for get_credential_vault_operations error path (HTTP 500)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_credential_vault_operations( + + aid=aid, + + _headers=self.te_headers("get_credential_vault_operations", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_update_credential_vault_operation_happy_path(self) -> None: + """Integration test for update_credential_vault_operation success path""" + request_body_json = """ + + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "My operation", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "type" : "webhook", + "secrets" : [ { + "secretKey" : "secret/key", + "name" : "secret_name", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf" + }, { + "secretKey" : "secret/key", + "name" : "secret_name", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf" + } ], + "status" : "pending" + } + + """ + credential_vault_operation = thousandeyes_sdk.connectors.models.CredentialVaultOperation.from_json(request_body_json) + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + aid = '1234' + response_body_json = """ + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "My operation", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "type" : "webhook", + "secrets" : [ { + "secretKey" : "secret/key", + "name" : "secret_name", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf" + }, { + "secretKey" : "secret/key", + "name" : "secret_name", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf" + } ], + "status" : "pending" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.update_credential_vault_operation( + + id=id, + + credential_vault_operation=credential_vault_operation, + + aid=aid, + + _headers=self.te_headers("update_credential_vault_operation"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_update_credential_vault_operation_error_400(self) -> None: + """Integration test for update_credential_vault_operation error path (HTTP 400)""" + request_body_json = """ + + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "My operation", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "type" : "webhook", + "secrets" : [ { + "secretKey" : "secret/key", + "name" : "secret_name", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf" + }, { + "secretKey" : "secret/key", + "name" : "secret_name", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf" + } ], + "status" : "pending" + } + + """ + credential_vault_operation = thousandeyes_sdk.connectors.models.CredentialVaultOperation.from_json(request_body_json) + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.update_credential_vault_operation( + + id=id, + + credential_vault_operation=credential_vault_operation, + + aid=aid, + + _headers=self.te_headers("update_credential_vault_operation", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_credential_vault_operation_error_401(self) -> None: + """Integration test for update_credential_vault_operation error path (HTTP 401)""" + request_body_json = """ + + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "My operation", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "type" : "webhook", + "secrets" : [ { + "secretKey" : "secret/key", + "name" : "secret_name", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf" + }, { + "secretKey" : "secret/key", + "name" : "secret_name", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf" + } ], + "status" : "pending" + } + + """ + credential_vault_operation = thousandeyes_sdk.connectors.models.CredentialVaultOperation.from_json(request_body_json) + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.update_credential_vault_operation( + + id=id, + + credential_vault_operation=credential_vault_operation, + + aid=aid, + + _headers=self.te_headers("update_credential_vault_operation", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_credential_vault_operation_error_403(self) -> None: + """Integration test for update_credential_vault_operation error path (HTTP 403)""" + request_body_json = """ + + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "My operation", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "type" : "webhook", + "secrets" : [ { + "secretKey" : "secret/key", + "name" : "secret_name", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf" + }, { + "secretKey" : "secret/key", + "name" : "secret_name", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf" + } ], + "status" : "pending" + } + + """ + credential_vault_operation = thousandeyes_sdk.connectors.models.CredentialVaultOperation.from_json(request_body_json) + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.update_credential_vault_operation( + + id=id, + + credential_vault_operation=credential_vault_operation, + + aid=aid, + + _headers=self.te_headers("update_credential_vault_operation", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_credential_vault_operation_error_404(self) -> None: + """Integration test for update_credential_vault_operation error path (HTTP 404)""" + request_body_json = """ + + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "My operation", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "type" : "webhook", + "secrets" : [ { + "secretKey" : "secret/key", + "name" : "secret_name", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf" + }, { + "secretKey" : "secret/key", + "name" : "secret_name", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf" + } ], + "status" : "pending" + } + + """ + credential_vault_operation = thousandeyes_sdk.connectors.models.CredentialVaultOperation.from_json(request_body_json) + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.update_credential_vault_operation( + + id=id, + + credential_vault_operation=credential_vault_operation, + + aid=aid, + + _headers=self.te_headers("update_credential_vault_operation", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_credential_vault_operation_error_500(self) -> None: + """Integration test for update_credential_vault_operation error path (HTTP 500)""" + request_body_json = """ + + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "My operation", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "type" : "webhook", + "secrets" : [ { + "secretKey" : "secret/key", + "name" : "secret_name", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf" + }, { + "secretKey" : "secret/key", + "name" : "secret_name", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf" + } ], + "status" : "pending" + } + + """ + credential_vault_operation = thousandeyes_sdk.connectors.models.CredentialVaultOperation.from_json(request_body_json) + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.update_credential_vault_operation( + + id=id, + + credential_vault_operation=credential_vault_operation, + + aid=aid, + + _headers=self.te_headers("update_credential_vault_operation", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-connectors/test/test_cyber_ark_conjur_connectors_api_integration.py b/thousandeyes-sdk-connectors/test/test_cyber_ark_conjur_connectors_api_integration.py new file mode 100644 index 00000000..fd05aef0 --- /dev/null +++ b/thousandeyes-sdk-connectors/test/test_cyber_ark_conjur_connectors_api_integration.py @@ -0,0 +1,1548 @@ +# coding: utf-8 + +""" + Integrations API + + **Note:** The Webhook Operations APIs are not available for ThousandEyes for Government instance. Manage connectors and operations. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.connectors.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.connectors.api.cyber_ark_conjur_connectors_api import CyberArkConjurConnectorsApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestCyberArkConjurConnectorsApiIntegration(IntegrationTestBase): + """CyberArkConjurConnectorsApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = CyberArkConjurConnectorsApi(self.api_client) + + + def test_create_conjur_connector_happy_path(self) -> None: + """Integration test for create_conjur_connector success path""" + request_body_json = """ + + { + "lastModifiedDate" : 1770293655756, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "Cisco Slack", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "type" : "generic", + "account" : "My CyberArk Account", + "target" : "https://eval.conjur.org/secrets", + "authentication" : { + "apiKey" : "abc123", + "hostId" : "host1", + "type" : "basic" + } + } + + """ + conjur_connector = thousandeyes_sdk.connectors.models.ConjurConnector.from_json(request_body_json) + aid = '1234' + response_body_json = """ + { + "lastModifiedDate" : 1770293655756, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "Cisco Slack", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "type" : "generic", + "account" : "My CyberArk Account", + "target" : "https://eval.conjur.org/secrets", + "authentication" : { + "apiKey" : "abc123", + "hostId" : "host1", + "type" : "basic" + } + } + """ + expected_response = json.loads(response_body_json) + response = self.api.create_conjur_connector( + + conjur_connector=conjur_connector, + + aid=aid, + + _headers=self.te_headers("create_conjur_connector"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_create_conjur_connector_error_400(self) -> None: + """Integration test for create_conjur_connector error path (HTTP 400)""" + request_body_json = """ + + { + "lastModifiedDate" : 1770293655756, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "Cisco Slack", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "type" : "generic", + "account" : "My CyberArk Account", + "target" : "https://eval.conjur.org/secrets", + "authentication" : { + "apiKey" : "abc123", + "hostId" : "host1", + "type" : "basic" + } + } + + """ + conjur_connector = thousandeyes_sdk.connectors.models.ConjurConnector.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.create_conjur_connector( + + conjur_connector=conjur_connector, + + aid=aid, + + _headers=self.te_headers("create_conjur_connector", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_conjur_connector_error_401(self) -> None: + """Integration test for create_conjur_connector error path (HTTP 401)""" + request_body_json = """ + + { + "lastModifiedDate" : 1770293655756, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "Cisco Slack", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "type" : "generic", + "account" : "My CyberArk Account", + "target" : "https://eval.conjur.org/secrets", + "authentication" : { + "apiKey" : "abc123", + "hostId" : "host1", + "type" : "basic" + } + } + + """ + conjur_connector = thousandeyes_sdk.connectors.models.ConjurConnector.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.create_conjur_connector( + + conjur_connector=conjur_connector, + + aid=aid, + + _headers=self.te_headers("create_conjur_connector", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_conjur_connector_error_403(self) -> None: + """Integration test for create_conjur_connector error path (HTTP 403)""" + request_body_json = """ + + { + "lastModifiedDate" : 1770293655756, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "Cisco Slack", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "type" : "generic", + "account" : "My CyberArk Account", + "target" : "https://eval.conjur.org/secrets", + "authentication" : { + "apiKey" : "abc123", + "hostId" : "host1", + "type" : "basic" + } + } + + """ + conjur_connector = thousandeyes_sdk.connectors.models.ConjurConnector.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.create_conjur_connector( + + conjur_connector=conjur_connector, + + aid=aid, + + _headers=self.te_headers("create_conjur_connector", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_conjur_connector_error_404(self) -> None: + """Integration test for create_conjur_connector error path (HTTP 404)""" + request_body_json = """ + + { + "lastModifiedDate" : 1770293655756, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "Cisco Slack", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "type" : "generic", + "account" : "My CyberArk Account", + "target" : "https://eval.conjur.org/secrets", + "authentication" : { + "apiKey" : "abc123", + "hostId" : "host1", + "type" : "basic" + } + } + + """ + conjur_connector = thousandeyes_sdk.connectors.models.ConjurConnector.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.create_conjur_connector( + + conjur_connector=conjur_connector, + + aid=aid, + + _headers=self.te_headers("create_conjur_connector", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_conjur_connector_error_500(self) -> None: + """Integration test for create_conjur_connector error path (HTTP 500)""" + request_body_json = """ + + { + "lastModifiedDate" : 1770293655756, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "Cisco Slack", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "type" : "generic", + "account" : "My CyberArk Account", + "target" : "https://eval.conjur.org/secrets", + "authentication" : { + "apiKey" : "abc123", + "hostId" : "host1", + "type" : "basic" + } + } + + """ + conjur_connector = thousandeyes_sdk.connectors.models.ConjurConnector.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.create_conjur_connector( + + conjur_connector=conjur_connector, + + aid=aid, + + _headers=self.te_headers("create_conjur_connector", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_delete_conjur_connector_happy_path(self) -> None: + """Integration test for delete_conjur_connector success path""" + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + confirm_disabled_objects = False + aid = '1234' + response = self.api.delete_conjur_connector_with_http_info( + + id=id, + + confirm_disabled_objects=confirm_disabled_objects, + + aid=aid, + + _headers=self.te_headers("delete_conjur_connector"), + ) + self.assertEqual(204, response.status_code) + self.assertIsNone(response.data) + + + def test_delete_conjur_connector_error_400(self) -> None: + """Integration test for delete_conjur_connector error path (HTTP 400)""" + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + confirm_disabled_objects = False + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.delete_conjur_connector( + + id=id, + + confirm_disabled_objects=confirm_disabled_objects, + + aid=aid, + + _headers=self.te_headers("delete_conjur_connector", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_conjur_connector_error_401(self) -> None: + """Integration test for delete_conjur_connector error path (HTTP 401)""" + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + confirm_disabled_objects = False + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.delete_conjur_connector( + + id=id, + + confirm_disabled_objects=confirm_disabled_objects, + + aid=aid, + + _headers=self.te_headers("delete_conjur_connector", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_conjur_connector_error_403(self) -> None: + """Integration test for delete_conjur_connector error path (HTTP 403)""" + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + confirm_disabled_objects = False + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.delete_conjur_connector( + + id=id, + + confirm_disabled_objects=confirm_disabled_objects, + + aid=aid, + + _headers=self.te_headers("delete_conjur_connector", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_conjur_connector_error_404(self) -> None: + """Integration test for delete_conjur_connector error path (HTTP 404)""" + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + confirm_disabled_objects = False + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.delete_conjur_connector( + + id=id, + + confirm_disabled_objects=confirm_disabled_objects, + + aid=aid, + + _headers=self.te_headers("delete_conjur_connector", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_conjur_connector_error_500(self) -> None: + """Integration test for delete_conjur_connector error path (HTTP 500)""" + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + confirm_disabled_objects = False + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.delete_conjur_connector( + + id=id, + + confirm_disabled_objects=confirm_disabled_objects, + + aid=aid, + + _headers=self.te_headers("delete_conjur_connector", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_conjur_connector_happy_path(self) -> None: + """Integration test for get_conjur_connector success path""" + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + aid = '1234' + response_body_json = """ + { + "lastModifiedDate" : 1770293655756, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "Cisco Slack", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "type" : "generic", + "account" : "My CyberArk Account", + "target" : "https://eval.conjur.org/secrets", + "authentication" : { + "apiKey" : "abc123", + "hostId" : "host1", + "type" : "basic" + } + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_conjur_connector( + + id=id, + + aid=aid, + + _headers=self.te_headers("get_conjur_connector"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_conjur_connector_error_400(self) -> None: + """Integration test for get_conjur_connector error path (HTTP 400)""" + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.get_conjur_connector( + + id=id, + + aid=aid, + + _headers=self.te_headers("get_conjur_connector", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_conjur_connector_error_401(self) -> None: + """Integration test for get_conjur_connector error path (HTTP 401)""" + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_conjur_connector( + + id=id, + + aid=aid, + + _headers=self.te_headers("get_conjur_connector", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_conjur_connector_error_403(self) -> None: + """Integration test for get_conjur_connector error path (HTTP 403)""" + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_conjur_connector( + + id=id, + + aid=aid, + + _headers=self.te_headers("get_conjur_connector", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_conjur_connector_error_404(self) -> None: + """Integration test for get_conjur_connector error path (HTTP 404)""" + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_conjur_connector( + + id=id, + + aid=aid, + + _headers=self.te_headers("get_conjur_connector", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_conjur_connector_error_500(self) -> None: + """Integration test for get_conjur_connector error path (HTTP 500)""" + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_conjur_connector( + + id=id, + + aid=aid, + + _headers=self.te_headers("get_conjur_connector", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_conjur_connector_operations_happy_path(self) -> None: + """Integration test for get_conjur_connector_operations success path""" + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + aid = '1234' + response_body_json = """ + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "items" : [ "ca39314d-eb4f-496f-9435-b5d20b1bfbff", "ca39314d-eb4f-496f-9435-b5d20b1bfbff" ] + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_conjur_connector_operations( + + id=id, + + aid=aid, + + _headers=self.te_headers("get_conjur_connector_operations"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_conjur_connector_operations_error_400(self) -> None: + """Integration test for get_conjur_connector_operations error path (HTTP 400)""" + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.get_conjur_connector_operations( + + id=id, + + aid=aid, + + _headers=self.te_headers("get_conjur_connector_operations", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_conjur_connector_operations_error_401(self) -> None: + """Integration test for get_conjur_connector_operations error path (HTTP 401)""" + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_conjur_connector_operations( + + id=id, + + aid=aid, + + _headers=self.te_headers("get_conjur_connector_operations", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_conjur_connector_operations_error_403(self) -> None: + """Integration test for get_conjur_connector_operations error path (HTTP 403)""" + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_conjur_connector_operations( + + id=id, + + aid=aid, + + _headers=self.te_headers("get_conjur_connector_operations", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_conjur_connector_operations_error_404(self) -> None: + """Integration test for get_conjur_connector_operations error path (HTTP 404)""" + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_conjur_connector_operations( + + id=id, + + aid=aid, + + _headers=self.te_headers("get_conjur_connector_operations", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_conjur_connector_operations_error_500(self) -> None: + """Integration test for get_conjur_connector_operations error path (HTTP 500)""" + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_conjur_connector_operations( + + id=id, + + aid=aid, + + _headers=self.te_headers("get_conjur_connector_operations", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_conjur_connectors_happy_path(self) -> None: + """Integration test for get_conjur_connectors success path""" + aid = '1234' + response_body_json = """ + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "items" : [ { + "lastModifiedDate" : 1770293655756, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "Cisco Slack", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "type" : "generic", + "account" : "My CyberArk Account", + "target" : "https://eval.conjur.org/secrets", + "authentication" : { + "apiKey" : "abc123", + "hostId" : "host1", + "type" : "basic" + } + }, { + "lastModifiedDate" : 1770293655756, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "Cisco Slack", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "type" : "generic", + "account" : "My CyberArk Account", + "target" : "https://eval.conjur.org/secrets", + "authentication" : { + "apiKey" : "abc123", + "hostId" : "host1", + "type" : "basic" + } + } ] + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_conjur_connectors( + + aid=aid, + + _headers=self.te_headers("get_conjur_connectors"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_conjur_connectors_error_400(self) -> None: + """Integration test for get_conjur_connectors error path (HTTP 400)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.get_conjur_connectors( + + aid=aid, + + _headers=self.te_headers("get_conjur_connectors", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_conjur_connectors_error_401(self) -> None: + """Integration test for get_conjur_connectors error path (HTTP 401)""" + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_conjur_connectors( + + aid=aid, + + _headers=self.te_headers("get_conjur_connectors", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_conjur_connectors_error_403(self) -> None: + """Integration test for get_conjur_connectors error path (HTTP 403)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_conjur_connectors( + + aid=aid, + + _headers=self.te_headers("get_conjur_connectors", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_conjur_connectors_error_404(self) -> None: + """Integration test for get_conjur_connectors error path (HTTP 404)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_conjur_connectors( + + aid=aid, + + _headers=self.te_headers("get_conjur_connectors", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_conjur_connectors_error_500(self) -> None: + """Integration test for get_conjur_connectors error path (HTTP 500)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_conjur_connectors( + + aid=aid, + + _headers=self.te_headers("get_conjur_connectors", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_update_conjur_connector_happy_path(self) -> None: + """Integration test for update_conjur_connector success path""" + request_body_json = """ + + { + "lastModifiedDate" : 1770293655756, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "Cisco Slack", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "type" : "generic", + "account" : "My CyberArk Account", + "target" : "https://eval.conjur.org/secrets", + "authentication" : { + "apiKey" : "abc123", + "hostId" : "host1", + "type" : "basic" + } + } + + """ + conjur_connector = thousandeyes_sdk.connectors.models.ConjurConnector.from_json(request_body_json) + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + aid = '1234' + response_body_json = """ + { + "lastModifiedDate" : 1770293655756, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "Cisco Slack", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "type" : "generic", + "account" : "My CyberArk Account", + "target" : "https://eval.conjur.org/secrets", + "authentication" : { + "apiKey" : "abc123", + "hostId" : "host1", + "type" : "basic" + } + } + """ + expected_response = json.loads(response_body_json) + response = self.api.update_conjur_connector( + + id=id, + + conjur_connector=conjur_connector, + + aid=aid, + + _headers=self.te_headers("update_conjur_connector"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_update_conjur_connector_error_400(self) -> None: + """Integration test for update_conjur_connector error path (HTTP 400)""" + request_body_json = """ + + { + "lastModifiedDate" : 1770293655756, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "Cisco Slack", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "type" : "generic", + "account" : "My CyberArk Account", + "target" : "https://eval.conjur.org/secrets", + "authentication" : { + "apiKey" : "abc123", + "hostId" : "host1", + "type" : "basic" + } + } + + """ + conjur_connector = thousandeyes_sdk.connectors.models.ConjurConnector.from_json(request_body_json) + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.update_conjur_connector( + + id=id, + + conjur_connector=conjur_connector, + + aid=aid, + + _headers=self.te_headers("update_conjur_connector", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_conjur_connector_error_401(self) -> None: + """Integration test for update_conjur_connector error path (HTTP 401)""" + request_body_json = """ + + { + "lastModifiedDate" : 1770293655756, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "Cisco Slack", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "type" : "generic", + "account" : "My CyberArk Account", + "target" : "https://eval.conjur.org/secrets", + "authentication" : { + "apiKey" : "abc123", + "hostId" : "host1", + "type" : "basic" + } + } + + """ + conjur_connector = thousandeyes_sdk.connectors.models.ConjurConnector.from_json(request_body_json) + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.update_conjur_connector( + + id=id, + + conjur_connector=conjur_connector, + + aid=aid, + + _headers=self.te_headers("update_conjur_connector", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_conjur_connector_error_403(self) -> None: + """Integration test for update_conjur_connector error path (HTTP 403)""" + request_body_json = """ + + { + "lastModifiedDate" : 1770293655756, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "Cisco Slack", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "type" : "generic", + "account" : "My CyberArk Account", + "target" : "https://eval.conjur.org/secrets", + "authentication" : { + "apiKey" : "abc123", + "hostId" : "host1", + "type" : "basic" + } + } + + """ + conjur_connector = thousandeyes_sdk.connectors.models.ConjurConnector.from_json(request_body_json) + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.update_conjur_connector( + + id=id, + + conjur_connector=conjur_connector, + + aid=aid, + + _headers=self.te_headers("update_conjur_connector", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_conjur_connector_error_404(self) -> None: + """Integration test for update_conjur_connector error path (HTTP 404)""" + request_body_json = """ + + { + "lastModifiedDate" : 1770293655756, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "Cisco Slack", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "type" : "generic", + "account" : "My CyberArk Account", + "target" : "https://eval.conjur.org/secrets", + "authentication" : { + "apiKey" : "abc123", + "hostId" : "host1", + "type" : "basic" + } + } + + """ + conjur_connector = thousandeyes_sdk.connectors.models.ConjurConnector.from_json(request_body_json) + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.update_conjur_connector( + + id=id, + + conjur_connector=conjur_connector, + + aid=aid, + + _headers=self.te_headers("update_conjur_connector", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_conjur_connector_error_500(self) -> None: + """Integration test for update_conjur_connector error path (HTTP 500)""" + request_body_json = """ + + { + "lastModifiedDate" : 1770293655756, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "Cisco Slack", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "type" : "generic", + "account" : "My CyberArk Account", + "target" : "https://eval.conjur.org/secrets", + "authentication" : { + "apiKey" : "abc123", + "hostId" : "host1", + "type" : "basic" + } + } + + """ + conjur_connector = thousandeyes_sdk.connectors.models.ConjurConnector.from_json(request_body_json) + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.update_conjur_connector( + + id=id, + + conjur_connector=conjur_connector, + + aid=aid, + + _headers=self.te_headers("update_conjur_connector", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-connectors/test/test_generic_connectors_api_integration.py b/thousandeyes-sdk-connectors/test/test_generic_connectors_api_integration.py new file mode 100644 index 00000000..77671948 --- /dev/null +++ b/thousandeyes-sdk-connectors/test/test_generic_connectors_api_integration.py @@ -0,0 +1,1632 @@ +# coding: utf-8 + +""" + Integrations API + + **Note:** The Webhook Operations APIs are not available for ThousandEyes for Government instance. Manage connectors and operations. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.connectors.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.connectors.api.generic_connectors_api import GenericConnectorsApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestGenericConnectorsApiIntegration(IntegrationTestBase): + """GenericConnectorsApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = GenericConnectorsApi(self.api_client) + + + def test_create_generic_connector_happy_path(self) -> None: + """Integration test for create_generic_connector success path""" + request_body_json = """ + + { + "headers" : [ { + "name" : "Content-Type", + "value" : "application/json" + }, { + "name" : "Content-Type", + "value" : "application/json" + } ], + "lastModifiedDate" : 1770293655756, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "Cisco Slack", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "type" : "generic", + "target" : "https://hooks.slack.com/services/abc/xyz", + "authentication" : { + "password" : "abc123", + "type" : "basic", + "username" : "user1" + } + } + + """ + generic_connector = thousandeyes_sdk.connectors.models.GenericConnector.from_json(request_body_json) + aid = '1234' + response_body_json = """ + { + "headers" : [ { + "name" : "Content-Type", + "value" : "application/json" + }, { + "name" : "Content-Type", + "value" : "application/json" + } ], + "lastModifiedDate" : 1770293655756, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "Cisco Slack", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "type" : "generic", + "target" : "https://hooks.slack.com/services/abc/xyz", + "authentication" : { + "password" : "abc123", + "type" : "basic", + "username" : "user1" + } + } + """ + expected_response = json.loads(response_body_json) + response = self.api.create_generic_connector( + + generic_connector=generic_connector, + + aid=aid, + + _headers=self.te_headers("create_generic_connector"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_create_generic_connector_error_400(self) -> None: + """Integration test for create_generic_connector error path (HTTP 400)""" + request_body_json = """ + + { + "headers" : [ { + "name" : "Content-Type", + "value" : "application/json" + }, { + "name" : "Content-Type", + "value" : "application/json" + } ], + "lastModifiedDate" : 1770293655756, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "Cisco Slack", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "type" : "generic", + "target" : "https://hooks.slack.com/services/abc/xyz", + "authentication" : { + "password" : "abc123", + "type" : "basic", + "username" : "user1" + } + } + + """ + generic_connector = thousandeyes_sdk.connectors.models.GenericConnector.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.create_generic_connector( + + generic_connector=generic_connector, + + aid=aid, + + _headers=self.te_headers("create_generic_connector", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_generic_connector_error_401(self) -> None: + """Integration test for create_generic_connector error path (HTTP 401)""" + request_body_json = """ + + { + "headers" : [ { + "name" : "Content-Type", + "value" : "application/json" + }, { + "name" : "Content-Type", + "value" : "application/json" + } ], + "lastModifiedDate" : 1770293655756, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "Cisco Slack", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "type" : "generic", + "target" : "https://hooks.slack.com/services/abc/xyz", + "authentication" : { + "password" : "abc123", + "type" : "basic", + "username" : "user1" + } + } + + """ + generic_connector = thousandeyes_sdk.connectors.models.GenericConnector.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.create_generic_connector( + + generic_connector=generic_connector, + + aid=aid, + + _headers=self.te_headers("create_generic_connector", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_generic_connector_error_403(self) -> None: + """Integration test for create_generic_connector error path (HTTP 403)""" + request_body_json = """ + + { + "headers" : [ { + "name" : "Content-Type", + "value" : "application/json" + }, { + "name" : "Content-Type", + "value" : "application/json" + } ], + "lastModifiedDate" : 1770293655756, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "Cisco Slack", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "type" : "generic", + "target" : "https://hooks.slack.com/services/abc/xyz", + "authentication" : { + "password" : "abc123", + "type" : "basic", + "username" : "user1" + } + } + + """ + generic_connector = thousandeyes_sdk.connectors.models.GenericConnector.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.create_generic_connector( + + generic_connector=generic_connector, + + aid=aid, + + _headers=self.te_headers("create_generic_connector", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_generic_connector_error_404(self) -> None: + """Integration test for create_generic_connector error path (HTTP 404)""" + request_body_json = """ + + { + "headers" : [ { + "name" : "Content-Type", + "value" : "application/json" + }, { + "name" : "Content-Type", + "value" : "application/json" + } ], + "lastModifiedDate" : 1770293655756, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "Cisco Slack", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "type" : "generic", + "target" : "https://hooks.slack.com/services/abc/xyz", + "authentication" : { + "password" : "abc123", + "type" : "basic", + "username" : "user1" + } + } + + """ + generic_connector = thousandeyes_sdk.connectors.models.GenericConnector.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.create_generic_connector( + + generic_connector=generic_connector, + + aid=aid, + + _headers=self.te_headers("create_generic_connector", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_generic_connector_error_500(self) -> None: + """Integration test for create_generic_connector error path (HTTP 500)""" + request_body_json = """ + + { + "headers" : [ { + "name" : "Content-Type", + "value" : "application/json" + }, { + "name" : "Content-Type", + "value" : "application/json" + } ], + "lastModifiedDate" : 1770293655756, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "Cisco Slack", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "type" : "generic", + "target" : "https://hooks.slack.com/services/abc/xyz", + "authentication" : { + "password" : "abc123", + "type" : "basic", + "username" : "user1" + } + } + + """ + generic_connector = thousandeyes_sdk.connectors.models.GenericConnector.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.create_generic_connector( + + generic_connector=generic_connector, + + aid=aid, + + _headers=self.te_headers("create_generic_connector", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_delete_generic_connector_happy_path(self) -> None: + """Integration test for delete_generic_connector success path""" + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + aid = '1234' + response = self.api.delete_generic_connector_with_http_info( + + id=id, + + aid=aid, + + _headers=self.te_headers("delete_generic_connector"), + ) + self.assertEqual(204, response.status_code) + self.assertIsNone(response.data) + + + def test_delete_generic_connector_error_400(self) -> None: + """Integration test for delete_generic_connector error path (HTTP 400)""" + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.delete_generic_connector( + + id=id, + + aid=aid, + + _headers=self.te_headers("delete_generic_connector", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_generic_connector_error_401(self) -> None: + """Integration test for delete_generic_connector error path (HTTP 401)""" + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.delete_generic_connector( + + id=id, + + aid=aid, + + _headers=self.te_headers("delete_generic_connector", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_generic_connector_error_403(self) -> None: + """Integration test for delete_generic_connector error path (HTTP 403)""" + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.delete_generic_connector( + + id=id, + + aid=aid, + + _headers=self.te_headers("delete_generic_connector", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_generic_connector_error_404(self) -> None: + """Integration test for delete_generic_connector error path (HTTP 404)""" + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.delete_generic_connector( + + id=id, + + aid=aid, + + _headers=self.te_headers("delete_generic_connector", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_generic_connector_error_500(self) -> None: + """Integration test for delete_generic_connector error path (HTTP 500)""" + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.delete_generic_connector( + + id=id, + + aid=aid, + + _headers=self.te_headers("delete_generic_connector", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_generic_connector_happy_path(self) -> None: + """Integration test for get_generic_connector success path""" + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + aid = '1234' + response_body_json = """ + { + "headers" : [ { + "name" : "Content-Type", + "value" : "application/json" + }, { + "name" : "Content-Type", + "value" : "application/json" + } ], + "lastModifiedDate" : 1770293655756, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "Cisco Slack", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "type" : "generic", + "target" : "https://hooks.slack.com/services/abc/xyz", + "authentication" : { + "password" : "abc123", + "type" : "basic", + "username" : "user1" + } + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_generic_connector( + + id=id, + + aid=aid, + + _headers=self.te_headers("get_generic_connector"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_generic_connector_error_400(self) -> None: + """Integration test for get_generic_connector error path (HTTP 400)""" + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.get_generic_connector( + + id=id, + + aid=aid, + + _headers=self.te_headers("get_generic_connector", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_generic_connector_error_401(self) -> None: + """Integration test for get_generic_connector error path (HTTP 401)""" + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_generic_connector( + + id=id, + + aid=aid, + + _headers=self.te_headers("get_generic_connector", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_generic_connector_error_403(self) -> None: + """Integration test for get_generic_connector error path (HTTP 403)""" + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_generic_connector( + + id=id, + + aid=aid, + + _headers=self.te_headers("get_generic_connector", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_generic_connector_error_404(self) -> None: + """Integration test for get_generic_connector error path (HTTP 404)""" + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_generic_connector( + + id=id, + + aid=aid, + + _headers=self.te_headers("get_generic_connector", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_generic_connector_error_500(self) -> None: + """Integration test for get_generic_connector error path (HTTP 500)""" + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_generic_connector( + + id=id, + + aid=aid, + + _headers=self.te_headers("get_generic_connector", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_generic_connectors_happy_path(self) -> None: + """Integration test for get_generic_connectors success path""" + aid = '1234' + response_body_json = """ + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "items" : [ { + "headers" : [ { + "name" : "Content-Type", + "value" : "application/json" + }, { + "name" : "Content-Type", + "value" : "application/json" + } ], + "lastModifiedDate" : 1770293655756, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "Cisco Slack", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "type" : "generic", + "target" : "https://hooks.slack.com/services/abc/xyz", + "authentication" : { + "password" : "abc123", + "type" : "basic", + "username" : "user1" + } + }, { + "headers" : [ { + "name" : "Content-Type", + "value" : "application/json" + }, { + "name" : "Content-Type", + "value" : "application/json" + } ], + "lastModifiedDate" : 1770293655756, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "Cisco Slack", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "type" : "generic", + "target" : "https://hooks.slack.com/services/abc/xyz", + "authentication" : { + "password" : "abc123", + "type" : "basic", + "username" : "user1" + } + } ] + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_generic_connectors( + + aid=aid, + + _headers=self.te_headers("get_generic_connectors"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_generic_connectors_error_400(self) -> None: + """Integration test for get_generic_connectors error path (HTTP 400)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.get_generic_connectors( + + aid=aid, + + _headers=self.te_headers("get_generic_connectors", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_generic_connectors_error_401(self) -> None: + """Integration test for get_generic_connectors error path (HTTP 401)""" + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_generic_connectors( + + aid=aid, + + _headers=self.te_headers("get_generic_connectors", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_generic_connectors_error_403(self) -> None: + """Integration test for get_generic_connectors error path (HTTP 403)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_generic_connectors( + + aid=aid, + + _headers=self.te_headers("get_generic_connectors", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_generic_connectors_error_404(self) -> None: + """Integration test for get_generic_connectors error path (HTTP 404)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_generic_connectors( + + aid=aid, + + _headers=self.te_headers("get_generic_connectors", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_generic_connectors_error_500(self) -> None: + """Integration test for get_generic_connectors error path (HTTP 500)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_generic_connectors( + + aid=aid, + + _headers=self.te_headers("get_generic_connectors", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_list_generic_connector_operations_happy_path(self) -> None: + """Integration test for list_generic_connector_operations success path""" + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + aid = '1234' + response_body_json = """ + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "items" : [ "ca39314d-eb4f-496f-9435-b5d20b1bfbff", "ca39314d-eb4f-496f-9435-b5d20b1bfbff" ] + } + """ + expected_response = json.loads(response_body_json) + response = self.api.list_generic_connector_operations( + + id=id, + + aid=aid, + + _headers=self.te_headers("list_generic_connector_operations"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_list_generic_connector_operations_error_400(self) -> None: + """Integration test for list_generic_connector_operations error path (HTTP 400)""" + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.list_generic_connector_operations( + + id=id, + + aid=aid, + + _headers=self.te_headers("list_generic_connector_operations", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_list_generic_connector_operations_error_401(self) -> None: + """Integration test for list_generic_connector_operations error path (HTTP 401)""" + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.list_generic_connector_operations( + + id=id, + + aid=aid, + + _headers=self.te_headers("list_generic_connector_operations", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_list_generic_connector_operations_error_403(self) -> None: + """Integration test for list_generic_connector_operations error path (HTTP 403)""" + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.list_generic_connector_operations( + + id=id, + + aid=aid, + + _headers=self.te_headers("list_generic_connector_operations", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_list_generic_connector_operations_error_404(self) -> None: + """Integration test for list_generic_connector_operations error path (HTTP 404)""" + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.list_generic_connector_operations( + + id=id, + + aid=aid, + + _headers=self.te_headers("list_generic_connector_operations", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_list_generic_connector_operations_error_500(self) -> None: + """Integration test for list_generic_connector_operations error path (HTTP 500)""" + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.list_generic_connector_operations( + + id=id, + + aid=aid, + + _headers=self.te_headers("list_generic_connector_operations", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_update_generic_connector_happy_path(self) -> None: + """Integration test for update_generic_connector success path""" + request_body_json = """ + + { + "headers" : [ { + "name" : "Content-Type", + "value" : "application/json" + }, { + "name" : "Content-Type", + "value" : "application/json" + } ], + "lastModifiedDate" : 1770293655756, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "Cisco Slack", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "type" : "generic", + "target" : "https://hooks.slack.com/services/abc/xyz", + "authentication" : { + "password" : "abc123", + "type" : "basic", + "username" : "user1" + } + } + + """ + generic_connector = thousandeyes_sdk.connectors.models.GenericConnector.from_json(request_body_json) + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + aid = '1234' + response_body_json = """ + { + "headers" : [ { + "name" : "Content-Type", + "value" : "application/json" + }, { + "name" : "Content-Type", + "value" : "application/json" + } ], + "lastModifiedDate" : 1770293655756, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "Cisco Slack", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "type" : "generic", + "target" : "https://hooks.slack.com/services/abc/xyz", + "authentication" : { + "password" : "abc123", + "type" : "basic", + "username" : "user1" + } + } + """ + expected_response = json.loads(response_body_json) + response = self.api.update_generic_connector( + + id=id, + + generic_connector=generic_connector, + + aid=aid, + + _headers=self.te_headers("update_generic_connector"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_update_generic_connector_error_400(self) -> None: + """Integration test for update_generic_connector error path (HTTP 400)""" + request_body_json = """ + + { + "headers" : [ { + "name" : "Content-Type", + "value" : "application/json" + }, { + "name" : "Content-Type", + "value" : "application/json" + } ], + "lastModifiedDate" : 1770293655756, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "Cisco Slack", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "type" : "generic", + "target" : "https://hooks.slack.com/services/abc/xyz", + "authentication" : { + "password" : "abc123", + "type" : "basic", + "username" : "user1" + } + } + + """ + generic_connector = thousandeyes_sdk.connectors.models.GenericConnector.from_json(request_body_json) + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.update_generic_connector( + + id=id, + + generic_connector=generic_connector, + + aid=aid, + + _headers=self.te_headers("update_generic_connector", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_generic_connector_error_401(self) -> None: + """Integration test for update_generic_connector error path (HTTP 401)""" + request_body_json = """ + + { + "headers" : [ { + "name" : "Content-Type", + "value" : "application/json" + }, { + "name" : "Content-Type", + "value" : "application/json" + } ], + "lastModifiedDate" : 1770293655756, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "Cisco Slack", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "type" : "generic", + "target" : "https://hooks.slack.com/services/abc/xyz", + "authentication" : { + "password" : "abc123", + "type" : "basic", + "username" : "user1" + } + } + + """ + generic_connector = thousandeyes_sdk.connectors.models.GenericConnector.from_json(request_body_json) + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.update_generic_connector( + + id=id, + + generic_connector=generic_connector, + + aid=aid, + + _headers=self.te_headers("update_generic_connector", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_generic_connector_error_403(self) -> None: + """Integration test for update_generic_connector error path (HTTP 403)""" + request_body_json = """ + + { + "headers" : [ { + "name" : "Content-Type", + "value" : "application/json" + }, { + "name" : "Content-Type", + "value" : "application/json" + } ], + "lastModifiedDate" : 1770293655756, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "Cisco Slack", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "type" : "generic", + "target" : "https://hooks.slack.com/services/abc/xyz", + "authentication" : { + "password" : "abc123", + "type" : "basic", + "username" : "user1" + } + } + + """ + generic_connector = thousandeyes_sdk.connectors.models.GenericConnector.from_json(request_body_json) + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.update_generic_connector( + + id=id, + + generic_connector=generic_connector, + + aid=aid, + + _headers=self.te_headers("update_generic_connector", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_generic_connector_error_404(self) -> None: + """Integration test for update_generic_connector error path (HTTP 404)""" + request_body_json = """ + + { + "headers" : [ { + "name" : "Content-Type", + "value" : "application/json" + }, { + "name" : "Content-Type", + "value" : "application/json" + } ], + "lastModifiedDate" : 1770293655756, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "Cisco Slack", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "type" : "generic", + "target" : "https://hooks.slack.com/services/abc/xyz", + "authentication" : { + "password" : "abc123", + "type" : "basic", + "username" : "user1" + } + } + + """ + generic_connector = thousandeyes_sdk.connectors.models.GenericConnector.from_json(request_body_json) + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.update_generic_connector( + + id=id, + + generic_connector=generic_connector, + + aid=aid, + + _headers=self.te_headers("update_generic_connector", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_generic_connector_error_500(self) -> None: + """Integration test for update_generic_connector error path (HTTP 500)""" + request_body_json = """ + + { + "headers" : [ { + "name" : "Content-Type", + "value" : "application/json" + }, { + "name" : "Content-Type", + "value" : "application/json" + } ], + "lastModifiedDate" : 1770293655756, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "Cisco Slack", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "type" : "generic", + "target" : "https://hooks.slack.com/services/abc/xyz", + "authentication" : { + "password" : "abc123", + "type" : "basic", + "username" : "user1" + } + } + + """ + generic_connector = thousandeyes_sdk.connectors.models.GenericConnector.from_json(request_body_json) + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.update_generic_connector( + + id=id, + + generic_connector=generic_connector, + + aid=aid, + + _headers=self.te_headers("update_generic_connector", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-connectors/test/test_operation_connectors_api_integration.py b/thousandeyes-sdk-connectors/test/test_operation_connectors_api_integration.py new file mode 100644 index 00000000..3a3e2f1a --- /dev/null +++ b/thousandeyes-sdk-connectors/test/test_operation_connectors_api_integration.py @@ -0,0 +1,234 @@ +# coding: utf-8 + +""" + Integrations API + + **Note:** The Webhook Operations APIs are not available for ThousandEyes for Government instance. Manage connectors and operations. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.connectors.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.connectors.api.operation_connectors_api import OperationConnectorsApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestOperationConnectorsApiIntegration(IntegrationTestBase): + """OperationConnectorsApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = OperationConnectorsApi(self.api_client) + + + def test_get_operation_connectors_happy_path(self) -> None: + """Integration test for get_operation_connectors success path""" + type = 'webhooks' + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + aid = '1234' + response_body_json = """ + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "items" : [ "ca39314d-eb4f-496f-9435-b5d20b1bfbff", "ca39314d-eb4f-496f-9435-b5d20b1bfbff" ] + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_operation_connectors( + + type=type, + + id=id, + + aid=aid, + + _headers=self.te_headers("get_operation_connectors"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_operation_connectors_error_400(self) -> None: + """Integration test for get_operation_connectors error path (HTTP 400)""" + type = 'webhooks' + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.get_operation_connectors( + + type=type, + + id=id, + + aid=aid, + + _headers=self.te_headers("get_operation_connectors", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_operation_connectors_error_401(self) -> None: + """Integration test for get_operation_connectors error path (HTTP 401)""" + type = 'webhooks' + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_operation_connectors( + + type=type, + + id=id, + + aid=aid, + + _headers=self.te_headers("get_operation_connectors", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_operation_connectors_error_403(self) -> None: + """Integration test for get_operation_connectors error path (HTTP 403)""" + type = 'webhooks' + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_operation_connectors( + + type=type, + + id=id, + + aid=aid, + + _headers=self.te_headers("get_operation_connectors", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_operation_connectors_error_404(self) -> None: + """Integration test for get_operation_connectors error path (HTTP 404)""" + type = 'webhooks' + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_operation_connectors( + + type=type, + + id=id, + + aid=aid, + + _headers=self.te_headers("get_operation_connectors", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_operation_connectors_error_500(self) -> None: + """Integration test for get_operation_connectors error path (HTTP 500)""" + type = 'webhooks' + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_operation_connectors( + + type=type, + + id=id, + + aid=aid, + + _headers=self.te_headers("get_operation_connectors", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-connectors/test/test_utils.py b/thousandeyes-sdk-connectors/test/test_utils.py index 930528d9..37913f62 100644 --- a/thousandeyes-sdk-connectors/test/test_utils.py +++ b/thousandeyes-sdk-connectors/test/test_utils.py @@ -2,15 +2,36 @@ import json import unittest +from typing import Any from pydantic import BaseModel +def _project_onto_constructed(expected: Any, constructed: Any) -> Any: + """Keep only example fields that appear in the constructed model output.""" + if isinstance(constructed, dict): + if not isinstance(expected, dict): + return expected + return { + key: _project_onto_constructed(expected.get(key), value) + for key, value in constructed.items() + } + if isinstance(constructed, list): + if not isinstance(expected, list): + return expected + return [ + _project_onto_constructed(expected[index], value) + for index, value in enumerate(constructed) + ] + return expected + + def assert_constructed_model_matches_example_json(model: BaseModel, loaded_json: dict): test_case = unittest.TestCase() test_case.maxDiff = None test_case.assertIsNotNone(model) constructed_json = json.loads(model.to_json()) - sorted_loaded_json = json.dumps(loaded_json, sort_keys=True) + projected_loaded_json = _project_onto_constructed(loaded_json, constructed_json) + sorted_loaded_json = json.dumps(projected_loaded_json, sort_keys=True) sorted_constructed_json = json.dumps(constructed_json, sort_keys=True) test_case.assertEqual(sorted_loaded_json, sorted_constructed_json) diff --git a/thousandeyes-sdk-connectors/test/test_webhook_operations_api_integration.py b/thousandeyes-sdk-connectors/test/test_webhook_operations_api_integration.py new file mode 100644 index 00000000..4233aae4 --- /dev/null +++ b/thousandeyes-sdk-connectors/test/test_webhook_operations_api_integration.py @@ -0,0 +1,1434 @@ +# coding: utf-8 + +""" + Integrations API + + **Note:** The Webhook Operations APIs are not available for ThousandEyes for Government instance. Manage connectors and operations. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.connectors.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.connectors.api.webhook_operations_api import WebhookOperationsApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestWebhookOperationsApiIntegration(IntegrationTestBase): + """WebhookOperationsApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = WebhookOperationsApi(self.api_client) + + + def test_create_webhook_operation_happy_path(self) -> None: + """Integration test for create_webhook_operation success path""" + request_body_json = """ + + { + "path" : "/custom/path", + "headers" : [ { + "name" : "Content-Type", + "value" : "application/json" + }, { + "name" : "Content-Type", + "value" : "application/json" + } ], + "payload" : "{\\"property1\\": {{numericVar}}, \\"property2\\": \\"{{stringVar}}\\"}", + "queryParams" : "{\\"queryParam1\\":\\"{{stringVar}}\\"}", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "My operation", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "category" : "alerts", + "type" : "webhook", + "enabled" : true, + "status" : "pending" + } + + """ + webhook_operation = thousandeyes_sdk.connectors.models.WebhookOperation.from_json(request_body_json) + aid = '1234' + response_body_json = """ + { + "path" : "/custom/path", + "headers" : [ { + "name" : "Content-Type", + "value" : "application/json" + }, { + "name" : "Content-Type", + "value" : "application/json" + } ], + "payload" : "{\\"property1\\": {{numericVar}}, \\"property2\\": \\"{{stringVar}}\\"}", + "queryParams" : "{\\"queryParam1\\":\\"{{stringVar}}\\"}", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "My operation", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "category" : "alerts", + "type" : "webhook", + "enabled" : true, + "status" : "pending" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.create_webhook_operation( + + webhook_operation=webhook_operation, + + aid=aid, + + _headers=self.te_headers("create_webhook_operation"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_create_webhook_operation_error_400(self) -> None: + """Integration test for create_webhook_operation error path (HTTP 400)""" + request_body_json = """ + + { + "path" : "/custom/path", + "headers" : [ { + "name" : "Content-Type", + "value" : "application/json" + }, { + "name" : "Content-Type", + "value" : "application/json" + } ], + "payload" : "{\\"property1\\": {{numericVar}}, \\"property2\\": \\"{{stringVar}}\\"}", + "queryParams" : "{\\"queryParam1\\":\\"{{stringVar}}\\"}", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "My operation", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "category" : "alerts", + "type" : "webhook", + "enabled" : true, + "status" : "pending" + } + + """ + webhook_operation = thousandeyes_sdk.connectors.models.WebhookOperation.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.create_webhook_operation( + + webhook_operation=webhook_operation, + + aid=aid, + + _headers=self.te_headers("create_webhook_operation", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_webhook_operation_error_401(self) -> None: + """Integration test for create_webhook_operation error path (HTTP 401)""" + request_body_json = """ + + { + "path" : "/custom/path", + "headers" : [ { + "name" : "Content-Type", + "value" : "application/json" + }, { + "name" : "Content-Type", + "value" : "application/json" + } ], + "payload" : "{\\"property1\\": {{numericVar}}, \\"property2\\": \\"{{stringVar}}\\"}", + "queryParams" : "{\\"queryParam1\\":\\"{{stringVar}}\\"}", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "My operation", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "category" : "alerts", + "type" : "webhook", + "enabled" : true, + "status" : "pending" + } + + """ + webhook_operation = thousandeyes_sdk.connectors.models.WebhookOperation.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.create_webhook_operation( + + webhook_operation=webhook_operation, + + aid=aid, + + _headers=self.te_headers("create_webhook_operation", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_webhook_operation_error_403(self) -> None: + """Integration test for create_webhook_operation error path (HTTP 403)""" + request_body_json = """ + + { + "path" : "/custom/path", + "headers" : [ { + "name" : "Content-Type", + "value" : "application/json" + }, { + "name" : "Content-Type", + "value" : "application/json" + } ], + "payload" : "{\\"property1\\": {{numericVar}}, \\"property2\\": \\"{{stringVar}}\\"}", + "queryParams" : "{\\"queryParam1\\":\\"{{stringVar}}\\"}", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "My operation", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "category" : "alerts", + "type" : "webhook", + "enabled" : true, + "status" : "pending" + } + + """ + webhook_operation = thousandeyes_sdk.connectors.models.WebhookOperation.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.create_webhook_operation( + + webhook_operation=webhook_operation, + + aid=aid, + + _headers=self.te_headers("create_webhook_operation", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_webhook_operation_error_404(self) -> None: + """Integration test for create_webhook_operation error path (HTTP 404)""" + request_body_json = """ + + { + "path" : "/custom/path", + "headers" : [ { + "name" : "Content-Type", + "value" : "application/json" + }, { + "name" : "Content-Type", + "value" : "application/json" + } ], + "payload" : "{\\"property1\\": {{numericVar}}, \\"property2\\": \\"{{stringVar}}\\"}", + "queryParams" : "{\\"queryParam1\\":\\"{{stringVar}}\\"}", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "My operation", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "category" : "alerts", + "type" : "webhook", + "enabled" : true, + "status" : "pending" + } + + """ + webhook_operation = thousandeyes_sdk.connectors.models.WebhookOperation.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.create_webhook_operation( + + webhook_operation=webhook_operation, + + aid=aid, + + _headers=self.te_headers("create_webhook_operation", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_webhook_operation_error_500(self) -> None: + """Integration test for create_webhook_operation error path (HTTP 500)""" + request_body_json = """ + + { + "path" : "/custom/path", + "headers" : [ { + "name" : "Content-Type", + "value" : "application/json" + }, { + "name" : "Content-Type", + "value" : "application/json" + } ], + "payload" : "{\\"property1\\": {{numericVar}}, \\"property2\\": \\"{{stringVar}}\\"}", + "queryParams" : "{\\"queryParam1\\":\\"{{stringVar}}\\"}", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "My operation", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "category" : "alerts", + "type" : "webhook", + "enabled" : true, + "status" : "pending" + } + + """ + webhook_operation = thousandeyes_sdk.connectors.models.WebhookOperation.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.create_webhook_operation( + + webhook_operation=webhook_operation, + + aid=aid, + + _headers=self.te_headers("create_webhook_operation", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_delete_webhook_operation_happy_path(self) -> None: + """Integration test for delete_webhook_operation success path""" + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + aid = '1234' + response = self.api.delete_webhook_operation_with_http_info( + + id=id, + + aid=aid, + + _headers=self.te_headers("delete_webhook_operation"), + ) + self.assertEqual(204, response.status_code) + self.assertIsNone(response.data) + + + def test_delete_webhook_operation_error_400(self) -> None: + """Integration test for delete_webhook_operation error path (HTTP 400)""" + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.delete_webhook_operation( + + id=id, + + aid=aid, + + _headers=self.te_headers("delete_webhook_operation", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_webhook_operation_error_401(self) -> None: + """Integration test for delete_webhook_operation error path (HTTP 401)""" + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.delete_webhook_operation( + + id=id, + + aid=aid, + + _headers=self.te_headers("delete_webhook_operation", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_webhook_operation_error_403(self) -> None: + """Integration test for delete_webhook_operation error path (HTTP 403)""" + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.delete_webhook_operation( + + id=id, + + aid=aid, + + _headers=self.te_headers("delete_webhook_operation", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_webhook_operation_error_404(self) -> None: + """Integration test for delete_webhook_operation error path (HTTP 404)""" + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.delete_webhook_operation( + + id=id, + + aid=aid, + + _headers=self.te_headers("delete_webhook_operation", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_webhook_operation_error_500(self) -> None: + """Integration test for delete_webhook_operation error path (HTTP 500)""" + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.delete_webhook_operation( + + id=id, + + aid=aid, + + _headers=self.te_headers("delete_webhook_operation", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_webhook_operation_happy_path(self) -> None: + """Integration test for get_webhook_operation success path""" + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + aid = '1234' + response_body_json = """ + { + "path" : "/custom/path", + "headers" : [ { + "name" : "Content-Type", + "value" : "application/json" + }, { + "name" : "Content-Type", + "value" : "application/json" + } ], + "payload" : "{\\"property1\\": {{numericVar}}, \\"property2\\": \\"{{stringVar}}\\"}", + "queryParams" : "{\\"queryParam1\\":\\"{{stringVar}}\\"}", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "My operation", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "category" : "alerts", + "type" : "webhook", + "enabled" : true, + "status" : "pending" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_webhook_operation( + + id=id, + + aid=aid, + + _headers=self.te_headers("get_webhook_operation"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_webhook_operation_error_400(self) -> None: + """Integration test for get_webhook_operation error path (HTTP 400)""" + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.get_webhook_operation( + + id=id, + + aid=aid, + + _headers=self.te_headers("get_webhook_operation", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_webhook_operation_error_401(self) -> None: + """Integration test for get_webhook_operation error path (HTTP 401)""" + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_webhook_operation( + + id=id, + + aid=aid, + + _headers=self.te_headers("get_webhook_operation", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_webhook_operation_error_403(self) -> None: + """Integration test for get_webhook_operation error path (HTTP 403)""" + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_webhook_operation( + + id=id, + + aid=aid, + + _headers=self.te_headers("get_webhook_operation", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_webhook_operation_error_404(self) -> None: + """Integration test for get_webhook_operation error path (HTTP 404)""" + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_webhook_operation( + + id=id, + + aid=aid, + + _headers=self.te_headers("get_webhook_operation", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_webhook_operation_error_500(self) -> None: + """Integration test for get_webhook_operation error path (HTTP 500)""" + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_webhook_operation( + + id=id, + + aid=aid, + + _headers=self.te_headers("get_webhook_operation", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_webhook_operations_happy_path(self) -> None: + """Integration test for get_webhook_operations success path""" + aid = '1234' + response_body_json = """ + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "items" : [ { + "path" : "/custom/path", + "headers" : [ { + "name" : "Content-Type", + "value" : "application/json" + }, { + "name" : "Content-Type", + "value" : "application/json" + } ], + "payload" : "{\\"property1\\": {{numericVar}}, \\"property2\\": \\"{{stringVar}}\\"}", + "queryParams" : "{\\"queryParam1\\":\\"{{stringVar}}\\"}", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "My operation", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "category" : "alerts", + "type" : "webhook", + "enabled" : true, + "status" : "pending" + }, { + "path" : "/custom/path", + "headers" : [ { + "name" : "Content-Type", + "value" : "application/json" + }, { + "name" : "Content-Type", + "value" : "application/json" + } ], + "payload" : "{\\"property1\\": {{numericVar}}, \\"property2\\": \\"{{stringVar}}\\"}", + "queryParams" : "{\\"queryParam1\\":\\"{{stringVar}}\\"}", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "My operation", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "category" : "alerts", + "type" : "webhook", + "enabled" : true, + "status" : "pending" + } ] + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_webhook_operations( + + aid=aid, + + _headers=self.te_headers("get_webhook_operations"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_webhook_operations_error_400(self) -> None: + """Integration test for get_webhook_operations error path (HTTP 400)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.get_webhook_operations( + + aid=aid, + + _headers=self.te_headers("get_webhook_operations", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_webhook_operations_error_401(self) -> None: + """Integration test for get_webhook_operations error path (HTTP 401)""" + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_webhook_operations( + + aid=aid, + + _headers=self.te_headers("get_webhook_operations", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_webhook_operations_error_403(self) -> None: + """Integration test for get_webhook_operations error path (HTTP 403)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_webhook_operations( + + aid=aid, + + _headers=self.te_headers("get_webhook_operations", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_webhook_operations_error_404(self) -> None: + """Integration test for get_webhook_operations error path (HTTP 404)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_webhook_operations( + + aid=aid, + + _headers=self.te_headers("get_webhook_operations", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_webhook_operations_error_500(self) -> None: + """Integration test for get_webhook_operations error path (HTTP 500)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_webhook_operations( + + aid=aid, + + _headers=self.te_headers("get_webhook_operations", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_update_webhook_operation_happy_path(self) -> None: + """Integration test for update_webhook_operation success path""" + request_body_json = """ + + { + "path" : "/custom/path", + "headers" : [ { + "name" : "Content-Type", + "value" : "application/json" + }, { + "name" : "Content-Type", + "value" : "application/json" + } ], + "payload" : "{\\"property1\\": {{numericVar}}, \\"property2\\": \\"{{stringVar}}\\"}", + "queryParams" : "{\\"queryParam1\\":\\"{{stringVar}}\\"}", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "My operation", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "category" : "alerts", + "type" : "webhook", + "enabled" : true, + "status" : "pending" + } + + """ + webhook_operation = thousandeyes_sdk.connectors.models.WebhookOperation.from_json(request_body_json) + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + aid = '1234' + response_body_json = """ + { + "path" : "/custom/path", + "headers" : [ { + "name" : "Content-Type", + "value" : "application/json" + }, { + "name" : "Content-Type", + "value" : "application/json" + } ], + "payload" : "{\\"property1\\": {{numericVar}}, \\"property2\\": \\"{{stringVar}}\\"}", + "queryParams" : "{\\"queryParam1\\":\\"{{stringVar}}\\"}", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "My operation", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "category" : "alerts", + "type" : "webhook", + "enabled" : true, + "status" : "pending" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.update_webhook_operation( + + id=id, + + webhook_operation=webhook_operation, + + aid=aid, + + _headers=self.te_headers("update_webhook_operation"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_update_webhook_operation_error_400(self) -> None: + """Integration test for update_webhook_operation error path (HTTP 400)""" + request_body_json = """ + + { + "path" : "/custom/path", + "headers" : [ { + "name" : "Content-Type", + "value" : "application/json" + }, { + "name" : "Content-Type", + "value" : "application/json" + } ], + "payload" : "{\\"property1\\": {{numericVar}}, \\"property2\\": \\"{{stringVar}}\\"}", + "queryParams" : "{\\"queryParam1\\":\\"{{stringVar}}\\"}", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "My operation", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "category" : "alerts", + "type" : "webhook", + "enabled" : true, + "status" : "pending" + } + + """ + webhook_operation = thousandeyes_sdk.connectors.models.WebhookOperation.from_json(request_body_json) + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.update_webhook_operation( + + id=id, + + webhook_operation=webhook_operation, + + aid=aid, + + _headers=self.te_headers("update_webhook_operation", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_webhook_operation_error_401(self) -> None: + """Integration test for update_webhook_operation error path (HTTP 401)""" + request_body_json = """ + + { + "path" : "/custom/path", + "headers" : [ { + "name" : "Content-Type", + "value" : "application/json" + }, { + "name" : "Content-Type", + "value" : "application/json" + } ], + "payload" : "{\\"property1\\": {{numericVar}}, \\"property2\\": \\"{{stringVar}}\\"}", + "queryParams" : "{\\"queryParam1\\":\\"{{stringVar}}\\"}", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "My operation", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "category" : "alerts", + "type" : "webhook", + "enabled" : true, + "status" : "pending" + } + + """ + webhook_operation = thousandeyes_sdk.connectors.models.WebhookOperation.from_json(request_body_json) + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.update_webhook_operation( + + id=id, + + webhook_operation=webhook_operation, + + aid=aid, + + _headers=self.te_headers("update_webhook_operation", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_webhook_operation_error_403(self) -> None: + """Integration test for update_webhook_operation error path (HTTP 403)""" + request_body_json = """ + + { + "path" : "/custom/path", + "headers" : [ { + "name" : "Content-Type", + "value" : "application/json" + }, { + "name" : "Content-Type", + "value" : "application/json" + } ], + "payload" : "{\\"property1\\": {{numericVar}}, \\"property2\\": \\"{{stringVar}}\\"}", + "queryParams" : "{\\"queryParam1\\":\\"{{stringVar}}\\"}", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "My operation", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "category" : "alerts", + "type" : "webhook", + "enabled" : true, + "status" : "pending" + } + + """ + webhook_operation = thousandeyes_sdk.connectors.models.WebhookOperation.from_json(request_body_json) + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.update_webhook_operation( + + id=id, + + webhook_operation=webhook_operation, + + aid=aid, + + _headers=self.te_headers("update_webhook_operation", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_webhook_operation_error_404(self) -> None: + """Integration test for update_webhook_operation error path (HTTP 404)""" + request_body_json = """ + + { + "path" : "/custom/path", + "headers" : [ { + "name" : "Content-Type", + "value" : "application/json" + }, { + "name" : "Content-Type", + "value" : "application/json" + } ], + "payload" : "{\\"property1\\": {{numericVar}}, \\"property2\\": \\"{{stringVar}}\\"}", + "queryParams" : "{\\"queryParam1\\":\\"{{stringVar}}\\"}", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "My operation", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "category" : "alerts", + "type" : "webhook", + "enabled" : true, + "status" : "pending" + } + + """ + webhook_operation = thousandeyes_sdk.connectors.models.WebhookOperation.from_json(request_body_json) + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.update_webhook_operation( + + id=id, + + webhook_operation=webhook_operation, + + aid=aid, + + _headers=self.te_headers("update_webhook_operation", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_webhook_operation_error_500(self) -> None: + """Integration test for update_webhook_operation error path (HTTP 500)""" + request_body_json = """ + + { + "path" : "/custom/path", + "headers" : [ { + "name" : "Content-Type", + "value" : "application/json" + }, { + "name" : "Content-Type", + "value" : "application/json" + } ], + "payload" : "{\\"property1\\": {{numericVar}}, \\"property2\\": \\"{{stringVar}}\\"}", + "queryParams" : "{\\"queryParam1\\":\\"{{stringVar}}\\"}", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "My operation", + "id" : "cb1b8033-ea2d-4e9b-a920-fe87850693cf", + "category" : "alerts", + "type" : "webhook", + "enabled" : true, + "status" : "pending" + } + + """ + webhook_operation = thousandeyes_sdk.connectors.models.WebhookOperation.from_json(request_body_json) + id = 'cb1b8033-ea2d-4e9b-a920-fe87850693cf' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.update_webhook_operation( + + id=id, + + webhook_operation=webhook_operation, + + aid=aid, + + _headers=self.te_headers("update_webhook_operation", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-credentials/test/conftest.py b/thousandeyes-sdk-credentials/test/conftest.py new file mode 100644 index 00000000..2edba7b3 --- /dev/null +++ b/thousandeyes-sdk-credentials/test/conftest.py @@ -0,0 +1,7 @@ +import sys +from pathlib import Path + +_repo_root = Path(__file__).resolve().parents[2] +_core_test_support = _repo_root / "thousandeyes-sdk-core" / "test" +if str(_core_test_support) not in sys.path: + sys.path.insert(0, str(_core_test_support)) diff --git a/thousandeyes-sdk-credentials/test/integration_test_utils.py b/thousandeyes-sdk-credentials/test/integration_test_utils.py new file mode 100644 index 00000000..68f51d3e --- /dev/null +++ b/thousandeyes-sdk-credentials/test/integration_test_utils.py @@ -0,0 +1,37 @@ +# coding: utf-8 + +""" + Credentials API + + Manage credentials for transaction tests using the Credentials API. The following permissions are required to access Credentials API operations: * `Settings Tests Read` for read operations. * `Settings Tests Update` for write operations. * `View sensitive data in web transaction scripts` to view the encrypted value property of credentials. * `Settings Tests Create Transaction (Tx) Tests` to create credentials. For more information about credentials, see [Working With Secure Credentials](https://docs.thousandeyes.com/product-documentation/browser-synthetics/transaction-tests/getting-started/working-with-secure-credentials). + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from thousandeyes_sdk.core.api_client import ApiClient +from thousandeyes_sdk.core.configuration import Configuration +from sdk_test_support.mock_server import ERROR_STATUS_HEADER, OPERATION_ID_HEADER, MockApiServer + +from .mock_manifest import OPERATION_MANIFEST + + +class IntegrationTestBase(unittest.TestCase): + def setUp(self) -> None: + self.server = MockApiServer(OPERATION_MANIFEST) + self.server.start() + configuration = Configuration(host=self.server.base_url, access_token="test-token") + self.api_client = ApiClient(configuration=configuration) + + def tearDown(self) -> None: + self.server.stop() + + def te_headers(self, operation_id: str, error_status=None): + headers = {OPERATION_ID_HEADER: operation_id} + if error_status is not None: + headers[ERROR_STATUS_HEADER] = error_status + return headers diff --git a/thousandeyes-sdk-credentials/test/mock_manifest.py b/thousandeyes-sdk-credentials/test/mock_manifest.py new file mode 100644 index 00000000..60292339 --- /dev/null +++ b/thousandeyes-sdk-credentials/test/mock_manifest.py @@ -0,0 +1,604 @@ +# coding: utf-8 + +""" + Credentials API + + Manage credentials for transaction tests using the Credentials API. The following permissions are required to access Credentials API operations: * `Settings Tests Read` for read operations. * `Settings Tests Update` for write operations. * `View sensitive data in web transaction scripts` to view the encrypted value property of credentials. * `Settings Tests Create Transaction (Tx) Tests` to create credentials. For more information about credentials, see [Working With Secure Credentials](https://docs.thousandeyes.com/product-documentation/browser-synthetics/transaction-tests/getting-started/working-with-secure-credentials). + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json + +from sdk_test_support.mock_server_types import ErrorResponseExpectation, OperationExpectation + +OPERATION_MANIFEST = { + + "create_credential": OperationExpectation( + operation_id="create_credential", + method="POST", + path="/credentials", + path_param_examples={ + }, + success_status=201, + success_body=json.loads(""" + + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "Example Credential", + "id" : "3247" + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "name" : "Example Credential 1", + "value" : "Example Credential 1 Password" + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "delete_credential": OperationExpectation( + operation_id="delete_credential", + method="DELETE", + path="/credentials/{id}", + path_param_examples={ + "id": '3247', + }, + success_status=204, + success_body=None, + success_content_type="application/json", + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_credential": OperationExpectation( + operation_id="get_credential", + method="GET", + path="/credentials/{id}", + path_param_examples={ + "id": '3247', + }, + success_status=200, + success_body=json.loads(""" + + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "Example Credential", + "id" : "3247", + "value" : "rwhR12uDm1Im47p5IVXgzz4ORgC7m48ajzzeWVUt" + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_credentials": OperationExpectation( + operation_id="get_credentials", + method="GET", + path="/credentials", + path_param_examples={ + }, + success_status=200, + success_body=json.loads(""" + + { + "credentials" : [ { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "Example Credential", + "id" : "3247", + "value" : "rwhR12uDm1Im47p5IVXgzz4ORgC7m48ajzzeWVUt" + }, { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "Example Credential", + "id" : "3247", + "value" : "rwhR12uDm1Im47p5IVXgzz4ORgC7m48ajzzeWVUt" + } ], + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "update_credential": OperationExpectation( + operation_id="update_credential", + method="PUT", + path="/credentials/{id}", + path_param_examples={ + "id": '3247', + }, + success_status=200, + success_body=json.loads(""" + + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "Example Credential", + "id" : "3247" + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "name" : "Example Credential 1", + "value" : "Example Credential 1 Password" + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + +} diff --git a/thousandeyes-sdk-credentials/test/test_credentials_api_integration.py b/thousandeyes-sdk-credentials/test/test_credentials_api_integration.py new file mode 100644 index 00000000..2642639c --- /dev/null +++ b/thousandeyes-sdk-credentials/test/test_credentials_api_integration.py @@ -0,0 +1,1140 @@ +# coding: utf-8 + +""" + Credentials API + + Manage credentials for transaction tests using the Credentials API. The following permissions are required to access Credentials API operations: * `Settings Tests Read` for read operations. * `Settings Tests Update` for write operations. * `View sensitive data in web transaction scripts` to view the encrypted value property of credentials. * `Settings Tests Create Transaction (Tx) Tests` to create credentials. For more information about credentials, see [Working With Secure Credentials](https://docs.thousandeyes.com/product-documentation/browser-synthetics/transaction-tests/getting-started/working-with-secure-credentials). + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.credentials.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.credentials.api.credentials_api import CredentialsApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestCredentialsApiIntegration(IntegrationTestBase): + """CredentialsApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = CredentialsApi(self.api_client) + + + def test_create_credential_happy_path(self) -> None: + """Integration test for create_credential success path""" + request_body_json = """ + + { + "name" : "Example Credential 1", + "value" : "Example Credential 1 Password" + } + + """ + credential_request = thousandeyes_sdk.credentials.models.CredentialRequest.from_json(request_body_json) + aid = '1234' + response_body_json = """ + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "Example Credential", + "id" : "3247" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.create_credential( + + credential_request=credential_request, + + aid=aid, + + _headers=self.te_headers("create_credential"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_create_credential_error_400(self) -> None: + """Integration test for create_credential error path (HTTP 400)""" + request_body_json = """ + + { + "name" : "Example Credential 1", + "value" : "Example Credential 1 Password" + } + + """ + credential_request = thousandeyes_sdk.credentials.models.CredentialRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.create_credential( + + credential_request=credential_request, + + aid=aid, + + _headers=self.te_headers("create_credential", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_credential_error_401(self) -> None: + """Integration test for create_credential error path (HTTP 401)""" + request_body_json = """ + + { + "name" : "Example Credential 1", + "value" : "Example Credential 1 Password" + } + + """ + credential_request = thousandeyes_sdk.credentials.models.CredentialRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.create_credential( + + credential_request=credential_request, + + aid=aid, + + _headers=self.te_headers("create_credential", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_credential_error_403(self) -> None: + """Integration test for create_credential error path (HTTP 403)""" + request_body_json = """ + + { + "name" : "Example Credential 1", + "value" : "Example Credential 1 Password" + } + + """ + credential_request = thousandeyes_sdk.credentials.models.CredentialRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.create_credential( + + credential_request=credential_request, + + aid=aid, + + _headers=self.te_headers("create_credential", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_credential_error_404(self) -> None: + """Integration test for create_credential error path (HTTP 404)""" + request_body_json = """ + + { + "name" : "Example Credential 1", + "value" : "Example Credential 1 Password" + } + + """ + credential_request = thousandeyes_sdk.credentials.models.CredentialRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.create_credential( + + credential_request=credential_request, + + aid=aid, + + _headers=self.te_headers("create_credential", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_credential_error_429(self) -> None: + """Integration test for create_credential error path (HTTP 429)""" + request_body_json = """ + + { + "name" : "Example Credential 1", + "value" : "Example Credential 1 Password" + } + + """ + credential_request = thousandeyes_sdk.credentials.models.CredentialRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.create_credential( + + credential_request=credential_request, + + aid=aid, + + _headers=self.te_headers("create_credential", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_credential_error_500(self) -> None: + """Integration test for create_credential error path (HTTP 500)""" + request_body_json = """ + + { + "name" : "Example Credential 1", + "value" : "Example Credential 1 Password" + } + + """ + credential_request = thousandeyes_sdk.credentials.models.CredentialRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.create_credential( + + credential_request=credential_request, + + aid=aid, + + _headers=self.te_headers("create_credential", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_delete_credential_happy_path(self) -> None: + """Integration test for delete_credential success path""" + id = '3247' + aid = '1234' + response = self.api.delete_credential_with_http_info( + + id=id, + + aid=aid, + + _headers=self.te_headers("delete_credential"), + ) + self.assertEqual(204, response.status_code) + self.assertIsNone(response.data) + + + def test_delete_credential_error_401(self) -> None: + """Integration test for delete_credential error path (HTTP 401)""" + id = '3247' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.delete_credential( + + id=id, + + aid=aid, + + _headers=self.te_headers("delete_credential", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_credential_error_403(self) -> None: + """Integration test for delete_credential error path (HTTP 403)""" + id = '3247' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.delete_credential( + + id=id, + + aid=aid, + + _headers=self.te_headers("delete_credential", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_credential_error_404(self) -> None: + """Integration test for delete_credential error path (HTTP 404)""" + id = '3247' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.delete_credential( + + id=id, + + aid=aid, + + _headers=self.te_headers("delete_credential", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_credential_error_429(self) -> None: + """Integration test for delete_credential error path (HTTP 429)""" + id = '3247' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.delete_credential( + + id=id, + + aid=aid, + + _headers=self.te_headers("delete_credential", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_credential_error_500(self) -> None: + """Integration test for delete_credential error path (HTTP 500)""" + id = '3247' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.delete_credential( + + id=id, + + aid=aid, + + _headers=self.te_headers("delete_credential", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_credential_happy_path(self) -> None: + """Integration test for get_credential success path""" + id = '3247' + aid = '1234' + response_body_json = """ + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "Example Credential", + "id" : "3247", + "value" : "rwhR12uDm1Im47p5IVXgzz4ORgC7m48ajzzeWVUt" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_credential( + + id=id, + + aid=aid, + + _headers=self.te_headers("get_credential"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_credential_error_400(self) -> None: + """Integration test for get_credential error path (HTTP 400)""" + id = '3247' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.get_credential( + + id=id, + + aid=aid, + + _headers=self.te_headers("get_credential", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_credential_error_401(self) -> None: + """Integration test for get_credential error path (HTTP 401)""" + id = '3247' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_credential( + + id=id, + + aid=aid, + + _headers=self.te_headers("get_credential", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_credential_error_403(self) -> None: + """Integration test for get_credential error path (HTTP 403)""" + id = '3247' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_credential( + + id=id, + + aid=aid, + + _headers=self.te_headers("get_credential", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_credential_error_404(self) -> None: + """Integration test for get_credential error path (HTTP 404)""" + id = '3247' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_credential( + + id=id, + + aid=aid, + + _headers=self.te_headers("get_credential", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_credential_error_429(self) -> None: + """Integration test for get_credential error path (HTTP 429)""" + id = '3247' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_credential( + + id=id, + + aid=aid, + + _headers=self.te_headers("get_credential", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_credential_error_500(self) -> None: + """Integration test for get_credential error path (HTTP 500)""" + id = '3247' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_credential( + + id=id, + + aid=aid, + + _headers=self.te_headers("get_credential", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_credentials_happy_path(self) -> None: + """Integration test for get_credentials success path""" + aid = '1234' + response_body_json = """ + { + "credentials" : [ { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "Example Credential", + "id" : "3247", + "value" : "rwhR12uDm1Im47p5IVXgzz4ORgC7m48ajzzeWVUt" + }, { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "Example Credential", + "id" : "3247", + "value" : "rwhR12uDm1Im47p5IVXgzz4ORgC7m48ajzzeWVUt" + } ], + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_credentials( + + aid=aid, + + _headers=self.te_headers("get_credentials"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_credentials_error_401(self) -> None: + """Integration test for get_credentials error path (HTTP 401)""" + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_credentials( + + aid=aid, + + _headers=self.te_headers("get_credentials", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_credentials_error_403(self) -> None: + """Integration test for get_credentials error path (HTTP 403)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_credentials( + + aid=aid, + + _headers=self.te_headers("get_credentials", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_credentials_error_404(self) -> None: + """Integration test for get_credentials error path (HTTP 404)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_credentials( + + aid=aid, + + _headers=self.te_headers("get_credentials", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_credentials_error_429(self) -> None: + """Integration test for get_credentials error path (HTTP 429)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_credentials( + + aid=aid, + + _headers=self.te_headers("get_credentials", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_credentials_error_500(self) -> None: + """Integration test for get_credentials error path (HTTP 500)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_credentials( + + aid=aid, + + _headers=self.te_headers("get_credentials", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_update_credential_happy_path(self) -> None: + """Integration test for update_credential success path""" + request_body_json = """ + + { + "name" : "Example Credential 1", + "value" : "Example Credential 1 Password" + } + + """ + credential_request = thousandeyes_sdk.credentials.models.CredentialRequest.from_json(request_body_json) + id = '3247' + aid = '1234' + response_body_json = """ + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "Example Credential", + "id" : "3247" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.update_credential( + + id=id, + + credential_request=credential_request, + + aid=aid, + + _headers=self.te_headers("update_credential"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_update_credential_error_400(self) -> None: + """Integration test for update_credential error path (HTTP 400)""" + request_body_json = """ + + { + "name" : "Example Credential 1", + "value" : "Example Credential 1 Password" + } + + """ + credential_request = thousandeyes_sdk.credentials.models.CredentialRequest.from_json(request_body_json) + id = '3247' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.update_credential( + + id=id, + + credential_request=credential_request, + + aid=aid, + + _headers=self.te_headers("update_credential", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_credential_error_401(self) -> None: + """Integration test for update_credential error path (HTTP 401)""" + request_body_json = """ + + { + "name" : "Example Credential 1", + "value" : "Example Credential 1 Password" + } + + """ + credential_request = thousandeyes_sdk.credentials.models.CredentialRequest.from_json(request_body_json) + id = '3247' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.update_credential( + + id=id, + + credential_request=credential_request, + + aid=aid, + + _headers=self.te_headers("update_credential", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_credential_error_403(self) -> None: + """Integration test for update_credential error path (HTTP 403)""" + request_body_json = """ + + { + "name" : "Example Credential 1", + "value" : "Example Credential 1 Password" + } + + """ + credential_request = thousandeyes_sdk.credentials.models.CredentialRequest.from_json(request_body_json) + id = '3247' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.update_credential( + + id=id, + + credential_request=credential_request, + + aid=aid, + + _headers=self.te_headers("update_credential", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_credential_error_404(self) -> None: + """Integration test for update_credential error path (HTTP 404)""" + request_body_json = """ + + { + "name" : "Example Credential 1", + "value" : "Example Credential 1 Password" + } + + """ + credential_request = thousandeyes_sdk.credentials.models.CredentialRequest.from_json(request_body_json) + id = '3247' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.update_credential( + + id=id, + + credential_request=credential_request, + + aid=aid, + + _headers=self.te_headers("update_credential", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_credential_error_429(self) -> None: + """Integration test for update_credential error path (HTTP 429)""" + request_body_json = """ + + { + "name" : "Example Credential 1", + "value" : "Example Credential 1 Password" + } + + """ + credential_request = thousandeyes_sdk.credentials.models.CredentialRequest.from_json(request_body_json) + id = '3247' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.update_credential( + + id=id, + + credential_request=credential_request, + + aid=aid, + + _headers=self.te_headers("update_credential", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_credential_error_500(self) -> None: + """Integration test for update_credential error path (HTTP 500)""" + request_body_json = """ + + { + "name" : "Example Credential 1", + "value" : "Example Credential 1 Password" + } + + """ + credential_request = thousandeyes_sdk.credentials.models.CredentialRequest.from_json(request_body_json) + id = '3247' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.update_credential( + + id=id, + + credential_request=credential_request, + + aid=aid, + + _headers=self.te_headers("update_credential", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-credentials/test/test_utils.py b/thousandeyes-sdk-credentials/test/test_utils.py index 930528d9..37913f62 100644 --- a/thousandeyes-sdk-credentials/test/test_utils.py +++ b/thousandeyes-sdk-credentials/test/test_utils.py @@ -2,15 +2,36 @@ import json import unittest +from typing import Any from pydantic import BaseModel +def _project_onto_constructed(expected: Any, constructed: Any) -> Any: + """Keep only example fields that appear in the constructed model output.""" + if isinstance(constructed, dict): + if not isinstance(expected, dict): + return expected + return { + key: _project_onto_constructed(expected.get(key), value) + for key, value in constructed.items() + } + if isinstance(constructed, list): + if not isinstance(expected, list): + return expected + return [ + _project_onto_constructed(expected[index], value) + for index, value in enumerate(constructed) + ] + return expected + + def assert_constructed_model_matches_example_json(model: BaseModel, loaded_json: dict): test_case = unittest.TestCase() test_case.maxDiff = None test_case.assertIsNotNone(model) constructed_json = json.loads(model.to_json()) - sorted_loaded_json = json.dumps(loaded_json, sort_keys=True) + projected_loaded_json = _project_onto_constructed(loaded_json, constructed_json) + sorted_loaded_json = json.dumps(projected_loaded_json, sort_keys=True) sorted_constructed_json = json.dumps(constructed_json, sort_keys=True) test_case.assertEqual(sorted_loaded_json, sorted_constructed_json) diff --git a/thousandeyes-sdk-dashboards/test/conftest.py b/thousandeyes-sdk-dashboards/test/conftest.py new file mode 100644 index 00000000..2edba7b3 --- /dev/null +++ b/thousandeyes-sdk-dashboards/test/conftest.py @@ -0,0 +1,7 @@ +import sys +from pathlib import Path + +_repo_root = Path(__file__).resolve().parents[2] +_core_test_support = _repo_root / "thousandeyes-sdk-core" / "test" +if str(_core_test_support) not in sys.path: + sys.path.insert(0, str(_core_test_support)) diff --git a/thousandeyes-sdk-dashboards/test/integration_test_utils.py b/thousandeyes-sdk-dashboards/test/integration_test_utils.py new file mode 100644 index 00000000..752c1c5d --- /dev/null +++ b/thousandeyes-sdk-dashboards/test/integration_test_utils.py @@ -0,0 +1,37 @@ +# coding: utf-8 + +""" + Dashboards API + + Manage ThousandEyes Dashboards. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from thousandeyes_sdk.core.api_client import ApiClient +from thousandeyes_sdk.core.configuration import Configuration +from sdk_test_support.mock_server import ERROR_STATUS_HEADER, OPERATION_ID_HEADER, MockApiServer + +from .mock_manifest import OPERATION_MANIFEST + + +class IntegrationTestBase(unittest.TestCase): + def setUp(self) -> None: + self.server = MockApiServer(OPERATION_MANIFEST) + self.server.start() + configuration = Configuration(host=self.server.base_url, access_token="test-token") + self.api_client = ApiClient(configuration=configuration) + + def tearDown(self) -> None: + self.server.stop() + + def te_headers(self, operation_id: str, error_status=None): + headers = {OPERATION_ID_HEADER: operation_id} + if error_status is not None: + headers[ERROR_STATUS_HEADER] = error_status + return headers diff --git a/thousandeyes-sdk-dashboards/test/mock_manifest.py b/thousandeyes-sdk-dashboards/test/mock_manifest.py new file mode 100644 index 00000000..bf980ccd --- /dev/null +++ b/thousandeyes-sdk-dashboards/test/mock_manifest.py @@ -0,0 +1,5061 @@ +# coding: utf-8 + +""" + Dashboards API + + Manage ThousandEyes Dashboards. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json + +from sdk_test_support.mock_server_types import ErrorResponseExpectation, OperationExpectation + +OPERATION_MANIFEST = { + + "create_dashboard_snapshot": OperationExpectation( + operation_id="create_dashboard_snapshot", + method="POST", + path="/dashboard-snapshots", + path_param_examples={ + }, + success_status=201, + success_body=json.loads(""" + + { + "snapshotId" : "d28bb71f-5a47-4783-8f12-d4b115e61b0c", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "endDate" : "2023-05-16T10:14:28Z", + "dashboardId" : "646f4d2ce3c99b0536c3821e", + "displayName" : "snapshot from API", + "anonymizeData" : true, + "timezone" : "PST", + "startDate" : "2023-05-16T10:14:28Z", + "expirationDate" : "2023-05-16T10:14:28Z" + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "delete_dashboard_snapshot": OperationExpectation( + operation_id="delete_dashboard_snapshot", + method="DELETE", + path="/dashboard-snapshots/{snapshotId}", + path_param_examples={ + "snapshotId": 'd28bb71f-5a47-4783-8f12-d4b115e61b0c', + }, + success_status=204, + success_body=None, + success_content_type="application/json", + request_body_example=None, + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_dashboard_snapshot": OperationExpectation( + operation_id="get_dashboard_snapshot", + method="GET", + path="/dashboard-snapshots/{snapshotId}", + path_param_examples={ + "snapshotId": 'd28bb71f-5a47-4783-8f12-d4b115e61b0c', + }, + success_status=200, + success_body=json.loads(""" + + { + "snapshotId" : "d28bb71f-5a47-4783-8f12-d4b115e61b0c", + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "apiLinks" : [ { + "key" : "" + }, { + "key" : "" + } ], + "snapshotExpirationDate" : "2023-05-16T10:14:28Z", + "isScheduled" : true, + "widgets" : [ { + "embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f", + "shouldExcludeAlertSuppressionWindows" : true, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "visualMode" : "Full", + "filters" : { + "TEST" : [ 5187, 5227 ], + "ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ] + }, + "title" : "Widget Title", + "type" : "Agent Status", + "metricGroup" : "BGP", + "measure" : { + "percentileValue" : 95, + "type" : "MEAN" + }, + "apiLink" : "apiLink", + "metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT", + "isEmbedded" : true, + "id" : "1234", + "fixedTimespan" : { + "unit" : "Days", + "value" : 10 + }, + "dataSource" : "ENDPOINT_AGENTS", + "direction" : "FROM_TARGET" + }, { + "embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f", + "shouldExcludeAlertSuppressionWindows" : true, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "visualMode" : "Full", + "filters" : { + "TEST" : [ 5187, 5227 ], + "ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ] + }, + "title" : "Widget Title", + "type" : "Agent Status", + "metricGroup" : "BGP", + "measure" : { + "percentileValue" : 95, + "type" : "MEAN" + }, + "apiLink" : "apiLink", + "metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT", + "isEmbedded" : true, + "id" : "1234", + "fixedTimespan" : { + "unit" : "Days", + "value" : 10 + }, + "dataSource" : "ENDPOINT_AGENTS", + "direction" : "FROM_TARGET" + } ], + "accountId" : 1234, + "createdDate" : "2023-05-16 10:14:28", + "snapshotName" : "HTTP Server Dashboard Snapshot", + "timeSpan" : { + "duration" : 60, + "start" : "2023-05-16T10:14:28Z", + "startDate" : "2023-05-16 10:14:28" + }, + "permalink" : "https://app.thousandeyes.com/dashboard/?snapshotId=d28bb71f-5a47-4783-8f12-d4b115e61b0c", + "aid" : "1234", + "snapshotCreatedDate" : "2023-05-16T10:14:28Z", + "isShared" : true, + "dashboard" : { + "isMigratedReport" : false, + "dashboardCreatedBy" : "1", + "_links" : { + "snapshots" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isDefaultForUser" : true, + "description" : "HTTP Server Widgets", + "isPrivate" : true, + "title" : "HTTP Server Widgets", + "isBuiltIn" : true, + "widgets" : [ { + "embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f", + "shouldExcludeAlertSuppressionWindows" : true, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "visualMode" : "Full", + "filters" : { + "TEST" : [ 5187, 5227 ], + "ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ] + }, + "title" : "Widget Title", + "type" : "Agent Status", + "metricGroup" : "BGP", + "measure" : { + "percentileValue" : 95, + "type" : "MEAN" + }, + "apiLink" : "apiLink", + "metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT", + "isEmbedded" : true, + "id" : "1234", + "fixedTimespan" : { + "unit" : "Days", + "value" : 10 + }, + "dataSource" : "ENDPOINT_AGENTS", + "direction" : "FROM_TARGET" + }, { + "embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f", + "shouldExcludeAlertSuppressionWindows" : true, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "visualMode" : "Full", + "filters" : { + "TEST" : [ 5187, 5227 ], + "ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ] + }, + "title" : "Widget Title", + "type" : "Agent Status", + "metricGroup" : "BGP", + "measure" : { + "percentileValue" : 95, + "type" : "MEAN" + }, + "apiLink" : "apiLink", + "metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT", + "isEmbedded" : true, + "id" : "1234", + "fixedTimespan" : { + "unit" : "Days", + "value" : 10 + }, + "dataSource" : "ENDPOINT_AGENTS", + "direction" : "FROM_TARGET" + } ], + "globalFilterId" : "65babd9bb90bf55b17c96c8d", + "modifiedBy" : 1, + "dashboardModifiedBy" : "1", + "migratedReport" : false, + "isDefaultForAccount" : false, + "defaultTimespan" : { + "duration" : 7200, + "timespanDuration" : 7200, + "start" : "2023-05-16T10:14:28Z", + "end" : "2023-05-16T11:14:28Z", + "timespanStart" : "2023-05-16 10:14:28", + "timespanEnd" : "2023-05-16 11:14:28" + }, + "layout" : { + "layoutId" : "grid-layout-1", + "type" : "grid", + "details" : { + "widgetPositioning" : [ { + "x" : 0, + "y" : 0, + "w" : 9, + "h" : 5, + "id" : "widgetId-71lbb" + } ] + } + }, + "accountId" : 1234, + "apiLink" : [ { + "key" : "" + }, { + "key" : "" + } ], + "dashboardId" : "5e1f7a99143ae6004fdc3bb4", + "createdBy" : 1, + "globalOverride" : true, + "modifiedDate" : "2023-05-16 10:14:28", + "isGlobalOverride" : true, + "aid" : "1234", + "dashboardModifiedDate" : "2023-05-16T10:14:28Z" + }, + "expirationDate" : "2023-05-16 10:14:28" + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_dashboard_snapshot_widget_data": OperationExpectation( + operation_id="get_dashboard_snapshot_widget_data", + method="GET", + path="/dashboard-snapshots/{snapshotId}/widgets/{widgetId}", + path_param_examples={ + "snapshotId": 'd28bb71f-5a47-4783-8f12-d4b115e61b0c', + "widgetId": 'unpmg', + }, + success_status=200, + success_body=json.loads(""" + + { + "groupLabels" : [ { + "groupProperty" : "AGENT", + "groupLabels" : [ { + "groupId" : "2565", + "groupLabel" : "San Francisco, CA" + }, { + "groupId" : "2565", + "groupLabel" : "San Francisco, CA" + } ] + }, { + "groupProperty" : "AGENT", + "groupLabels" : [ { + "groupId" : "2565", + "groupLabel" : "San Francisco, CA" + }, { + "groupId" : "2565", + "groupLabel" : "San Francisco, CA" + } ] + } ], + "data" : { + "alerts" : [ { + "alertType" : "network-end-to-end-server", + "durationInSeconds" : 25, + "alertSource" : "Http Test", + "active" : true, + "testId" : "56512", + "startTime" : "2023-06-02T08:54:00Z", + "alertId" : "2004945", + "ruleId" : "281724", + "alertRule" : "Http Test Rule" + }, { + "alertType" : "network-end-to-end-server", + "durationInSeconds" : 25, + "alertSource" : "Http Test", + "active" : true, + "testId" : "56512", + "startTime" : "2023-06-02T08:54:00Z", + "alertId" : "2004945", + "ruleId" : "281724", + "alertRule" : "Http Test Rule" + } ], + "summary" : { + "offline" : 2, + "online" : 10, + "disabled" : 3 + }, + "totalAlerts" : 500, + "cards" : [ { + "numberOfDataPoints" : 24192, + "cardName" : "Card Name", + "endDate" : "2023-05-16T10:14:28Z", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "cardId" : "lrxxr", + "alertSuppressionWindows" : [ { + "testIds" : [ "281474976710661" ], + "repeatUnit" : "week", + "durationInSeconds" : 7200, + "repeat" : "custom", + "name" : "Test dashboards", + "repeatEvery" : 5, + "id" : "281474976710662", + "startTimes" : [ "2023-05-16T10:14:28Z" ] + }, { + "testIds" : [ "281474976710661" ], + "repeatUnit" : "week", + "durationInSeconds" : 7200, + "repeat" : "custom", + "name" : "Test dashboards", + "repeatEvery" : 5, + "id" : "281474976710662", + "startTimes" : [ "2023-05-16T10:14:28Z" ] + } ], + "binSize" : 3600, + "previousValue" : 500, + "value" : 100, + "startDate" : "2023-05-16T10:14:28Z", + "timestamp" : 1567620000, + "status" : "No data" + }, { + "numberOfDataPoints" : 24192, + "cardName" : "Card Name", + "endDate" : "2023-05-16T10:14:28Z", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "cardId" : "lrxxr", + "alertSuppressionWindows" : [ { + "testIds" : [ "281474976710661" ], + "repeatUnit" : "week", + "durationInSeconds" : 7200, + "repeat" : "custom", + "name" : "Test dashboards", + "repeatEvery" : 5, + "id" : "281474976710662", + "startTimes" : [ "2023-05-16T10:14:28Z" ] + }, { + "testIds" : [ "281474976710661" ], + "repeatUnit" : "week", + "durationInSeconds" : 7200, + "repeat" : "custom", + "name" : "Test dashboards", + "repeatEvery" : 5, + "id" : "281474976710662", + "startTimes" : [ "2023-05-16T10:14:28Z" ] + } ], + "binSize" : 3600, + "previousValue" : 500, + "value" : 100, + "startDate" : "2023-05-16T10:14:28Z", + "timestamp" : 1567620000, + "status" : "No data" + } ], + "tests" : [ { + "graphlets" : [ { + "metric" : "Availability", + "testId" : "68257", + "points" : [ { + "x" : 1580403900, + "y" : 128.249 + }, { + "x" : 1580403900, + "y" : 128.249 + } ] + }, { + "metric" : "Availability", + "testId" : "68257", + "points" : [ { + "x" : 1580403900, + "y" : 128.249 + }, { + "x" : 1580403900, + "y" : 128.249 + } ] + } ], + "alertCount" : 398, + "testType" : "Web - HTTP Server", + "testId" : "68256", + "isShared" : true, + "testName" : "Http Test Name", + "target" : "www.google.com" + }, { + "graphlets" : [ { + "metric" : "Availability", + "testId" : "68257", + "points" : [ { + "x" : 1580403900, + "y" : 128.249 + }, { + "x" : 1580403900, + "y" : 128.249 + } ] + }, { + "metric" : "Availability", + "testId" : "68257", + "points" : [ { + "x" : 1580403900, + "y" : 128.249 + }, { + "x" : 1580403900, + "y" : 128.249 + } ] + } ], + "alertCount" : 398, + "testType" : "Web - HTTP Server", + "testId" : "68256", + "isShared" : true, + "testName" : "Http Test Name", + "target" : "www.google.com" + } ], + "columns" : [ { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "columnId" : "938to", + "alertSuppressionWindows" : [ { + "testIds" : [ "281474976710661" ], + "repeatUnit" : "week", + "durationInSeconds" : 7200, + "repeat" : "custom", + "name" : "Test dashboards", + "repeatEvery" : 5, + "id" : "281474976710662", + "startTimes" : [ "2023-05-16T10:14:28Z" ] + }, { + "testIds" : [ "281474976710661" ], + "repeatUnit" : "week", + "durationInSeconds" : 7200, + "repeat" : "custom", + "name" : "Test dashboards", + "repeatEvery" : 5, + "id" : "281474976710662", + "startTimes" : [ "2023-05-16T10:14:28Z" ] + } ], + "binSize" : 3600, + "points" : [ { + "numberOfDataPoints" : 23304, + "groups" : [ { + "groupProperty" : "COUNTRY", + "groupValue" : "US" + }, { + "groupProperty" : "COUNTRY", + "groupValue" : "US" + } ], + "value" : 100, + "timestamp" : 1567620000 + }, { + "numberOfDataPoints" : 23304, + "groups" : [ { + "groupProperty" : "COUNTRY", + "groupValue" : "US" + }, { + "groupProperty" : "COUNTRY", + "groupValue" : "US" + } ], + "value" : 100, + "timestamp" : 1567620000 + } ], + "status" : "No data" + }, { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "columnId" : "938to", + "alertSuppressionWindows" : [ { + "testIds" : [ "281474976710661" ], + "repeatUnit" : "week", + "durationInSeconds" : 7200, + "repeat" : "custom", + "name" : "Test dashboards", + "repeatEvery" : 5, + "id" : "281474976710662", + "startTimes" : [ "2023-05-16T10:14:28Z" ] + }, { + "testIds" : [ "281474976710661" ], + "repeatUnit" : "week", + "durationInSeconds" : 7200, + "repeat" : "custom", + "name" : "Test dashboards", + "repeatEvery" : 5, + "id" : "281474976710662", + "startTimes" : [ "2023-05-16T10:14:28Z" ] + } ], + "binSize" : 3600, + "points" : [ { + "numberOfDataPoints" : 23304, + "groups" : [ { + "groupProperty" : "COUNTRY", + "groupValue" : "US" + }, { + "groupProperty" : "COUNTRY", + "groupValue" : "US" + } ], + "value" : 100, + "timestamp" : 1567620000 + }, { + "numberOfDataPoints" : 23304, + "groups" : [ { + "groupProperty" : "COUNTRY", + "groupValue" : "US" + }, { + "groupProperty" : "COUNTRY", + "groupValue" : "US" + } ], + "value" : 100, + "timestamp" : 1567620000 + } ], + "status" : "No data" + } ], + "alertSuppressionWindows" : [ { + "testIds" : [ "281474976710661" ], + "repeatUnit" : "week", + "durationInSeconds" : 7200, + "repeat" : "custom", + "name" : "Test dashboards", + "repeatEvery" : 5, + "id" : "281474976710662", + "startTimes" : [ "2023-05-16T10:14:28Z" ] + }, { + "testIds" : [ "281474976710661" ], + "repeatUnit" : "week", + "durationInSeconds" : 7200, + "repeat" : "custom", + "name" : "Test dashboards", + "repeatEvery" : 5, + "id" : "281474976710662", + "startTimes" : [ "2023-05-16T10:14:28Z" ] + } ], + "activeAlerts" : 483, + "startRound" : 1384309800, + "points" : [ { + "numberOfDataPoints" : 23304, + "groups" : [ { + "groupProperty" : "COUNTRY", + "groupValue" : "US" + }, { + "groupProperty" : "COUNTRY", + "groupValue" : "US" + } ], + "value" : 100, + "timestamp" : 1567620000 + }, { + "numberOfDataPoints" : 23304, + "groups" : [ { + "groupProperty" : "COUNTRY", + "groupValue" : "US" + }, { + "groupProperty" : "COUNTRY", + "groupValue" : "US" + } ], + "value" : 100, + "timestamp" : 1567620000 + } ], + "agents" : [ { + "agentId" : "6522", + "agentName" : "0c3898000117", + "location" : { + "locationName" : "San Francisco, California, US", + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "ipInfo" : { + "ipv6" : "ipv6", + "privateIp" : "172.58.92.31", + "operativeSystemVersion" : "operativeSystemVersion", + "publicIp" : "172.58.92.31" + }, + "status" : "online" + }, { + "agentId" : "6522", + "agentName" : "0c3898000117", + "location" : { + "locationName" : "San Francisco, California, US", + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "ipInfo" : { + "ipv6" : "ipv6", + "privateIp" : "172.58.92.31", + "operativeSystemVersion" : "operativeSystemVersion", + "publicIp" : "172.58.92.31" + }, + "status" : "online" + } ], + "status" : "No data" + }, + "endDate" : "2022-07-18T22:00:54Z", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "binSize" : 3600, + "startDate" : "2022-07-17T22:00:54Z" + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_dashboard_snapshots": OperationExpectation( + operation_id="get_dashboard_snapshots", + method="GET", + path="/dashboard-snapshots", + path_param_examples={ + }, + success_status=200, + success_body=json.loads(""" + + { + "pages" : { + "key" : "" + }, + "_links" : { + "next" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "previous" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dashboardSnapshots" : [ { + "snapshotId" : "d28bb71f-5a47-4783-8f12-d4b115e61b0c", + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "apiLinks" : [ { + "key" : "" + }, { + "key" : "" + } ], + "snapshotExpirationDate" : "2023-05-16T10:14:28Z", + "isScheduled" : true, + "widgets" : [ { + "embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f", + "shouldExcludeAlertSuppressionWindows" : true, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "visualMode" : "Full", + "filters" : { + "TEST" : [ 5187, 5227 ], + "ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ] + }, + "title" : "Widget Title", + "type" : "Agent Status", + "metricGroup" : "BGP", + "measure" : { + "percentileValue" : 95, + "type" : "MEAN" + }, + "apiLink" : "apiLink", + "metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT", + "isEmbedded" : true, + "id" : "1234", + "fixedTimespan" : { + "unit" : "Days", + "value" : 10 + }, + "dataSource" : "ENDPOINT_AGENTS", + "direction" : "FROM_TARGET" + }, { + "embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f", + "shouldExcludeAlertSuppressionWindows" : true, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "visualMode" : "Full", + "filters" : { + "TEST" : [ 5187, 5227 ], + "ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ] + }, + "title" : "Widget Title", + "type" : "Agent Status", + "metricGroup" : "BGP", + "measure" : { + "percentileValue" : 95, + "type" : "MEAN" + }, + "apiLink" : "apiLink", + "metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT", + "isEmbedded" : true, + "id" : "1234", + "fixedTimespan" : { + "unit" : "Days", + "value" : 10 + }, + "dataSource" : "ENDPOINT_AGENTS", + "direction" : "FROM_TARGET" + } ], + "accountId" : 1234, + "createdDate" : "2023-05-16 10:14:28", + "snapshotName" : "HTTP Server Dashboard Snapshot", + "timeSpan" : { + "duration" : 60, + "start" : "2023-05-16T10:14:28Z", + "startDate" : "2023-05-16 10:14:28" + }, + "permalink" : "https://app.thousandeyes.com/dashboard/?snapshotId=d28bb71f-5a47-4783-8f12-d4b115e61b0c", + "aid" : "1234", + "snapshotCreatedDate" : "2023-05-16T10:14:28Z", + "isShared" : true, + "dashboard" : { + "isMigratedReport" : false, + "dashboardCreatedBy" : "1", + "_links" : { + "snapshots" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isDefaultForUser" : true, + "description" : "HTTP Server Widgets", + "isPrivate" : true, + "title" : "HTTP Server Widgets", + "isBuiltIn" : true, + "widgets" : [ { + "embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f", + "shouldExcludeAlertSuppressionWindows" : true, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "visualMode" : "Full", + "filters" : { + "TEST" : [ 5187, 5227 ], + "ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ] + }, + "title" : "Widget Title", + "type" : "Agent Status", + "metricGroup" : "BGP", + "measure" : { + "percentileValue" : 95, + "type" : "MEAN" + }, + "apiLink" : "apiLink", + "metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT", + "isEmbedded" : true, + "id" : "1234", + "fixedTimespan" : { + "unit" : "Days", + "value" : 10 + }, + "dataSource" : "ENDPOINT_AGENTS", + "direction" : "FROM_TARGET" + }, { + "embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f", + "shouldExcludeAlertSuppressionWindows" : true, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "visualMode" : "Full", + "filters" : { + "TEST" : [ 5187, 5227 ], + "ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ] + }, + "title" : "Widget Title", + "type" : "Agent Status", + "metricGroup" : "BGP", + "measure" : { + "percentileValue" : 95, + "type" : "MEAN" + }, + "apiLink" : "apiLink", + "metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT", + "isEmbedded" : true, + "id" : "1234", + "fixedTimespan" : { + "unit" : "Days", + "value" : 10 + }, + "dataSource" : "ENDPOINT_AGENTS", + "direction" : "FROM_TARGET" + } ], + "globalFilterId" : "65babd9bb90bf55b17c96c8d", + "modifiedBy" : 1, + "dashboardModifiedBy" : "1", + "migratedReport" : false, + "isDefaultForAccount" : false, + "defaultTimespan" : { + "duration" : 7200, + "timespanDuration" : 7200, + "start" : "2023-05-16T10:14:28Z", + "end" : "2023-05-16T11:14:28Z", + "timespanStart" : "2023-05-16 10:14:28", + "timespanEnd" : "2023-05-16 11:14:28" + }, + "layout" : { + "layoutId" : "grid-layout-1", + "type" : "grid", + "details" : { + "widgetPositioning" : [ { + "x" : 0, + "y" : 0, + "w" : 9, + "h" : 5, + "id" : "widgetId-71lbb" + } ] + } + }, + "accountId" : 1234, + "apiLink" : [ { + "key" : "" + }, { + "key" : "" + } ], + "dashboardId" : "5e1f7a99143ae6004fdc3bb4", + "createdBy" : 1, + "globalOverride" : true, + "modifiedDate" : "2023-05-16 10:14:28", + "isGlobalOverride" : true, + "aid" : "1234", + "dashboardModifiedDate" : "2023-05-16T10:14:28Z" + }, + "expirationDate" : "2023-05-16 10:14:28" + }, { + "snapshotId" : "d28bb71f-5a47-4783-8f12-d4b115e61b0c", + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "apiLinks" : [ { + "key" : "" + }, { + "key" : "" + } ], + "snapshotExpirationDate" : "2023-05-16T10:14:28Z", + "isScheduled" : true, + "widgets" : [ { + "embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f", + "shouldExcludeAlertSuppressionWindows" : true, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "visualMode" : "Full", + "filters" : { + "TEST" : [ 5187, 5227 ], + "ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ] + }, + "title" : "Widget Title", + "type" : "Agent Status", + "metricGroup" : "BGP", + "measure" : { + "percentileValue" : 95, + "type" : "MEAN" + }, + "apiLink" : "apiLink", + "metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT", + "isEmbedded" : true, + "id" : "1234", + "fixedTimespan" : { + "unit" : "Days", + "value" : 10 + }, + "dataSource" : "ENDPOINT_AGENTS", + "direction" : "FROM_TARGET" + }, { + "embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f", + "shouldExcludeAlertSuppressionWindows" : true, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "visualMode" : "Full", + "filters" : { + "TEST" : [ 5187, 5227 ], + "ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ] + }, + "title" : "Widget Title", + "type" : "Agent Status", + "metricGroup" : "BGP", + "measure" : { + "percentileValue" : 95, + "type" : "MEAN" + }, + "apiLink" : "apiLink", + "metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT", + "isEmbedded" : true, + "id" : "1234", + "fixedTimespan" : { + "unit" : "Days", + "value" : 10 + }, + "dataSource" : "ENDPOINT_AGENTS", + "direction" : "FROM_TARGET" + } ], + "accountId" : 1234, + "createdDate" : "2023-05-16 10:14:28", + "snapshotName" : "HTTP Server Dashboard Snapshot", + "timeSpan" : { + "duration" : 60, + "start" : "2023-05-16T10:14:28Z", + "startDate" : "2023-05-16 10:14:28" + }, + "permalink" : "https://app.thousandeyes.com/dashboard/?snapshotId=d28bb71f-5a47-4783-8f12-d4b115e61b0c", + "aid" : "1234", + "snapshotCreatedDate" : "2023-05-16T10:14:28Z", + "isShared" : true, + "dashboard" : { + "isMigratedReport" : false, + "dashboardCreatedBy" : "1", + "_links" : { + "snapshots" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isDefaultForUser" : true, + "description" : "HTTP Server Widgets", + "isPrivate" : true, + "title" : "HTTP Server Widgets", + "isBuiltIn" : true, + "widgets" : [ { + "embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f", + "shouldExcludeAlertSuppressionWindows" : true, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "visualMode" : "Full", + "filters" : { + "TEST" : [ 5187, 5227 ], + "ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ] + }, + "title" : "Widget Title", + "type" : "Agent Status", + "metricGroup" : "BGP", + "measure" : { + "percentileValue" : 95, + "type" : "MEAN" + }, + "apiLink" : "apiLink", + "metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT", + "isEmbedded" : true, + "id" : "1234", + "fixedTimespan" : { + "unit" : "Days", + "value" : 10 + }, + "dataSource" : "ENDPOINT_AGENTS", + "direction" : "FROM_TARGET" + }, { + "embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f", + "shouldExcludeAlertSuppressionWindows" : true, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "visualMode" : "Full", + "filters" : { + "TEST" : [ 5187, 5227 ], + "ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ] + }, + "title" : "Widget Title", + "type" : "Agent Status", + "metricGroup" : "BGP", + "measure" : { + "percentileValue" : 95, + "type" : "MEAN" + }, + "apiLink" : "apiLink", + "metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT", + "isEmbedded" : true, + "id" : "1234", + "fixedTimespan" : { + "unit" : "Days", + "value" : 10 + }, + "dataSource" : "ENDPOINT_AGENTS", + "direction" : "FROM_TARGET" + } ], + "globalFilterId" : "65babd9bb90bf55b17c96c8d", + "modifiedBy" : 1, + "dashboardModifiedBy" : "1", + "migratedReport" : false, + "isDefaultForAccount" : false, + "defaultTimespan" : { + "duration" : 7200, + "timespanDuration" : 7200, + "start" : "2023-05-16T10:14:28Z", + "end" : "2023-05-16T11:14:28Z", + "timespanStart" : "2023-05-16 10:14:28", + "timespanEnd" : "2023-05-16 11:14:28" + }, + "layout" : { + "layoutId" : "grid-layout-1", + "type" : "grid", + "details" : { + "widgetPositioning" : [ { + "x" : 0, + "y" : 0, + "w" : 9, + "h" : 5, + "id" : "widgetId-71lbb" + } ] + } + }, + "accountId" : 1234, + "apiLink" : [ { + "key" : "" + }, { + "key" : "" + } ], + "dashboardId" : "5e1f7a99143ae6004fdc3bb4", + "createdBy" : 1, + "globalOverride" : true, + "modifiedDate" : "2023-05-16 10:14:28", + "isGlobalOverride" : true, + "aid" : "1234", + "dashboardModifiedDate" : "2023-05-16T10:14:28Z" + }, + "expirationDate" : "2023-05-16 10:14:28" + } ] + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "update_dashboard_snapshot_expiration_date": OperationExpectation( + operation_id="update_dashboard_snapshot_expiration_date", + method="PATCH", + path="/dashboard-snapshots/{snapshotId}", + path_param_examples={ + "snapshotId": 'd28bb71f-5a47-4783-8f12-d4b115e61b0c', + }, + success_status=204, + success_body=None, + success_content_type="application/json", + request_body_example=json.loads(""" + + { + "snapshotExpirationDate" : "2023-05-16T10:14:28Z", + "expirationDate" : "2023-05-16 10:14:28" + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "create_dashboard": OperationExpectation( + operation_id="create_dashboard", + method="POST", + path="/dashboards", + path_param_examples={ + }, + success_status=201, + success_body=json.loads(""" + + { + "isMigratedReport" : false, + "_links" : { + "snapshots" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isDefaultForAccount" : false, + "isDefaultForUser" : true, + "description" : "HTTP Server Widgets", + "isPrivate" : true, + "title" : "HTTP Server Widgets", + "isBuiltIn" : true, + "widgets" : [ { + "embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f", + "shouldExcludeAlertSuppressionWindows" : true, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "visualMode" : "Full", + "filters" : { + "TEST" : [ 5187, 5227 ], + "ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ] + }, + "title" : "Widget Title", + "type" : "Agent Status", + "metricGroup" : "BGP", + "measure" : { + "percentileValue" : 95, + "type" : "MEAN" + }, + "apiLink" : "apiLink", + "metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT", + "isEmbedded" : true, + "id" : "1234", + "fixedTimespan" : { + "unit" : "Days", + "value" : 10 + }, + "dataSource" : "ENDPOINT_AGENTS", + "direction" : "FROM_TARGET" + }, { + "embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f", + "shouldExcludeAlertSuppressionWindows" : true, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "visualMode" : "Full", + "filters" : { + "TEST" : [ 5187, 5227 ], + "ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ] + }, + "title" : "Widget Title", + "type" : "Agent Status", + "metricGroup" : "BGP", + "measure" : { + "percentileValue" : 95, + "type" : "MEAN" + }, + "apiLink" : "apiLink", + "metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT", + "isEmbedded" : true, + "id" : "1234", + "fixedTimespan" : { + "unit" : "Days", + "value" : 10 + }, + "dataSource" : "ENDPOINT_AGENTS", + "direction" : "FROM_TARGET" + } ], + "defaultTimespan" : { + "duration" : 7200, + "timespanDuration" : 7200, + "start" : "2023-05-16T10:14:28Z", + "end" : "2023-05-16T11:14:28Z", + "timespanStart" : "2023-05-16 10:14:28", + "timespanEnd" : "2023-05-16 11:14:28" + }, + "layout" : { + "layoutId" : "grid-layout-1", + "type" : "grid", + "details" : { + "widgetPositioning" : [ { + "x" : 0, + "y" : 0, + "w" : 9, + "h" : 5, + "id" : "widgetId-71lbb" + } ] + } + }, + "globalFilterId" : "65babd9bb90bf55b17c96c8d", + "dashboardId" : "5e1f7a99143ae6004fdc3bb4", + "createdBy" : "1", + "modifiedDate" : "2023-05-16T10:14:28Z", + "modifiedBy" : "1", + "isGlobalOverride" : true, + "aid" : "1234" + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "isMigratedReport" : false, + "_links" : { + "snapshots" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isDefaultForAccount" : false, + "isDefaultForUser" : true, + "description" : "HTTP Server Widgets", + "isPrivate" : true, + "title" : "HTTP Server Widgets", + "isBuiltIn" : true, + "widgets" : [ { + "embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f", + "shouldExcludeAlertSuppressionWindows" : true, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "visualMode" : "Full", + "filters" : { + "TEST" : [ 5187, 5227 ], + "ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ] + }, + "title" : "Widget Title", + "type" : "Agent Status", + "metricGroup" : "BGP", + "measure" : { + "percentileValue" : 95, + "type" : "MEAN" + }, + "apiLink" : "apiLink", + "metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT", + "isEmbedded" : true, + "id" : "1234", + "fixedTimespan" : { + "unit" : "Days", + "value" : 10 + }, + "dataSource" : "ENDPOINT_AGENTS", + "direction" : "FROM_TARGET" + }, { + "embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f", + "shouldExcludeAlertSuppressionWindows" : true, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "visualMode" : "Full", + "filters" : { + "TEST" : [ 5187, 5227 ], + "ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ] + }, + "title" : "Widget Title", + "type" : "Agent Status", + "metricGroup" : "BGP", + "measure" : { + "percentileValue" : 95, + "type" : "MEAN" + }, + "apiLink" : "apiLink", + "metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT", + "isEmbedded" : true, + "id" : "1234", + "fixedTimespan" : { + "unit" : "Days", + "value" : 10 + }, + "dataSource" : "ENDPOINT_AGENTS", + "direction" : "FROM_TARGET" + } ], + "defaultTimespan" : { + "duration" : 7200, + "timespanDuration" : 7200, + "start" : "2023-05-16T10:14:28Z", + "end" : "2023-05-16T11:14:28Z", + "timespanStart" : "2023-05-16 10:14:28", + "timespanEnd" : "2023-05-16 11:14:28" + }, + "layout" : { + "layoutId" : "grid-layout-1", + "type" : "grid", + "details" : { + "widgetPositioning" : [ { + "x" : 0, + "y" : 0, + "w" : 9, + "h" : 5, + "id" : "widgetId-71lbb" + } ] + } + }, + "globalFilterId" : "65babd9bb90bf55b17c96c8d", + "dashboardId" : "5e1f7a99143ae6004fdc3bb4", + "createdBy" : "1", + "modifiedDate" : "2023-05-16T10:14:28Z", + "modifiedBy" : "1", + "isGlobalOverride" : true, + "aid" : "1234" + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "delete_dashboard": OperationExpectation( + operation_id="delete_dashboard", + method="DELETE", + path="/dashboards/{dashboardId}", + path_param_examples={ + "dashboardId": '646f4d2ce3c99b0536c3821e', + }, + success_status=204, + success_body=None, + success_content_type="application/json", + request_body_example=None, + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_dashboard": OperationExpectation( + operation_id="get_dashboard", + method="GET", + path="/dashboards/{dashboardId}", + path_param_examples={ + "dashboardId": '646f4d2ce3c99b0536c3821e', + }, + success_status=200, + success_body=json.loads(""" + + { + "isMigratedReport" : false, + "dashboardCreatedBy" : "1", + "_links" : { + "snapshots" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isDefaultForUser" : true, + "description" : "HTTP Server Widgets", + "isPrivate" : true, + "title" : "HTTP Server Widgets", + "isBuiltIn" : true, + "widgets" : [ { + "embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f", + "shouldExcludeAlertSuppressionWindows" : true, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "visualMode" : "Full", + "filters" : { + "TEST" : [ 5187, 5227 ], + "ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ] + }, + "title" : "Widget Title", + "type" : "Agent Status", + "metricGroup" : "BGP", + "measure" : { + "percentileValue" : 95, + "type" : "MEAN" + }, + "apiLink" : "apiLink", + "metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT", + "isEmbedded" : true, + "id" : "1234", + "fixedTimespan" : { + "unit" : "Days", + "value" : 10 + }, + "dataSource" : "ENDPOINT_AGENTS", + "direction" : "FROM_TARGET" + }, { + "embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f", + "shouldExcludeAlertSuppressionWindows" : true, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "visualMode" : "Full", + "filters" : { + "TEST" : [ 5187, 5227 ], + "ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ] + }, + "title" : "Widget Title", + "type" : "Agent Status", + "metricGroup" : "BGP", + "measure" : { + "percentileValue" : 95, + "type" : "MEAN" + }, + "apiLink" : "apiLink", + "metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT", + "isEmbedded" : true, + "id" : "1234", + "fixedTimespan" : { + "unit" : "Days", + "value" : 10 + }, + "dataSource" : "ENDPOINT_AGENTS", + "direction" : "FROM_TARGET" + } ], + "globalFilterId" : "65babd9bb90bf55b17c96c8d", + "modifiedBy" : 1, + "dashboardModifiedBy" : "1", + "migratedReport" : false, + "isDefaultForAccount" : false, + "defaultTimespan" : { + "duration" : 7200, + "timespanDuration" : 7200, + "start" : "2023-05-16T10:14:28Z", + "end" : "2023-05-16T11:14:28Z", + "timespanStart" : "2023-05-16 10:14:28", + "timespanEnd" : "2023-05-16 11:14:28" + }, + "layout" : { + "layoutId" : "grid-layout-1", + "type" : "grid", + "details" : { + "widgetPositioning" : [ { + "x" : 0, + "y" : 0, + "w" : 9, + "h" : 5, + "id" : "widgetId-71lbb" + } ] + } + }, + "accountId" : 1234, + "apiLink" : [ { + "key" : "" + }, { + "key" : "" + } ], + "dashboardId" : "5e1f7a99143ae6004fdc3bb4", + "createdBy" : 1, + "globalOverride" : true, + "modifiedDate" : "2023-05-16 10:14:28", + "isGlobalOverride" : true, + "aid" : "1234", + "dashboardModifiedDate" : "2023-05-16T10:14:28Z" + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_dashboard_widget_data": OperationExpectation( + operation_id="get_dashboard_widget_data", + method="GET", + path="/dashboards/{dashboardId}/widgets/{widgetId}", + path_param_examples={ + "dashboardId": '646f4d2ce3c99b0536c3821e', + "widgetId": 'unpmg', + }, + success_status=200, + success_body=json.loads(""" + + { + "groupLabels" : [ { + "groupProperty" : "AGENT", + "groupLabels" : [ { + "groupId" : "2565", + "groupLabel" : "San Francisco, CA" + }, { + "groupId" : "2565", + "groupLabel" : "San Francisco, CA" + } ] + }, { + "groupProperty" : "AGENT", + "groupLabels" : [ { + "groupId" : "2565", + "groupLabel" : "San Francisco, CA" + }, { + "groupId" : "2565", + "groupLabel" : "San Francisco, CA" + } ] + } ], + "data" : { + "alerts" : [ { + "alertType" : "network-end-to-end-server", + "durationInSeconds" : 25, + "alertSource" : "Http Test", + "active" : true, + "testId" : "56512", + "startTime" : "2023-06-02T08:54:00Z", + "alertId" : "2004945", + "ruleId" : "281724", + "alertRule" : "Http Test Rule" + }, { + "alertType" : "network-end-to-end-server", + "durationInSeconds" : 25, + "alertSource" : "Http Test", + "active" : true, + "testId" : "56512", + "startTime" : "2023-06-02T08:54:00Z", + "alertId" : "2004945", + "ruleId" : "281724", + "alertRule" : "Http Test Rule" + } ], + "summary" : { + "offline" : 2, + "online" : 10, + "disabled" : 3 + }, + "totalAlerts" : 500, + "cards" : [ { + "numberOfDataPoints" : 24192, + "cardName" : "Card Name", + "endDate" : "2023-05-16T10:14:28Z", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "cardId" : "lrxxr", + "alertSuppressionWindows" : [ { + "testIds" : [ "281474976710661" ], + "repeatUnit" : "week", + "durationInSeconds" : 7200, + "repeat" : "custom", + "name" : "Test dashboards", + "repeatEvery" : 5, + "id" : "281474976710662", + "startTimes" : [ "2023-05-16T10:14:28Z" ] + }, { + "testIds" : [ "281474976710661" ], + "repeatUnit" : "week", + "durationInSeconds" : 7200, + "repeat" : "custom", + "name" : "Test dashboards", + "repeatEvery" : 5, + "id" : "281474976710662", + "startTimes" : [ "2023-05-16T10:14:28Z" ] + } ], + "binSize" : 3600, + "previousValue" : 500, + "value" : 100, + "startDate" : "2023-05-16T10:14:28Z", + "timestamp" : 1567620000, + "status" : "No data" + }, { + "numberOfDataPoints" : 24192, + "cardName" : "Card Name", + "endDate" : "2023-05-16T10:14:28Z", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "cardId" : "lrxxr", + "alertSuppressionWindows" : [ { + "testIds" : [ "281474976710661" ], + "repeatUnit" : "week", + "durationInSeconds" : 7200, + "repeat" : "custom", + "name" : "Test dashboards", + "repeatEvery" : 5, + "id" : "281474976710662", + "startTimes" : [ "2023-05-16T10:14:28Z" ] + }, { + "testIds" : [ "281474976710661" ], + "repeatUnit" : "week", + "durationInSeconds" : 7200, + "repeat" : "custom", + "name" : "Test dashboards", + "repeatEvery" : 5, + "id" : "281474976710662", + "startTimes" : [ "2023-05-16T10:14:28Z" ] + } ], + "binSize" : 3600, + "previousValue" : 500, + "value" : 100, + "startDate" : "2023-05-16T10:14:28Z", + "timestamp" : 1567620000, + "status" : "No data" + } ], + "tests" : [ { + "graphlets" : [ { + "metric" : "Availability", + "testId" : "68257", + "points" : [ { + "x" : 1580403900, + "y" : 128.249 + }, { + "x" : 1580403900, + "y" : 128.249 + } ] + }, { + "metric" : "Availability", + "testId" : "68257", + "points" : [ { + "x" : 1580403900, + "y" : 128.249 + }, { + "x" : 1580403900, + "y" : 128.249 + } ] + } ], + "alertCount" : 398, + "testType" : "Web - HTTP Server", + "testId" : "68256", + "isShared" : true, + "testName" : "Http Test Name", + "target" : "www.google.com" + }, { + "graphlets" : [ { + "metric" : "Availability", + "testId" : "68257", + "points" : [ { + "x" : 1580403900, + "y" : 128.249 + }, { + "x" : 1580403900, + "y" : 128.249 + } ] + }, { + "metric" : "Availability", + "testId" : "68257", + "points" : [ { + "x" : 1580403900, + "y" : 128.249 + }, { + "x" : 1580403900, + "y" : 128.249 + } ] + } ], + "alertCount" : 398, + "testType" : "Web - HTTP Server", + "testId" : "68256", + "isShared" : true, + "testName" : "Http Test Name", + "target" : "www.google.com" + } ], + "columns" : [ { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "columnId" : "938to", + "alertSuppressionWindows" : [ { + "testIds" : [ "281474976710661" ], + "repeatUnit" : "week", + "durationInSeconds" : 7200, + "repeat" : "custom", + "name" : "Test dashboards", + "repeatEvery" : 5, + "id" : "281474976710662", + "startTimes" : [ "2023-05-16T10:14:28Z" ] + }, { + "testIds" : [ "281474976710661" ], + "repeatUnit" : "week", + "durationInSeconds" : 7200, + "repeat" : "custom", + "name" : "Test dashboards", + "repeatEvery" : 5, + "id" : "281474976710662", + "startTimes" : [ "2023-05-16T10:14:28Z" ] + } ], + "binSize" : 3600, + "points" : [ { + "numberOfDataPoints" : 23304, + "groups" : [ { + "groupProperty" : "COUNTRY", + "groupValue" : "US" + }, { + "groupProperty" : "COUNTRY", + "groupValue" : "US" + } ], + "value" : 100, + "timestamp" : 1567620000 + }, { + "numberOfDataPoints" : 23304, + "groups" : [ { + "groupProperty" : "COUNTRY", + "groupValue" : "US" + }, { + "groupProperty" : "COUNTRY", + "groupValue" : "US" + } ], + "value" : 100, + "timestamp" : 1567620000 + } ], + "status" : "No data" + }, { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "columnId" : "938to", + "alertSuppressionWindows" : [ { + "testIds" : [ "281474976710661" ], + "repeatUnit" : "week", + "durationInSeconds" : 7200, + "repeat" : "custom", + "name" : "Test dashboards", + "repeatEvery" : 5, + "id" : "281474976710662", + "startTimes" : [ "2023-05-16T10:14:28Z" ] + }, { + "testIds" : [ "281474976710661" ], + "repeatUnit" : "week", + "durationInSeconds" : 7200, + "repeat" : "custom", + "name" : "Test dashboards", + "repeatEvery" : 5, + "id" : "281474976710662", + "startTimes" : [ "2023-05-16T10:14:28Z" ] + } ], + "binSize" : 3600, + "points" : [ { + "numberOfDataPoints" : 23304, + "groups" : [ { + "groupProperty" : "COUNTRY", + "groupValue" : "US" + }, { + "groupProperty" : "COUNTRY", + "groupValue" : "US" + } ], + "value" : 100, + "timestamp" : 1567620000 + }, { + "numberOfDataPoints" : 23304, + "groups" : [ { + "groupProperty" : "COUNTRY", + "groupValue" : "US" + }, { + "groupProperty" : "COUNTRY", + "groupValue" : "US" + } ], + "value" : 100, + "timestamp" : 1567620000 + } ], + "status" : "No data" + } ], + "alertSuppressionWindows" : [ { + "testIds" : [ "281474976710661" ], + "repeatUnit" : "week", + "durationInSeconds" : 7200, + "repeat" : "custom", + "name" : "Test dashboards", + "repeatEvery" : 5, + "id" : "281474976710662", + "startTimes" : [ "2023-05-16T10:14:28Z" ] + }, { + "testIds" : [ "281474976710661" ], + "repeatUnit" : "week", + "durationInSeconds" : 7200, + "repeat" : "custom", + "name" : "Test dashboards", + "repeatEvery" : 5, + "id" : "281474976710662", + "startTimes" : [ "2023-05-16T10:14:28Z" ] + } ], + "activeAlerts" : 483, + "startRound" : 1384309800, + "points" : [ { + "numberOfDataPoints" : 23304, + "groups" : [ { + "groupProperty" : "COUNTRY", + "groupValue" : "US" + }, { + "groupProperty" : "COUNTRY", + "groupValue" : "US" + } ], + "value" : 100, + "timestamp" : 1567620000 + }, { + "numberOfDataPoints" : 23304, + "groups" : [ { + "groupProperty" : "COUNTRY", + "groupValue" : "US" + }, { + "groupProperty" : "COUNTRY", + "groupValue" : "US" + } ], + "value" : 100, + "timestamp" : 1567620000 + } ], + "agents" : [ { + "agentId" : "6522", + "agentName" : "0c3898000117", + "location" : { + "locationName" : "San Francisco, California, US", + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "ipInfo" : { + "ipv6" : "ipv6", + "privateIp" : "172.58.92.31", + "operativeSystemVersion" : "operativeSystemVersion", + "publicIp" : "172.58.92.31" + }, + "status" : "online" + }, { + "agentId" : "6522", + "agentName" : "0c3898000117", + "location" : { + "locationName" : "San Francisco, California, US", + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "ipInfo" : { + "ipv6" : "ipv6", + "privateIp" : "172.58.92.31", + "operativeSystemVersion" : "operativeSystemVersion", + "publicIp" : "172.58.92.31" + }, + "status" : "online" + } ], + "status" : "No data" + }, + "endDate" : "2022-07-18T22:00:54Z", + "_links" : { + "next" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "previous" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "binSize" : 3600, + "startDate" : "2022-07-17T22:00:54Z" + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_dashboards": OperationExpectation( + operation_id="get_dashboards", + method="GET", + path="/dashboards", + path_param_examples={ + }, + success_status=200, + success_body=json.loads(""" + + [ { + "isMigratedReport" : false, + "dashboardCreatedBy" : "1", + "_links" : { + "snapshots" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isDefaultForUser" : true, + "description" : "HTTP Server Widgets", + "isPrivate" : true, + "title" : "HTTP Server Widgets", + "isBuiltIn" : true, + "widgets" : [ { + "embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f", + "shouldExcludeAlertSuppressionWindows" : true, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "visualMode" : "Full", + "filters" : { + "TEST" : [ 5187, 5227 ], + "ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ] + }, + "title" : "Widget Title", + "type" : "Agent Status", + "metricGroup" : "BGP", + "measure" : { + "percentileValue" : 95, + "type" : "MEAN" + }, + "apiLink" : "apiLink", + "metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT", + "isEmbedded" : true, + "id" : "1234", + "fixedTimespan" : { + "unit" : "Days", + "value" : 10 + }, + "dataSource" : "ENDPOINT_AGENTS", + "direction" : "FROM_TARGET" + }, { + "embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f", + "shouldExcludeAlertSuppressionWindows" : true, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "visualMode" : "Full", + "filters" : { + "TEST" : [ 5187, 5227 ], + "ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ] + }, + "title" : "Widget Title", + "type" : "Agent Status", + "metricGroup" : "BGP", + "measure" : { + "percentileValue" : 95, + "type" : "MEAN" + }, + "apiLink" : "apiLink", + "metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT", + "isEmbedded" : true, + "id" : "1234", + "fixedTimespan" : { + "unit" : "Days", + "value" : 10 + }, + "dataSource" : "ENDPOINT_AGENTS", + "direction" : "FROM_TARGET" + } ], + "globalFilterId" : "65babd9bb90bf55b17c96c8d", + "modifiedBy" : 1, + "dashboardModifiedBy" : "1", + "migratedReport" : false, + "isDefaultForAccount" : false, + "defaultTimespan" : { + "duration" : 7200, + "timespanDuration" : 7200, + "start" : "2023-05-16T10:14:28Z", + "end" : "2023-05-16T11:14:28Z", + "timespanStart" : "2023-05-16 10:14:28", + "timespanEnd" : "2023-05-16 11:14:28" + }, + "layout" : { + "layoutId" : "grid-layout-1", + "type" : "grid", + "details" : { + "widgetPositioning" : [ { + "x" : 0, + "y" : 0, + "w" : 9, + "h" : 5, + "id" : "widgetId-71lbb" + } ] + } + }, + "accountId" : 1234, + "apiLink" : [ { + "key" : "" + }, { + "key" : "" + } ], + "dashboardId" : "5e1f7a99143ae6004fdc3bb4", + "createdBy" : 1, + "globalOverride" : true, + "modifiedDate" : "2023-05-16 10:14:28", + "isGlobalOverride" : true, + "aid" : "1234", + "dashboardModifiedDate" : "2023-05-16T10:14:28Z" + }, { + "isMigratedReport" : false, + "dashboardCreatedBy" : "1", + "_links" : { + "snapshots" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isDefaultForUser" : true, + "description" : "HTTP Server Widgets", + "isPrivate" : true, + "title" : "HTTP Server Widgets", + "isBuiltIn" : true, + "widgets" : [ { + "embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f", + "shouldExcludeAlertSuppressionWindows" : true, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "visualMode" : "Full", + "filters" : { + "TEST" : [ 5187, 5227 ], + "ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ] + }, + "title" : "Widget Title", + "type" : "Agent Status", + "metricGroup" : "BGP", + "measure" : { + "percentileValue" : 95, + "type" : "MEAN" + }, + "apiLink" : "apiLink", + "metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT", + "isEmbedded" : true, + "id" : "1234", + "fixedTimespan" : { + "unit" : "Days", + "value" : 10 + }, + "dataSource" : "ENDPOINT_AGENTS", + "direction" : "FROM_TARGET" + }, { + "embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f", + "shouldExcludeAlertSuppressionWindows" : true, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "visualMode" : "Full", + "filters" : { + "TEST" : [ 5187, 5227 ], + "ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ] + }, + "title" : "Widget Title", + "type" : "Agent Status", + "metricGroup" : "BGP", + "measure" : { + "percentileValue" : 95, + "type" : "MEAN" + }, + "apiLink" : "apiLink", + "metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT", + "isEmbedded" : true, + "id" : "1234", + "fixedTimespan" : { + "unit" : "Days", + "value" : 10 + }, + "dataSource" : "ENDPOINT_AGENTS", + "direction" : "FROM_TARGET" + } ], + "globalFilterId" : "65babd9bb90bf55b17c96c8d", + "modifiedBy" : 1, + "dashboardModifiedBy" : "1", + "migratedReport" : false, + "isDefaultForAccount" : false, + "defaultTimespan" : { + "duration" : 7200, + "timespanDuration" : 7200, + "start" : "2023-05-16T10:14:28Z", + "end" : "2023-05-16T11:14:28Z", + "timespanStart" : "2023-05-16 10:14:28", + "timespanEnd" : "2023-05-16 11:14:28" + }, + "layout" : { + "layoutId" : "grid-layout-1", + "type" : "grid", + "details" : { + "widgetPositioning" : [ { + "x" : 0, + "y" : 0, + "w" : 9, + "h" : 5, + "id" : "widgetId-71lbb" + } ] + } + }, + "accountId" : 1234, + "apiLink" : [ { + "key" : "" + }, { + "key" : "" + } ], + "dashboardId" : "5e1f7a99143ae6004fdc3bb4", + "createdBy" : 1, + "globalOverride" : true, + "modifiedDate" : "2023-05-16 10:14:28", + "isGlobalOverride" : true, + "aid" : "1234", + "dashboardModifiedDate" : "2023-05-16T10:14:28Z" + } ] + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_individual_card_data": OperationExpectation( + operation_id="get_individual_card_data", + method="GET", + path="/dashboards/{dashboardId}/widgets/{widgetId}/cards/{cardId}", + path_param_examples={ + "dashboardId": '646f4d2ce3c99b0536c3821e', + "widgetId": 'unpmg', + "cardId": 'rvwgs', + }, + success_status=200, + success_body=json.loads(""" + + { + "numberOfDataPoints" : 24192, + "cardName" : "Card Name", + "endDate" : "2023-05-16T10:14:28Z", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "cardId" : "lrxxr", + "alertSuppressionWindows" : [ { + "testIds" : [ "281474976710661" ], + "repeatUnit" : "week", + "durationInSeconds" : 7200, + "repeat" : "custom", + "name" : "Test dashboards", + "repeatEvery" : 5, + "id" : "281474976710662", + "startTimes" : [ "2023-05-16T10:14:28Z" ] + }, { + "testIds" : [ "281474976710661" ], + "repeatUnit" : "week", + "durationInSeconds" : 7200, + "repeat" : "custom", + "name" : "Test dashboards", + "repeatEvery" : 5, + "id" : "281474976710662", + "startTimes" : [ "2023-05-16T10:14:28Z" ] + } ], + "binSize" : 3600, + "previousValue" : 500, + "value" : 100, + "startDate" : "2023-05-16T10:14:28Z", + "timestamp" : 1567620000, + "status" : "No data" + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_individual_column_data": OperationExpectation( + operation_id="get_individual_column_data", + method="GET", + path="/dashboards/{dashboardId}/widgets/{widgetId}/columns/{columnId}", + path_param_examples={ + "dashboardId": '646f4d2ce3c99b0536c3821e', + "widgetId": 'unpmg', + "columnId": 'col123', + }, + success_status=200, + success_body=json.loads(""" + + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "columnId" : "938to", + "alertSuppressionWindows" : [ { + "testIds" : [ "281474976710661" ], + "repeatUnit" : "week", + "durationInSeconds" : 7200, + "repeat" : "custom", + "name" : "Test dashboards", + "repeatEvery" : 5, + "id" : "281474976710662", + "startTimes" : [ "2023-05-16T10:14:28Z" ] + }, { + "testIds" : [ "281474976710661" ], + "repeatUnit" : "week", + "durationInSeconds" : 7200, + "repeat" : "custom", + "name" : "Test dashboards", + "repeatEvery" : 5, + "id" : "281474976710662", + "startTimes" : [ "2023-05-16T10:14:28Z" ] + } ], + "binSize" : 3600, + "points" : [ { + "numberOfDataPoints" : 23304, + "groups" : [ { + "groupProperty" : "COUNTRY", + "groupValue" : "US" + }, { + "groupProperty" : "COUNTRY", + "groupValue" : "US" + } ], + "value" : 100, + "timestamp" : 1567620000 + }, { + "numberOfDataPoints" : 23304, + "groups" : [ { + "groupProperty" : "COUNTRY", + "groupValue" : "US" + }, { + "groupProperty" : "COUNTRY", + "groupValue" : "US" + } ], + "value" : 100, + "timestamp" : 1567620000 + } ], + "status" : "No data" + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "update_dashboard": OperationExpectation( + operation_id="update_dashboard", + method="PUT", + path="/dashboards/{dashboardId}", + path_param_examples={ + "dashboardId": '646f4d2ce3c99b0536c3821e', + }, + success_status=200, + success_body=json.loads(""" + + { + "isMigratedReport" : false, + "_links" : { + "snapshots" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isDefaultForAccount" : false, + "isDefaultForUser" : true, + "description" : "HTTP Server Widgets", + "isPrivate" : true, + "title" : "HTTP Server Widgets", + "isBuiltIn" : true, + "widgets" : [ { + "embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f", + "shouldExcludeAlertSuppressionWindows" : true, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "visualMode" : "Full", + "filters" : { + "TEST" : [ 5187, 5227 ], + "ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ] + }, + "title" : "Widget Title", + "type" : "Agent Status", + "metricGroup" : "BGP", + "measure" : { + "percentileValue" : 95, + "type" : "MEAN" + }, + "apiLink" : "apiLink", + "metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT", + "isEmbedded" : true, + "id" : "1234", + "fixedTimespan" : { + "unit" : "Days", + "value" : 10 + }, + "dataSource" : "ENDPOINT_AGENTS", + "direction" : "FROM_TARGET" + }, { + "embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f", + "shouldExcludeAlertSuppressionWindows" : true, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "visualMode" : "Full", + "filters" : { + "TEST" : [ 5187, 5227 ], + "ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ] + }, + "title" : "Widget Title", + "type" : "Agent Status", + "metricGroup" : "BGP", + "measure" : { + "percentileValue" : 95, + "type" : "MEAN" + }, + "apiLink" : "apiLink", + "metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT", + "isEmbedded" : true, + "id" : "1234", + "fixedTimespan" : { + "unit" : "Days", + "value" : 10 + }, + "dataSource" : "ENDPOINT_AGENTS", + "direction" : "FROM_TARGET" + } ], + "defaultTimespan" : { + "duration" : 7200, + "timespanDuration" : 7200, + "start" : "2023-05-16T10:14:28Z", + "end" : "2023-05-16T11:14:28Z", + "timespanStart" : "2023-05-16 10:14:28", + "timespanEnd" : "2023-05-16 11:14:28" + }, + "layout" : { + "layoutId" : "grid-layout-1", + "type" : "grid", + "details" : { + "widgetPositioning" : [ { + "x" : 0, + "y" : 0, + "w" : 9, + "h" : 5, + "id" : "widgetId-71lbb" + } ] + } + }, + "globalFilterId" : "65babd9bb90bf55b17c96c8d", + "dashboardId" : "5e1f7a99143ae6004fdc3bb4", + "createdBy" : "1", + "modifiedDate" : "2023-05-16T10:14:28Z", + "modifiedBy" : "1", + "isGlobalOverride" : true, + "aid" : "1234" + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "isMigratedReport" : false, + "_links" : { + "snapshots" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isDefaultForAccount" : false, + "isDefaultForUser" : true, + "description" : "HTTP Server Widgets", + "isPrivate" : true, + "title" : "HTTP Server Widgets", + "isBuiltIn" : true, + "widgets" : [ { + "embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f", + "shouldExcludeAlertSuppressionWindows" : true, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "visualMode" : "Full", + "filters" : { + "TEST" : [ 5187, 5227 ], + "ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ] + }, + "title" : "Widget Title", + "type" : "Agent Status", + "metricGroup" : "BGP", + "measure" : { + "percentileValue" : 95, + "type" : "MEAN" + }, + "apiLink" : "apiLink", + "metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT", + "isEmbedded" : true, + "id" : "1234", + "fixedTimespan" : { + "unit" : "Days", + "value" : 10 + }, + "dataSource" : "ENDPOINT_AGENTS", + "direction" : "FROM_TARGET" + }, { + "embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f", + "shouldExcludeAlertSuppressionWindows" : true, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "visualMode" : "Full", + "filters" : { + "TEST" : [ 5187, 5227 ], + "ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ] + }, + "title" : "Widget Title", + "type" : "Agent Status", + "metricGroup" : "BGP", + "measure" : { + "percentileValue" : 95, + "type" : "MEAN" + }, + "apiLink" : "apiLink", + "metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT", + "isEmbedded" : true, + "id" : "1234", + "fixedTimespan" : { + "unit" : "Days", + "value" : 10 + }, + "dataSource" : "ENDPOINT_AGENTS", + "direction" : "FROM_TARGET" + } ], + "defaultTimespan" : { + "duration" : 7200, + "timespanDuration" : 7200, + "start" : "2023-05-16T10:14:28Z", + "end" : "2023-05-16T11:14:28Z", + "timespanStart" : "2023-05-16 10:14:28", + "timespanEnd" : "2023-05-16 11:14:28" + }, + "layout" : { + "layoutId" : "grid-layout-1", + "type" : "grid", + "details" : { + "widgetPositioning" : [ { + "x" : 0, + "y" : 0, + "w" : 9, + "h" : 5, + "id" : "widgetId-71lbb" + } ] + } + }, + "globalFilterId" : "65babd9bb90bf55b17c96c8d", + "dashboardId" : "5e1f7a99143ae6004fdc3bb4", + "createdBy" : "1", + "modifiedDate" : "2023-05-16T10:14:28Z", + "modifiedBy" : "1", + "isGlobalOverride" : true, + "aid" : "1234" + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "create_dashboard_filter": OperationExpectation( + operation_id="create_dashboard_filter", + method="POST", + path="/dashboards/filters", + path_param_examples={ + }, + success_status=201, + success_body=json.loads(""" + + { + "createdDate" : "2024-02-01T22:19:19Z", + "createdBy" : { + "uid" : "1", + "name" : "Test User" + }, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "context" : [ { + "dataSourceId" : "VIRTUAL_AGENT", + "filters" : [ { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + }, { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + } ] + }, { + "dataSourceId" : "VIRTUAL_AGENT", + "filters" : [ { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + }, { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + } ] + } ], + "name" : "cea-filter", + "modifiedDate" : "2024-02-01T22:19:19Z", + "description" : "Global filter for CEA widgets", + "modifiedBy" : { + "uid" : "1", + "name" : "Test User" + }, + "id" : "65bc18e8f2073a4a469cd958", + "aid" : "11" + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "context" : [ { + "dataSourceId" : "VIRTUAL_AGENT", + "filters" : [ { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + }, { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + } ] + }, { + "dataSourceId" : "VIRTUAL_AGENT", + "filters" : [ { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + }, { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + } ] + } ], + "name" : "cea-filter", + "description" : "Global filter for CEA widgets" + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "delete_dashboard_filter": OperationExpectation( + operation_id="delete_dashboard_filter", + method="DELETE", + path="/dashboards/filters/{id}", + path_param_examples={ + "id": '65bc18e8f2073a4a469cd958', + }, + success_status=204, + success_body=None, + success_content_type="application/json", + request_body_example=None, + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_dashboard_filter": OperationExpectation( + operation_id="get_dashboard_filter", + method="GET", + path="/dashboards/filters/{id}", + path_param_examples={ + "id": '65bc18e8f2073a4a469cd958', + }, + success_status=200, + success_body=json.loads(""" + + { + "createdDate" : "2024-02-01T22:19:19Z", + "createdBy" : { + "uid" : "1", + "name" : "Test User" + }, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "context" : [ { + "dataSourceId" : "VIRTUAL_AGENT", + "filters" : [ { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + }, { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + } ] + }, { + "dataSourceId" : "VIRTUAL_AGENT", + "filters" : [ { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + }, { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + } ] + } ], + "name" : "cea-filter", + "modifiedDate" : "2024-02-01T22:19:19Z", + "description" : "Global filter for CEA widgets", + "modifiedBy" : { + "uid" : "1", + "name" : "Test User" + }, + "id" : "65bc18e8f2073a4a469cd958", + "aid" : "11" + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_dashboards_filters": OperationExpectation( + operation_id="get_dashboards_filters", + method="GET", + path="/dashboards/filters", + path_param_examples={ + }, + success_status=200, + success_body=json.loads(""" + + { + "dashboardFilters" : [ { + "createdDate" : "2024-02-01T22:19:19Z", + "createdBy" : { + "uid" : "1", + "name" : "Test User" + }, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "context" : [ { + "dataSourceId" : "VIRTUAL_AGENT", + "filters" : [ { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + }, { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + } ] + }, { + "dataSourceId" : "VIRTUAL_AGENT", + "filters" : [ { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + }, { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + } ] + } ], + "name" : "cea-filter", + "modifiedDate" : "2024-02-01T22:19:19Z", + "description" : "Global filter for CEA widgets", + "modifiedBy" : { + "uid" : "1", + "name" : "Test User" + }, + "id" : "65bc18e8f2073a4a469cd958", + "aid" : "11" + }, { + "createdDate" : "2024-02-01T22:19:19Z", + "createdBy" : { + "uid" : "1", + "name" : "Test User" + }, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "context" : [ { + "dataSourceId" : "VIRTUAL_AGENT", + "filters" : [ { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + }, { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + } ] + }, { + "dataSourceId" : "VIRTUAL_AGENT", + "filters" : [ { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + }, { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + } ] + } ], + "name" : "cea-filter", + "modifiedDate" : "2024-02-01T22:19:19Z", + "description" : "Global filter for CEA widgets", + "modifiedBy" : { + "uid" : "1", + "name" : "Test User" + }, + "id" : "65bc18e8f2073a4a469cd958", + "aid" : "11" + } ] + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "update_dashboard_filter": OperationExpectation( + operation_id="update_dashboard_filter", + method="PUT", + path="/dashboards/filters/{id}", + path_param_examples={ + "id": '65bc18e8f2073a4a469cd958', + }, + success_status=200, + success_body=json.loads(""" + + { + "createdDate" : "2024-02-01T22:19:19Z", + "createdBy" : { + "uid" : "1", + "name" : "Test User" + }, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "context" : [ { + "dataSourceId" : "VIRTUAL_AGENT", + "filters" : [ { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + }, { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + } ] + }, { + "dataSourceId" : "VIRTUAL_AGENT", + "filters" : [ { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + }, { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + } ] + } ], + "name" : "cea-filter", + "modifiedDate" : "2024-02-01T22:19:19Z", + "description" : "Global filter for CEA widgets", + "modifiedBy" : { + "uid" : "1", + "name" : "Test User" + }, + "id" : "65bc18e8f2073a4a469cd958", + "aid" : "11" + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "context" : [ { + "dataSourceId" : "VIRTUAL_AGENT", + "filters" : [ { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + }, { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + } ] + }, { + "dataSourceId" : "VIRTUAL_AGENT", + "filters" : [ { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + }, { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + } ] + } ], + "name" : "cea-filter", + "description" : "Global filter for CEA widgets" + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + +} diff --git a/thousandeyes-sdk-dashboards/test/test_dashboard_snapshots_api_integration.py b/thousandeyes-sdk-dashboards/test/test_dashboard_snapshots_api_integration.py new file mode 100644 index 00000000..6ae79e8c --- /dev/null +++ b/thousandeyes-sdk-dashboards/test/test_dashboard_snapshots_api_integration.py @@ -0,0 +1,2610 @@ +# coding: utf-8 + +""" + Dashboards API + + Manage ThousandEyes Dashboards. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.dashboards.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.dashboards.api.dashboard_snapshots_api import DashboardSnapshotsApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestDashboardSnapshotsApiIntegration(IntegrationTestBase): + """DashboardSnapshotsApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = DashboardSnapshotsApi(self.api_client) + + + def test_create_dashboard_snapshot_happy_path(self) -> None: + """Integration test for create_dashboard_snapshot success path""" + request_body_json = """ + + { + "endDate" : "2023-05-16T10:14:28Z", + "dashboardId" : "646f4d2ce3c99b0536c3821e", + "displayName" : "snapshot from API", + "anonymizeData" : true, + "timezone" : "PST", + "startDate" : "2023-05-16T10:14:28Z", + "expirationDate" : "2023-05-16T10:14:28Z" + } + + """ + generate_dashboard_snapshot_request = thousandeyes_sdk.dashboards.models.GenerateDashboardSnapshotRequest.from_json(request_body_json) + aid = '1234' + response_body_json = """ + { + "snapshotId" : "d28bb71f-5a47-4783-8f12-d4b115e61b0c", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + } + """ + expected_response = json.loads(response_body_json) + response = self.api.create_dashboard_snapshot( + + generate_dashboard_snapshot_request=generate_dashboard_snapshot_request, + + aid=aid, + + _headers=self.te_headers("create_dashboard_snapshot"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_create_dashboard_snapshot_error_400(self) -> None: + """Integration test for create_dashboard_snapshot error path (HTTP 400)""" + request_body_json = """ + + { + "endDate" : "2023-05-16T10:14:28Z", + "dashboardId" : "646f4d2ce3c99b0536c3821e", + "displayName" : "snapshot from API", + "anonymizeData" : true, + "timezone" : "PST", + "startDate" : "2023-05-16T10:14:28Z", + "expirationDate" : "2023-05-16T10:14:28Z" + } + + """ + generate_dashboard_snapshot_request = thousandeyes_sdk.dashboards.models.GenerateDashboardSnapshotRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.create_dashboard_snapshot( + + generate_dashboard_snapshot_request=generate_dashboard_snapshot_request, + + aid=aid, + + _headers=self.te_headers("create_dashboard_snapshot", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_dashboard_snapshot_error_401(self) -> None: + """Integration test for create_dashboard_snapshot error path (HTTP 401)""" + request_body_json = """ + + { + "endDate" : "2023-05-16T10:14:28Z", + "dashboardId" : "646f4d2ce3c99b0536c3821e", + "displayName" : "snapshot from API", + "anonymizeData" : true, + "timezone" : "PST", + "startDate" : "2023-05-16T10:14:28Z", + "expirationDate" : "2023-05-16T10:14:28Z" + } + + """ + generate_dashboard_snapshot_request = thousandeyes_sdk.dashboards.models.GenerateDashboardSnapshotRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.create_dashboard_snapshot( + + generate_dashboard_snapshot_request=generate_dashboard_snapshot_request, + + aid=aid, + + _headers=self.te_headers("create_dashboard_snapshot", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_dashboard_snapshot_error_403(self) -> None: + """Integration test for create_dashboard_snapshot error path (HTTP 403)""" + request_body_json = """ + + { + "endDate" : "2023-05-16T10:14:28Z", + "dashboardId" : "646f4d2ce3c99b0536c3821e", + "displayName" : "snapshot from API", + "anonymizeData" : true, + "timezone" : "PST", + "startDate" : "2023-05-16T10:14:28Z", + "expirationDate" : "2023-05-16T10:14:28Z" + } + + """ + generate_dashboard_snapshot_request = thousandeyes_sdk.dashboards.models.GenerateDashboardSnapshotRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.create_dashboard_snapshot( + + generate_dashboard_snapshot_request=generate_dashboard_snapshot_request, + + aid=aid, + + _headers=self.te_headers("create_dashboard_snapshot", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_dashboard_snapshot_error_404(self) -> None: + """Integration test for create_dashboard_snapshot error path (HTTP 404)""" + request_body_json = """ + + { + "endDate" : "2023-05-16T10:14:28Z", + "dashboardId" : "646f4d2ce3c99b0536c3821e", + "displayName" : "snapshot from API", + "anonymizeData" : true, + "timezone" : "PST", + "startDate" : "2023-05-16T10:14:28Z", + "expirationDate" : "2023-05-16T10:14:28Z" + } + + """ + generate_dashboard_snapshot_request = thousandeyes_sdk.dashboards.models.GenerateDashboardSnapshotRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.create_dashboard_snapshot( + + generate_dashboard_snapshot_request=generate_dashboard_snapshot_request, + + aid=aid, + + _headers=self.te_headers("create_dashboard_snapshot", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_dashboard_snapshot_error_500(self) -> None: + """Integration test for create_dashboard_snapshot error path (HTTP 500)""" + request_body_json = """ + + { + "endDate" : "2023-05-16T10:14:28Z", + "dashboardId" : "646f4d2ce3c99b0536c3821e", + "displayName" : "snapshot from API", + "anonymizeData" : true, + "timezone" : "PST", + "startDate" : "2023-05-16T10:14:28Z", + "expirationDate" : "2023-05-16T10:14:28Z" + } + + """ + generate_dashboard_snapshot_request = thousandeyes_sdk.dashboards.models.GenerateDashboardSnapshotRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.create_dashboard_snapshot( + + generate_dashboard_snapshot_request=generate_dashboard_snapshot_request, + + aid=aid, + + _headers=self.te_headers("create_dashboard_snapshot", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_delete_dashboard_snapshot_happy_path(self) -> None: + """Integration test for delete_dashboard_snapshot success path""" + snapshot_id = 'd28bb71f-5a47-4783-8f12-d4b115e61b0c' + aid = '1234' + response = self.api.delete_dashboard_snapshot_with_http_info( + + snapshot_id=snapshot_id, + + aid=aid, + + _headers=self.te_headers("delete_dashboard_snapshot"), + ) + self.assertEqual(204, response.status_code) + self.assertIsNone(response.data) + + + def test_delete_dashboard_snapshot_error_400(self) -> None: + """Integration test for delete_dashboard_snapshot error path (HTTP 400)""" + snapshot_id = 'd28bb71f-5a47-4783-8f12-d4b115e61b0c' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.delete_dashboard_snapshot( + + snapshot_id=snapshot_id, + + aid=aid, + + _headers=self.te_headers("delete_dashboard_snapshot", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_dashboard_snapshot_error_401(self) -> None: + """Integration test for delete_dashboard_snapshot error path (HTTP 401)""" + snapshot_id = 'd28bb71f-5a47-4783-8f12-d4b115e61b0c' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.delete_dashboard_snapshot( + + snapshot_id=snapshot_id, + + aid=aid, + + _headers=self.te_headers("delete_dashboard_snapshot", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_dashboard_snapshot_error_403(self) -> None: + """Integration test for delete_dashboard_snapshot error path (HTTP 403)""" + snapshot_id = 'd28bb71f-5a47-4783-8f12-d4b115e61b0c' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.delete_dashboard_snapshot( + + snapshot_id=snapshot_id, + + aid=aid, + + _headers=self.te_headers("delete_dashboard_snapshot", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_dashboard_snapshot_error_404(self) -> None: + """Integration test for delete_dashboard_snapshot error path (HTTP 404)""" + snapshot_id = 'd28bb71f-5a47-4783-8f12-d4b115e61b0c' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.delete_dashboard_snapshot( + + snapshot_id=snapshot_id, + + aid=aid, + + _headers=self.te_headers("delete_dashboard_snapshot", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_dashboard_snapshot_error_429(self) -> None: + """Integration test for delete_dashboard_snapshot error path (HTTP 429)""" + snapshot_id = 'd28bb71f-5a47-4783-8f12-d4b115e61b0c' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.delete_dashboard_snapshot( + + snapshot_id=snapshot_id, + + aid=aid, + + _headers=self.te_headers("delete_dashboard_snapshot", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_dashboard_snapshot_error_500(self) -> None: + """Integration test for delete_dashboard_snapshot error path (HTTP 500)""" + snapshot_id = 'd28bb71f-5a47-4783-8f12-d4b115e61b0c' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.delete_dashboard_snapshot( + + snapshot_id=snapshot_id, + + aid=aid, + + _headers=self.te_headers("delete_dashboard_snapshot", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_dashboard_snapshot_happy_path(self) -> None: + """Integration test for get_dashboard_snapshot success path""" + snapshot_id = 'd28bb71f-5a47-4783-8f12-d4b115e61b0c' + aid = '1234' + response_body_json = """ + { + "snapshotId" : "d28bb71f-5a47-4783-8f12-d4b115e61b0c", + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "apiLinks" : [ { + "key" : "" + }, { + "key" : "" + } ], + "snapshotExpirationDate" : "2023-05-16T10:14:28Z", + "isScheduled" : true, + "widgets" : [ { + "embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f", + "shouldExcludeAlertSuppressionWindows" : true, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "visualMode" : "Full", + "filters" : { + "TEST" : [ 5187, 5227 ], + "ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ] + }, + "title" : "Widget Title", + "type" : "Agent Status", + "metricGroup" : "BGP", + "measure" : { + "percentileValue" : 95, + "type" : "MEAN" + }, + "apiLink" : "apiLink", + "metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT", + "isEmbedded" : true, + "id" : "1234", + "fixedTimespan" : { + "unit" : "Days", + "value" : 10 + }, + "dataSource" : "ENDPOINT_AGENTS", + "direction" : "FROM_TARGET" + }, { + "embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f", + "shouldExcludeAlertSuppressionWindows" : true, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "visualMode" : "Full", + "filters" : { + "TEST" : [ 5187, 5227 ], + "ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ] + }, + "title" : "Widget Title", + "type" : "Agent Status", + "metricGroup" : "BGP", + "measure" : { + "percentileValue" : 95, + "type" : "MEAN" + }, + "apiLink" : "apiLink", + "metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT", + "isEmbedded" : true, + "id" : "1234", + "fixedTimespan" : { + "unit" : "Days", + "value" : 10 + }, + "dataSource" : "ENDPOINT_AGENTS", + "direction" : "FROM_TARGET" + } ], + "accountId" : 1234, + "createdDate" : "2023-05-16 10:14:28", + "snapshotName" : "HTTP Server Dashboard Snapshot", + "timeSpan" : { + "duration" : 60, + "start" : "2023-05-16T10:14:28Z", + "startDate" : "2023-05-16 10:14:28" + }, + "permalink" : "https://app.thousandeyes.com/dashboard/?snapshotId=d28bb71f-5a47-4783-8f12-d4b115e61b0c", + "aid" : "1234", + "snapshotCreatedDate" : "2023-05-16T10:14:28Z", + "isShared" : true, + "dashboard" : { + "isMigratedReport" : false, + "dashboardCreatedBy" : "1", + "_links" : { + "snapshots" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isDefaultForUser" : true, + "description" : "HTTP Server Widgets", + "isPrivate" : true, + "title" : "HTTP Server Widgets", + "isBuiltIn" : true, + "widgets" : [ { + "embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f", + "shouldExcludeAlertSuppressionWindows" : true, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "visualMode" : "Full", + "filters" : { + "TEST" : [ 5187, 5227 ], + "ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ] + }, + "title" : "Widget Title", + "type" : "Agent Status", + "metricGroup" : "BGP", + "measure" : { + "percentileValue" : 95, + "type" : "MEAN" + }, + "apiLink" : "apiLink", + "metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT", + "isEmbedded" : true, + "id" : "1234", + "fixedTimespan" : { + "unit" : "Days", + "value" : 10 + }, + "dataSource" : "ENDPOINT_AGENTS", + "direction" : "FROM_TARGET" + }, { + "embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f", + "shouldExcludeAlertSuppressionWindows" : true, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "visualMode" : "Full", + "filters" : { + "TEST" : [ 5187, 5227 ], + "ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ] + }, + "title" : "Widget Title", + "type" : "Agent Status", + "metricGroup" : "BGP", + "measure" : { + "percentileValue" : 95, + "type" : "MEAN" + }, + "apiLink" : "apiLink", + "metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT", + "isEmbedded" : true, + "id" : "1234", + "fixedTimespan" : { + "unit" : "Days", + "value" : 10 + }, + "dataSource" : "ENDPOINT_AGENTS", + "direction" : "FROM_TARGET" + } ], + "globalFilterId" : "65babd9bb90bf55b17c96c8d", + "modifiedBy" : 1, + "dashboardModifiedBy" : "1", + "migratedReport" : false, + "isDefaultForAccount" : false, + "defaultTimespan" : { + "duration" : 7200, + "timespanDuration" : 7200, + "start" : "2023-05-16T10:14:28Z", + "end" : "2023-05-16T11:14:28Z", + "timespanStart" : "2023-05-16 10:14:28", + "timespanEnd" : "2023-05-16 11:14:28" + }, + "layout" : { + "layoutId" : "grid-layout-1", + "type" : "grid", + "details" : { + "widgetPositioning" : [ { + "x" : 0, + "y" : 0, + "w" : 9, + "h" : 5, + "id" : "widgetId-71lbb" + } ] + } + }, + "accountId" : 1234, + "apiLink" : [ { + "key" : "" + }, { + "key" : "" + } ], + "dashboardId" : "5e1f7a99143ae6004fdc3bb4", + "createdBy" : 1, + "globalOverride" : true, + "modifiedDate" : "2023-05-16 10:14:28", + "isGlobalOverride" : true, + "aid" : "1234", + "dashboardModifiedDate" : "2023-05-16T10:14:28Z" + }, + "expirationDate" : "2023-05-16 10:14:28" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_dashboard_snapshot( + + snapshot_id=snapshot_id, + + aid=aid, + + _headers=self.te_headers("get_dashboard_snapshot"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_dashboard_snapshot_error_400(self) -> None: + """Integration test for get_dashboard_snapshot error path (HTTP 400)""" + snapshot_id = 'd28bb71f-5a47-4783-8f12-d4b115e61b0c' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.get_dashboard_snapshot( + + snapshot_id=snapshot_id, + + aid=aid, + + _headers=self.te_headers("get_dashboard_snapshot", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_dashboard_snapshot_error_401(self) -> None: + """Integration test for get_dashboard_snapshot error path (HTTP 401)""" + snapshot_id = 'd28bb71f-5a47-4783-8f12-d4b115e61b0c' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_dashboard_snapshot( + + snapshot_id=snapshot_id, + + aid=aid, + + _headers=self.te_headers("get_dashboard_snapshot", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_dashboard_snapshot_error_403(self) -> None: + """Integration test for get_dashboard_snapshot error path (HTTP 403)""" + snapshot_id = 'd28bb71f-5a47-4783-8f12-d4b115e61b0c' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_dashboard_snapshot( + + snapshot_id=snapshot_id, + + aid=aid, + + _headers=self.te_headers("get_dashboard_snapshot", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_dashboard_snapshot_error_404(self) -> None: + """Integration test for get_dashboard_snapshot error path (HTTP 404)""" + snapshot_id = 'd28bb71f-5a47-4783-8f12-d4b115e61b0c' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_dashboard_snapshot( + + snapshot_id=snapshot_id, + + aid=aid, + + _headers=self.te_headers("get_dashboard_snapshot", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_dashboard_snapshot_error_429(self) -> None: + """Integration test for get_dashboard_snapshot error path (HTTP 429)""" + snapshot_id = 'd28bb71f-5a47-4783-8f12-d4b115e61b0c' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_dashboard_snapshot( + + snapshot_id=snapshot_id, + + aid=aid, + + _headers=self.te_headers("get_dashboard_snapshot", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_dashboard_snapshot_error_500(self) -> None: + """Integration test for get_dashboard_snapshot error path (HTTP 500)""" + snapshot_id = 'd28bb71f-5a47-4783-8f12-d4b115e61b0c' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_dashboard_snapshot( + + snapshot_id=snapshot_id, + + aid=aid, + + _headers=self.te_headers("get_dashboard_snapshot", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_dashboard_snapshot_widget_data_happy_path(self) -> None: + """Integration test for get_dashboard_snapshot_widget_data success path""" + snapshot_id = 'd28bb71f-5a47-4783-8f12-d4b115e61b0c' + widget_id = 'unpmg' + aid = '1234' + response_body_json = """ + { + "groupLabels" : [ { + "groupProperty" : "AGENT", + "groupLabels" : [ { + "groupId" : "2565", + "groupLabel" : "San Francisco, CA" + }, { + "groupId" : "2565", + "groupLabel" : "San Francisco, CA" + } ] + }, { + "groupProperty" : "AGENT", + "groupLabels" : [ { + "groupId" : "2565", + "groupLabel" : "San Francisco, CA" + }, { + "groupId" : "2565", + "groupLabel" : "San Francisco, CA" + } ] + } ], + "data" : { + "alerts" : [ { + "alertType" : "network-end-to-end-server", + "durationInSeconds" : 25, + "alertSource" : "Http Test", + "active" : true, + "testId" : "56512", + "startTime" : "2023-06-02T08:54:00Z", + "alertId" : "2004945", + "ruleId" : "281724", + "alertRule" : "Http Test Rule" + }, { + "alertType" : "network-end-to-end-server", + "durationInSeconds" : 25, + "alertSource" : "Http Test", + "active" : true, + "testId" : "56512", + "startTime" : "2023-06-02T08:54:00Z", + "alertId" : "2004945", + "ruleId" : "281724", + "alertRule" : "Http Test Rule" + } ], + "summary" : { + "offline" : 2, + "online" : 10, + "disabled" : 3 + }, + "totalAlerts" : 500, + "cards" : [ { + "numberOfDataPoints" : 24192, + "cardName" : "Card Name", + "endDate" : "2023-05-16T10:14:28Z", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "cardId" : "lrxxr", + "alertSuppressionWindows" : [ { + "testIds" : [ "281474976710661" ], + "repeatUnit" : "week", + "durationInSeconds" : 7200, + "repeat" : "custom", + "name" : "Test dashboards", + "repeatEvery" : 5, + "id" : "281474976710662", + "startTimes" : [ "2023-05-16T10:14:28Z" ] + }, { + "testIds" : [ "281474976710661" ], + "repeatUnit" : "week", + "durationInSeconds" : 7200, + "repeat" : "custom", + "name" : "Test dashboards", + "repeatEvery" : 5, + "id" : "281474976710662", + "startTimes" : [ "2023-05-16T10:14:28Z" ] + } ], + "binSize" : 3600, + "previousValue" : 500, + "value" : 100, + "startDate" : "2023-05-16T10:14:28Z", + "timestamp" : 1567620000, + "status" : "No data" + }, { + "numberOfDataPoints" : 24192, + "cardName" : "Card Name", + "endDate" : "2023-05-16T10:14:28Z", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "cardId" : "lrxxr", + "alertSuppressionWindows" : [ { + "testIds" : [ "281474976710661" ], + "repeatUnit" : "week", + "durationInSeconds" : 7200, + "repeat" : "custom", + "name" : "Test dashboards", + "repeatEvery" : 5, + "id" : "281474976710662", + "startTimes" : [ "2023-05-16T10:14:28Z" ] + }, { + "testIds" : [ "281474976710661" ], + "repeatUnit" : "week", + "durationInSeconds" : 7200, + "repeat" : "custom", + "name" : "Test dashboards", + "repeatEvery" : 5, + "id" : "281474976710662", + "startTimes" : [ "2023-05-16T10:14:28Z" ] + } ], + "binSize" : 3600, + "previousValue" : 500, + "value" : 100, + "startDate" : "2023-05-16T10:14:28Z", + "timestamp" : 1567620000, + "status" : "No data" + } ], + "tests" : [ { + "graphlets" : [ { + "metric" : "Availability", + "testId" : "68257", + "points" : [ { + "x" : 1580403900, + "y" : 128.249 + }, { + "x" : 1580403900, + "y" : 128.249 + } ] + }, { + "metric" : "Availability", + "testId" : "68257", + "points" : [ { + "x" : 1580403900, + "y" : 128.249 + }, { + "x" : 1580403900, + "y" : 128.249 + } ] + } ], + "alertCount" : 398, + "testType" : "Web - HTTP Server", + "testId" : "68256", + "isShared" : true, + "testName" : "Http Test Name", + "target" : "www.google.com" + }, { + "graphlets" : [ { + "metric" : "Availability", + "testId" : "68257", + "points" : [ { + "x" : 1580403900, + "y" : 128.249 + }, { + "x" : 1580403900, + "y" : 128.249 + } ] + }, { + "metric" : "Availability", + "testId" : "68257", + "points" : [ { + "x" : 1580403900, + "y" : 128.249 + }, { + "x" : 1580403900, + "y" : 128.249 + } ] + } ], + "alertCount" : 398, + "testType" : "Web - HTTP Server", + "testId" : "68256", + "isShared" : true, + "testName" : "Http Test Name", + "target" : "www.google.com" + } ], + "columns" : [ { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "columnId" : "938to", + "alertSuppressionWindows" : [ { + "testIds" : [ "281474976710661" ], + "repeatUnit" : "week", + "durationInSeconds" : 7200, + "repeat" : "custom", + "name" : "Test dashboards", + "repeatEvery" : 5, + "id" : "281474976710662", + "startTimes" : [ "2023-05-16T10:14:28Z" ] + }, { + "testIds" : [ "281474976710661" ], + "repeatUnit" : "week", + "durationInSeconds" : 7200, + "repeat" : "custom", + "name" : "Test dashboards", + "repeatEvery" : 5, + "id" : "281474976710662", + "startTimes" : [ "2023-05-16T10:14:28Z" ] + } ], + "binSize" : 3600, + "points" : [ { + "numberOfDataPoints" : 23304, + "groups" : [ { + "groupProperty" : "COUNTRY", + "groupValue" : "US" + }, { + "groupProperty" : "COUNTRY", + "groupValue" : "US" + } ], + "value" : 100, + "timestamp" : 1567620000 + }, { + "numberOfDataPoints" : 23304, + "groups" : [ { + "groupProperty" : "COUNTRY", + "groupValue" : "US" + }, { + "groupProperty" : "COUNTRY", + "groupValue" : "US" + } ], + "value" : 100, + "timestamp" : 1567620000 + } ], + "status" : "No data" + }, { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "columnId" : "938to", + "alertSuppressionWindows" : [ { + "testIds" : [ "281474976710661" ], + "repeatUnit" : "week", + "durationInSeconds" : 7200, + "repeat" : "custom", + "name" : "Test dashboards", + "repeatEvery" : 5, + "id" : "281474976710662", + "startTimes" : [ "2023-05-16T10:14:28Z" ] + }, { + "testIds" : [ "281474976710661" ], + "repeatUnit" : "week", + "durationInSeconds" : 7200, + "repeat" : "custom", + "name" : "Test dashboards", + "repeatEvery" : 5, + "id" : "281474976710662", + "startTimes" : [ "2023-05-16T10:14:28Z" ] + } ], + "binSize" : 3600, + "points" : [ { + "numberOfDataPoints" : 23304, + "groups" : [ { + "groupProperty" : "COUNTRY", + "groupValue" : "US" + }, { + "groupProperty" : "COUNTRY", + "groupValue" : "US" + } ], + "value" : 100, + "timestamp" : 1567620000 + }, { + "numberOfDataPoints" : 23304, + "groups" : [ { + "groupProperty" : "COUNTRY", + "groupValue" : "US" + }, { + "groupProperty" : "COUNTRY", + "groupValue" : "US" + } ], + "value" : 100, + "timestamp" : 1567620000 + } ], + "status" : "No data" + } ], + "alertSuppressionWindows" : [ { + "testIds" : [ "281474976710661" ], + "repeatUnit" : "week", + "durationInSeconds" : 7200, + "repeat" : "custom", + "name" : "Test dashboards", + "repeatEvery" : 5, + "id" : "281474976710662", + "startTimes" : [ "2023-05-16T10:14:28Z" ] + }, { + "testIds" : [ "281474976710661" ], + "repeatUnit" : "week", + "durationInSeconds" : 7200, + "repeat" : "custom", + "name" : "Test dashboards", + "repeatEvery" : 5, + "id" : "281474976710662", + "startTimes" : [ "2023-05-16T10:14:28Z" ] + } ], + "activeAlerts" : 483, + "startRound" : 1384309800, + "points" : [ { + "numberOfDataPoints" : 23304, + "groups" : [ { + "groupProperty" : "COUNTRY", + "groupValue" : "US" + }, { + "groupProperty" : "COUNTRY", + "groupValue" : "US" + } ], + "value" : 100, + "timestamp" : 1567620000 + }, { + "numberOfDataPoints" : 23304, + "groups" : [ { + "groupProperty" : "COUNTRY", + "groupValue" : "US" + }, { + "groupProperty" : "COUNTRY", + "groupValue" : "US" + } ], + "value" : 100, + "timestamp" : 1567620000 + } ], + "agents" : [ { + "agentId" : "6522", + "agentName" : "0c3898000117", + "location" : { + "locationName" : "San Francisco, California, US", + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "ipInfo" : { + "ipv6" : "ipv6", + "privateIp" : "172.58.92.31", + "operativeSystemVersion" : "operativeSystemVersion", + "publicIp" : "172.58.92.31" + }, + "status" : "online" + }, { + "agentId" : "6522", + "agentName" : "0c3898000117", + "location" : { + "locationName" : "San Francisco, California, US", + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "ipInfo" : { + "ipv6" : "ipv6", + "privateIp" : "172.58.92.31", + "operativeSystemVersion" : "operativeSystemVersion", + "publicIp" : "172.58.92.31" + }, + "status" : "online" + } ], + "status" : "No data" + }, + "endDate" : "2022-07-18T22:00:54Z", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "binSize" : 3600, + "startDate" : "2022-07-17T22:00:54Z" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_dashboard_snapshot_widget_data( + + snapshot_id=snapshot_id, + + widget_id=widget_id, + + aid=aid, + + _headers=self.te_headers("get_dashboard_snapshot_widget_data"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_dashboard_snapshot_widget_data_error_400(self) -> None: + """Integration test for get_dashboard_snapshot_widget_data error path (HTTP 400)""" + snapshot_id = 'd28bb71f-5a47-4783-8f12-d4b115e61b0c' + widget_id = 'unpmg' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.get_dashboard_snapshot_widget_data( + + snapshot_id=snapshot_id, + + widget_id=widget_id, + + aid=aid, + + _headers=self.te_headers("get_dashboard_snapshot_widget_data", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_dashboard_snapshot_widget_data_error_401(self) -> None: + """Integration test for get_dashboard_snapshot_widget_data error path (HTTP 401)""" + snapshot_id = 'd28bb71f-5a47-4783-8f12-d4b115e61b0c' + widget_id = 'unpmg' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_dashboard_snapshot_widget_data( + + snapshot_id=snapshot_id, + + widget_id=widget_id, + + aid=aid, + + _headers=self.te_headers("get_dashboard_snapshot_widget_data", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_dashboard_snapshot_widget_data_error_403(self) -> None: + """Integration test for get_dashboard_snapshot_widget_data error path (HTTP 403)""" + snapshot_id = 'd28bb71f-5a47-4783-8f12-d4b115e61b0c' + widget_id = 'unpmg' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_dashboard_snapshot_widget_data( + + snapshot_id=snapshot_id, + + widget_id=widget_id, + + aid=aid, + + _headers=self.te_headers("get_dashboard_snapshot_widget_data", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_dashboard_snapshot_widget_data_error_404(self) -> None: + """Integration test for get_dashboard_snapshot_widget_data error path (HTTP 404)""" + snapshot_id = 'd28bb71f-5a47-4783-8f12-d4b115e61b0c' + widget_id = 'unpmg' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_dashboard_snapshot_widget_data( + + snapshot_id=snapshot_id, + + widget_id=widget_id, + + aid=aid, + + _headers=self.te_headers("get_dashboard_snapshot_widget_data", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_dashboard_snapshot_widget_data_error_429(self) -> None: + """Integration test for get_dashboard_snapshot_widget_data error path (HTTP 429)""" + snapshot_id = 'd28bb71f-5a47-4783-8f12-d4b115e61b0c' + widget_id = 'unpmg' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_dashboard_snapshot_widget_data( + + snapshot_id=snapshot_id, + + widget_id=widget_id, + + aid=aid, + + _headers=self.te_headers("get_dashboard_snapshot_widget_data", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_dashboard_snapshot_widget_data_error_500(self) -> None: + """Integration test for get_dashboard_snapshot_widget_data error path (HTTP 500)""" + snapshot_id = 'd28bb71f-5a47-4783-8f12-d4b115e61b0c' + widget_id = 'unpmg' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_dashboard_snapshot_widget_data( + + snapshot_id=snapshot_id, + + widget_id=widget_id, + + aid=aid, + + _headers=self.te_headers("get_dashboard_snapshot_widget_data", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_dashboard_snapshots_happy_path(self) -> None: + """Integration test for get_dashboard_snapshots success path""" + aid = '1234' + dashboard_id = '646f4d2ce3c99b0536c3821e' + cursor = 'cursor_example' + response_body_json = """ + { + "pages" : { + "key" : "" + }, + "_links" : { + "next" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "previous" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dashboardSnapshots" : [ { + "snapshotId" : "d28bb71f-5a47-4783-8f12-d4b115e61b0c", + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "apiLinks" : [ { + "key" : "" + }, { + "key" : "" + } ], + "snapshotExpirationDate" : "2023-05-16T10:14:28Z", + "isScheduled" : true, + "widgets" : [ { + "embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f", + "shouldExcludeAlertSuppressionWindows" : true, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "visualMode" : "Full", + "filters" : { + "TEST" : [ 5187, 5227 ], + "ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ] + }, + "title" : "Widget Title", + "type" : "Agent Status", + "metricGroup" : "BGP", + "measure" : { + "percentileValue" : 95, + "type" : "MEAN" + }, + "apiLink" : "apiLink", + "metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT", + "isEmbedded" : true, + "id" : "1234", + "fixedTimespan" : { + "unit" : "Days", + "value" : 10 + }, + "dataSource" : "ENDPOINT_AGENTS", + "direction" : "FROM_TARGET" + }, { + "embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f", + "shouldExcludeAlertSuppressionWindows" : true, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "visualMode" : "Full", + "filters" : { + "TEST" : [ 5187, 5227 ], + "ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ] + }, + "title" : "Widget Title", + "type" : "Agent Status", + "metricGroup" : "BGP", + "measure" : { + "percentileValue" : 95, + "type" : "MEAN" + }, + "apiLink" : "apiLink", + "metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT", + "isEmbedded" : true, + "id" : "1234", + "fixedTimespan" : { + "unit" : "Days", + "value" : 10 + }, + "dataSource" : "ENDPOINT_AGENTS", + "direction" : "FROM_TARGET" + } ], + "accountId" : 1234, + "createdDate" : "2023-05-16 10:14:28", + "snapshotName" : "HTTP Server Dashboard Snapshot", + "timeSpan" : { + "duration" : 60, + "start" : "2023-05-16T10:14:28Z", + "startDate" : "2023-05-16 10:14:28" + }, + "permalink" : "https://app.thousandeyes.com/dashboard/?snapshotId=d28bb71f-5a47-4783-8f12-d4b115e61b0c", + "aid" : "1234", + "snapshotCreatedDate" : "2023-05-16T10:14:28Z", + "isShared" : true, + "dashboard" : { + "isMigratedReport" : false, + "dashboardCreatedBy" : "1", + "_links" : { + "snapshots" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isDefaultForUser" : true, + "description" : "HTTP Server Widgets", + "isPrivate" : true, + "title" : "HTTP Server Widgets", + "isBuiltIn" : true, + "widgets" : [ { + "embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f", + "shouldExcludeAlertSuppressionWindows" : true, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "visualMode" : "Full", + "filters" : { + "TEST" : [ 5187, 5227 ], + "ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ] + }, + "title" : "Widget Title", + "type" : "Agent Status", + "metricGroup" : "BGP", + "measure" : { + "percentileValue" : 95, + "type" : "MEAN" + }, + "apiLink" : "apiLink", + "metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT", + "isEmbedded" : true, + "id" : "1234", + "fixedTimespan" : { + "unit" : "Days", + "value" : 10 + }, + "dataSource" : "ENDPOINT_AGENTS", + "direction" : "FROM_TARGET" + }, { + "embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f", + "shouldExcludeAlertSuppressionWindows" : true, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "visualMode" : "Full", + "filters" : { + "TEST" : [ 5187, 5227 ], + "ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ] + }, + "title" : "Widget Title", + "type" : "Agent Status", + "metricGroup" : "BGP", + "measure" : { + "percentileValue" : 95, + "type" : "MEAN" + }, + "apiLink" : "apiLink", + "metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT", + "isEmbedded" : true, + "id" : "1234", + "fixedTimespan" : { + "unit" : "Days", + "value" : 10 + }, + "dataSource" : "ENDPOINT_AGENTS", + "direction" : "FROM_TARGET" + } ], + "globalFilterId" : "65babd9bb90bf55b17c96c8d", + "modifiedBy" : 1, + "dashboardModifiedBy" : "1", + "migratedReport" : false, + "isDefaultForAccount" : false, + "defaultTimespan" : { + "duration" : 7200, + "timespanDuration" : 7200, + "start" : "2023-05-16T10:14:28Z", + "end" : "2023-05-16T11:14:28Z", + "timespanStart" : "2023-05-16 10:14:28", + "timespanEnd" : "2023-05-16 11:14:28" + }, + "layout" : { + "layoutId" : "grid-layout-1", + "type" : "grid", + "details" : { + "widgetPositioning" : [ { + "x" : 0, + "y" : 0, + "w" : 9, + "h" : 5, + "id" : "widgetId-71lbb" + } ] + } + }, + "accountId" : 1234, + "apiLink" : [ { + "key" : "" + }, { + "key" : "" + } ], + "dashboardId" : "5e1f7a99143ae6004fdc3bb4", + "createdBy" : 1, + "globalOverride" : true, + "modifiedDate" : "2023-05-16 10:14:28", + "isGlobalOverride" : true, + "aid" : "1234", + "dashboardModifiedDate" : "2023-05-16T10:14:28Z" + }, + "expirationDate" : "2023-05-16 10:14:28" + }, { + "snapshotId" : "d28bb71f-5a47-4783-8f12-d4b115e61b0c", + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "apiLinks" : [ { + "key" : "" + }, { + "key" : "" + } ], + "snapshotExpirationDate" : "2023-05-16T10:14:28Z", + "isScheduled" : true, + "widgets" : [ { + "embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f", + "shouldExcludeAlertSuppressionWindows" : true, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "visualMode" : "Full", + "filters" : { + "TEST" : [ 5187, 5227 ], + "ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ] + }, + "title" : "Widget Title", + "type" : "Agent Status", + "metricGroup" : "BGP", + "measure" : { + "percentileValue" : 95, + "type" : "MEAN" + }, + "apiLink" : "apiLink", + "metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT", + "isEmbedded" : true, + "id" : "1234", + "fixedTimespan" : { + "unit" : "Days", + "value" : 10 + }, + "dataSource" : "ENDPOINT_AGENTS", + "direction" : "FROM_TARGET" + }, { + "embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f", + "shouldExcludeAlertSuppressionWindows" : true, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "visualMode" : "Full", + "filters" : { + "TEST" : [ 5187, 5227 ], + "ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ] + }, + "title" : "Widget Title", + "type" : "Agent Status", + "metricGroup" : "BGP", + "measure" : { + "percentileValue" : 95, + "type" : "MEAN" + }, + "apiLink" : "apiLink", + "metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT", + "isEmbedded" : true, + "id" : "1234", + "fixedTimespan" : { + "unit" : "Days", + "value" : 10 + }, + "dataSource" : "ENDPOINT_AGENTS", + "direction" : "FROM_TARGET" + } ], + "accountId" : 1234, + "createdDate" : "2023-05-16 10:14:28", + "snapshotName" : "HTTP Server Dashboard Snapshot", + "timeSpan" : { + "duration" : 60, + "start" : "2023-05-16T10:14:28Z", + "startDate" : "2023-05-16 10:14:28" + }, + "permalink" : "https://app.thousandeyes.com/dashboard/?snapshotId=d28bb71f-5a47-4783-8f12-d4b115e61b0c", + "aid" : "1234", + "snapshotCreatedDate" : "2023-05-16T10:14:28Z", + "isShared" : true, + "dashboard" : { + "isMigratedReport" : false, + "dashboardCreatedBy" : "1", + "_links" : { + "snapshots" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isDefaultForUser" : true, + "description" : "HTTP Server Widgets", + "isPrivate" : true, + "title" : "HTTP Server Widgets", + "isBuiltIn" : true, + "widgets" : [ { + "embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f", + "shouldExcludeAlertSuppressionWindows" : true, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "visualMode" : "Full", + "filters" : { + "TEST" : [ 5187, 5227 ], + "ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ] + }, + "title" : "Widget Title", + "type" : "Agent Status", + "metricGroup" : "BGP", + "measure" : { + "percentileValue" : 95, + "type" : "MEAN" + }, + "apiLink" : "apiLink", + "metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT", + "isEmbedded" : true, + "id" : "1234", + "fixedTimespan" : { + "unit" : "Days", + "value" : 10 + }, + "dataSource" : "ENDPOINT_AGENTS", + "direction" : "FROM_TARGET" + }, { + "embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f", + "shouldExcludeAlertSuppressionWindows" : true, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "visualMode" : "Full", + "filters" : { + "TEST" : [ 5187, 5227 ], + "ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ] + }, + "title" : "Widget Title", + "type" : "Agent Status", + "metricGroup" : "BGP", + "measure" : { + "percentileValue" : 95, + "type" : "MEAN" + }, + "apiLink" : "apiLink", + "metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT", + "isEmbedded" : true, + "id" : "1234", + "fixedTimespan" : { + "unit" : "Days", + "value" : 10 + }, + "dataSource" : "ENDPOINT_AGENTS", + "direction" : "FROM_TARGET" + } ], + "globalFilterId" : "65babd9bb90bf55b17c96c8d", + "modifiedBy" : 1, + "dashboardModifiedBy" : "1", + "migratedReport" : false, + "isDefaultForAccount" : false, + "defaultTimespan" : { + "duration" : 7200, + "timespanDuration" : 7200, + "start" : "2023-05-16T10:14:28Z", + "end" : "2023-05-16T11:14:28Z", + "timespanStart" : "2023-05-16 10:14:28", + "timespanEnd" : "2023-05-16 11:14:28" + }, + "layout" : { + "layoutId" : "grid-layout-1", + "type" : "grid", + "details" : { + "widgetPositioning" : [ { + "x" : 0, + "y" : 0, + "w" : 9, + "h" : 5, + "id" : "widgetId-71lbb" + } ] + } + }, + "accountId" : 1234, + "apiLink" : [ { + "key" : "" + }, { + "key" : "" + } ], + "dashboardId" : "5e1f7a99143ae6004fdc3bb4", + "createdBy" : 1, + "globalOverride" : true, + "modifiedDate" : "2023-05-16 10:14:28", + "isGlobalOverride" : true, + "aid" : "1234", + "dashboardModifiedDate" : "2023-05-16T10:14:28Z" + }, + "expirationDate" : "2023-05-16 10:14:28" + } ] + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_dashboard_snapshots( + + aid=aid, + + dashboard_id=dashboard_id, + + cursor=cursor, + + _headers=self.te_headers("get_dashboard_snapshots"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_dashboard_snapshots_error_400(self) -> None: + """Integration test for get_dashboard_snapshots error path (HTTP 400)""" + aid = '1234' + dashboard_id = '646f4d2ce3c99b0536c3821e' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.get_dashboard_snapshots( + + aid=aid, + + dashboard_id=dashboard_id, + + cursor=cursor, + + _headers=self.te_headers("get_dashboard_snapshots", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_dashboard_snapshots_error_401(self) -> None: + """Integration test for get_dashboard_snapshots error path (HTTP 401)""" + aid = '1234' + dashboard_id = '646f4d2ce3c99b0536c3821e' + cursor = 'cursor_example' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_dashboard_snapshots( + + aid=aid, + + dashboard_id=dashboard_id, + + cursor=cursor, + + _headers=self.te_headers("get_dashboard_snapshots", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_dashboard_snapshots_error_403(self) -> None: + """Integration test for get_dashboard_snapshots error path (HTTP 403)""" + aid = '1234' + dashboard_id = '646f4d2ce3c99b0536c3821e' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_dashboard_snapshots( + + aid=aid, + + dashboard_id=dashboard_id, + + cursor=cursor, + + _headers=self.te_headers("get_dashboard_snapshots", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_dashboard_snapshots_error_404(self) -> None: + """Integration test for get_dashboard_snapshots error path (HTTP 404)""" + aid = '1234' + dashboard_id = '646f4d2ce3c99b0536c3821e' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_dashboard_snapshots( + + aid=aid, + + dashboard_id=dashboard_id, + + cursor=cursor, + + _headers=self.te_headers("get_dashboard_snapshots", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_dashboard_snapshots_error_429(self) -> None: + """Integration test for get_dashboard_snapshots error path (HTTP 429)""" + aid = '1234' + dashboard_id = '646f4d2ce3c99b0536c3821e' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_dashboard_snapshots( + + aid=aid, + + dashboard_id=dashboard_id, + + cursor=cursor, + + _headers=self.te_headers("get_dashboard_snapshots", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_dashboard_snapshots_error_500(self) -> None: + """Integration test for get_dashboard_snapshots error path (HTTP 500)""" + aid = '1234' + dashboard_id = '646f4d2ce3c99b0536c3821e' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_dashboard_snapshots( + + aid=aid, + + dashboard_id=dashboard_id, + + cursor=cursor, + + _headers=self.te_headers("get_dashboard_snapshots", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_update_dashboard_snapshot_expiration_date_happy_path(self) -> None: + """Integration test for update_dashboard_snapshot_expiration_date success path""" + request_body_json = """ + + { + "snapshotExpirationDate" : "2023-05-16T10:14:28Z", + "expirationDate" : "2023-05-16 10:14:28" + } + + """ + update_snapshot_expiration_date_api_request = thousandeyes_sdk.dashboards.models.UpdateSnapshotExpirationDateApiRequest.from_json(request_body_json) + snapshot_id = 'd28bb71f-5a47-4783-8f12-d4b115e61b0c' + aid = '1234' + response = self.api.update_dashboard_snapshot_expiration_date_with_http_info( + + snapshot_id=snapshot_id, + + update_snapshot_expiration_date_api_request=update_snapshot_expiration_date_api_request, + + aid=aid, + + _headers=self.te_headers("update_dashboard_snapshot_expiration_date"), + ) + self.assertEqual(204, response.status_code) + self.assertIsNone(response.data) + + + def test_update_dashboard_snapshot_expiration_date_error_400(self) -> None: + """Integration test for update_dashboard_snapshot_expiration_date error path (HTTP 400)""" + request_body_json = """ + + { + "snapshotExpirationDate" : "2023-05-16T10:14:28Z", + "expirationDate" : "2023-05-16 10:14:28" + } + + """ + update_snapshot_expiration_date_api_request = thousandeyes_sdk.dashboards.models.UpdateSnapshotExpirationDateApiRequest.from_json(request_body_json) + snapshot_id = 'd28bb71f-5a47-4783-8f12-d4b115e61b0c' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.update_dashboard_snapshot_expiration_date( + + snapshot_id=snapshot_id, + + update_snapshot_expiration_date_api_request=update_snapshot_expiration_date_api_request, + + aid=aid, + + _headers=self.te_headers("update_dashboard_snapshot_expiration_date", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_dashboard_snapshot_expiration_date_error_401(self) -> None: + """Integration test for update_dashboard_snapshot_expiration_date error path (HTTP 401)""" + request_body_json = """ + + { + "snapshotExpirationDate" : "2023-05-16T10:14:28Z", + "expirationDate" : "2023-05-16 10:14:28" + } + + """ + update_snapshot_expiration_date_api_request = thousandeyes_sdk.dashboards.models.UpdateSnapshotExpirationDateApiRequest.from_json(request_body_json) + snapshot_id = 'd28bb71f-5a47-4783-8f12-d4b115e61b0c' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.update_dashboard_snapshot_expiration_date( + + snapshot_id=snapshot_id, + + update_snapshot_expiration_date_api_request=update_snapshot_expiration_date_api_request, + + aid=aid, + + _headers=self.te_headers("update_dashboard_snapshot_expiration_date", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_dashboard_snapshot_expiration_date_error_403(self) -> None: + """Integration test for update_dashboard_snapshot_expiration_date error path (HTTP 403)""" + request_body_json = """ + + { + "snapshotExpirationDate" : "2023-05-16T10:14:28Z", + "expirationDate" : "2023-05-16 10:14:28" + } + + """ + update_snapshot_expiration_date_api_request = thousandeyes_sdk.dashboards.models.UpdateSnapshotExpirationDateApiRequest.from_json(request_body_json) + snapshot_id = 'd28bb71f-5a47-4783-8f12-d4b115e61b0c' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.update_dashboard_snapshot_expiration_date( + + snapshot_id=snapshot_id, + + update_snapshot_expiration_date_api_request=update_snapshot_expiration_date_api_request, + + aid=aid, + + _headers=self.te_headers("update_dashboard_snapshot_expiration_date", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_dashboard_snapshot_expiration_date_error_404(self) -> None: + """Integration test for update_dashboard_snapshot_expiration_date error path (HTTP 404)""" + request_body_json = """ + + { + "snapshotExpirationDate" : "2023-05-16T10:14:28Z", + "expirationDate" : "2023-05-16 10:14:28" + } + + """ + update_snapshot_expiration_date_api_request = thousandeyes_sdk.dashboards.models.UpdateSnapshotExpirationDateApiRequest.from_json(request_body_json) + snapshot_id = 'd28bb71f-5a47-4783-8f12-d4b115e61b0c' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.update_dashboard_snapshot_expiration_date( + + snapshot_id=snapshot_id, + + update_snapshot_expiration_date_api_request=update_snapshot_expiration_date_api_request, + + aid=aid, + + _headers=self.te_headers("update_dashboard_snapshot_expiration_date", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_dashboard_snapshot_expiration_date_error_429(self) -> None: + """Integration test for update_dashboard_snapshot_expiration_date error path (HTTP 429)""" + request_body_json = """ + + { + "snapshotExpirationDate" : "2023-05-16T10:14:28Z", + "expirationDate" : "2023-05-16 10:14:28" + } + + """ + update_snapshot_expiration_date_api_request = thousandeyes_sdk.dashboards.models.UpdateSnapshotExpirationDateApiRequest.from_json(request_body_json) + snapshot_id = 'd28bb71f-5a47-4783-8f12-d4b115e61b0c' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.update_dashboard_snapshot_expiration_date( + + snapshot_id=snapshot_id, + + update_snapshot_expiration_date_api_request=update_snapshot_expiration_date_api_request, + + aid=aid, + + _headers=self.te_headers("update_dashboard_snapshot_expiration_date", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_dashboard_snapshot_expiration_date_error_500(self) -> None: + """Integration test for update_dashboard_snapshot_expiration_date error path (HTTP 500)""" + request_body_json = """ + + { + "snapshotExpirationDate" : "2023-05-16T10:14:28Z", + "expirationDate" : "2023-05-16 10:14:28" + } + + """ + update_snapshot_expiration_date_api_request = thousandeyes_sdk.dashboards.models.UpdateSnapshotExpirationDateApiRequest.from_json(request_body_json) + snapshot_id = 'd28bb71f-5a47-4783-8f12-d4b115e61b0c' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.update_dashboard_snapshot_expiration_date( + + snapshot_id=snapshot_id, + + update_snapshot_expiration_date_api_request=update_snapshot_expiration_date_api_request, + + aid=aid, + + _headers=self.te_headers("update_dashboard_snapshot_expiration_date", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-dashboards/test/test_dashboards_api_integration.py b/thousandeyes-sdk-dashboards/test/test_dashboards_api_integration.py new file mode 100644 index 00000000..c2ff1ea4 --- /dev/null +++ b/thousandeyes-sdk-dashboards/test/test_dashboards_api_integration.py @@ -0,0 +1,5101 @@ +# coding: utf-8 + +""" + Dashboards API + + Manage ThousandEyes Dashboards. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.dashboards.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.dashboards.api.dashboards_api import DashboardsApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestDashboardsApiIntegration(IntegrationTestBase): + """DashboardsApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = DashboardsApi(self.api_client) + + + def test_create_dashboard_happy_path(self) -> None: + """Integration test for create_dashboard success path""" + request_body_json = """ + + { + "isMigratedReport" : false, + "_links" : { + "snapshots" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isDefaultForAccount" : false, + "isDefaultForUser" : true, + "description" : "HTTP Server Widgets", + "isPrivate" : true, + "title" : "HTTP Server Widgets", + "isBuiltIn" : true, + "widgets" : [ { + "embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f", + "shouldExcludeAlertSuppressionWindows" : true, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "visualMode" : "Full", + "filters" : { + "TEST" : [ 5187, 5227 ], + "ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ] + }, + "title" : "Widget Title", + "type" : "Agent Status", + "metricGroup" : "BGP", + "measure" : { + "percentileValue" : 95, + "type" : "MEAN" + }, + "apiLink" : "apiLink", + "metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT", + "isEmbedded" : true, + "id" : "1234", + "fixedTimespan" : { + "unit" : "Days", + "value" : 10 + }, + "dataSource" : "ENDPOINT_AGENTS", + "direction" : "FROM_TARGET" + }, { + "embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f", + "shouldExcludeAlertSuppressionWindows" : true, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "visualMode" : "Full", + "filters" : { + "TEST" : [ 5187, 5227 ], + "ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ] + }, + "title" : "Widget Title", + "type" : "Agent Status", + "metricGroup" : "BGP", + "measure" : { + "percentileValue" : 95, + "type" : "MEAN" + }, + "apiLink" : "apiLink", + "metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT", + "isEmbedded" : true, + "id" : "1234", + "fixedTimespan" : { + "unit" : "Days", + "value" : 10 + }, + "dataSource" : "ENDPOINT_AGENTS", + "direction" : "FROM_TARGET" + } ], + "defaultTimespan" : { + "duration" : 7200, + "timespanDuration" : 7200, + "start" : "2023-05-16T10:14:28Z", + "end" : "2023-05-16T11:14:28Z", + "timespanStart" : "2023-05-16 10:14:28", + "timespanEnd" : "2023-05-16 11:14:28" + }, + "layout" : { + "layoutId" : "grid-layout-1", + "type" : "grid", + "details" : { + "widgetPositioning" : [ { + "x" : 0, + "y" : 0, + "w" : 9, + "h" : 5, + "id" : "widgetId-71lbb" + } ] + } + }, + "globalFilterId" : "65babd9bb90bf55b17c96c8d", + "dashboardId" : "5e1f7a99143ae6004fdc3bb4", + "createdBy" : "1", + "modifiedDate" : "2023-05-16T10:14:28Z", + "modifiedBy" : "1", + "isGlobalOverride" : true, + "aid" : "1234" + } + + """ + dashboard = thousandeyes_sdk.dashboards.models.Dashboard.from_json(request_body_json) + aid = '1234' + response_body_json = """ + { + "isMigratedReport" : false, + "_links" : { + "snapshots" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isDefaultForAccount" : false, + "isDefaultForUser" : true, + "description" : "HTTP Server Widgets", + "isPrivate" : true, + "title" : "HTTP Server Widgets", + "isBuiltIn" : true, + "widgets" : [ { + "embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f", + "shouldExcludeAlertSuppressionWindows" : true, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "visualMode" : "Full", + "filters" : { + "TEST" : [ 5187, 5227 ], + "ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ] + }, + "title" : "Widget Title", + "type" : "Agent Status", + "metricGroup" : "BGP", + "measure" : { + "percentileValue" : 95, + "type" : "MEAN" + }, + "apiLink" : "apiLink", + "metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT", + "isEmbedded" : true, + "id" : "1234", + "fixedTimespan" : { + "unit" : "Days", + "value" : 10 + }, + "dataSource" : "ENDPOINT_AGENTS", + "direction" : "FROM_TARGET" + }, { + "embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f", + "shouldExcludeAlertSuppressionWindows" : true, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "visualMode" : "Full", + "filters" : { + "TEST" : [ 5187, 5227 ], + "ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ] + }, + "title" : "Widget Title", + "type" : "Agent Status", + "metricGroup" : "BGP", + "measure" : { + "percentileValue" : 95, + "type" : "MEAN" + }, + "apiLink" : "apiLink", + "metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT", + "isEmbedded" : true, + "id" : "1234", + "fixedTimespan" : { + "unit" : "Days", + "value" : 10 + }, + "dataSource" : "ENDPOINT_AGENTS", + "direction" : "FROM_TARGET" + } ], + "defaultTimespan" : { + "duration" : 7200, + "timespanDuration" : 7200, + "start" : "2023-05-16T10:14:28Z", + "end" : "2023-05-16T11:14:28Z", + "timespanStart" : "2023-05-16 10:14:28", + "timespanEnd" : "2023-05-16 11:14:28" + }, + "layout" : { + "layoutId" : "grid-layout-1", + "type" : "grid", + "details" : { + "widgetPositioning" : [ { + "x" : 0, + "y" : 0, + "w" : 9, + "h" : 5, + "id" : "widgetId-71lbb" + } ] + } + }, + "globalFilterId" : "65babd9bb90bf55b17c96c8d", + "dashboardId" : "5e1f7a99143ae6004fdc3bb4", + "createdBy" : "1", + "modifiedDate" : "2023-05-16T10:14:28Z", + "modifiedBy" : "1", + "isGlobalOverride" : true, + "aid" : "1234" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.create_dashboard( + + dashboard=dashboard, + + aid=aid, + + _headers=self.te_headers("create_dashboard"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_create_dashboard_error_400(self) -> None: + """Integration test for create_dashboard error path (HTTP 400)""" + request_body_json = """ + + { + "isMigratedReport" : false, + "_links" : { + "snapshots" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isDefaultForAccount" : false, + "isDefaultForUser" : true, + "description" : "HTTP Server Widgets", + "isPrivate" : true, + "title" : "HTTP Server Widgets", + "isBuiltIn" : true, + "widgets" : [ { + "embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f", + "shouldExcludeAlertSuppressionWindows" : true, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "visualMode" : "Full", + "filters" : { + "TEST" : [ 5187, 5227 ], + "ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ] + }, + "title" : "Widget Title", + "type" : "Agent Status", + "metricGroup" : "BGP", + "measure" : { + "percentileValue" : 95, + "type" : "MEAN" + }, + "apiLink" : "apiLink", + "metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT", + "isEmbedded" : true, + "id" : "1234", + "fixedTimespan" : { + "unit" : "Days", + "value" : 10 + }, + "dataSource" : "ENDPOINT_AGENTS", + "direction" : "FROM_TARGET" + }, { + "embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f", + "shouldExcludeAlertSuppressionWindows" : true, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "visualMode" : "Full", + "filters" : { + "TEST" : [ 5187, 5227 ], + "ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ] + }, + "title" : "Widget Title", + "type" : "Agent Status", + "metricGroup" : "BGP", + "measure" : { + "percentileValue" : 95, + "type" : "MEAN" + }, + "apiLink" : "apiLink", + "metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT", + "isEmbedded" : true, + "id" : "1234", + "fixedTimespan" : { + "unit" : "Days", + "value" : 10 + }, + "dataSource" : "ENDPOINT_AGENTS", + "direction" : "FROM_TARGET" + } ], + "defaultTimespan" : { + "duration" : 7200, + "timespanDuration" : 7200, + "start" : "2023-05-16T10:14:28Z", + "end" : "2023-05-16T11:14:28Z", + "timespanStart" : "2023-05-16 10:14:28", + "timespanEnd" : "2023-05-16 11:14:28" + }, + "layout" : { + "layoutId" : "grid-layout-1", + "type" : "grid", + "details" : { + "widgetPositioning" : [ { + "x" : 0, + "y" : 0, + "w" : 9, + "h" : 5, + "id" : "widgetId-71lbb" + } ] + } + }, + "globalFilterId" : "65babd9bb90bf55b17c96c8d", + "dashboardId" : "5e1f7a99143ae6004fdc3bb4", + "createdBy" : "1", + "modifiedDate" : "2023-05-16T10:14:28Z", + "modifiedBy" : "1", + "isGlobalOverride" : true, + "aid" : "1234" + } + + """ + dashboard = thousandeyes_sdk.dashboards.models.Dashboard.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.create_dashboard( + + dashboard=dashboard, + + aid=aid, + + _headers=self.te_headers("create_dashboard", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_dashboard_error_401(self) -> None: + """Integration test for create_dashboard error path (HTTP 401)""" + request_body_json = """ + + { + "isMigratedReport" : false, + "_links" : { + "snapshots" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isDefaultForAccount" : false, + "isDefaultForUser" : true, + "description" : "HTTP Server Widgets", + "isPrivate" : true, + "title" : "HTTP Server Widgets", + "isBuiltIn" : true, + "widgets" : [ { + "embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f", + "shouldExcludeAlertSuppressionWindows" : true, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "visualMode" : "Full", + "filters" : { + "TEST" : [ 5187, 5227 ], + "ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ] + }, + "title" : "Widget Title", + "type" : "Agent Status", + "metricGroup" : "BGP", + "measure" : { + "percentileValue" : 95, + "type" : "MEAN" + }, + "apiLink" : "apiLink", + "metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT", + "isEmbedded" : true, + "id" : "1234", + "fixedTimespan" : { + "unit" : "Days", + "value" : 10 + }, + "dataSource" : "ENDPOINT_AGENTS", + "direction" : "FROM_TARGET" + }, { + "embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f", + "shouldExcludeAlertSuppressionWindows" : true, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "visualMode" : "Full", + "filters" : { + "TEST" : [ 5187, 5227 ], + "ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ] + }, + "title" : "Widget Title", + "type" : "Agent Status", + "metricGroup" : "BGP", + "measure" : { + "percentileValue" : 95, + "type" : "MEAN" + }, + "apiLink" : "apiLink", + "metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT", + "isEmbedded" : true, + "id" : "1234", + "fixedTimespan" : { + "unit" : "Days", + "value" : 10 + }, + "dataSource" : "ENDPOINT_AGENTS", + "direction" : "FROM_TARGET" + } ], + "defaultTimespan" : { + "duration" : 7200, + "timespanDuration" : 7200, + "start" : "2023-05-16T10:14:28Z", + "end" : "2023-05-16T11:14:28Z", + "timespanStart" : "2023-05-16 10:14:28", + "timespanEnd" : "2023-05-16 11:14:28" + }, + "layout" : { + "layoutId" : "grid-layout-1", + "type" : "grid", + "details" : { + "widgetPositioning" : [ { + "x" : 0, + "y" : 0, + "w" : 9, + "h" : 5, + "id" : "widgetId-71lbb" + } ] + } + }, + "globalFilterId" : "65babd9bb90bf55b17c96c8d", + "dashboardId" : "5e1f7a99143ae6004fdc3bb4", + "createdBy" : "1", + "modifiedDate" : "2023-05-16T10:14:28Z", + "modifiedBy" : "1", + "isGlobalOverride" : true, + "aid" : "1234" + } + + """ + dashboard = thousandeyes_sdk.dashboards.models.Dashboard.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.create_dashboard( + + dashboard=dashboard, + + aid=aid, + + _headers=self.te_headers("create_dashboard", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_dashboard_error_403(self) -> None: + """Integration test for create_dashboard error path (HTTP 403)""" + request_body_json = """ + + { + "isMigratedReport" : false, + "_links" : { + "snapshots" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isDefaultForAccount" : false, + "isDefaultForUser" : true, + "description" : "HTTP Server Widgets", + "isPrivate" : true, + "title" : "HTTP Server Widgets", + "isBuiltIn" : true, + "widgets" : [ { + "embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f", + "shouldExcludeAlertSuppressionWindows" : true, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "visualMode" : "Full", + "filters" : { + "TEST" : [ 5187, 5227 ], + "ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ] + }, + "title" : "Widget Title", + "type" : "Agent Status", + "metricGroup" : "BGP", + "measure" : { + "percentileValue" : 95, + "type" : "MEAN" + }, + "apiLink" : "apiLink", + "metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT", + "isEmbedded" : true, + "id" : "1234", + "fixedTimespan" : { + "unit" : "Days", + "value" : 10 + }, + "dataSource" : "ENDPOINT_AGENTS", + "direction" : "FROM_TARGET" + }, { + "embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f", + "shouldExcludeAlertSuppressionWindows" : true, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "visualMode" : "Full", + "filters" : { + "TEST" : [ 5187, 5227 ], + "ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ] + }, + "title" : "Widget Title", + "type" : "Agent Status", + "metricGroup" : "BGP", + "measure" : { + "percentileValue" : 95, + "type" : "MEAN" + }, + "apiLink" : "apiLink", + "metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT", + "isEmbedded" : true, + "id" : "1234", + "fixedTimespan" : { + "unit" : "Days", + "value" : 10 + }, + "dataSource" : "ENDPOINT_AGENTS", + "direction" : "FROM_TARGET" + } ], + "defaultTimespan" : { + "duration" : 7200, + "timespanDuration" : 7200, + "start" : "2023-05-16T10:14:28Z", + "end" : "2023-05-16T11:14:28Z", + "timespanStart" : "2023-05-16 10:14:28", + "timespanEnd" : "2023-05-16 11:14:28" + }, + "layout" : { + "layoutId" : "grid-layout-1", + "type" : "grid", + "details" : { + "widgetPositioning" : [ { + "x" : 0, + "y" : 0, + "w" : 9, + "h" : 5, + "id" : "widgetId-71lbb" + } ] + } + }, + "globalFilterId" : "65babd9bb90bf55b17c96c8d", + "dashboardId" : "5e1f7a99143ae6004fdc3bb4", + "createdBy" : "1", + "modifiedDate" : "2023-05-16T10:14:28Z", + "modifiedBy" : "1", + "isGlobalOverride" : true, + "aid" : "1234" + } + + """ + dashboard = thousandeyes_sdk.dashboards.models.Dashboard.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.create_dashboard( + + dashboard=dashboard, + + aid=aid, + + _headers=self.te_headers("create_dashboard", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_dashboard_error_404(self) -> None: + """Integration test for create_dashboard error path (HTTP 404)""" + request_body_json = """ + + { + "isMigratedReport" : false, + "_links" : { + "snapshots" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isDefaultForAccount" : false, + "isDefaultForUser" : true, + "description" : "HTTP Server Widgets", + "isPrivate" : true, + "title" : "HTTP Server Widgets", + "isBuiltIn" : true, + "widgets" : [ { + "embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f", + "shouldExcludeAlertSuppressionWindows" : true, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "visualMode" : "Full", + "filters" : { + "TEST" : [ 5187, 5227 ], + "ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ] + }, + "title" : "Widget Title", + "type" : "Agent Status", + "metricGroup" : "BGP", + "measure" : { + "percentileValue" : 95, + "type" : "MEAN" + }, + "apiLink" : "apiLink", + "metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT", + "isEmbedded" : true, + "id" : "1234", + "fixedTimespan" : { + "unit" : "Days", + "value" : 10 + }, + "dataSource" : "ENDPOINT_AGENTS", + "direction" : "FROM_TARGET" + }, { + "embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f", + "shouldExcludeAlertSuppressionWindows" : true, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "visualMode" : "Full", + "filters" : { + "TEST" : [ 5187, 5227 ], + "ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ] + }, + "title" : "Widget Title", + "type" : "Agent Status", + "metricGroup" : "BGP", + "measure" : { + "percentileValue" : 95, + "type" : "MEAN" + }, + "apiLink" : "apiLink", + "metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT", + "isEmbedded" : true, + "id" : "1234", + "fixedTimespan" : { + "unit" : "Days", + "value" : 10 + }, + "dataSource" : "ENDPOINT_AGENTS", + "direction" : "FROM_TARGET" + } ], + "defaultTimespan" : { + "duration" : 7200, + "timespanDuration" : 7200, + "start" : "2023-05-16T10:14:28Z", + "end" : "2023-05-16T11:14:28Z", + "timespanStart" : "2023-05-16 10:14:28", + "timespanEnd" : "2023-05-16 11:14:28" + }, + "layout" : { + "layoutId" : "grid-layout-1", + "type" : "grid", + "details" : { + "widgetPositioning" : [ { + "x" : 0, + "y" : 0, + "w" : 9, + "h" : 5, + "id" : "widgetId-71lbb" + } ] + } + }, + "globalFilterId" : "65babd9bb90bf55b17c96c8d", + "dashboardId" : "5e1f7a99143ae6004fdc3bb4", + "createdBy" : "1", + "modifiedDate" : "2023-05-16T10:14:28Z", + "modifiedBy" : "1", + "isGlobalOverride" : true, + "aid" : "1234" + } + + """ + dashboard = thousandeyes_sdk.dashboards.models.Dashboard.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.create_dashboard( + + dashboard=dashboard, + + aid=aid, + + _headers=self.te_headers("create_dashboard", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_dashboard_error_429(self) -> None: + """Integration test for create_dashboard error path (HTTP 429)""" + request_body_json = """ + + { + "isMigratedReport" : false, + "_links" : { + "snapshots" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isDefaultForAccount" : false, + "isDefaultForUser" : true, + "description" : "HTTP Server Widgets", + "isPrivate" : true, + "title" : "HTTP Server Widgets", + "isBuiltIn" : true, + "widgets" : [ { + "embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f", + "shouldExcludeAlertSuppressionWindows" : true, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "visualMode" : "Full", + "filters" : { + "TEST" : [ 5187, 5227 ], + "ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ] + }, + "title" : "Widget Title", + "type" : "Agent Status", + "metricGroup" : "BGP", + "measure" : { + "percentileValue" : 95, + "type" : "MEAN" + }, + "apiLink" : "apiLink", + "metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT", + "isEmbedded" : true, + "id" : "1234", + "fixedTimespan" : { + "unit" : "Days", + "value" : 10 + }, + "dataSource" : "ENDPOINT_AGENTS", + "direction" : "FROM_TARGET" + }, { + "embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f", + "shouldExcludeAlertSuppressionWindows" : true, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "visualMode" : "Full", + "filters" : { + "TEST" : [ 5187, 5227 ], + "ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ] + }, + "title" : "Widget Title", + "type" : "Agent Status", + "metricGroup" : "BGP", + "measure" : { + "percentileValue" : 95, + "type" : "MEAN" + }, + "apiLink" : "apiLink", + "metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT", + "isEmbedded" : true, + "id" : "1234", + "fixedTimespan" : { + "unit" : "Days", + "value" : 10 + }, + "dataSource" : "ENDPOINT_AGENTS", + "direction" : "FROM_TARGET" + } ], + "defaultTimespan" : { + "duration" : 7200, + "timespanDuration" : 7200, + "start" : "2023-05-16T10:14:28Z", + "end" : "2023-05-16T11:14:28Z", + "timespanStart" : "2023-05-16 10:14:28", + "timespanEnd" : "2023-05-16 11:14:28" + }, + "layout" : { + "layoutId" : "grid-layout-1", + "type" : "grid", + "details" : { + "widgetPositioning" : [ { + "x" : 0, + "y" : 0, + "w" : 9, + "h" : 5, + "id" : "widgetId-71lbb" + } ] + } + }, + "globalFilterId" : "65babd9bb90bf55b17c96c8d", + "dashboardId" : "5e1f7a99143ae6004fdc3bb4", + "createdBy" : "1", + "modifiedDate" : "2023-05-16T10:14:28Z", + "modifiedBy" : "1", + "isGlobalOverride" : true, + "aid" : "1234" + } + + """ + dashboard = thousandeyes_sdk.dashboards.models.Dashboard.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.create_dashboard( + + dashboard=dashboard, + + aid=aid, + + _headers=self.te_headers("create_dashboard", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_dashboard_error_500(self) -> None: + """Integration test for create_dashboard error path (HTTP 500)""" + request_body_json = """ + + { + "isMigratedReport" : false, + "_links" : { + "snapshots" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isDefaultForAccount" : false, + "isDefaultForUser" : true, + "description" : "HTTP Server Widgets", + "isPrivate" : true, + "title" : "HTTP Server Widgets", + "isBuiltIn" : true, + "widgets" : [ { + "embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f", + "shouldExcludeAlertSuppressionWindows" : true, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "visualMode" : "Full", + "filters" : { + "TEST" : [ 5187, 5227 ], + "ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ] + }, + "title" : "Widget Title", + "type" : "Agent Status", + "metricGroup" : "BGP", + "measure" : { + "percentileValue" : 95, + "type" : "MEAN" + }, + "apiLink" : "apiLink", + "metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT", + "isEmbedded" : true, + "id" : "1234", + "fixedTimespan" : { + "unit" : "Days", + "value" : 10 + }, + "dataSource" : "ENDPOINT_AGENTS", + "direction" : "FROM_TARGET" + }, { + "embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f", + "shouldExcludeAlertSuppressionWindows" : true, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "visualMode" : "Full", + "filters" : { + "TEST" : [ 5187, 5227 ], + "ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ] + }, + "title" : "Widget Title", + "type" : "Agent Status", + "metricGroup" : "BGP", + "measure" : { + "percentileValue" : 95, + "type" : "MEAN" + }, + "apiLink" : "apiLink", + "metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT", + "isEmbedded" : true, + "id" : "1234", + "fixedTimespan" : { + "unit" : "Days", + "value" : 10 + }, + "dataSource" : "ENDPOINT_AGENTS", + "direction" : "FROM_TARGET" + } ], + "defaultTimespan" : { + "duration" : 7200, + "timespanDuration" : 7200, + "start" : "2023-05-16T10:14:28Z", + "end" : "2023-05-16T11:14:28Z", + "timespanStart" : "2023-05-16 10:14:28", + "timespanEnd" : "2023-05-16 11:14:28" + }, + "layout" : { + "layoutId" : "grid-layout-1", + "type" : "grid", + "details" : { + "widgetPositioning" : [ { + "x" : 0, + "y" : 0, + "w" : 9, + "h" : 5, + "id" : "widgetId-71lbb" + } ] + } + }, + "globalFilterId" : "65babd9bb90bf55b17c96c8d", + "dashboardId" : "5e1f7a99143ae6004fdc3bb4", + "createdBy" : "1", + "modifiedDate" : "2023-05-16T10:14:28Z", + "modifiedBy" : "1", + "isGlobalOverride" : true, + "aid" : "1234" + } + + """ + dashboard = thousandeyes_sdk.dashboards.models.Dashboard.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.create_dashboard( + + dashboard=dashboard, + + aid=aid, + + _headers=self.te_headers("create_dashboard", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_delete_dashboard_happy_path(self) -> None: + """Integration test for delete_dashboard success path""" + dashboard_id = '646f4d2ce3c99b0536c3821e' + aid = '1234' + response = self.api.delete_dashboard_with_http_info( + + dashboard_id=dashboard_id, + + aid=aid, + + _headers=self.te_headers("delete_dashboard"), + ) + self.assertEqual(204, response.status_code) + self.assertIsNone(response.data) + + + def test_delete_dashboard_error_400(self) -> None: + """Integration test for delete_dashboard error path (HTTP 400)""" + dashboard_id = '646f4d2ce3c99b0536c3821e' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.delete_dashboard( + + dashboard_id=dashboard_id, + + aid=aid, + + _headers=self.te_headers("delete_dashboard", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_dashboard_error_401(self) -> None: + """Integration test for delete_dashboard error path (HTTP 401)""" + dashboard_id = '646f4d2ce3c99b0536c3821e' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.delete_dashboard( + + dashboard_id=dashboard_id, + + aid=aid, + + _headers=self.te_headers("delete_dashboard", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_dashboard_error_403(self) -> None: + """Integration test for delete_dashboard error path (HTTP 403)""" + dashboard_id = '646f4d2ce3c99b0536c3821e' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.delete_dashboard( + + dashboard_id=dashboard_id, + + aid=aid, + + _headers=self.te_headers("delete_dashboard", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_dashboard_error_404(self) -> None: + """Integration test for delete_dashboard error path (HTTP 404)""" + dashboard_id = '646f4d2ce3c99b0536c3821e' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.delete_dashboard( + + dashboard_id=dashboard_id, + + aid=aid, + + _headers=self.te_headers("delete_dashboard", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_dashboard_error_429(self) -> None: + """Integration test for delete_dashboard error path (HTTP 429)""" + dashboard_id = '646f4d2ce3c99b0536c3821e' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.delete_dashboard( + + dashboard_id=dashboard_id, + + aid=aid, + + _headers=self.te_headers("delete_dashboard", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_dashboard_error_500(self) -> None: + """Integration test for delete_dashboard error path (HTTP 500)""" + dashboard_id = '646f4d2ce3c99b0536c3821e' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.delete_dashboard( + + dashboard_id=dashboard_id, + + aid=aid, + + _headers=self.te_headers("delete_dashboard", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_dashboard_happy_path(self) -> None: + """Integration test for get_dashboard success path""" + dashboard_id = '646f4d2ce3c99b0536c3821e' + aid = '1234' + response_body_json = """ + { + "isMigratedReport" : false, + "dashboardCreatedBy" : "1", + "_links" : { + "snapshots" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isDefaultForUser" : true, + "description" : "HTTP Server Widgets", + "isPrivate" : true, + "title" : "HTTP Server Widgets", + "isBuiltIn" : true, + "widgets" : [ { + "embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f", + "shouldExcludeAlertSuppressionWindows" : true, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "visualMode" : "Full", + "filters" : { + "TEST" : [ 5187, 5227 ], + "ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ] + }, + "title" : "Widget Title", + "type" : "Agent Status", + "metricGroup" : "BGP", + "measure" : { + "percentileValue" : 95, + "type" : "MEAN" + }, + "apiLink" : "apiLink", + "metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT", + "isEmbedded" : true, + "id" : "1234", + "fixedTimespan" : { + "unit" : "Days", + "value" : 10 + }, + "dataSource" : "ENDPOINT_AGENTS", + "direction" : "FROM_TARGET" + }, { + "embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f", + "shouldExcludeAlertSuppressionWindows" : true, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "visualMode" : "Full", + "filters" : { + "TEST" : [ 5187, 5227 ], + "ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ] + }, + "title" : "Widget Title", + "type" : "Agent Status", + "metricGroup" : "BGP", + "measure" : { + "percentileValue" : 95, + "type" : "MEAN" + }, + "apiLink" : "apiLink", + "metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT", + "isEmbedded" : true, + "id" : "1234", + "fixedTimespan" : { + "unit" : "Days", + "value" : 10 + }, + "dataSource" : "ENDPOINT_AGENTS", + "direction" : "FROM_TARGET" + } ], + "globalFilterId" : "65babd9bb90bf55b17c96c8d", + "modifiedBy" : 1, + "dashboardModifiedBy" : "1", + "migratedReport" : false, + "isDefaultForAccount" : false, + "defaultTimespan" : { + "duration" : 7200, + "timespanDuration" : 7200, + "start" : "2023-05-16T10:14:28Z", + "end" : "2023-05-16T11:14:28Z", + "timespanStart" : "2023-05-16 10:14:28", + "timespanEnd" : "2023-05-16 11:14:28" + }, + "layout" : { + "layoutId" : "grid-layout-1", + "type" : "grid", + "details" : { + "widgetPositioning" : [ { + "x" : 0, + "y" : 0, + "w" : 9, + "h" : 5, + "id" : "widgetId-71lbb" + } ] + } + }, + "accountId" : 1234, + "apiLink" : [ { + "key" : "" + }, { + "key" : "" + } ], + "dashboardId" : "5e1f7a99143ae6004fdc3bb4", + "createdBy" : 1, + "globalOverride" : true, + "modifiedDate" : "2023-05-16 10:14:28", + "isGlobalOverride" : true, + "aid" : "1234", + "dashboardModifiedDate" : "2023-05-16T10:14:28Z" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_dashboard( + + dashboard_id=dashboard_id, + + aid=aid, + + _headers=self.te_headers("get_dashboard"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_dashboard_error_400(self) -> None: + """Integration test for get_dashboard error path (HTTP 400)""" + dashboard_id = '646f4d2ce3c99b0536c3821e' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.get_dashboard( + + dashboard_id=dashboard_id, + + aid=aid, + + _headers=self.te_headers("get_dashboard", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_dashboard_error_401(self) -> None: + """Integration test for get_dashboard error path (HTTP 401)""" + dashboard_id = '646f4d2ce3c99b0536c3821e' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_dashboard( + + dashboard_id=dashboard_id, + + aid=aid, + + _headers=self.te_headers("get_dashboard", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_dashboard_error_403(self) -> None: + """Integration test for get_dashboard error path (HTTP 403)""" + dashboard_id = '646f4d2ce3c99b0536c3821e' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_dashboard( + + dashboard_id=dashboard_id, + + aid=aid, + + _headers=self.te_headers("get_dashboard", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_dashboard_error_404(self) -> None: + """Integration test for get_dashboard error path (HTTP 404)""" + dashboard_id = '646f4d2ce3c99b0536c3821e' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_dashboard( + + dashboard_id=dashboard_id, + + aid=aid, + + _headers=self.te_headers("get_dashboard", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_dashboard_error_429(self) -> None: + """Integration test for get_dashboard error path (HTTP 429)""" + dashboard_id = '646f4d2ce3c99b0536c3821e' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_dashboard( + + dashboard_id=dashboard_id, + + aid=aid, + + _headers=self.te_headers("get_dashboard", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_dashboard_error_500(self) -> None: + """Integration test for get_dashboard error path (HTTP 500)""" + dashboard_id = '646f4d2ce3c99b0536c3821e' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_dashboard( + + dashboard_id=dashboard_id, + + aid=aid, + + _headers=self.te_headers("get_dashboard", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_dashboard_widget_data_happy_path(self) -> None: + """Integration test for get_dashboard_widget_data success path""" + dashboard_id = '646f4d2ce3c99b0536c3821e' + widget_id = 'unpmg' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + max = 10 + cursor = 'bGFzdFJvdW5kSWQ9MTY4MTQxMDQ4MA' + sort = 'alertStatus' + response_body_json = """ + { + "groupLabels" : [ { + "groupProperty" : "AGENT", + "groupLabels" : [ { + "groupId" : "2565", + "groupLabel" : "San Francisco, CA" + }, { + "groupId" : "2565", + "groupLabel" : "San Francisco, CA" + } ] + }, { + "groupProperty" : "AGENT", + "groupLabels" : [ { + "groupId" : "2565", + "groupLabel" : "San Francisco, CA" + }, { + "groupId" : "2565", + "groupLabel" : "San Francisco, CA" + } ] + } ], + "data" : { + "alerts" : [ { + "alertType" : "network-end-to-end-server", + "durationInSeconds" : 25, + "alertSource" : "Http Test", + "active" : true, + "testId" : "56512", + "startTime" : "2023-06-02T08:54:00Z", + "alertId" : "2004945", + "ruleId" : "281724", + "alertRule" : "Http Test Rule" + }, { + "alertType" : "network-end-to-end-server", + "durationInSeconds" : 25, + "alertSource" : "Http Test", + "active" : true, + "testId" : "56512", + "startTime" : "2023-06-02T08:54:00Z", + "alertId" : "2004945", + "ruleId" : "281724", + "alertRule" : "Http Test Rule" + } ], + "summary" : { + "offline" : 2, + "online" : 10, + "disabled" : 3 + }, + "totalAlerts" : 500, + "cards" : [ { + "numberOfDataPoints" : 24192, + "cardName" : "Card Name", + "endDate" : "2023-05-16T10:14:28Z", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "cardId" : "lrxxr", + "alertSuppressionWindows" : [ { + "testIds" : [ "281474976710661" ], + "repeatUnit" : "week", + "durationInSeconds" : 7200, + "repeat" : "custom", + "name" : "Test dashboards", + "repeatEvery" : 5, + "id" : "281474976710662", + "startTimes" : [ "2023-05-16T10:14:28Z" ] + }, { + "testIds" : [ "281474976710661" ], + "repeatUnit" : "week", + "durationInSeconds" : 7200, + "repeat" : "custom", + "name" : "Test dashboards", + "repeatEvery" : 5, + "id" : "281474976710662", + "startTimes" : [ "2023-05-16T10:14:28Z" ] + } ], + "binSize" : 3600, + "previousValue" : 500, + "value" : 100, + "startDate" : "2023-05-16T10:14:28Z", + "timestamp" : 1567620000, + "status" : "No data" + }, { + "numberOfDataPoints" : 24192, + "cardName" : "Card Name", + "endDate" : "2023-05-16T10:14:28Z", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "cardId" : "lrxxr", + "alertSuppressionWindows" : [ { + "testIds" : [ "281474976710661" ], + "repeatUnit" : "week", + "durationInSeconds" : 7200, + "repeat" : "custom", + "name" : "Test dashboards", + "repeatEvery" : 5, + "id" : "281474976710662", + "startTimes" : [ "2023-05-16T10:14:28Z" ] + }, { + "testIds" : [ "281474976710661" ], + "repeatUnit" : "week", + "durationInSeconds" : 7200, + "repeat" : "custom", + "name" : "Test dashboards", + "repeatEvery" : 5, + "id" : "281474976710662", + "startTimes" : [ "2023-05-16T10:14:28Z" ] + } ], + "binSize" : 3600, + "previousValue" : 500, + "value" : 100, + "startDate" : "2023-05-16T10:14:28Z", + "timestamp" : 1567620000, + "status" : "No data" + } ], + "tests" : [ { + "graphlets" : [ { + "metric" : "Availability", + "testId" : "68257", + "points" : [ { + "x" : 1580403900, + "y" : 128.249 + }, { + "x" : 1580403900, + "y" : 128.249 + } ] + }, { + "metric" : "Availability", + "testId" : "68257", + "points" : [ { + "x" : 1580403900, + "y" : 128.249 + }, { + "x" : 1580403900, + "y" : 128.249 + } ] + } ], + "alertCount" : 398, + "testType" : "Web - HTTP Server", + "testId" : "68256", + "isShared" : true, + "testName" : "Http Test Name", + "target" : "www.google.com" + }, { + "graphlets" : [ { + "metric" : "Availability", + "testId" : "68257", + "points" : [ { + "x" : 1580403900, + "y" : 128.249 + }, { + "x" : 1580403900, + "y" : 128.249 + } ] + }, { + "metric" : "Availability", + "testId" : "68257", + "points" : [ { + "x" : 1580403900, + "y" : 128.249 + }, { + "x" : 1580403900, + "y" : 128.249 + } ] + } ], + "alertCount" : 398, + "testType" : "Web - HTTP Server", + "testId" : "68256", + "isShared" : true, + "testName" : "Http Test Name", + "target" : "www.google.com" + } ], + "columns" : [ { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "columnId" : "938to", + "alertSuppressionWindows" : [ { + "testIds" : [ "281474976710661" ], + "repeatUnit" : "week", + "durationInSeconds" : 7200, + "repeat" : "custom", + "name" : "Test dashboards", + "repeatEvery" : 5, + "id" : "281474976710662", + "startTimes" : [ "2023-05-16T10:14:28Z" ] + }, { + "testIds" : [ "281474976710661" ], + "repeatUnit" : "week", + "durationInSeconds" : 7200, + "repeat" : "custom", + "name" : "Test dashboards", + "repeatEvery" : 5, + "id" : "281474976710662", + "startTimes" : [ "2023-05-16T10:14:28Z" ] + } ], + "binSize" : 3600, + "points" : [ { + "numberOfDataPoints" : 23304, + "groups" : [ { + "groupProperty" : "COUNTRY", + "groupValue" : "US" + }, { + "groupProperty" : "COUNTRY", + "groupValue" : "US" + } ], + "value" : 100, + "timestamp" : 1567620000 + }, { + "numberOfDataPoints" : 23304, + "groups" : [ { + "groupProperty" : "COUNTRY", + "groupValue" : "US" + }, { + "groupProperty" : "COUNTRY", + "groupValue" : "US" + } ], + "value" : 100, + "timestamp" : 1567620000 + } ], + "status" : "No data" + }, { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "columnId" : "938to", + "alertSuppressionWindows" : [ { + "testIds" : [ "281474976710661" ], + "repeatUnit" : "week", + "durationInSeconds" : 7200, + "repeat" : "custom", + "name" : "Test dashboards", + "repeatEvery" : 5, + "id" : "281474976710662", + "startTimes" : [ "2023-05-16T10:14:28Z" ] + }, { + "testIds" : [ "281474976710661" ], + "repeatUnit" : "week", + "durationInSeconds" : 7200, + "repeat" : "custom", + "name" : "Test dashboards", + "repeatEvery" : 5, + "id" : "281474976710662", + "startTimes" : [ "2023-05-16T10:14:28Z" ] + } ], + "binSize" : 3600, + "points" : [ { + "numberOfDataPoints" : 23304, + "groups" : [ { + "groupProperty" : "COUNTRY", + "groupValue" : "US" + }, { + "groupProperty" : "COUNTRY", + "groupValue" : "US" + } ], + "value" : 100, + "timestamp" : 1567620000 + }, { + "numberOfDataPoints" : 23304, + "groups" : [ { + "groupProperty" : "COUNTRY", + "groupValue" : "US" + }, { + "groupProperty" : "COUNTRY", + "groupValue" : "US" + } ], + "value" : 100, + "timestamp" : 1567620000 + } ], + "status" : "No data" + } ], + "alertSuppressionWindows" : [ { + "testIds" : [ "281474976710661" ], + "repeatUnit" : "week", + "durationInSeconds" : 7200, + "repeat" : "custom", + "name" : "Test dashboards", + "repeatEvery" : 5, + "id" : "281474976710662", + "startTimes" : [ "2023-05-16T10:14:28Z" ] + }, { + "testIds" : [ "281474976710661" ], + "repeatUnit" : "week", + "durationInSeconds" : 7200, + "repeat" : "custom", + "name" : "Test dashboards", + "repeatEvery" : 5, + "id" : "281474976710662", + "startTimes" : [ "2023-05-16T10:14:28Z" ] + } ], + "activeAlerts" : 483, + "startRound" : 1384309800, + "points" : [ { + "numberOfDataPoints" : 23304, + "groups" : [ { + "groupProperty" : "COUNTRY", + "groupValue" : "US" + }, { + "groupProperty" : "COUNTRY", + "groupValue" : "US" + } ], + "value" : 100, + "timestamp" : 1567620000 + }, { + "numberOfDataPoints" : 23304, + "groups" : [ { + "groupProperty" : "COUNTRY", + "groupValue" : "US" + }, { + "groupProperty" : "COUNTRY", + "groupValue" : "US" + } ], + "value" : 100, + "timestamp" : 1567620000 + } ], + "agents" : [ { + "agentId" : "6522", + "agentName" : "0c3898000117", + "location" : { + "locationName" : "San Francisco, California, US", + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "ipInfo" : { + "ipv6" : "ipv6", + "privateIp" : "172.58.92.31", + "operativeSystemVersion" : "operativeSystemVersion", + "publicIp" : "172.58.92.31" + }, + "status" : "online" + }, { + "agentId" : "6522", + "agentName" : "0c3898000117", + "location" : { + "locationName" : "San Francisco, California, US", + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "ipInfo" : { + "ipv6" : "ipv6", + "privateIp" : "172.58.92.31", + "operativeSystemVersion" : "operativeSystemVersion", + "publicIp" : "172.58.92.31" + }, + "status" : "online" + } ], + "status" : "No data" + }, + "endDate" : "2022-07-18T22:00:54Z", + "_links" : { + "next" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "previous" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "binSize" : 3600, + "startDate" : "2022-07-17T22:00:54Z" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_dashboard_widget_data( + + dashboard_id=dashboard_id, + + widget_id=widget_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + max=max, + + cursor=cursor, + + sort=sort, + + _headers=self.te_headers("get_dashboard_widget_data"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_dashboard_widget_data_error_400(self) -> None: + """Integration test for get_dashboard_widget_data error path (HTTP 400)""" + dashboard_id = '646f4d2ce3c99b0536c3821e' + widget_id = 'unpmg' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + max = 10 + cursor = 'bGFzdFJvdW5kSWQ9MTY4MTQxMDQ4MA' + sort = 'alertStatus' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.get_dashboard_widget_data( + + dashboard_id=dashboard_id, + + widget_id=widget_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + max=max, + + cursor=cursor, + + sort=sort, + + _headers=self.te_headers("get_dashboard_widget_data", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_dashboard_widget_data_error_401(self) -> None: + """Integration test for get_dashboard_widget_data error path (HTTP 401)""" + dashboard_id = '646f4d2ce3c99b0536c3821e' + widget_id = 'unpmg' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + max = 10 + cursor = 'bGFzdFJvdW5kSWQ9MTY4MTQxMDQ4MA' + sort = 'alertStatus' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_dashboard_widget_data( + + dashboard_id=dashboard_id, + + widget_id=widget_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + max=max, + + cursor=cursor, + + sort=sort, + + _headers=self.te_headers("get_dashboard_widget_data", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_dashboard_widget_data_error_403(self) -> None: + """Integration test for get_dashboard_widget_data error path (HTTP 403)""" + dashboard_id = '646f4d2ce3c99b0536c3821e' + widget_id = 'unpmg' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + max = 10 + cursor = 'bGFzdFJvdW5kSWQ9MTY4MTQxMDQ4MA' + sort = 'alertStatus' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_dashboard_widget_data( + + dashboard_id=dashboard_id, + + widget_id=widget_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + max=max, + + cursor=cursor, + + sort=sort, + + _headers=self.te_headers("get_dashboard_widget_data", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_dashboard_widget_data_error_404(self) -> None: + """Integration test for get_dashboard_widget_data error path (HTTP 404)""" + dashboard_id = '646f4d2ce3c99b0536c3821e' + widget_id = 'unpmg' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + max = 10 + cursor = 'bGFzdFJvdW5kSWQ9MTY4MTQxMDQ4MA' + sort = 'alertStatus' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_dashboard_widget_data( + + dashboard_id=dashboard_id, + + widget_id=widget_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + max=max, + + cursor=cursor, + + sort=sort, + + _headers=self.te_headers("get_dashboard_widget_data", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_dashboard_widget_data_error_429(self) -> None: + """Integration test for get_dashboard_widget_data error path (HTTP 429)""" + dashboard_id = '646f4d2ce3c99b0536c3821e' + widget_id = 'unpmg' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + max = 10 + cursor = 'bGFzdFJvdW5kSWQ9MTY4MTQxMDQ4MA' + sort = 'alertStatus' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_dashboard_widget_data( + + dashboard_id=dashboard_id, + + widget_id=widget_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + max=max, + + cursor=cursor, + + sort=sort, + + _headers=self.te_headers("get_dashboard_widget_data", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_dashboard_widget_data_error_500(self) -> None: + """Integration test for get_dashboard_widget_data error path (HTTP 500)""" + dashboard_id = '646f4d2ce3c99b0536c3821e' + widget_id = 'unpmg' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + max = 10 + cursor = 'bGFzdFJvdW5kSWQ9MTY4MTQxMDQ4MA' + sort = 'alertStatus' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_dashboard_widget_data( + + dashboard_id=dashboard_id, + + widget_id=widget_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + max=max, + + cursor=cursor, + + sort=sort, + + _headers=self.te_headers("get_dashboard_widget_data", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_dashboards_happy_path(self) -> None: + """Integration test for get_dashboards success path""" + aid = '1234' + response_body_json = """ + [ { + "isMigratedReport" : false, + "dashboardCreatedBy" : "1", + "_links" : { + "snapshots" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isDefaultForUser" : true, + "description" : "HTTP Server Widgets", + "isPrivate" : true, + "title" : "HTTP Server Widgets", + "isBuiltIn" : true, + "widgets" : [ { + "embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f", + "shouldExcludeAlertSuppressionWindows" : true, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "visualMode" : "Full", + "filters" : { + "TEST" : [ 5187, 5227 ], + "ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ] + }, + "title" : "Widget Title", + "type" : "Agent Status", + "metricGroup" : "BGP", + "measure" : { + "percentileValue" : 95, + "type" : "MEAN" + }, + "apiLink" : "apiLink", + "metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT", + "isEmbedded" : true, + "id" : "1234", + "fixedTimespan" : { + "unit" : "Days", + "value" : 10 + }, + "dataSource" : "ENDPOINT_AGENTS", + "direction" : "FROM_TARGET" + }, { + "embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f", + "shouldExcludeAlertSuppressionWindows" : true, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "visualMode" : "Full", + "filters" : { + "TEST" : [ 5187, 5227 ], + "ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ] + }, + "title" : "Widget Title", + "type" : "Agent Status", + "metricGroup" : "BGP", + "measure" : { + "percentileValue" : 95, + "type" : "MEAN" + }, + "apiLink" : "apiLink", + "metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT", + "isEmbedded" : true, + "id" : "1234", + "fixedTimespan" : { + "unit" : "Days", + "value" : 10 + }, + "dataSource" : "ENDPOINT_AGENTS", + "direction" : "FROM_TARGET" + } ], + "globalFilterId" : "65babd9bb90bf55b17c96c8d", + "modifiedBy" : 1, + "dashboardModifiedBy" : "1", + "migratedReport" : false, + "isDefaultForAccount" : false, + "defaultTimespan" : { + "duration" : 7200, + "timespanDuration" : 7200, + "start" : "2023-05-16T10:14:28Z", + "end" : "2023-05-16T11:14:28Z", + "timespanStart" : "2023-05-16 10:14:28", + "timespanEnd" : "2023-05-16 11:14:28" + }, + "layout" : { + "layoutId" : "grid-layout-1", + "type" : "grid", + "details" : { + "widgetPositioning" : [ { + "x" : 0, + "y" : 0, + "w" : 9, + "h" : 5, + "id" : "widgetId-71lbb" + } ] + } + }, + "accountId" : 1234, + "apiLink" : [ { + "key" : "" + }, { + "key" : "" + } ], + "dashboardId" : "5e1f7a99143ae6004fdc3bb4", + "createdBy" : 1, + "globalOverride" : true, + "modifiedDate" : "2023-05-16 10:14:28", + "isGlobalOverride" : true, + "aid" : "1234", + "dashboardModifiedDate" : "2023-05-16T10:14:28Z" + }, { + "isMigratedReport" : false, + "dashboardCreatedBy" : "1", + "_links" : { + "snapshots" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isDefaultForUser" : true, + "description" : "HTTP Server Widgets", + "isPrivate" : true, + "title" : "HTTP Server Widgets", + "isBuiltIn" : true, + "widgets" : [ { + "embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f", + "shouldExcludeAlertSuppressionWindows" : true, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "visualMode" : "Full", + "filters" : { + "TEST" : [ 5187, 5227 ], + "ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ] + }, + "title" : "Widget Title", + "type" : "Agent Status", + "metricGroup" : "BGP", + "measure" : { + "percentileValue" : 95, + "type" : "MEAN" + }, + "apiLink" : "apiLink", + "metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT", + "isEmbedded" : true, + "id" : "1234", + "fixedTimespan" : { + "unit" : "Days", + "value" : 10 + }, + "dataSource" : "ENDPOINT_AGENTS", + "direction" : "FROM_TARGET" + }, { + "embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f", + "shouldExcludeAlertSuppressionWindows" : true, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "visualMode" : "Full", + "filters" : { + "TEST" : [ 5187, 5227 ], + "ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ] + }, + "title" : "Widget Title", + "type" : "Agent Status", + "metricGroup" : "BGP", + "measure" : { + "percentileValue" : 95, + "type" : "MEAN" + }, + "apiLink" : "apiLink", + "metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT", + "isEmbedded" : true, + "id" : "1234", + "fixedTimespan" : { + "unit" : "Days", + "value" : 10 + }, + "dataSource" : "ENDPOINT_AGENTS", + "direction" : "FROM_TARGET" + } ], + "globalFilterId" : "65babd9bb90bf55b17c96c8d", + "modifiedBy" : 1, + "dashboardModifiedBy" : "1", + "migratedReport" : false, + "isDefaultForAccount" : false, + "defaultTimespan" : { + "duration" : 7200, + "timespanDuration" : 7200, + "start" : "2023-05-16T10:14:28Z", + "end" : "2023-05-16T11:14:28Z", + "timespanStart" : "2023-05-16 10:14:28", + "timespanEnd" : "2023-05-16 11:14:28" + }, + "layout" : { + "layoutId" : "grid-layout-1", + "type" : "grid", + "details" : { + "widgetPositioning" : [ { + "x" : 0, + "y" : 0, + "w" : 9, + "h" : 5, + "id" : "widgetId-71lbb" + } ] + } + }, + "accountId" : 1234, + "apiLink" : [ { + "key" : "" + }, { + "key" : "" + } ], + "dashboardId" : "5e1f7a99143ae6004fdc3bb4", + "createdBy" : 1, + "globalOverride" : true, + "modifiedDate" : "2023-05-16 10:14:28", + "isGlobalOverride" : true, + "aid" : "1234", + "dashboardModifiedDate" : "2023-05-16T10:14:28Z" + } ] + """ + expected_response = json.loads(response_body_json) + response = self.api.get_dashboards( + + aid=aid, + + _headers=self.te_headers("get_dashboards"), + ) + self.assertIsInstance(response, list) + self.assertEqual(len(response), len(expected_response)) + for index, element in enumerate(response): + assert_constructed_model_matches_example_json(element, expected_response[index]) + + + def test_get_dashboards_error_400(self) -> None: + """Integration test for get_dashboards error path (HTTP 400)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.get_dashboards( + + aid=aid, + + _headers=self.te_headers("get_dashboards", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_dashboards_error_401(self) -> None: + """Integration test for get_dashboards error path (HTTP 401)""" + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_dashboards( + + aid=aid, + + _headers=self.te_headers("get_dashboards", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_dashboards_error_403(self) -> None: + """Integration test for get_dashboards error path (HTTP 403)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_dashboards( + + aid=aid, + + _headers=self.te_headers("get_dashboards", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_dashboards_error_404(self) -> None: + """Integration test for get_dashboards error path (HTTP 404)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_dashboards( + + aid=aid, + + _headers=self.te_headers("get_dashboards", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_dashboards_error_429(self) -> None: + """Integration test for get_dashboards error path (HTTP 429)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_dashboards( + + aid=aid, + + _headers=self.te_headers("get_dashboards", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_dashboards_error_500(self) -> None: + """Integration test for get_dashboards error path (HTTP 500)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_dashboards( + + aid=aid, + + _headers=self.te_headers("get_dashboards", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_individual_card_data_happy_path(self) -> None: + """Integration test for get_individual_card_data success path""" + dashboard_id = '646f4d2ce3c99b0536c3821e' + widget_id = 'unpmg' + card_id = 'rvwgs' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + response_body_json = """ + { + "numberOfDataPoints" : 24192, + "cardName" : "Card Name", + "endDate" : "2023-05-16T10:14:28Z", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "cardId" : "lrxxr", + "alertSuppressionWindows" : [ { + "testIds" : [ "281474976710661" ], + "repeatUnit" : "week", + "durationInSeconds" : 7200, + "repeat" : "custom", + "name" : "Test dashboards", + "repeatEvery" : 5, + "id" : "281474976710662", + "startTimes" : [ "2023-05-16T10:14:28Z" ] + }, { + "testIds" : [ "281474976710661" ], + "repeatUnit" : "week", + "durationInSeconds" : 7200, + "repeat" : "custom", + "name" : "Test dashboards", + "repeatEvery" : 5, + "id" : "281474976710662", + "startTimes" : [ "2023-05-16T10:14:28Z" ] + } ], + "binSize" : 3600, + "previousValue" : 500, + "value" : 100, + "startDate" : "2023-05-16T10:14:28Z", + "timestamp" : 1567620000, + "status" : "No data" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_individual_card_data( + + dashboard_id=dashboard_id, + + widget_id=widget_id, + + card_id=card_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + _headers=self.te_headers("get_individual_card_data"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_individual_card_data_error_400(self) -> None: + """Integration test for get_individual_card_data error path (HTTP 400)""" + dashboard_id = '646f4d2ce3c99b0536c3821e' + widget_id = 'unpmg' + card_id = 'rvwgs' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.get_individual_card_data( + + dashboard_id=dashboard_id, + + widget_id=widget_id, + + card_id=card_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + _headers=self.te_headers("get_individual_card_data", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_individual_card_data_error_401(self) -> None: + """Integration test for get_individual_card_data error path (HTTP 401)""" + dashboard_id = '646f4d2ce3c99b0536c3821e' + widget_id = 'unpmg' + card_id = 'rvwgs' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_individual_card_data( + + dashboard_id=dashboard_id, + + widget_id=widget_id, + + card_id=card_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + _headers=self.te_headers("get_individual_card_data", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_individual_card_data_error_403(self) -> None: + """Integration test for get_individual_card_data error path (HTTP 403)""" + dashboard_id = '646f4d2ce3c99b0536c3821e' + widget_id = 'unpmg' + card_id = 'rvwgs' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_individual_card_data( + + dashboard_id=dashboard_id, + + widget_id=widget_id, + + card_id=card_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + _headers=self.te_headers("get_individual_card_data", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_individual_card_data_error_404(self) -> None: + """Integration test for get_individual_card_data error path (HTTP 404)""" + dashboard_id = '646f4d2ce3c99b0536c3821e' + widget_id = 'unpmg' + card_id = 'rvwgs' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_individual_card_data( + + dashboard_id=dashboard_id, + + widget_id=widget_id, + + card_id=card_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + _headers=self.te_headers("get_individual_card_data", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_individual_card_data_error_429(self) -> None: + """Integration test for get_individual_card_data error path (HTTP 429)""" + dashboard_id = '646f4d2ce3c99b0536c3821e' + widget_id = 'unpmg' + card_id = 'rvwgs' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_individual_card_data( + + dashboard_id=dashboard_id, + + widget_id=widget_id, + + card_id=card_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + _headers=self.te_headers("get_individual_card_data", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_individual_card_data_error_500(self) -> None: + """Integration test for get_individual_card_data error path (HTTP 500)""" + dashboard_id = '646f4d2ce3c99b0536c3821e' + widget_id = 'unpmg' + card_id = 'rvwgs' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_individual_card_data( + + dashboard_id=dashboard_id, + + widget_id=widget_id, + + card_id=card_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + _headers=self.te_headers("get_individual_card_data", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_individual_column_data_happy_path(self) -> None: + """Integration test for get_individual_column_data success path""" + dashboard_id = '646f4d2ce3c99b0536c3821e' + widget_id = 'unpmg' + column_id = 'col123' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + response_body_json = """ + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "columnId" : "938to", + "alertSuppressionWindows" : [ { + "testIds" : [ "281474976710661" ], + "repeatUnit" : "week", + "durationInSeconds" : 7200, + "repeat" : "custom", + "name" : "Test dashboards", + "repeatEvery" : 5, + "id" : "281474976710662", + "startTimes" : [ "2023-05-16T10:14:28Z" ] + }, { + "testIds" : [ "281474976710661" ], + "repeatUnit" : "week", + "durationInSeconds" : 7200, + "repeat" : "custom", + "name" : "Test dashboards", + "repeatEvery" : 5, + "id" : "281474976710662", + "startTimes" : [ "2023-05-16T10:14:28Z" ] + } ], + "binSize" : 3600, + "points" : [ { + "numberOfDataPoints" : 23304, + "groups" : [ { + "groupProperty" : "COUNTRY", + "groupValue" : "US" + }, { + "groupProperty" : "COUNTRY", + "groupValue" : "US" + } ], + "value" : 100, + "timestamp" : 1567620000 + }, { + "numberOfDataPoints" : 23304, + "groups" : [ { + "groupProperty" : "COUNTRY", + "groupValue" : "US" + }, { + "groupProperty" : "COUNTRY", + "groupValue" : "US" + } ], + "value" : 100, + "timestamp" : 1567620000 + } ], + "status" : "No data" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_individual_column_data( + + dashboard_id=dashboard_id, + + widget_id=widget_id, + + column_id=column_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + _headers=self.te_headers("get_individual_column_data"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_individual_column_data_error_400(self) -> None: + """Integration test for get_individual_column_data error path (HTTP 400)""" + dashboard_id = '646f4d2ce3c99b0536c3821e' + widget_id = 'unpmg' + column_id = 'col123' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.get_individual_column_data( + + dashboard_id=dashboard_id, + + widget_id=widget_id, + + column_id=column_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + _headers=self.te_headers("get_individual_column_data", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_individual_column_data_error_401(self) -> None: + """Integration test for get_individual_column_data error path (HTTP 401)""" + dashboard_id = '646f4d2ce3c99b0536c3821e' + widget_id = 'unpmg' + column_id = 'col123' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_individual_column_data( + + dashboard_id=dashboard_id, + + widget_id=widget_id, + + column_id=column_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + _headers=self.te_headers("get_individual_column_data", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_individual_column_data_error_403(self) -> None: + """Integration test for get_individual_column_data error path (HTTP 403)""" + dashboard_id = '646f4d2ce3c99b0536c3821e' + widget_id = 'unpmg' + column_id = 'col123' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_individual_column_data( + + dashboard_id=dashboard_id, + + widget_id=widget_id, + + column_id=column_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + _headers=self.te_headers("get_individual_column_data", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_individual_column_data_error_404(self) -> None: + """Integration test for get_individual_column_data error path (HTTP 404)""" + dashboard_id = '646f4d2ce3c99b0536c3821e' + widget_id = 'unpmg' + column_id = 'col123' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_individual_column_data( + + dashboard_id=dashboard_id, + + widget_id=widget_id, + + column_id=column_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + _headers=self.te_headers("get_individual_column_data", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_individual_column_data_error_429(self) -> None: + """Integration test for get_individual_column_data error path (HTTP 429)""" + dashboard_id = '646f4d2ce3c99b0536c3821e' + widget_id = 'unpmg' + column_id = 'col123' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_individual_column_data( + + dashboard_id=dashboard_id, + + widget_id=widget_id, + + column_id=column_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + _headers=self.te_headers("get_individual_column_data", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_individual_column_data_error_500(self) -> None: + """Integration test for get_individual_column_data error path (HTTP 500)""" + dashboard_id = '646f4d2ce3c99b0536c3821e' + widget_id = 'unpmg' + column_id = 'col123' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_individual_column_data( + + dashboard_id=dashboard_id, + + widget_id=widget_id, + + column_id=column_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + _headers=self.te_headers("get_individual_column_data", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_update_dashboard_happy_path(self) -> None: + """Integration test for update_dashboard success path""" + request_body_json = """ + + { + "isMigratedReport" : false, + "_links" : { + "snapshots" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isDefaultForAccount" : false, + "isDefaultForUser" : true, + "description" : "HTTP Server Widgets", + "isPrivate" : true, + "title" : "HTTP Server Widgets", + "isBuiltIn" : true, + "widgets" : [ { + "embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f", + "shouldExcludeAlertSuppressionWindows" : true, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "visualMode" : "Full", + "filters" : { + "TEST" : [ 5187, 5227 ], + "ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ] + }, + "title" : "Widget Title", + "type" : "Agent Status", + "metricGroup" : "BGP", + "measure" : { + "percentileValue" : 95, + "type" : "MEAN" + }, + "apiLink" : "apiLink", + "metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT", + "isEmbedded" : true, + "id" : "1234", + "fixedTimespan" : { + "unit" : "Days", + "value" : 10 + }, + "dataSource" : "ENDPOINT_AGENTS", + "direction" : "FROM_TARGET" + }, { + "embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f", + "shouldExcludeAlertSuppressionWindows" : true, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "visualMode" : "Full", + "filters" : { + "TEST" : [ 5187, 5227 ], + "ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ] + }, + "title" : "Widget Title", + "type" : "Agent Status", + "metricGroup" : "BGP", + "measure" : { + "percentileValue" : 95, + "type" : "MEAN" + }, + "apiLink" : "apiLink", + "metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT", + "isEmbedded" : true, + "id" : "1234", + "fixedTimespan" : { + "unit" : "Days", + "value" : 10 + }, + "dataSource" : "ENDPOINT_AGENTS", + "direction" : "FROM_TARGET" + } ], + "defaultTimespan" : { + "duration" : 7200, + "timespanDuration" : 7200, + "start" : "2023-05-16T10:14:28Z", + "end" : "2023-05-16T11:14:28Z", + "timespanStart" : "2023-05-16 10:14:28", + "timespanEnd" : "2023-05-16 11:14:28" + }, + "layout" : { + "layoutId" : "grid-layout-1", + "type" : "grid", + "details" : { + "widgetPositioning" : [ { + "x" : 0, + "y" : 0, + "w" : 9, + "h" : 5, + "id" : "widgetId-71lbb" + } ] + } + }, + "globalFilterId" : "65babd9bb90bf55b17c96c8d", + "dashboardId" : "5e1f7a99143ae6004fdc3bb4", + "createdBy" : "1", + "modifiedDate" : "2023-05-16T10:14:28Z", + "modifiedBy" : "1", + "isGlobalOverride" : true, + "aid" : "1234" + } + + """ + dashboard = thousandeyes_sdk.dashboards.models.Dashboard.from_json(request_body_json) + dashboard_id = '646f4d2ce3c99b0536c3821e' + aid = '1234' + response_body_json = """ + { + "isMigratedReport" : false, + "_links" : { + "snapshots" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isDefaultForAccount" : false, + "isDefaultForUser" : true, + "description" : "HTTP Server Widgets", + "isPrivate" : true, + "title" : "HTTP Server Widgets", + "isBuiltIn" : true, + "widgets" : [ { + "embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f", + "shouldExcludeAlertSuppressionWindows" : true, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "visualMode" : "Full", + "filters" : { + "TEST" : [ 5187, 5227 ], + "ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ] + }, + "title" : "Widget Title", + "type" : "Agent Status", + "metricGroup" : "BGP", + "measure" : { + "percentileValue" : 95, + "type" : "MEAN" + }, + "apiLink" : "apiLink", + "metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT", + "isEmbedded" : true, + "id" : "1234", + "fixedTimespan" : { + "unit" : "Days", + "value" : 10 + }, + "dataSource" : "ENDPOINT_AGENTS", + "direction" : "FROM_TARGET" + }, { + "embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f", + "shouldExcludeAlertSuppressionWindows" : true, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "visualMode" : "Full", + "filters" : { + "TEST" : [ 5187, 5227 ], + "ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ] + }, + "title" : "Widget Title", + "type" : "Agent Status", + "metricGroup" : "BGP", + "measure" : { + "percentileValue" : 95, + "type" : "MEAN" + }, + "apiLink" : "apiLink", + "metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT", + "isEmbedded" : true, + "id" : "1234", + "fixedTimespan" : { + "unit" : "Days", + "value" : 10 + }, + "dataSource" : "ENDPOINT_AGENTS", + "direction" : "FROM_TARGET" + } ], + "defaultTimespan" : { + "duration" : 7200, + "timespanDuration" : 7200, + "start" : "2023-05-16T10:14:28Z", + "end" : "2023-05-16T11:14:28Z", + "timespanStart" : "2023-05-16 10:14:28", + "timespanEnd" : "2023-05-16 11:14:28" + }, + "layout" : { + "layoutId" : "grid-layout-1", + "type" : "grid", + "details" : { + "widgetPositioning" : [ { + "x" : 0, + "y" : 0, + "w" : 9, + "h" : 5, + "id" : "widgetId-71lbb" + } ] + } + }, + "globalFilterId" : "65babd9bb90bf55b17c96c8d", + "dashboardId" : "5e1f7a99143ae6004fdc3bb4", + "createdBy" : "1", + "modifiedDate" : "2023-05-16T10:14:28Z", + "modifiedBy" : "1", + "isGlobalOverride" : true, + "aid" : "1234" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.update_dashboard( + + dashboard_id=dashboard_id, + + dashboard=dashboard, + + aid=aid, + + _headers=self.te_headers("update_dashboard"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_update_dashboard_error_400(self) -> None: + """Integration test for update_dashboard error path (HTTP 400)""" + request_body_json = """ + + { + "isMigratedReport" : false, + "_links" : { + "snapshots" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isDefaultForAccount" : false, + "isDefaultForUser" : true, + "description" : "HTTP Server Widgets", + "isPrivate" : true, + "title" : "HTTP Server Widgets", + "isBuiltIn" : true, + "widgets" : [ { + "embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f", + "shouldExcludeAlertSuppressionWindows" : true, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "visualMode" : "Full", + "filters" : { + "TEST" : [ 5187, 5227 ], + "ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ] + }, + "title" : "Widget Title", + "type" : "Agent Status", + "metricGroup" : "BGP", + "measure" : { + "percentileValue" : 95, + "type" : "MEAN" + }, + "apiLink" : "apiLink", + "metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT", + "isEmbedded" : true, + "id" : "1234", + "fixedTimespan" : { + "unit" : "Days", + "value" : 10 + }, + "dataSource" : "ENDPOINT_AGENTS", + "direction" : "FROM_TARGET" + }, { + "embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f", + "shouldExcludeAlertSuppressionWindows" : true, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "visualMode" : "Full", + "filters" : { + "TEST" : [ 5187, 5227 ], + "ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ] + }, + "title" : "Widget Title", + "type" : "Agent Status", + "metricGroup" : "BGP", + "measure" : { + "percentileValue" : 95, + "type" : "MEAN" + }, + "apiLink" : "apiLink", + "metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT", + "isEmbedded" : true, + "id" : "1234", + "fixedTimespan" : { + "unit" : "Days", + "value" : 10 + }, + "dataSource" : "ENDPOINT_AGENTS", + "direction" : "FROM_TARGET" + } ], + "defaultTimespan" : { + "duration" : 7200, + "timespanDuration" : 7200, + "start" : "2023-05-16T10:14:28Z", + "end" : "2023-05-16T11:14:28Z", + "timespanStart" : "2023-05-16 10:14:28", + "timespanEnd" : "2023-05-16 11:14:28" + }, + "layout" : { + "layoutId" : "grid-layout-1", + "type" : "grid", + "details" : { + "widgetPositioning" : [ { + "x" : 0, + "y" : 0, + "w" : 9, + "h" : 5, + "id" : "widgetId-71lbb" + } ] + } + }, + "globalFilterId" : "65babd9bb90bf55b17c96c8d", + "dashboardId" : "5e1f7a99143ae6004fdc3bb4", + "createdBy" : "1", + "modifiedDate" : "2023-05-16T10:14:28Z", + "modifiedBy" : "1", + "isGlobalOverride" : true, + "aid" : "1234" + } + + """ + dashboard = thousandeyes_sdk.dashboards.models.Dashboard.from_json(request_body_json) + dashboard_id = '646f4d2ce3c99b0536c3821e' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.update_dashboard( + + dashboard_id=dashboard_id, + + dashboard=dashboard, + + aid=aid, + + _headers=self.te_headers("update_dashboard", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_dashboard_error_401(self) -> None: + """Integration test for update_dashboard error path (HTTP 401)""" + request_body_json = """ + + { + "isMigratedReport" : false, + "_links" : { + "snapshots" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isDefaultForAccount" : false, + "isDefaultForUser" : true, + "description" : "HTTP Server Widgets", + "isPrivate" : true, + "title" : "HTTP Server Widgets", + "isBuiltIn" : true, + "widgets" : [ { + "embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f", + "shouldExcludeAlertSuppressionWindows" : true, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "visualMode" : "Full", + "filters" : { + "TEST" : [ 5187, 5227 ], + "ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ] + }, + "title" : "Widget Title", + "type" : "Agent Status", + "metricGroup" : "BGP", + "measure" : { + "percentileValue" : 95, + "type" : "MEAN" + }, + "apiLink" : "apiLink", + "metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT", + "isEmbedded" : true, + "id" : "1234", + "fixedTimespan" : { + "unit" : "Days", + "value" : 10 + }, + "dataSource" : "ENDPOINT_AGENTS", + "direction" : "FROM_TARGET" + }, { + "embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f", + "shouldExcludeAlertSuppressionWindows" : true, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "visualMode" : "Full", + "filters" : { + "TEST" : [ 5187, 5227 ], + "ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ] + }, + "title" : "Widget Title", + "type" : "Agent Status", + "metricGroup" : "BGP", + "measure" : { + "percentileValue" : 95, + "type" : "MEAN" + }, + "apiLink" : "apiLink", + "metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT", + "isEmbedded" : true, + "id" : "1234", + "fixedTimespan" : { + "unit" : "Days", + "value" : 10 + }, + "dataSource" : "ENDPOINT_AGENTS", + "direction" : "FROM_TARGET" + } ], + "defaultTimespan" : { + "duration" : 7200, + "timespanDuration" : 7200, + "start" : "2023-05-16T10:14:28Z", + "end" : "2023-05-16T11:14:28Z", + "timespanStart" : "2023-05-16 10:14:28", + "timespanEnd" : "2023-05-16 11:14:28" + }, + "layout" : { + "layoutId" : "grid-layout-1", + "type" : "grid", + "details" : { + "widgetPositioning" : [ { + "x" : 0, + "y" : 0, + "w" : 9, + "h" : 5, + "id" : "widgetId-71lbb" + } ] + } + }, + "globalFilterId" : "65babd9bb90bf55b17c96c8d", + "dashboardId" : "5e1f7a99143ae6004fdc3bb4", + "createdBy" : "1", + "modifiedDate" : "2023-05-16T10:14:28Z", + "modifiedBy" : "1", + "isGlobalOverride" : true, + "aid" : "1234" + } + + """ + dashboard = thousandeyes_sdk.dashboards.models.Dashboard.from_json(request_body_json) + dashboard_id = '646f4d2ce3c99b0536c3821e' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.update_dashboard( + + dashboard_id=dashboard_id, + + dashboard=dashboard, + + aid=aid, + + _headers=self.te_headers("update_dashboard", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_dashboard_error_403(self) -> None: + """Integration test for update_dashboard error path (HTTP 403)""" + request_body_json = """ + + { + "isMigratedReport" : false, + "_links" : { + "snapshots" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isDefaultForAccount" : false, + "isDefaultForUser" : true, + "description" : "HTTP Server Widgets", + "isPrivate" : true, + "title" : "HTTP Server Widgets", + "isBuiltIn" : true, + "widgets" : [ { + "embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f", + "shouldExcludeAlertSuppressionWindows" : true, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "visualMode" : "Full", + "filters" : { + "TEST" : [ 5187, 5227 ], + "ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ] + }, + "title" : "Widget Title", + "type" : "Agent Status", + "metricGroup" : "BGP", + "measure" : { + "percentileValue" : 95, + "type" : "MEAN" + }, + "apiLink" : "apiLink", + "metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT", + "isEmbedded" : true, + "id" : "1234", + "fixedTimespan" : { + "unit" : "Days", + "value" : 10 + }, + "dataSource" : "ENDPOINT_AGENTS", + "direction" : "FROM_TARGET" + }, { + "embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f", + "shouldExcludeAlertSuppressionWindows" : true, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "visualMode" : "Full", + "filters" : { + "TEST" : [ 5187, 5227 ], + "ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ] + }, + "title" : "Widget Title", + "type" : "Agent Status", + "metricGroup" : "BGP", + "measure" : { + "percentileValue" : 95, + "type" : "MEAN" + }, + "apiLink" : "apiLink", + "metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT", + "isEmbedded" : true, + "id" : "1234", + "fixedTimespan" : { + "unit" : "Days", + "value" : 10 + }, + "dataSource" : "ENDPOINT_AGENTS", + "direction" : "FROM_TARGET" + } ], + "defaultTimespan" : { + "duration" : 7200, + "timespanDuration" : 7200, + "start" : "2023-05-16T10:14:28Z", + "end" : "2023-05-16T11:14:28Z", + "timespanStart" : "2023-05-16 10:14:28", + "timespanEnd" : "2023-05-16 11:14:28" + }, + "layout" : { + "layoutId" : "grid-layout-1", + "type" : "grid", + "details" : { + "widgetPositioning" : [ { + "x" : 0, + "y" : 0, + "w" : 9, + "h" : 5, + "id" : "widgetId-71lbb" + } ] + } + }, + "globalFilterId" : "65babd9bb90bf55b17c96c8d", + "dashboardId" : "5e1f7a99143ae6004fdc3bb4", + "createdBy" : "1", + "modifiedDate" : "2023-05-16T10:14:28Z", + "modifiedBy" : "1", + "isGlobalOverride" : true, + "aid" : "1234" + } + + """ + dashboard = thousandeyes_sdk.dashboards.models.Dashboard.from_json(request_body_json) + dashboard_id = '646f4d2ce3c99b0536c3821e' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.update_dashboard( + + dashboard_id=dashboard_id, + + dashboard=dashboard, + + aid=aid, + + _headers=self.te_headers("update_dashboard", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_dashboard_error_404(self) -> None: + """Integration test for update_dashboard error path (HTTP 404)""" + request_body_json = """ + + { + "isMigratedReport" : false, + "_links" : { + "snapshots" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isDefaultForAccount" : false, + "isDefaultForUser" : true, + "description" : "HTTP Server Widgets", + "isPrivate" : true, + "title" : "HTTP Server Widgets", + "isBuiltIn" : true, + "widgets" : [ { + "embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f", + "shouldExcludeAlertSuppressionWindows" : true, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "visualMode" : "Full", + "filters" : { + "TEST" : [ 5187, 5227 ], + "ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ] + }, + "title" : "Widget Title", + "type" : "Agent Status", + "metricGroup" : "BGP", + "measure" : { + "percentileValue" : 95, + "type" : "MEAN" + }, + "apiLink" : "apiLink", + "metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT", + "isEmbedded" : true, + "id" : "1234", + "fixedTimespan" : { + "unit" : "Days", + "value" : 10 + }, + "dataSource" : "ENDPOINT_AGENTS", + "direction" : "FROM_TARGET" + }, { + "embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f", + "shouldExcludeAlertSuppressionWindows" : true, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "visualMode" : "Full", + "filters" : { + "TEST" : [ 5187, 5227 ], + "ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ] + }, + "title" : "Widget Title", + "type" : "Agent Status", + "metricGroup" : "BGP", + "measure" : { + "percentileValue" : 95, + "type" : "MEAN" + }, + "apiLink" : "apiLink", + "metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT", + "isEmbedded" : true, + "id" : "1234", + "fixedTimespan" : { + "unit" : "Days", + "value" : 10 + }, + "dataSource" : "ENDPOINT_AGENTS", + "direction" : "FROM_TARGET" + } ], + "defaultTimespan" : { + "duration" : 7200, + "timespanDuration" : 7200, + "start" : "2023-05-16T10:14:28Z", + "end" : "2023-05-16T11:14:28Z", + "timespanStart" : "2023-05-16 10:14:28", + "timespanEnd" : "2023-05-16 11:14:28" + }, + "layout" : { + "layoutId" : "grid-layout-1", + "type" : "grid", + "details" : { + "widgetPositioning" : [ { + "x" : 0, + "y" : 0, + "w" : 9, + "h" : 5, + "id" : "widgetId-71lbb" + } ] + } + }, + "globalFilterId" : "65babd9bb90bf55b17c96c8d", + "dashboardId" : "5e1f7a99143ae6004fdc3bb4", + "createdBy" : "1", + "modifiedDate" : "2023-05-16T10:14:28Z", + "modifiedBy" : "1", + "isGlobalOverride" : true, + "aid" : "1234" + } + + """ + dashboard = thousandeyes_sdk.dashboards.models.Dashboard.from_json(request_body_json) + dashboard_id = '646f4d2ce3c99b0536c3821e' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.update_dashboard( + + dashboard_id=dashboard_id, + + dashboard=dashboard, + + aid=aid, + + _headers=self.te_headers("update_dashboard", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_dashboard_error_429(self) -> None: + """Integration test for update_dashboard error path (HTTP 429)""" + request_body_json = """ + + { + "isMigratedReport" : false, + "_links" : { + "snapshots" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isDefaultForAccount" : false, + "isDefaultForUser" : true, + "description" : "HTTP Server Widgets", + "isPrivate" : true, + "title" : "HTTP Server Widgets", + "isBuiltIn" : true, + "widgets" : [ { + "embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f", + "shouldExcludeAlertSuppressionWindows" : true, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "visualMode" : "Full", + "filters" : { + "TEST" : [ 5187, 5227 ], + "ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ] + }, + "title" : "Widget Title", + "type" : "Agent Status", + "metricGroup" : "BGP", + "measure" : { + "percentileValue" : 95, + "type" : "MEAN" + }, + "apiLink" : "apiLink", + "metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT", + "isEmbedded" : true, + "id" : "1234", + "fixedTimespan" : { + "unit" : "Days", + "value" : 10 + }, + "dataSource" : "ENDPOINT_AGENTS", + "direction" : "FROM_TARGET" + }, { + "embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f", + "shouldExcludeAlertSuppressionWindows" : true, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "visualMode" : "Full", + "filters" : { + "TEST" : [ 5187, 5227 ], + "ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ] + }, + "title" : "Widget Title", + "type" : "Agent Status", + "metricGroup" : "BGP", + "measure" : { + "percentileValue" : 95, + "type" : "MEAN" + }, + "apiLink" : "apiLink", + "metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT", + "isEmbedded" : true, + "id" : "1234", + "fixedTimespan" : { + "unit" : "Days", + "value" : 10 + }, + "dataSource" : "ENDPOINT_AGENTS", + "direction" : "FROM_TARGET" + } ], + "defaultTimespan" : { + "duration" : 7200, + "timespanDuration" : 7200, + "start" : "2023-05-16T10:14:28Z", + "end" : "2023-05-16T11:14:28Z", + "timespanStart" : "2023-05-16 10:14:28", + "timespanEnd" : "2023-05-16 11:14:28" + }, + "layout" : { + "layoutId" : "grid-layout-1", + "type" : "grid", + "details" : { + "widgetPositioning" : [ { + "x" : 0, + "y" : 0, + "w" : 9, + "h" : 5, + "id" : "widgetId-71lbb" + } ] + } + }, + "globalFilterId" : "65babd9bb90bf55b17c96c8d", + "dashboardId" : "5e1f7a99143ae6004fdc3bb4", + "createdBy" : "1", + "modifiedDate" : "2023-05-16T10:14:28Z", + "modifiedBy" : "1", + "isGlobalOverride" : true, + "aid" : "1234" + } + + """ + dashboard = thousandeyes_sdk.dashboards.models.Dashboard.from_json(request_body_json) + dashboard_id = '646f4d2ce3c99b0536c3821e' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.update_dashboard( + + dashboard_id=dashboard_id, + + dashboard=dashboard, + + aid=aid, + + _headers=self.te_headers("update_dashboard", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_dashboard_error_500(self) -> None: + """Integration test for update_dashboard error path (HTTP 500)""" + request_body_json = """ + + { + "isMigratedReport" : false, + "_links" : { + "snapshots" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isDefaultForAccount" : false, + "isDefaultForUser" : true, + "description" : "HTTP Server Widgets", + "isPrivate" : true, + "title" : "HTTP Server Widgets", + "isBuiltIn" : true, + "widgets" : [ { + "embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f", + "shouldExcludeAlertSuppressionWindows" : true, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "visualMode" : "Full", + "filters" : { + "TEST" : [ 5187, 5227 ], + "ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ] + }, + "title" : "Widget Title", + "type" : "Agent Status", + "metricGroup" : "BGP", + "measure" : { + "percentileValue" : 95, + "type" : "MEAN" + }, + "apiLink" : "apiLink", + "metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT", + "isEmbedded" : true, + "id" : "1234", + "fixedTimespan" : { + "unit" : "Days", + "value" : 10 + }, + "dataSource" : "ENDPOINT_AGENTS", + "direction" : "FROM_TARGET" + }, { + "embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f", + "shouldExcludeAlertSuppressionWindows" : true, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "visualMode" : "Full", + "filters" : { + "TEST" : [ 5187, 5227 ], + "ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ] + }, + "title" : "Widget Title", + "type" : "Agent Status", + "metricGroup" : "BGP", + "measure" : { + "percentileValue" : 95, + "type" : "MEAN" + }, + "apiLink" : "apiLink", + "metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT", + "isEmbedded" : true, + "id" : "1234", + "fixedTimespan" : { + "unit" : "Days", + "value" : 10 + }, + "dataSource" : "ENDPOINT_AGENTS", + "direction" : "FROM_TARGET" + } ], + "defaultTimespan" : { + "duration" : 7200, + "timespanDuration" : 7200, + "start" : "2023-05-16T10:14:28Z", + "end" : "2023-05-16T11:14:28Z", + "timespanStart" : "2023-05-16 10:14:28", + "timespanEnd" : "2023-05-16 11:14:28" + }, + "layout" : { + "layoutId" : "grid-layout-1", + "type" : "grid", + "details" : { + "widgetPositioning" : [ { + "x" : 0, + "y" : 0, + "w" : 9, + "h" : 5, + "id" : "widgetId-71lbb" + } ] + } + }, + "globalFilterId" : "65babd9bb90bf55b17c96c8d", + "dashboardId" : "5e1f7a99143ae6004fdc3bb4", + "createdBy" : "1", + "modifiedDate" : "2023-05-16T10:14:28Z", + "modifiedBy" : "1", + "isGlobalOverride" : true, + "aid" : "1234" + } + + """ + dashboard = thousandeyes_sdk.dashboards.models.Dashboard.from_json(request_body_json) + dashboard_id = '646f4d2ce3c99b0536c3821e' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.update_dashboard( + + dashboard_id=dashboard_id, + + dashboard=dashboard, + + aid=aid, + + _headers=self.te_headers("update_dashboard", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-dashboards/test/test_dashboards_filters_api_integration.py b/thousandeyes-sdk-dashboards/test/test_dashboards_filters_api_integration.py new file mode 100644 index 00000000..eb0562ad --- /dev/null +++ b/thousandeyes-sdk-dashboards/test/test_dashboards_filters_api_integration.py @@ -0,0 +1,1714 @@ +# coding: utf-8 + +""" + Dashboards API + + Manage ThousandEyes Dashboards. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.dashboards.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.dashboards.api.dashboards_filters_api import DashboardsFiltersApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestDashboardsFiltersApiIntegration(IntegrationTestBase): + """DashboardsFiltersApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = DashboardsFiltersApi(self.api_client) + + + def test_create_dashboard_filter_happy_path(self) -> None: + """Integration test for create_dashboard_filter success path""" + request_body_json = """ + + { + "context" : [ { + "dataSourceId" : "VIRTUAL_AGENT", + "filters" : [ { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + }, { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + } ] + }, { + "dataSourceId" : "VIRTUAL_AGENT", + "filters" : [ { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + }, { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + } ] + } ], + "name" : "cea-filter", + "description" : "Global filter for CEA widgets" + } + + """ + api_context_filter_request = thousandeyes_sdk.dashboards.models.ApiContextFilterRequest.from_json(request_body_json) + aid = '1234' + response_body_json = """ + { + "createdDate" : "2024-02-01T22:19:19Z", + "createdBy" : { + "uid" : "1", + "name" : "Test User" + }, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "context" : [ { + "dataSourceId" : "VIRTUAL_AGENT", + "filters" : [ { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + }, { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + } ] + }, { + "dataSourceId" : "VIRTUAL_AGENT", + "filters" : [ { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + }, { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + } ] + } ], + "name" : "cea-filter", + "modifiedDate" : "2024-02-01T22:19:19Z", + "description" : "Global filter for CEA widgets", + "modifiedBy" : { + "uid" : "1", + "name" : "Test User" + }, + "id" : "65bc18e8f2073a4a469cd958", + "aid" : "11" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.create_dashboard_filter( + + api_context_filter_request=api_context_filter_request, + + aid=aid, + + _headers=self.te_headers("create_dashboard_filter"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_create_dashboard_filter_error_400(self) -> None: + """Integration test for create_dashboard_filter error path (HTTP 400)""" + request_body_json = """ + + { + "context" : [ { + "dataSourceId" : "VIRTUAL_AGENT", + "filters" : [ { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + }, { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + } ] + }, { + "dataSourceId" : "VIRTUAL_AGENT", + "filters" : [ { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + }, { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + } ] + } ], + "name" : "cea-filter", + "description" : "Global filter for CEA widgets" + } + + """ + api_context_filter_request = thousandeyes_sdk.dashboards.models.ApiContextFilterRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.create_dashboard_filter( + + api_context_filter_request=api_context_filter_request, + + aid=aid, + + _headers=self.te_headers("create_dashboard_filter", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_dashboard_filter_error_401(self) -> None: + """Integration test for create_dashboard_filter error path (HTTP 401)""" + request_body_json = """ + + { + "context" : [ { + "dataSourceId" : "VIRTUAL_AGENT", + "filters" : [ { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + }, { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + } ] + }, { + "dataSourceId" : "VIRTUAL_AGENT", + "filters" : [ { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + }, { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + } ] + } ], + "name" : "cea-filter", + "description" : "Global filter for CEA widgets" + } + + """ + api_context_filter_request = thousandeyes_sdk.dashboards.models.ApiContextFilterRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.create_dashboard_filter( + + api_context_filter_request=api_context_filter_request, + + aid=aid, + + _headers=self.te_headers("create_dashboard_filter", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_dashboard_filter_error_403(self) -> None: + """Integration test for create_dashboard_filter error path (HTTP 403)""" + request_body_json = """ + + { + "context" : [ { + "dataSourceId" : "VIRTUAL_AGENT", + "filters" : [ { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + }, { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + } ] + }, { + "dataSourceId" : "VIRTUAL_AGENT", + "filters" : [ { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + }, { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + } ] + } ], + "name" : "cea-filter", + "description" : "Global filter for CEA widgets" + } + + """ + api_context_filter_request = thousandeyes_sdk.dashboards.models.ApiContextFilterRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.create_dashboard_filter( + + api_context_filter_request=api_context_filter_request, + + aid=aid, + + _headers=self.te_headers("create_dashboard_filter", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_dashboard_filter_error_404(self) -> None: + """Integration test for create_dashboard_filter error path (HTTP 404)""" + request_body_json = """ + + { + "context" : [ { + "dataSourceId" : "VIRTUAL_AGENT", + "filters" : [ { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + }, { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + } ] + }, { + "dataSourceId" : "VIRTUAL_AGENT", + "filters" : [ { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + }, { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + } ] + } ], + "name" : "cea-filter", + "description" : "Global filter for CEA widgets" + } + + """ + api_context_filter_request = thousandeyes_sdk.dashboards.models.ApiContextFilterRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.create_dashboard_filter( + + api_context_filter_request=api_context_filter_request, + + aid=aid, + + _headers=self.te_headers("create_dashboard_filter", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_dashboard_filter_error_429(self) -> None: + """Integration test for create_dashboard_filter error path (HTTP 429)""" + request_body_json = """ + + { + "context" : [ { + "dataSourceId" : "VIRTUAL_AGENT", + "filters" : [ { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + }, { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + } ] + }, { + "dataSourceId" : "VIRTUAL_AGENT", + "filters" : [ { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + }, { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + } ] + } ], + "name" : "cea-filter", + "description" : "Global filter for CEA widgets" + } + + """ + api_context_filter_request = thousandeyes_sdk.dashboards.models.ApiContextFilterRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.create_dashboard_filter( + + api_context_filter_request=api_context_filter_request, + + aid=aid, + + _headers=self.te_headers("create_dashboard_filter", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_dashboard_filter_error_500(self) -> None: + """Integration test for create_dashboard_filter error path (HTTP 500)""" + request_body_json = """ + + { + "context" : [ { + "dataSourceId" : "VIRTUAL_AGENT", + "filters" : [ { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + }, { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + } ] + }, { + "dataSourceId" : "VIRTUAL_AGENT", + "filters" : [ { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + }, { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + } ] + } ], + "name" : "cea-filter", + "description" : "Global filter for CEA widgets" + } + + """ + api_context_filter_request = thousandeyes_sdk.dashboards.models.ApiContextFilterRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.create_dashboard_filter( + + api_context_filter_request=api_context_filter_request, + + aid=aid, + + _headers=self.te_headers("create_dashboard_filter", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_delete_dashboard_filter_happy_path(self) -> None: + """Integration test for delete_dashboard_filter success path""" + id = '65bc18e8f2073a4a469cd958' + aid = '1234' + response = self.api.delete_dashboard_filter_with_http_info( + + id=id, + + aid=aid, + + _headers=self.te_headers("delete_dashboard_filter"), + ) + self.assertEqual(204, response.status_code) + self.assertIsNone(response.data) + + + def test_delete_dashboard_filter_error_400(self) -> None: + """Integration test for delete_dashboard_filter error path (HTTP 400)""" + id = '65bc18e8f2073a4a469cd958' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.delete_dashboard_filter( + + id=id, + + aid=aid, + + _headers=self.te_headers("delete_dashboard_filter", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_dashboard_filter_error_401(self) -> None: + """Integration test for delete_dashboard_filter error path (HTTP 401)""" + id = '65bc18e8f2073a4a469cd958' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.delete_dashboard_filter( + + id=id, + + aid=aid, + + _headers=self.te_headers("delete_dashboard_filter", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_dashboard_filter_error_403(self) -> None: + """Integration test for delete_dashboard_filter error path (HTTP 403)""" + id = '65bc18e8f2073a4a469cd958' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.delete_dashboard_filter( + + id=id, + + aid=aid, + + _headers=self.te_headers("delete_dashboard_filter", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_dashboard_filter_error_404(self) -> None: + """Integration test for delete_dashboard_filter error path (HTTP 404)""" + id = '65bc18e8f2073a4a469cd958' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.delete_dashboard_filter( + + id=id, + + aid=aid, + + _headers=self.te_headers("delete_dashboard_filter", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_dashboard_filter_error_429(self) -> None: + """Integration test for delete_dashboard_filter error path (HTTP 429)""" + id = '65bc18e8f2073a4a469cd958' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.delete_dashboard_filter( + + id=id, + + aid=aid, + + _headers=self.te_headers("delete_dashboard_filter", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_dashboard_filter_error_500(self) -> None: + """Integration test for delete_dashboard_filter error path (HTTP 500)""" + id = '65bc18e8f2073a4a469cd958' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.delete_dashboard_filter( + + id=id, + + aid=aid, + + _headers=self.te_headers("delete_dashboard_filter", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_dashboard_filter_happy_path(self) -> None: + """Integration test for get_dashboard_filter success path""" + id = '65bc18e8f2073a4a469cd958' + aid = '1234' + response_body_json = """ + { + "createdDate" : "2024-02-01T22:19:19Z", + "createdBy" : { + "uid" : "1", + "name" : "Test User" + }, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "context" : [ { + "dataSourceId" : "VIRTUAL_AGENT", + "filters" : [ { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + }, { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + } ] + }, { + "dataSourceId" : "VIRTUAL_AGENT", + "filters" : [ { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + }, { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + } ] + } ], + "name" : "cea-filter", + "modifiedDate" : "2024-02-01T22:19:19Z", + "description" : "Global filter for CEA widgets", + "modifiedBy" : { + "uid" : "1", + "name" : "Test User" + }, + "id" : "65bc18e8f2073a4a469cd958", + "aid" : "11" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_dashboard_filter( + + id=id, + + aid=aid, + + _headers=self.te_headers("get_dashboard_filter"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_dashboard_filter_error_400(self) -> None: + """Integration test for get_dashboard_filter error path (HTTP 400)""" + id = '65bc18e8f2073a4a469cd958' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.get_dashboard_filter( + + id=id, + + aid=aid, + + _headers=self.te_headers("get_dashboard_filter", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_dashboard_filter_error_401(self) -> None: + """Integration test for get_dashboard_filter error path (HTTP 401)""" + id = '65bc18e8f2073a4a469cd958' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_dashboard_filter( + + id=id, + + aid=aid, + + _headers=self.te_headers("get_dashboard_filter", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_dashboard_filter_error_403(self) -> None: + """Integration test for get_dashboard_filter error path (HTTP 403)""" + id = '65bc18e8f2073a4a469cd958' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_dashboard_filter( + + id=id, + + aid=aid, + + _headers=self.te_headers("get_dashboard_filter", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_dashboard_filter_error_404(self) -> None: + """Integration test for get_dashboard_filter error path (HTTP 404)""" + id = '65bc18e8f2073a4a469cd958' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_dashboard_filter( + + id=id, + + aid=aid, + + _headers=self.te_headers("get_dashboard_filter", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_dashboard_filter_error_429(self) -> None: + """Integration test for get_dashboard_filter error path (HTTP 429)""" + id = '65bc18e8f2073a4a469cd958' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_dashboard_filter( + + id=id, + + aid=aid, + + _headers=self.te_headers("get_dashboard_filter", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_dashboard_filter_error_500(self) -> None: + """Integration test for get_dashboard_filter error path (HTTP 500)""" + id = '65bc18e8f2073a4a469cd958' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_dashboard_filter( + + id=id, + + aid=aid, + + _headers=self.te_headers("get_dashboard_filter", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_dashboards_filters_happy_path(self) -> None: + """Integration test for get_dashboards_filters success path""" + search_pattern = 'cea-filter' + aid = '1234' + response_body_json = """ + { + "dashboardFilters" : [ { + "createdDate" : "2024-02-01T22:19:19Z", + "createdBy" : { + "uid" : "1", + "name" : "Test User" + }, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "context" : [ { + "dataSourceId" : "VIRTUAL_AGENT", + "filters" : [ { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + }, { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + } ] + }, { + "dataSourceId" : "VIRTUAL_AGENT", + "filters" : [ { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + }, { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + } ] + } ], + "name" : "cea-filter", + "modifiedDate" : "2024-02-01T22:19:19Z", + "description" : "Global filter for CEA widgets", + "modifiedBy" : { + "uid" : "1", + "name" : "Test User" + }, + "id" : "65bc18e8f2073a4a469cd958", + "aid" : "11" + }, { + "createdDate" : "2024-02-01T22:19:19Z", + "createdBy" : { + "uid" : "1", + "name" : "Test User" + }, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "context" : [ { + "dataSourceId" : "VIRTUAL_AGENT", + "filters" : [ { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + }, { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + } ] + }, { + "dataSourceId" : "VIRTUAL_AGENT", + "filters" : [ { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + }, { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + } ] + } ], + "name" : "cea-filter", + "modifiedDate" : "2024-02-01T22:19:19Z", + "description" : "Global filter for CEA widgets", + "modifiedBy" : { + "uid" : "1", + "name" : "Test User" + }, + "id" : "65bc18e8f2073a4a469cd958", + "aid" : "11" + } ] + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_dashboards_filters( + + search_pattern=search_pattern, + + aid=aid, + + _headers=self.te_headers("get_dashboards_filters"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_dashboards_filters_error_400(self) -> None: + """Integration test for get_dashboards_filters error path (HTTP 400)""" + search_pattern = 'cea-filter' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.get_dashboards_filters( + + search_pattern=search_pattern, + + aid=aid, + + _headers=self.te_headers("get_dashboards_filters", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_dashboards_filters_error_401(self) -> None: + """Integration test for get_dashboards_filters error path (HTTP 401)""" + search_pattern = 'cea-filter' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_dashboards_filters( + + search_pattern=search_pattern, + + aid=aid, + + _headers=self.te_headers("get_dashboards_filters", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_dashboards_filters_error_403(self) -> None: + """Integration test for get_dashboards_filters error path (HTTP 403)""" + search_pattern = 'cea-filter' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_dashboards_filters( + + search_pattern=search_pattern, + + aid=aid, + + _headers=self.te_headers("get_dashboards_filters", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_dashboards_filters_error_404(self) -> None: + """Integration test for get_dashboards_filters error path (HTTP 404)""" + search_pattern = 'cea-filter' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_dashboards_filters( + + search_pattern=search_pattern, + + aid=aid, + + _headers=self.te_headers("get_dashboards_filters", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_dashboards_filters_error_429(self) -> None: + """Integration test for get_dashboards_filters error path (HTTP 429)""" + search_pattern = 'cea-filter' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_dashboards_filters( + + search_pattern=search_pattern, + + aid=aid, + + _headers=self.te_headers("get_dashboards_filters", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_dashboards_filters_error_500(self) -> None: + """Integration test for get_dashboards_filters error path (HTTP 500)""" + search_pattern = 'cea-filter' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_dashboards_filters( + + search_pattern=search_pattern, + + aid=aid, + + _headers=self.te_headers("get_dashboards_filters", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_update_dashboard_filter_happy_path(self) -> None: + """Integration test for update_dashboard_filter success path""" + request_body_json = """ + + { + "context" : [ { + "dataSourceId" : "VIRTUAL_AGENT", + "filters" : [ { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + }, { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + } ] + }, { + "dataSourceId" : "VIRTUAL_AGENT", + "filters" : [ { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + }, { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + } ] + } ], + "name" : "cea-filter", + "description" : "Global filter for CEA widgets" + } + + """ + api_context_filter_request = thousandeyes_sdk.dashboards.models.ApiContextFilterRequest.from_json(request_body_json) + id = '65bc18e8f2073a4a469cd958' + aid = '1234' + response_body_json = """ + { + "createdDate" : "2024-02-01T22:19:19Z", + "createdBy" : { + "uid" : "1", + "name" : "Test User" + }, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "context" : [ { + "dataSourceId" : "VIRTUAL_AGENT", + "filters" : [ { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + }, { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + } ] + }, { + "dataSourceId" : "VIRTUAL_AGENT", + "filters" : [ { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + }, { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + } ] + } ], + "name" : "cea-filter", + "modifiedDate" : "2024-02-01T22:19:19Z", + "description" : "Global filter for CEA widgets", + "modifiedBy" : { + "uid" : "1", + "name" : "Test User" + }, + "id" : "65bc18e8f2073a4a469cd958", + "aid" : "11" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.update_dashboard_filter( + + id=id, + + api_context_filter_request=api_context_filter_request, + + aid=aid, + + _headers=self.te_headers("update_dashboard_filter"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_update_dashboard_filter_error_400(self) -> None: + """Integration test for update_dashboard_filter error path (HTTP 400)""" + request_body_json = """ + + { + "context" : [ { + "dataSourceId" : "VIRTUAL_AGENT", + "filters" : [ { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + }, { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + } ] + }, { + "dataSourceId" : "VIRTUAL_AGENT", + "filters" : [ { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + }, { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + } ] + } ], + "name" : "cea-filter", + "description" : "Global filter for CEA widgets" + } + + """ + api_context_filter_request = thousandeyes_sdk.dashboards.models.ApiContextFilterRequest.from_json(request_body_json) + id = '65bc18e8f2073a4a469cd958' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.update_dashboard_filter( + + id=id, + + api_context_filter_request=api_context_filter_request, + + aid=aid, + + _headers=self.te_headers("update_dashboard_filter", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_dashboard_filter_error_401(self) -> None: + """Integration test for update_dashboard_filter error path (HTTP 401)""" + request_body_json = """ + + { + "context" : [ { + "dataSourceId" : "VIRTUAL_AGENT", + "filters" : [ { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + }, { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + } ] + }, { + "dataSourceId" : "VIRTUAL_AGENT", + "filters" : [ { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + }, { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + } ] + } ], + "name" : "cea-filter", + "description" : "Global filter for CEA widgets" + } + + """ + api_context_filter_request = thousandeyes_sdk.dashboards.models.ApiContextFilterRequest.from_json(request_body_json) + id = '65bc18e8f2073a4a469cd958' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.update_dashboard_filter( + + id=id, + + api_context_filter_request=api_context_filter_request, + + aid=aid, + + _headers=self.te_headers("update_dashboard_filter", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_dashboard_filter_error_403(self) -> None: + """Integration test for update_dashboard_filter error path (HTTP 403)""" + request_body_json = """ + + { + "context" : [ { + "dataSourceId" : "VIRTUAL_AGENT", + "filters" : [ { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + }, { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + } ] + }, { + "dataSourceId" : "VIRTUAL_AGENT", + "filters" : [ { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + }, { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + } ] + } ], + "name" : "cea-filter", + "description" : "Global filter for CEA widgets" + } + + """ + api_context_filter_request = thousandeyes_sdk.dashboards.models.ApiContextFilterRequest.from_json(request_body_json) + id = '65bc18e8f2073a4a469cd958' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.update_dashboard_filter( + + id=id, + + api_context_filter_request=api_context_filter_request, + + aid=aid, + + _headers=self.te_headers("update_dashboard_filter", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_dashboard_filter_error_404(self) -> None: + """Integration test for update_dashboard_filter error path (HTTP 404)""" + request_body_json = """ + + { + "context" : [ { + "dataSourceId" : "VIRTUAL_AGENT", + "filters" : [ { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + }, { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + } ] + }, { + "dataSourceId" : "VIRTUAL_AGENT", + "filters" : [ { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + }, { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + } ] + } ], + "name" : "cea-filter", + "description" : "Global filter for CEA widgets" + } + + """ + api_context_filter_request = thousandeyes_sdk.dashboards.models.ApiContextFilterRequest.from_json(request_body_json) + id = '65bc18e8f2073a4a469cd958' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.update_dashboard_filter( + + id=id, + + api_context_filter_request=api_context_filter_request, + + aid=aid, + + _headers=self.te_headers("update_dashboard_filter", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_dashboard_filter_error_429(self) -> None: + """Integration test for update_dashboard_filter error path (HTTP 429)""" + request_body_json = """ + + { + "context" : [ { + "dataSourceId" : "VIRTUAL_AGENT", + "filters" : [ { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + }, { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + } ] + }, { + "dataSourceId" : "VIRTUAL_AGENT", + "filters" : [ { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + }, { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + } ] + } ], + "name" : "cea-filter", + "description" : "Global filter for CEA widgets" + } + + """ + api_context_filter_request = thousandeyes_sdk.dashboards.models.ApiContextFilterRequest.from_json(request_body_json) + id = '65bc18e8f2073a4a469cd958' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.update_dashboard_filter( + + id=id, + + api_context_filter_request=api_context_filter_request, + + aid=aid, + + _headers=self.te_headers("update_dashboard_filter", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_dashboard_filter_error_500(self) -> None: + """Integration test for update_dashboard_filter error path (HTTP 500)""" + request_body_json = """ + + { + "context" : [ { + "dataSourceId" : "VIRTUAL_AGENT", + "filters" : [ { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + }, { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + } ] + }, { + "dataSourceId" : "VIRTUAL_AGENT", + "filters" : [ { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + }, { + "filterId" : "TEST_LABEL", + "metricIds" : [ "WEB_PAGE_LOAD_COMPLETION_RATE", "WEB_TTFB", "WEB_AVAILABILITY" ], + "values" : [ "45862", "59749" ] + } ] + } ], + "name" : "cea-filter", + "description" : "Global filter for CEA widgets" + } + + """ + api_context_filter_request = thousandeyes_sdk.dashboards.models.ApiContextFilterRequest.from_json(request_body_json) + id = '65bc18e8f2073a4a469cd958' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.update_dashboard_filter( + + id=id, + + api_context_filter_request=api_context_filter_request, + + aid=aid, + + _headers=self.te_headers("update_dashboard_filter", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-dashboards/test/test_utils.py b/thousandeyes-sdk-dashboards/test/test_utils.py index 930528d9..37913f62 100644 --- a/thousandeyes-sdk-dashboards/test/test_utils.py +++ b/thousandeyes-sdk-dashboards/test/test_utils.py @@ -2,15 +2,36 @@ import json import unittest +from typing import Any from pydantic import BaseModel +def _project_onto_constructed(expected: Any, constructed: Any) -> Any: + """Keep only example fields that appear in the constructed model output.""" + if isinstance(constructed, dict): + if not isinstance(expected, dict): + return expected + return { + key: _project_onto_constructed(expected.get(key), value) + for key, value in constructed.items() + } + if isinstance(constructed, list): + if not isinstance(expected, list): + return expected + return [ + _project_onto_constructed(expected[index], value) + for index, value in enumerate(constructed) + ] + return expected + + def assert_constructed_model_matches_example_json(model: BaseModel, loaded_json: dict): test_case = unittest.TestCase() test_case.maxDiff = None test_case.assertIsNotNone(model) constructed_json = json.loads(model.to_json()) - sorted_loaded_json = json.dumps(loaded_json, sort_keys=True) + projected_loaded_json = _project_onto_constructed(loaded_json, constructed_json) + sorted_loaded_json = json.dumps(projected_loaded_json, sort_keys=True) sorted_constructed_json = json.dumps(constructed_json, sort_keys=True) test_case.assertEqual(sorted_loaded_json, sorted_constructed_json) diff --git a/thousandeyes-sdk-emulation/test/conftest.py b/thousandeyes-sdk-emulation/test/conftest.py new file mode 100644 index 00000000..2edba7b3 --- /dev/null +++ b/thousandeyes-sdk-emulation/test/conftest.py @@ -0,0 +1,7 @@ +import sys +from pathlib import Path + +_repo_root = Path(__file__).resolve().parents[2] +_core_test_support = _repo_root / "thousandeyes-sdk-core" / "test" +if str(_core_test_support) not in sys.path: + sys.path.insert(0, str(_core_test_support)) diff --git a/thousandeyes-sdk-emulation/test/integration_test_utils.py b/thousandeyes-sdk-emulation/test/integration_test_utils.py new file mode 100644 index 00000000..4b2b0465 --- /dev/null +++ b/thousandeyes-sdk-emulation/test/integration_test_utils.py @@ -0,0 +1,37 @@ +# coding: utf-8 + +""" + Emulation API + + **Note:** All Emulation APIs are not available for ThousandEyes for Government instance. The Emulation API facilitates the retrieval of user-agent strings for HTTP, pageload, and transaction tests. It also enables the retrieval and addition of emulated devices for pageload and transaction tests. To access Emulation API operations, the following permissions are required: * `Settings Tests Read` for read operations. * `Settings Tests Update` for write operations. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from thousandeyes_sdk.core.api_client import ApiClient +from thousandeyes_sdk.core.configuration import Configuration +from sdk_test_support.mock_server import ERROR_STATUS_HEADER, OPERATION_ID_HEADER, MockApiServer + +from .mock_manifest import OPERATION_MANIFEST + + +class IntegrationTestBase(unittest.TestCase): + def setUp(self) -> None: + self.server = MockApiServer(OPERATION_MANIFEST) + self.server.start() + configuration = Configuration(host=self.server.base_url, access_token="test-token") + self.api_client = ApiClient(configuration=configuration) + + def tearDown(self) -> None: + self.server.stop() + + def te_headers(self, operation_id: str, error_status=None): + headers = {OPERATION_ID_HEADER: operation_id} + if error_status is not None: + headers[ERROR_STATUS_HEADER] = error_status + return headers diff --git a/thousandeyes-sdk-emulation/test/mock_manifest.py b/thousandeyes-sdk-emulation/test/mock_manifest.py new file mode 100644 index 00000000..395e0ebb --- /dev/null +++ b/thousandeyes-sdk-emulation/test/mock_manifest.py @@ -0,0 +1,340 @@ +# coding: utf-8 + +""" + Emulation API + + **Note:** All Emulation APIs are not available for ThousandEyes for Government instance. The Emulation API facilitates the retrieval of user-agent strings for HTTP, pageload, and transaction tests. It also enables the retrieval and addition of emulated devices for pageload and transaction tests. To access Emulation API operations, the following permissions are required: * `Settings Tests Read` for read operations. * `Settings Tests Update` for write operations. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json + +from sdk_test_support.mock_server_types import ErrorResponseExpectation, OperationExpectation + +OPERATION_MANIFEST = { + + "create_emulated_device": OperationExpectation( + operation_id="create_emulated_device", + method="POST", + path="/emulated-devices", + path_param_examples={ + }, + success_status=201, + success_body=json.loads(""" + + { + "availableUserAgents" : [ "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.5993.70 Mobile Safari/537.36", "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.5993.70 Safari/537.36" ], + "width" : 1024, + "name" : "iPad Pro 12.9-in", + "codeName" : "IPAD_PRO_12_9", + "id" : "11", + "category" : "desktop", + "defaultUserAgentTemplate" : "Mozilla/5.0 (Android 4.4; Tablet; rv:70.0) Gecko/70.0 Firefox/70.0", + "height" : 768 + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "width" : 1024, + "category" : "desktop", + "height" : 768 + } + + """), + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_emulated_devices": OperationExpectation( + operation_id="get_emulated_devices", + method="GET", + path="/emulated-devices", + path_param_examples={ + }, + success_status=200, + success_body=json.loads(""" + + { + "emulatedDevices" : [ { + "availableUserAgents" : [ "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.5993.70 Mobile Safari/537.36", "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.5993.70 Safari/537.36" ], + "width" : 1024, + "name" : "iPad Pro 12.9-in", + "codeName" : "IPAD_PRO_12_9", + "id" : "11", + "category" : "desktop", + "defaultUserAgentTemplate" : "Mozilla/5.0 (Android 4.4; Tablet; rv:70.0) Gecko/70.0 Firefox/70.0", + "height" : 768 + }, { + "availableUserAgents" : [ "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.5993.70 Mobile Safari/537.36", "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.5993.70 Safari/537.36" ], + "width" : 1024, + "name" : "iPad Pro 12.9-in", + "codeName" : "IPAD_PRO_12_9", + "id" : "11", + "category" : "desktop", + "defaultUserAgentTemplate" : "Mozilla/5.0 (Android 4.4; Tablet; rv:70.0) Gecko/70.0 Firefox/70.0", + "height" : 768 + } ], + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_user_agents": OperationExpectation( + operation_id="get_user_agents", + method="GET", + path="/user-agents", + path_param_examples={ + }, + success_status=200, + success_body=json.loads(""" + + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "userAgents" : [ { + "os" : "Windows", + "browser" : "Firefox", + "value" : "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.5993.70 Mobile Safari/537.36" + }, { + "os" : "Windows", + "browser" : "Firefox", + "value" : "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.5993.70 Mobile Safari/537.36" + } ] + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + +} diff --git a/thousandeyes-sdk-emulation/test/test_emulation_api_integration.py b/thousandeyes-sdk-emulation/test/test_emulation_api_integration.py new file mode 100644 index 00000000..4dee7203 --- /dev/null +++ b/thousandeyes-sdk-emulation/test/test_emulation_api_integration.py @@ -0,0 +1,572 @@ +# coding: utf-8 + +""" + Emulation API + + **Note:** All Emulation APIs are not available for ThousandEyes for Government instance. The Emulation API facilitates the retrieval of user-agent strings for HTTP, pageload, and transaction tests. It also enables the retrieval and addition of emulated devices for pageload and transaction tests. To access Emulation API operations, the following permissions are required: * `Settings Tests Read` for read operations. * `Settings Tests Update` for write operations. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.emulation.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.emulation.api.emulation_api import EmulationApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestEmulationApiIntegration(IntegrationTestBase): + """EmulationApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = EmulationApi(self.api_client) + + + def test_create_emulated_device_happy_path(self) -> None: + """Integration test for create_emulated_device success path""" + request_body_json = """ + + { + "width" : 1024, + "category" : "desktop", + "height" : 768 + } + + """ + emulated_device = thousandeyes_sdk.emulation.models.EmulatedDevice.from_json(request_body_json) + aid = '1234' + response_body_json = """ + { + "availableUserAgents" : [ "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.5993.70 Mobile Safari/537.36", "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.5993.70 Safari/537.36" ], + "width" : 1024, + "name" : "iPad Pro 12.9-in", + "codeName" : "IPAD_PRO_12_9", + "id" : "11", + "category" : "desktop", + "defaultUserAgentTemplate" : "Mozilla/5.0 (Android 4.4; Tablet; rv:70.0) Gecko/70.0 Firefox/70.0", + "height" : 768 + } + """ + expected_response = json.loads(response_body_json) + response = self.api.create_emulated_device( + + emulated_device=emulated_device, + + aid=aid, + + _headers=self.te_headers("create_emulated_device"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_create_emulated_device_error_401(self) -> None: + """Integration test for create_emulated_device error path (HTTP 401)""" + request_body_json = """ + + { + "width" : 1024, + "category" : "desktop", + "height" : 768 + } + + """ + emulated_device = thousandeyes_sdk.emulation.models.EmulatedDevice.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.create_emulated_device( + + emulated_device=emulated_device, + + aid=aid, + + _headers=self.te_headers("create_emulated_device", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_emulated_device_error_403(self) -> None: + """Integration test for create_emulated_device error path (HTTP 403)""" + request_body_json = """ + + { + "width" : 1024, + "category" : "desktop", + "height" : 768 + } + + """ + emulated_device = thousandeyes_sdk.emulation.models.EmulatedDevice.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.create_emulated_device( + + emulated_device=emulated_device, + + aid=aid, + + _headers=self.te_headers("create_emulated_device", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_emulated_device_error_404(self) -> None: + """Integration test for create_emulated_device error path (HTTP 404)""" + request_body_json = """ + + { + "width" : 1024, + "category" : "desktop", + "height" : 768 + } + + """ + emulated_device = thousandeyes_sdk.emulation.models.EmulatedDevice.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.create_emulated_device( + + emulated_device=emulated_device, + + aid=aid, + + _headers=self.te_headers("create_emulated_device", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_emulated_device_error_429(self) -> None: + """Integration test for create_emulated_device error path (HTTP 429)""" + request_body_json = """ + + { + "width" : 1024, + "category" : "desktop", + "height" : 768 + } + + """ + emulated_device = thousandeyes_sdk.emulation.models.EmulatedDevice.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.create_emulated_device( + + emulated_device=emulated_device, + + aid=aid, + + _headers=self.te_headers("create_emulated_device", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_emulated_device_error_500(self) -> None: + """Integration test for create_emulated_device error path (HTTP 500)""" + request_body_json = """ + + { + "width" : 1024, + "category" : "desktop", + "height" : 768 + } + + """ + emulated_device = thousandeyes_sdk.emulation.models.EmulatedDevice.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.create_emulated_device( + + emulated_device=emulated_device, + + aid=aid, + + _headers=self.te_headers("create_emulated_device", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_emulated_devices_happy_path(self) -> None: + """Integration test for get_emulated_devices success path""" + response_body_json = """ + { + "emulatedDevices" : [ { + "availableUserAgents" : [ "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.5993.70 Mobile Safari/537.36", "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.5993.70 Safari/537.36" ], + "width" : 1024, + "name" : "iPad Pro 12.9-in", + "codeName" : "IPAD_PRO_12_9", + "id" : "11", + "category" : "desktop", + "defaultUserAgentTemplate" : "Mozilla/5.0 (Android 4.4; Tablet; rv:70.0) Gecko/70.0 Firefox/70.0", + "height" : 768 + }, { + "availableUserAgents" : [ "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.5993.70 Mobile Safari/537.36", "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.5993.70 Safari/537.36" ], + "width" : 1024, + "name" : "iPad Pro 12.9-in", + "codeName" : "IPAD_PRO_12_9", + "id" : "11", + "category" : "desktop", + "defaultUserAgentTemplate" : "Mozilla/5.0 (Android 4.4; Tablet; rv:70.0) Gecko/70.0 Firefox/70.0", + "height" : 768 + } ], + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_emulated_devices( + + _headers=self.te_headers("get_emulated_devices"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_emulated_devices_error_401(self) -> None: + """Integration test for get_emulated_devices error path (HTTP 401)""" + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_emulated_devices( + + _headers=self.te_headers("get_emulated_devices", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_emulated_devices_error_403(self) -> None: + """Integration test for get_emulated_devices error path (HTTP 403)""" + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_emulated_devices( + + _headers=self.te_headers("get_emulated_devices", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_emulated_devices_error_404(self) -> None: + """Integration test for get_emulated_devices error path (HTTP 404)""" + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_emulated_devices( + + _headers=self.te_headers("get_emulated_devices", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_emulated_devices_error_429(self) -> None: + """Integration test for get_emulated_devices error path (HTTP 429)""" + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_emulated_devices( + + _headers=self.te_headers("get_emulated_devices", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_emulated_devices_error_500(self) -> None: + """Integration test for get_emulated_devices error path (HTTP 500)""" + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_emulated_devices( + + _headers=self.te_headers("get_emulated_devices", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_user_agents_happy_path(self) -> None: + """Integration test for get_user_agents success path""" + aid = '1234' + response_body_json = """ + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "userAgents" : [ { + "os" : "Windows", + "browser" : "Firefox", + "value" : "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.5993.70 Mobile Safari/537.36" + }, { + "os" : "Windows", + "browser" : "Firefox", + "value" : "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.5993.70 Mobile Safari/537.36" + } ] + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_user_agents( + + aid=aid, + + _headers=self.te_headers("get_user_agents"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_user_agents_error_401(self) -> None: + """Integration test for get_user_agents error path (HTTP 401)""" + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_user_agents( + + aid=aid, + + _headers=self.te_headers("get_user_agents", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_user_agents_error_403(self) -> None: + """Integration test for get_user_agents error path (HTTP 403)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_user_agents( + + aid=aid, + + _headers=self.te_headers("get_user_agents", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_user_agents_error_404(self) -> None: + """Integration test for get_user_agents error path (HTTP 404)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_user_agents( + + aid=aid, + + _headers=self.te_headers("get_user_agents", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_user_agents_error_429(self) -> None: + """Integration test for get_user_agents error path (HTTP 429)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_user_agents( + + aid=aid, + + _headers=self.te_headers("get_user_agents", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_user_agents_error_500(self) -> None: + """Integration test for get_user_agents error path (HTTP 500)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_user_agents( + + aid=aid, + + _headers=self.te_headers("get_user_agents", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-emulation/test/test_utils.py b/thousandeyes-sdk-emulation/test/test_utils.py index 930528d9..37913f62 100644 --- a/thousandeyes-sdk-emulation/test/test_utils.py +++ b/thousandeyes-sdk-emulation/test/test_utils.py @@ -2,15 +2,36 @@ import json import unittest +from typing import Any from pydantic import BaseModel +def _project_onto_constructed(expected: Any, constructed: Any) -> Any: + """Keep only example fields that appear in the constructed model output.""" + if isinstance(constructed, dict): + if not isinstance(expected, dict): + return expected + return { + key: _project_onto_constructed(expected.get(key), value) + for key, value in constructed.items() + } + if isinstance(constructed, list): + if not isinstance(expected, list): + return expected + return [ + _project_onto_constructed(expected[index], value) + for index, value in enumerate(constructed) + ] + return expected + + def assert_constructed_model_matches_example_json(model: BaseModel, loaded_json: dict): test_case = unittest.TestCase() test_case.maxDiff = None test_case.assertIsNotNone(model) constructed_json = json.loads(model.to_json()) - sorted_loaded_json = json.dumps(loaded_json, sort_keys=True) + projected_loaded_json = _project_onto_constructed(loaded_json, constructed_json) + sorted_loaded_json = json.dumps(projected_loaded_json, sort_keys=True) sorted_constructed_json = json.dumps(constructed_json, sort_keys=True) test_case.assertEqual(sorted_loaded_json, sorted_constructed_json) diff --git a/thousandeyes-sdk-endpoint-agents/test/conftest.py b/thousandeyes-sdk-endpoint-agents/test/conftest.py new file mode 100644 index 00000000..2edba7b3 --- /dev/null +++ b/thousandeyes-sdk-endpoint-agents/test/conftest.py @@ -0,0 +1,7 @@ +import sys +from pathlib import Path + +_repo_root = Path(__file__).resolve().parents[2] +_core_test_support = _repo_root / "thousandeyes-sdk-core" / "test" +if str(_core_test_support) not in sys.path: + sys.path.insert(0, str(_core_test_support)) diff --git a/thousandeyes-sdk-endpoint-agents/test/integration_test_utils.py b/thousandeyes-sdk-endpoint-agents/test/integration_test_utils.py new file mode 100644 index 00000000..494f9642 --- /dev/null +++ b/thousandeyes-sdk-endpoint-agents/test/integration_test_utils.py @@ -0,0 +1,37 @@ +# coding: utf-8 + +""" + Endpoint Agents API + + **Note:** The Endpoint Agents Transfer APIs are not available for ThousandEyes for Government instance. Manage ThousandEyes Endpoint Agents using this API. For more information about Endpoint Agents, see [Endpoint Agents](https://docs.thousandeyes.com/product-documentation/global-vantage-points/endpoint-agents). + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from thousandeyes_sdk.core.api_client import ApiClient +from thousandeyes_sdk.core.configuration import Configuration +from sdk_test_support.mock_server import ERROR_STATUS_HEADER, OPERATION_ID_HEADER, MockApiServer + +from .mock_manifest import OPERATION_MANIFEST + + +class IntegrationTestBase(unittest.TestCase): + def setUp(self) -> None: + self.server = MockApiServer(OPERATION_MANIFEST) + self.server.start() + configuration = Configuration(host=self.server.base_url, access_token="test-token") + self.api_client = ApiClient(configuration=configuration) + + def tearDown(self) -> None: + self.server.stop() + + def te_headers(self, operation_id: str, error_status=None): + headers = {OPERATION_ID_HEADER: operation_id} + if error_status is not None: + headers[ERROR_STATUS_HEADER] = error_status + return headers diff --git a/thousandeyes-sdk-endpoint-agents/test/mock_manifest.py b/thousandeyes-sdk-endpoint-agents/test/mock_manifest.py new file mode 100644 index 00000000..6ddba81c --- /dev/null +++ b/thousandeyes-sdk-endpoint-agents/test/mock_manifest.py @@ -0,0 +1,2514 @@ +# coding: utf-8 + +""" + Endpoint Agents API + + **Note:** The Endpoint Agents Transfer APIs are not available for ThousandEyes for Government instance. Manage ThousandEyes Endpoint Agents using this API. For more information about Endpoint Agents, see [Endpoint Agents](https://docs.thousandeyes.com/product-documentation/global-vantage-points/endpoint-agents). + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json + +from sdk_test_support.mock_server_types import ErrorResponseExpectation, OperationExpectation + +OPERATION_MANIFEST = { + + "get_endpoint_agent_log_items": OperationExpectation( + operation_id="get_endpoint_agent_log_items", + method="GET", + path="/endpoint/agents/{agentId}/logs", + path_param_examples={ + "agentId": 'agent_id_example', + }, + success_status=200, + success_body=json.loads(""" + + { + "_links" : { + "next" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "logs" : [ { + "wifiLogItem" : { + "bssidFrom" : "00:11:22:33:44:54", + "bssid" : "00:11:22:33:44:55", + "failure" : { + "code" : 4, + "context" : "WPA authentication failed", + "type" : "auth" + }, + "logItemType" : "wifi-connect", + "channel" : "36", + "physicalMode" : "802.11ac", + "physicalModeFrom" : "802.11n", + "ssid" : "CorpWiFi", + "channelFrom" : "11" + }, + "agentLogItemType" : "wifi", + "onlineOfflineLogItem" : { + "logItemType" : "online" + }, + "id" : "8d23f1b7-74ef-4e0c-925c-58601fc0662d", + "vpnLogItem" : { + "logItemType" : "vpn-connect", + "vpnServerName" : "vpn-us-west", + "vpnType" : "cisco-anyconnect", + "vpnServerAddress" : "192.0.2.10" + }, + "stateChangesLogItem" : { + "logItemType" : "enabled" + }, + "timestampMs" : 1709240000000 + }, { + "wifiLogItem" : { + "bssidFrom" : "00:11:22:33:44:54", + "bssid" : "00:11:22:33:44:55", + "failure" : { + "code" : 4, + "context" : "WPA authentication failed", + "type" : "auth" + }, + "logItemType" : "wifi-connect", + "channel" : "36", + "physicalMode" : "802.11ac", + "physicalModeFrom" : "802.11n", + "ssid" : "CorpWiFi", + "channelFrom" : "11" + }, + "agentLogItemType" : "wifi", + "onlineOfflineLogItem" : { + "logItemType" : "online" + }, + "id" : "8d23f1b7-74ef-4e0c-925c-58601fc0662d", + "vpnLogItem" : { + "logItemType" : "vpn-connect", + "vpnServerName" : "vpn-us-west", + "vpnType" : "cisco-anyconnect", + "vpnServerAddress" : "192.0.2.10" + }, + "stateChangesLogItem" : { + "logItemType" : "enabled" + }, + "timestampMs" : 1709240000000 + } ] + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "delete_endpoint_agent": OperationExpectation( + operation_id="delete_endpoint_agent", + method="DELETE", + path="/endpoint/agents/{agentId}", + path_param_examples={ + "agentId": 'agent_id_example', + }, + success_status=204, + success_body=None, + success_content_type="application/json", + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "disable_endpoint_agent": OperationExpectation( + operation_id="disable_endpoint_agent", + method="POST", + path="/endpoint/agents/{agentId}/disable", + path_param_examples={ + "agentId": 'agent_id_example', + }, + success_status=200, + success_body=json.loads(""" + + { + "npcapVersion" : "npcapVersion", + "asnDetails" : { + "asName" : "Virgin Media Limited", + "asNumber" : 5089 + }, + "clients" : [ { + "browserExtensions" : [ { + "browser" : "edge", + "profile" : "Profile 1", + "active" : true, + "error" : "", + "version" : "0.123.0", + "enabled" : true + }, { + "browser" : "edge", + "profile" : "Profile 1", + "active" : true, + "error" : "", + "version" : "0.123.0", + "enabled" : true + } ], + "userProfile" : { + "userName" : "joeblogs32", + "userPrincipalName" : "joeblogs32@c.com" + } + }, { + "browserExtensions" : [ { + "browser" : "edge", + "profile" : "Profile 1", + "active" : true, + "error" : "", + "version" : "0.123.0", + "enabled" : true + }, { + "browser" : "edge", + "profile" : "Profile 1", + "active" : true, + "error" : "", + "version" : "0.123.0", + "enabled" : true + } ], + "userProfile" : { + "userName" : "joeblogs32", + "userPrincipalName" : "joeblogs32@c.com" + } + } ], + "agentType" : "endpoint", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "batteryMetrics" : { + "batteryHealthNormalizedPercent" : 0.92, + "batteryLevel" : "medium", + "batteryLevelNormalizedPercent" : 0.3 + }, + "publicIP" : "88.45.2.123", + "tcpDriverAvailable" : true, + "platform" : "mac", + "manufacturer" : "Apple, Inc.", + "targetVersion" : "0.123.4", + "cellularProfile" : { + "rssi" : -10, + "advertisedNetworkSubtype" : "LTE/HSPA", + "carrierName" : "T-Mobile", + "rsrq" : -30, + "rsrp" : -30, + "advertisedNetworkGen" : "2g, 3g, 4g, 5g", + "rscp" : -30, + "networkGen" : "2g, 3g, 4g, 5g", + "networkSubtype" : "LTE/HSPA", + "sinr" : 20 + }, + "nicModel" : "Intel(R) Wi-Fi 6 AX200 160MHz", + "createdAt" : "2022-05-26T23:37:16Z", + "numberOfClients" : 3, + "licenseType" : "essentials", + "osVersion" : "Version 10.15.2 (Build 19C57)", + "computerName" : "DESKJET-123", + "freeDiskSpaceNormalized" : 0.41, + "model" : "MacBookAir7,2", + "id" : "861b7557-cd57-4bbb-b648-00bddf88ef49", + "nicDriverVersion" : "22.250.0.9", + "serialNumber" : "xaab2ba4-d40f-4e80-9363-7e4826556055", + "externalMetadata" : [ { + "key" : "anyConnectDeviceId", + "value" : "DF434343D" + }, { + "key" : "anyConnectDeviceId", + "value" : "DF434343D" + } ], + "version" : "0.123.4", + "vpnProfiles" : [ { + "vpnClientNetworkRange" : [ "10.100.0.0/22" ], + "vpnGatewayAddress" : "vpnGatewayAddress", + "vpnType" : "cisco-anyconnect", + "interfaceName" : "interfaceName", + "vpnClientAddresses" : [ "10.100.0.10" ] + }, { + "vpnClientNetworkRange" : [ "10.100.0.0/22" ], + "vpnGatewayAddress" : "vpnGatewayAddress", + "vpnType" : "cisco-anyconnect", + "interfaceName" : "interfaceName", + "vpnClientAddresses" : [ "10.100.0.10" ] + } ], + "lastSeen" : "2022-05-26T23:37:16Z", + "deleted" : true, + "totalMemory" : "16384 MB", + "kernelVersion" : "Darwin 19.2.0", + "name" : "Office Printer", + "location" : { + "locationName" : "London", + "latitude" : 51.51279, + "longitude" : -0.09184 + }, + "aid" : "", + "status" : "enabled", + "networkInterfaceProfiles" : [ { + "ethernetProfile" : { + "linkSpeed" : 0 + }, + "hardwareType" : "wireless", + "interfaceName" : "en0", + "addressProfiles" : [ { + "prefixLength" : 24, + "addressType" : "unique-local", + "ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888", + "routerHardwareAddress" : "5c:b1:3e:46:1c:84", + "gateway" : "192.168.0.254" + }, { + "prefixLength" : 24, + "addressType" : "unique-local", + "ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888", + "routerHardwareAddress" : "5c:b1:3e:46:1c:84", + "gateway" : "192.168.0.254" + } ], + "wirelessProfile" : { + "rssi" : -36, + "bssid" : "00:11:22:aa:bb:cc", + "channel" : 48, + "phyMode" : "802.11ac", + "ssid" : "GuestWiFi" + } + }, { + "ethernetProfile" : { + "linkSpeed" : 0 + }, + "hardwareType" : "wireless", + "interfaceName" : "en0", + "addressProfiles" : [ { + "prefixLength" : 24, + "addressType" : "unique-local", + "ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888", + "routerHardwareAddress" : "5c:b1:3e:46:1c:84", + "gateway" : "192.168.0.254" + }, { + "prefixLength" : 24, + "addressType" : "unique-local", + "ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888", + "routerHardwareAddress" : "5c:b1:3e:46:1c:84", + "gateway" : "192.168.0.254" + } ], + "wirelessProfile" : { + "rssi" : -36, + "bssid" : "00:11:22:aa:bb:cc", + "channel" : 48, + "phyMode" : "802.11ac", + "ssid" : "GuestWiFi" + } + } ] + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "enable_endpoint_agent": OperationExpectation( + operation_id="enable_endpoint_agent", + method="POST", + path="/endpoint/agents/{agentId}/enable", + path_param_examples={ + "agentId": 'agent_id_example', + }, + success_status=200, + success_body=json.loads(""" + + { + "npcapVersion" : "npcapVersion", + "asnDetails" : { + "asName" : "Virgin Media Limited", + "asNumber" : 5089 + }, + "clients" : [ { + "browserExtensions" : [ { + "browser" : "edge", + "profile" : "Profile 1", + "active" : true, + "error" : "", + "version" : "0.123.0", + "enabled" : true + }, { + "browser" : "edge", + "profile" : "Profile 1", + "active" : true, + "error" : "", + "version" : "0.123.0", + "enabled" : true + } ], + "userProfile" : { + "userName" : "joeblogs32", + "userPrincipalName" : "joeblogs32@c.com" + } + }, { + "browserExtensions" : [ { + "browser" : "edge", + "profile" : "Profile 1", + "active" : true, + "error" : "", + "version" : "0.123.0", + "enabled" : true + }, { + "browser" : "edge", + "profile" : "Profile 1", + "active" : true, + "error" : "", + "version" : "0.123.0", + "enabled" : true + } ], + "userProfile" : { + "userName" : "joeblogs32", + "userPrincipalName" : "joeblogs32@c.com" + } + } ], + "agentType" : "endpoint", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "batteryMetrics" : { + "batteryHealthNormalizedPercent" : 0.92, + "batteryLevel" : "medium", + "batteryLevelNormalizedPercent" : 0.3 + }, + "publicIP" : "88.45.2.123", + "tcpDriverAvailable" : true, + "platform" : "mac", + "manufacturer" : "Apple, Inc.", + "targetVersion" : "0.123.4", + "cellularProfile" : { + "rssi" : -10, + "advertisedNetworkSubtype" : "LTE/HSPA", + "carrierName" : "T-Mobile", + "rsrq" : -30, + "rsrp" : -30, + "advertisedNetworkGen" : "2g, 3g, 4g, 5g", + "rscp" : -30, + "networkGen" : "2g, 3g, 4g, 5g", + "networkSubtype" : "LTE/HSPA", + "sinr" : 20 + }, + "nicModel" : "Intel(R) Wi-Fi 6 AX200 160MHz", + "createdAt" : "2022-05-26T23:37:16Z", + "numberOfClients" : 3, + "licenseType" : "essentials", + "osVersion" : "Version 10.15.2 (Build 19C57)", + "computerName" : "DESKJET-123", + "freeDiskSpaceNormalized" : 0.41, + "model" : "MacBookAir7,2", + "id" : "861b7557-cd57-4bbb-b648-00bddf88ef49", + "nicDriverVersion" : "22.250.0.9", + "serialNumber" : "xaab2ba4-d40f-4e80-9363-7e4826556055", + "externalMetadata" : [ { + "key" : "anyConnectDeviceId", + "value" : "DF434343D" + }, { + "key" : "anyConnectDeviceId", + "value" : "DF434343D" + } ], + "version" : "0.123.4", + "vpnProfiles" : [ { + "vpnClientNetworkRange" : [ "10.100.0.0/22" ], + "vpnGatewayAddress" : "vpnGatewayAddress", + "vpnType" : "cisco-anyconnect", + "interfaceName" : "interfaceName", + "vpnClientAddresses" : [ "10.100.0.10" ] + }, { + "vpnClientNetworkRange" : [ "10.100.0.0/22" ], + "vpnGatewayAddress" : "vpnGatewayAddress", + "vpnType" : "cisco-anyconnect", + "interfaceName" : "interfaceName", + "vpnClientAddresses" : [ "10.100.0.10" ] + } ], + "lastSeen" : "2022-05-26T23:37:16Z", + "deleted" : true, + "totalMemory" : "16384 MB", + "kernelVersion" : "Darwin 19.2.0", + "name" : "Office Printer", + "location" : { + "locationName" : "London", + "latitude" : 51.51279, + "longitude" : -0.09184 + }, + "aid" : "", + "status" : "enabled", + "networkInterfaceProfiles" : [ { + "ethernetProfile" : { + "linkSpeed" : 0 + }, + "hardwareType" : "wireless", + "interfaceName" : "en0", + "addressProfiles" : [ { + "prefixLength" : 24, + "addressType" : "unique-local", + "ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888", + "routerHardwareAddress" : "5c:b1:3e:46:1c:84", + "gateway" : "192.168.0.254" + }, { + "prefixLength" : 24, + "addressType" : "unique-local", + "ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888", + "routerHardwareAddress" : "5c:b1:3e:46:1c:84", + "gateway" : "192.168.0.254" + } ], + "wirelessProfile" : { + "rssi" : -36, + "bssid" : "00:11:22:aa:bb:cc", + "channel" : 48, + "phyMode" : "802.11ac", + "ssid" : "GuestWiFi" + } + }, { + "ethernetProfile" : { + "linkSpeed" : 0 + }, + "hardwareType" : "wireless", + "interfaceName" : "en0", + "addressProfiles" : [ { + "prefixLength" : 24, + "addressType" : "unique-local", + "ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888", + "routerHardwareAddress" : "5c:b1:3e:46:1c:84", + "gateway" : "192.168.0.254" + }, { + "prefixLength" : 24, + "addressType" : "unique-local", + "ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888", + "routerHardwareAddress" : "5c:b1:3e:46:1c:84", + "gateway" : "192.168.0.254" + } ], + "wirelessProfile" : { + "rssi" : -36, + "bssid" : "00:11:22:aa:bb:cc", + "channel" : 48, + "phyMode" : "802.11ac", + "ssid" : "GuestWiFi" + } + } ] + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "filter_endpoint_agents": OperationExpectation( + operation_id="filter_endpoint_agents", + method="POST", + path="/endpoint/agents/filter", + path_param_examples={ + }, + success_status=200, + success_body=json.loads(""" + + { + "_links" : { + "next" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "totalAgents" : 1, + "agents" : [ { + "npcapVersion" : "npcapVersion", + "asnDetails" : { + "asName" : "Virgin Media Limited", + "asNumber" : 5089 + }, + "clients" : [ { + "browserExtensions" : [ { + "browser" : "edge", + "profile" : "Profile 1", + "active" : true, + "error" : "", + "version" : "0.123.0", + "enabled" : true + }, { + "browser" : "edge", + "profile" : "Profile 1", + "active" : true, + "error" : "", + "version" : "0.123.0", + "enabled" : true + } ], + "userProfile" : { + "userName" : "joeblogs32", + "userPrincipalName" : "joeblogs32@c.com" + } + }, { + "browserExtensions" : [ { + "browser" : "edge", + "profile" : "Profile 1", + "active" : true, + "error" : "", + "version" : "0.123.0", + "enabled" : true + }, { + "browser" : "edge", + "profile" : "Profile 1", + "active" : true, + "error" : "", + "version" : "0.123.0", + "enabled" : true + } ], + "userProfile" : { + "userName" : "joeblogs32", + "userPrincipalName" : "joeblogs32@c.com" + } + } ], + "agentType" : "endpoint", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "batteryMetrics" : { + "batteryHealthNormalizedPercent" : 0.92, + "batteryLevel" : "medium", + "batteryLevelNormalizedPercent" : 0.3 + }, + "publicIP" : "88.45.2.123", + "tcpDriverAvailable" : true, + "platform" : "mac", + "manufacturer" : "Apple, Inc.", + "targetVersion" : "0.123.4", + "cellularProfile" : { + "rssi" : -10, + "advertisedNetworkSubtype" : "LTE/HSPA", + "carrierName" : "T-Mobile", + "rsrq" : -30, + "rsrp" : -30, + "advertisedNetworkGen" : "2g, 3g, 4g, 5g", + "rscp" : -30, + "networkGen" : "2g, 3g, 4g, 5g", + "networkSubtype" : "LTE/HSPA", + "sinr" : 20 + }, + "nicModel" : "Intel(R) Wi-Fi 6 AX200 160MHz", + "createdAt" : "2022-05-26T23:37:16Z", + "numberOfClients" : 3, + "licenseType" : "essentials", + "osVersion" : "Version 10.15.2 (Build 19C57)", + "computerName" : "DESKJET-123", + "freeDiskSpaceNormalized" : 0.41, + "model" : "MacBookAir7,2", + "id" : "861b7557-cd57-4bbb-b648-00bddf88ef49", + "nicDriverVersion" : "22.250.0.9", + "serialNumber" : "xaab2ba4-d40f-4e80-9363-7e4826556055", + "externalMetadata" : [ { + "key" : "anyConnectDeviceId", + "value" : "DF434343D" + }, { + "key" : "anyConnectDeviceId", + "value" : "DF434343D" + } ], + "version" : "0.123.4", + "vpnProfiles" : [ { + "vpnClientNetworkRange" : [ "10.100.0.0/22" ], + "vpnGatewayAddress" : "vpnGatewayAddress", + "vpnType" : "cisco-anyconnect", + "interfaceName" : "interfaceName", + "vpnClientAddresses" : [ "10.100.0.10" ] + }, { + "vpnClientNetworkRange" : [ "10.100.0.0/22" ], + "vpnGatewayAddress" : "vpnGatewayAddress", + "vpnType" : "cisco-anyconnect", + "interfaceName" : "interfaceName", + "vpnClientAddresses" : [ "10.100.0.10" ] + } ], + "lastSeen" : "2022-05-26T23:37:16Z", + "deleted" : true, + "totalMemory" : "16384 MB", + "kernelVersion" : "Darwin 19.2.0", + "name" : "Office Printer", + "location" : { + "locationName" : "London", + "latitude" : 51.51279, + "longitude" : -0.09184 + }, + "aid" : "", + "status" : "enabled", + "networkInterfaceProfiles" : [ { + "ethernetProfile" : { + "linkSpeed" : 0 + }, + "hardwareType" : "wireless", + "interfaceName" : "en0", + "addressProfiles" : [ { + "prefixLength" : 24, + "addressType" : "unique-local", + "ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888", + "routerHardwareAddress" : "5c:b1:3e:46:1c:84", + "gateway" : "192.168.0.254" + }, { + "prefixLength" : 24, + "addressType" : "unique-local", + "ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888", + "routerHardwareAddress" : "5c:b1:3e:46:1c:84", + "gateway" : "192.168.0.254" + } ], + "wirelessProfile" : { + "rssi" : -36, + "bssid" : "00:11:22:aa:bb:cc", + "channel" : 48, + "phyMode" : "802.11ac", + "ssid" : "GuestWiFi" + } + }, { + "ethernetProfile" : { + "linkSpeed" : 0 + }, + "hardwareType" : "wireless", + "interfaceName" : "en0", + "addressProfiles" : [ { + "prefixLength" : 24, + "addressType" : "unique-local", + "ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888", + "routerHardwareAddress" : "5c:b1:3e:46:1c:84", + "gateway" : "192.168.0.254" + }, { + "prefixLength" : 24, + "addressType" : "unique-local", + "ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888", + "routerHardwareAddress" : "5c:b1:3e:46:1c:84", + "gateway" : "192.168.0.254" + } ], + "wirelessProfile" : { + "rssi" : -36, + "bssid" : "00:11:22:aa:bb:cc", + "channel" : 48, + "phyMode" : "802.11ac", + "ssid" : "GuestWiFi" + } + } ] + }, { + "npcapVersion" : "npcapVersion", + "asnDetails" : { + "asName" : "Virgin Media Limited", + "asNumber" : 5089 + }, + "clients" : [ { + "browserExtensions" : [ { + "browser" : "edge", + "profile" : "Profile 1", + "active" : true, + "error" : "", + "version" : "0.123.0", + "enabled" : true + }, { + "browser" : "edge", + "profile" : "Profile 1", + "active" : true, + "error" : "", + "version" : "0.123.0", + "enabled" : true + } ], + "userProfile" : { + "userName" : "joeblogs32", + "userPrincipalName" : "joeblogs32@c.com" + } + }, { + "browserExtensions" : [ { + "browser" : "edge", + "profile" : "Profile 1", + "active" : true, + "error" : "", + "version" : "0.123.0", + "enabled" : true + }, { + "browser" : "edge", + "profile" : "Profile 1", + "active" : true, + "error" : "", + "version" : "0.123.0", + "enabled" : true + } ], + "userProfile" : { + "userName" : "joeblogs32", + "userPrincipalName" : "joeblogs32@c.com" + } + } ], + "agentType" : "endpoint", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "batteryMetrics" : { + "batteryHealthNormalizedPercent" : 0.92, + "batteryLevel" : "medium", + "batteryLevelNormalizedPercent" : 0.3 + }, + "publicIP" : "88.45.2.123", + "tcpDriverAvailable" : true, + "platform" : "mac", + "manufacturer" : "Apple, Inc.", + "targetVersion" : "0.123.4", + "cellularProfile" : { + "rssi" : -10, + "advertisedNetworkSubtype" : "LTE/HSPA", + "carrierName" : "T-Mobile", + "rsrq" : -30, + "rsrp" : -30, + "advertisedNetworkGen" : "2g, 3g, 4g, 5g", + "rscp" : -30, + "networkGen" : "2g, 3g, 4g, 5g", + "networkSubtype" : "LTE/HSPA", + "sinr" : 20 + }, + "nicModel" : "Intel(R) Wi-Fi 6 AX200 160MHz", + "createdAt" : "2022-05-26T23:37:16Z", + "numberOfClients" : 3, + "licenseType" : "essentials", + "osVersion" : "Version 10.15.2 (Build 19C57)", + "computerName" : "DESKJET-123", + "freeDiskSpaceNormalized" : 0.41, + "model" : "MacBookAir7,2", + "id" : "861b7557-cd57-4bbb-b648-00bddf88ef49", + "nicDriverVersion" : "22.250.0.9", + "serialNumber" : "xaab2ba4-d40f-4e80-9363-7e4826556055", + "externalMetadata" : [ { + "key" : "anyConnectDeviceId", + "value" : "DF434343D" + }, { + "key" : "anyConnectDeviceId", + "value" : "DF434343D" + } ], + "version" : "0.123.4", + "vpnProfiles" : [ { + "vpnClientNetworkRange" : [ "10.100.0.0/22" ], + "vpnGatewayAddress" : "vpnGatewayAddress", + "vpnType" : "cisco-anyconnect", + "interfaceName" : "interfaceName", + "vpnClientAddresses" : [ "10.100.0.10" ] + }, { + "vpnClientNetworkRange" : [ "10.100.0.0/22" ], + "vpnGatewayAddress" : "vpnGatewayAddress", + "vpnType" : "cisco-anyconnect", + "interfaceName" : "interfaceName", + "vpnClientAddresses" : [ "10.100.0.10" ] + } ], + "lastSeen" : "2022-05-26T23:37:16Z", + "deleted" : true, + "totalMemory" : "16384 MB", + "kernelVersion" : "Darwin 19.2.0", + "name" : "Office Printer", + "location" : { + "locationName" : "London", + "latitude" : 51.51279, + "longitude" : -0.09184 + }, + "aid" : "", + "status" : "enabled", + "networkInterfaceProfiles" : [ { + "ethernetProfile" : { + "linkSpeed" : 0 + }, + "hardwareType" : "wireless", + "interfaceName" : "en0", + "addressProfiles" : [ { + "prefixLength" : 24, + "addressType" : "unique-local", + "ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888", + "routerHardwareAddress" : "5c:b1:3e:46:1c:84", + "gateway" : "192.168.0.254" + }, { + "prefixLength" : 24, + "addressType" : "unique-local", + "ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888", + "routerHardwareAddress" : "5c:b1:3e:46:1c:84", + "gateway" : "192.168.0.254" + } ], + "wirelessProfile" : { + "rssi" : -36, + "bssid" : "00:11:22:aa:bb:cc", + "channel" : 48, + "phyMode" : "802.11ac", + "ssid" : "GuestWiFi" + } + }, { + "ethernetProfile" : { + "linkSpeed" : 0 + }, + "hardwareType" : "wireless", + "interfaceName" : "en0", + "addressProfiles" : [ { + "prefixLength" : 24, + "addressType" : "unique-local", + "ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888", + "routerHardwareAddress" : "5c:b1:3e:46:1c:84", + "gateway" : "192.168.0.254" + }, { + "prefixLength" : 24, + "addressType" : "unique-local", + "ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888", + "routerHardwareAddress" : "5c:b1:3e:46:1c:84", + "gateway" : "192.168.0.254" + } ], + "wirelessProfile" : { + "rssi" : -36, + "bssid" : "00:11:22:aa:bb:cc", + "channel" : 48, + "phyMode" : "802.11ac", + "ssid" : "GuestWiFi" + } + } ] + } ] + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "searchSort" : [ { + "sort" : "platform", + "order" : "desc" + }, { + "sort" : "platform", + "order" : "desc" + } ], + "searchFilters" : { + "serialNumber" : [ "xaab2ba4-d40f-4e80-9363-7e4826556055", "xaab2ba4-d40f-4e80-9363-7e4826556055", "xaab2ba4-d40f-4e80-9363-7e4826556055", "xaab2ba4-d40f-4e80-9363-7e4826556055", "xaab2ba4-d40f-4e80-9363-7e4826556055" ], + "anyConnectDeviceId" : [ "JDLKSLFEIJER004334F" ], + "agentName" : [ "myagent-1234", "myagent-1234" ], + "locationSubdivision1Code" : [ "ENG", "ENG" ], + "platform" : [ "mac", "mac" ], + "licenseType" : [ "essentials", "essentials" ], + "osVersion" : [ "Version 10.15.2", "Version 10.15.2" ], + "computerName" : [ "DESKTOP-45AE8", "DESKTOP-45AE8" ], + "locationCountryISO" : [ "FR", "FR" ], + "id" : [ "861b7557-cd57-4bbb-b648-00bddf88ef49", "861b7557-cd57-4bbb-b648-00bddf88ef49" ], + "userPrincipalName" : [ "picard@c.com" ], + "locationCity" : [ "Paris", "Paris" ], + "username" : [ "picard" ] + }, + "thresholdFilter" : { + "conditionalOperator" : "and", + "filters" : [ { + "name" : "last-seen-ms", + "value" : 0.8008281904610115, + "operator" : "gte" + }, { + "name" : "last-seen-ms", + "value" : 0.8008281904610115, + "operator" : "gte" + } ] + } + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_endpoint_agent": OperationExpectation( + operation_id="get_endpoint_agent", + method="GET", + path="/endpoint/agents/{agentId}", + path_param_examples={ + "agentId": 'agent_id_example', + }, + success_status=200, + success_body=json.loads(""" + + { + "npcapVersion" : "npcapVersion", + "asnDetails" : { + "asName" : "Virgin Media Limited", + "asNumber" : 5089 + }, + "clients" : [ { + "browserExtensions" : [ { + "browser" : "edge", + "profile" : "Profile 1", + "active" : true, + "error" : "", + "version" : "0.123.0", + "enabled" : true + }, { + "browser" : "edge", + "profile" : "Profile 1", + "active" : true, + "error" : "", + "version" : "0.123.0", + "enabled" : true + } ], + "userProfile" : { + "userName" : "joeblogs32", + "userPrincipalName" : "joeblogs32@c.com" + } + }, { + "browserExtensions" : [ { + "browser" : "edge", + "profile" : "Profile 1", + "active" : true, + "error" : "", + "version" : "0.123.0", + "enabled" : true + }, { + "browser" : "edge", + "profile" : "Profile 1", + "active" : true, + "error" : "", + "version" : "0.123.0", + "enabled" : true + } ], + "userProfile" : { + "userName" : "joeblogs32", + "userPrincipalName" : "joeblogs32@c.com" + } + } ], + "agentType" : "endpoint", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "batteryMetrics" : { + "batteryHealthNormalizedPercent" : 0.92, + "batteryLevel" : "medium", + "batteryLevelNormalizedPercent" : 0.3 + }, + "publicIP" : "88.45.2.123", + "tcpDriverAvailable" : true, + "platform" : "mac", + "manufacturer" : "Apple, Inc.", + "targetVersion" : "0.123.4", + "cellularProfile" : { + "rssi" : -10, + "advertisedNetworkSubtype" : "LTE/HSPA", + "carrierName" : "T-Mobile", + "rsrq" : -30, + "rsrp" : -30, + "advertisedNetworkGen" : "2g, 3g, 4g, 5g", + "rscp" : -30, + "networkGen" : "2g, 3g, 4g, 5g", + "networkSubtype" : "LTE/HSPA", + "sinr" : 20 + }, + "nicModel" : "Intel(R) Wi-Fi 6 AX200 160MHz", + "createdAt" : "2022-05-26T23:37:16Z", + "numberOfClients" : 3, + "licenseType" : "essentials", + "osVersion" : "Version 10.15.2 (Build 19C57)", + "computerName" : "DESKJET-123", + "freeDiskSpaceNormalized" : 0.41, + "model" : "MacBookAir7,2", + "id" : "861b7557-cd57-4bbb-b648-00bddf88ef49", + "nicDriverVersion" : "22.250.0.9", + "serialNumber" : "xaab2ba4-d40f-4e80-9363-7e4826556055", + "externalMetadata" : [ { + "key" : "anyConnectDeviceId", + "value" : "DF434343D" + }, { + "key" : "anyConnectDeviceId", + "value" : "DF434343D" + } ], + "version" : "0.123.4", + "vpnProfiles" : [ { + "vpnClientNetworkRange" : [ "10.100.0.0/22" ], + "vpnGatewayAddress" : "vpnGatewayAddress", + "vpnType" : "cisco-anyconnect", + "interfaceName" : "interfaceName", + "vpnClientAddresses" : [ "10.100.0.10" ] + }, { + "vpnClientNetworkRange" : [ "10.100.0.0/22" ], + "vpnGatewayAddress" : "vpnGatewayAddress", + "vpnType" : "cisco-anyconnect", + "interfaceName" : "interfaceName", + "vpnClientAddresses" : [ "10.100.0.10" ] + } ], + "lastSeen" : "2022-05-26T23:37:16Z", + "deleted" : true, + "totalMemory" : "16384 MB", + "kernelVersion" : "Darwin 19.2.0", + "name" : "Office Printer", + "location" : { + "locationName" : "London", + "latitude" : 51.51279, + "longitude" : -0.09184 + }, + "aid" : "", + "status" : "enabled", + "networkInterfaceProfiles" : [ { + "ethernetProfile" : { + "linkSpeed" : 0 + }, + "hardwareType" : "wireless", + "interfaceName" : "en0", + "addressProfiles" : [ { + "prefixLength" : 24, + "addressType" : "unique-local", + "ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888", + "routerHardwareAddress" : "5c:b1:3e:46:1c:84", + "gateway" : "192.168.0.254" + }, { + "prefixLength" : 24, + "addressType" : "unique-local", + "ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888", + "routerHardwareAddress" : "5c:b1:3e:46:1c:84", + "gateway" : "192.168.0.254" + } ], + "wirelessProfile" : { + "rssi" : -36, + "bssid" : "00:11:22:aa:bb:cc", + "channel" : 48, + "phyMode" : "802.11ac", + "ssid" : "GuestWiFi" + } + }, { + "ethernetProfile" : { + "linkSpeed" : 0 + }, + "hardwareType" : "wireless", + "interfaceName" : "en0", + "addressProfiles" : [ { + "prefixLength" : 24, + "addressType" : "unique-local", + "ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888", + "routerHardwareAddress" : "5c:b1:3e:46:1c:84", + "gateway" : "192.168.0.254" + }, { + "prefixLength" : 24, + "addressType" : "unique-local", + "ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888", + "routerHardwareAddress" : "5c:b1:3e:46:1c:84", + "gateway" : "192.168.0.254" + } ], + "wirelessProfile" : { + "rssi" : -36, + "bssid" : "00:11:22:aa:bb:cc", + "channel" : 48, + "phyMode" : "802.11ac", + "ssid" : "GuestWiFi" + } + } ] + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_endpoint_agents": OperationExpectation( + operation_id="get_endpoint_agents", + method="GET", + path="/endpoint/agents", + path_param_examples={ + }, + success_status=200, + success_body=json.loads(""" + + { + "_links" : { + "next" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "totalAgents" : 1, + "agents" : [ { + "npcapVersion" : "npcapVersion", + "asnDetails" : { + "asName" : "Virgin Media Limited", + "asNumber" : 5089 + }, + "clients" : [ { + "browserExtensions" : [ { + "browser" : "edge", + "profile" : "Profile 1", + "active" : true, + "error" : "", + "version" : "0.123.0", + "enabled" : true + }, { + "browser" : "edge", + "profile" : "Profile 1", + "active" : true, + "error" : "", + "version" : "0.123.0", + "enabled" : true + } ], + "userProfile" : { + "userName" : "joeblogs32", + "userPrincipalName" : "joeblogs32@c.com" + } + }, { + "browserExtensions" : [ { + "browser" : "edge", + "profile" : "Profile 1", + "active" : true, + "error" : "", + "version" : "0.123.0", + "enabled" : true + }, { + "browser" : "edge", + "profile" : "Profile 1", + "active" : true, + "error" : "", + "version" : "0.123.0", + "enabled" : true + } ], + "userProfile" : { + "userName" : "joeblogs32", + "userPrincipalName" : "joeblogs32@c.com" + } + } ], + "agentType" : "endpoint", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "batteryMetrics" : { + "batteryHealthNormalizedPercent" : 0.92, + "batteryLevel" : "medium", + "batteryLevelNormalizedPercent" : 0.3 + }, + "publicIP" : "88.45.2.123", + "tcpDriverAvailable" : true, + "platform" : "mac", + "manufacturer" : "Apple, Inc.", + "targetVersion" : "0.123.4", + "cellularProfile" : { + "rssi" : -10, + "advertisedNetworkSubtype" : "LTE/HSPA", + "carrierName" : "T-Mobile", + "rsrq" : -30, + "rsrp" : -30, + "advertisedNetworkGen" : "2g, 3g, 4g, 5g", + "rscp" : -30, + "networkGen" : "2g, 3g, 4g, 5g", + "networkSubtype" : "LTE/HSPA", + "sinr" : 20 + }, + "nicModel" : "Intel(R) Wi-Fi 6 AX200 160MHz", + "createdAt" : "2022-05-26T23:37:16Z", + "numberOfClients" : 3, + "licenseType" : "essentials", + "osVersion" : "Version 10.15.2 (Build 19C57)", + "computerName" : "DESKJET-123", + "freeDiskSpaceNormalized" : 0.41, + "model" : "MacBookAir7,2", + "id" : "861b7557-cd57-4bbb-b648-00bddf88ef49", + "nicDriverVersion" : "22.250.0.9", + "serialNumber" : "xaab2ba4-d40f-4e80-9363-7e4826556055", + "externalMetadata" : [ { + "key" : "anyConnectDeviceId", + "value" : "DF434343D" + }, { + "key" : "anyConnectDeviceId", + "value" : "DF434343D" + } ], + "version" : "0.123.4", + "vpnProfiles" : [ { + "vpnClientNetworkRange" : [ "10.100.0.0/22" ], + "vpnGatewayAddress" : "vpnGatewayAddress", + "vpnType" : "cisco-anyconnect", + "interfaceName" : "interfaceName", + "vpnClientAddresses" : [ "10.100.0.10" ] + }, { + "vpnClientNetworkRange" : [ "10.100.0.0/22" ], + "vpnGatewayAddress" : "vpnGatewayAddress", + "vpnType" : "cisco-anyconnect", + "interfaceName" : "interfaceName", + "vpnClientAddresses" : [ "10.100.0.10" ] + } ], + "lastSeen" : "2022-05-26T23:37:16Z", + "deleted" : true, + "totalMemory" : "16384 MB", + "kernelVersion" : "Darwin 19.2.0", + "name" : "Office Printer", + "location" : { + "locationName" : "London", + "latitude" : 51.51279, + "longitude" : -0.09184 + }, + "aid" : "", + "status" : "enabled", + "networkInterfaceProfiles" : [ { + "ethernetProfile" : { + "linkSpeed" : 0 + }, + "hardwareType" : "wireless", + "interfaceName" : "en0", + "addressProfiles" : [ { + "prefixLength" : 24, + "addressType" : "unique-local", + "ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888", + "routerHardwareAddress" : "5c:b1:3e:46:1c:84", + "gateway" : "192.168.0.254" + }, { + "prefixLength" : 24, + "addressType" : "unique-local", + "ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888", + "routerHardwareAddress" : "5c:b1:3e:46:1c:84", + "gateway" : "192.168.0.254" + } ], + "wirelessProfile" : { + "rssi" : -36, + "bssid" : "00:11:22:aa:bb:cc", + "channel" : 48, + "phyMode" : "802.11ac", + "ssid" : "GuestWiFi" + } + }, { + "ethernetProfile" : { + "linkSpeed" : 0 + }, + "hardwareType" : "wireless", + "interfaceName" : "en0", + "addressProfiles" : [ { + "prefixLength" : 24, + "addressType" : "unique-local", + "ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888", + "routerHardwareAddress" : "5c:b1:3e:46:1c:84", + "gateway" : "192.168.0.254" + }, { + "prefixLength" : 24, + "addressType" : "unique-local", + "ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888", + "routerHardwareAddress" : "5c:b1:3e:46:1c:84", + "gateway" : "192.168.0.254" + } ], + "wirelessProfile" : { + "rssi" : -36, + "bssid" : "00:11:22:aa:bb:cc", + "channel" : 48, + "phyMode" : "802.11ac", + "ssid" : "GuestWiFi" + } + } ] + }, { + "npcapVersion" : "npcapVersion", + "asnDetails" : { + "asName" : "Virgin Media Limited", + "asNumber" : 5089 + }, + "clients" : [ { + "browserExtensions" : [ { + "browser" : "edge", + "profile" : "Profile 1", + "active" : true, + "error" : "", + "version" : "0.123.0", + "enabled" : true + }, { + "browser" : "edge", + "profile" : "Profile 1", + "active" : true, + "error" : "", + "version" : "0.123.0", + "enabled" : true + } ], + "userProfile" : { + "userName" : "joeblogs32", + "userPrincipalName" : "joeblogs32@c.com" + } + }, { + "browserExtensions" : [ { + "browser" : "edge", + "profile" : "Profile 1", + "active" : true, + "error" : "", + "version" : "0.123.0", + "enabled" : true + }, { + "browser" : "edge", + "profile" : "Profile 1", + "active" : true, + "error" : "", + "version" : "0.123.0", + "enabled" : true + } ], + "userProfile" : { + "userName" : "joeblogs32", + "userPrincipalName" : "joeblogs32@c.com" + } + } ], + "agentType" : "endpoint", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "batteryMetrics" : { + "batteryHealthNormalizedPercent" : 0.92, + "batteryLevel" : "medium", + "batteryLevelNormalizedPercent" : 0.3 + }, + "publicIP" : "88.45.2.123", + "tcpDriverAvailable" : true, + "platform" : "mac", + "manufacturer" : "Apple, Inc.", + "targetVersion" : "0.123.4", + "cellularProfile" : { + "rssi" : -10, + "advertisedNetworkSubtype" : "LTE/HSPA", + "carrierName" : "T-Mobile", + "rsrq" : -30, + "rsrp" : -30, + "advertisedNetworkGen" : "2g, 3g, 4g, 5g", + "rscp" : -30, + "networkGen" : "2g, 3g, 4g, 5g", + "networkSubtype" : "LTE/HSPA", + "sinr" : 20 + }, + "nicModel" : "Intel(R) Wi-Fi 6 AX200 160MHz", + "createdAt" : "2022-05-26T23:37:16Z", + "numberOfClients" : 3, + "licenseType" : "essentials", + "osVersion" : "Version 10.15.2 (Build 19C57)", + "computerName" : "DESKJET-123", + "freeDiskSpaceNormalized" : 0.41, + "model" : "MacBookAir7,2", + "id" : "861b7557-cd57-4bbb-b648-00bddf88ef49", + "nicDriverVersion" : "22.250.0.9", + "serialNumber" : "xaab2ba4-d40f-4e80-9363-7e4826556055", + "externalMetadata" : [ { + "key" : "anyConnectDeviceId", + "value" : "DF434343D" + }, { + "key" : "anyConnectDeviceId", + "value" : "DF434343D" + } ], + "version" : "0.123.4", + "vpnProfiles" : [ { + "vpnClientNetworkRange" : [ "10.100.0.0/22" ], + "vpnGatewayAddress" : "vpnGatewayAddress", + "vpnType" : "cisco-anyconnect", + "interfaceName" : "interfaceName", + "vpnClientAddresses" : [ "10.100.0.10" ] + }, { + "vpnClientNetworkRange" : [ "10.100.0.0/22" ], + "vpnGatewayAddress" : "vpnGatewayAddress", + "vpnType" : "cisco-anyconnect", + "interfaceName" : "interfaceName", + "vpnClientAddresses" : [ "10.100.0.10" ] + } ], + "lastSeen" : "2022-05-26T23:37:16Z", + "deleted" : true, + "totalMemory" : "16384 MB", + "kernelVersion" : "Darwin 19.2.0", + "name" : "Office Printer", + "location" : { + "locationName" : "London", + "latitude" : 51.51279, + "longitude" : -0.09184 + }, + "aid" : "", + "status" : "enabled", + "networkInterfaceProfiles" : [ { + "ethernetProfile" : { + "linkSpeed" : 0 + }, + "hardwareType" : "wireless", + "interfaceName" : "en0", + "addressProfiles" : [ { + "prefixLength" : 24, + "addressType" : "unique-local", + "ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888", + "routerHardwareAddress" : "5c:b1:3e:46:1c:84", + "gateway" : "192.168.0.254" + }, { + "prefixLength" : 24, + "addressType" : "unique-local", + "ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888", + "routerHardwareAddress" : "5c:b1:3e:46:1c:84", + "gateway" : "192.168.0.254" + } ], + "wirelessProfile" : { + "rssi" : -36, + "bssid" : "00:11:22:aa:bb:cc", + "channel" : 48, + "phyMode" : "802.11ac", + "ssid" : "GuestWiFi" + } + }, { + "ethernetProfile" : { + "linkSpeed" : 0 + }, + "hardwareType" : "wireless", + "interfaceName" : "en0", + "addressProfiles" : [ { + "prefixLength" : 24, + "addressType" : "unique-local", + "ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888", + "routerHardwareAddress" : "5c:b1:3e:46:1c:84", + "gateway" : "192.168.0.254" + }, { + "prefixLength" : 24, + "addressType" : "unique-local", + "ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888", + "routerHardwareAddress" : "5c:b1:3e:46:1c:84", + "gateway" : "192.168.0.254" + } ], + "wirelessProfile" : { + "rssi" : -36, + "bssid" : "00:11:22:aa:bb:cc", + "channel" : 48, + "phyMode" : "802.11ac", + "ssid" : "GuestWiFi" + } + } ] + } ] + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_endpoint_agents_connection_string": OperationExpectation( + operation_id="get_endpoint_agents_connection_string", + method="GET", + path="/endpoint/agents/connection-string", + path_param_examples={ + }, + success_status=200, + success_body=json.loads(""" + + { + "connectionString" : "D2xZSLlqo64Xe2EnYisklA==", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "update_endpoint_agent": OperationExpectation( + operation_id="update_endpoint_agent", + method="PATCH", + path="/endpoint/agents/{agentId}", + path_param_examples={ + "agentId": 'agent_id_example', + }, + success_status=200, + success_body=json.loads(""" + + { + "npcapVersion" : "npcapVersion", + "asnDetails" : { + "asName" : "Virgin Media Limited", + "asNumber" : 5089 + }, + "clients" : [ { + "browserExtensions" : [ { + "browser" : "edge", + "profile" : "Profile 1", + "active" : true, + "error" : "", + "version" : "0.123.0", + "enabled" : true + }, { + "browser" : "edge", + "profile" : "Profile 1", + "active" : true, + "error" : "", + "version" : "0.123.0", + "enabled" : true + } ], + "userProfile" : { + "userName" : "joeblogs32", + "userPrincipalName" : "joeblogs32@c.com" + } + }, { + "browserExtensions" : [ { + "browser" : "edge", + "profile" : "Profile 1", + "active" : true, + "error" : "", + "version" : "0.123.0", + "enabled" : true + }, { + "browser" : "edge", + "profile" : "Profile 1", + "active" : true, + "error" : "", + "version" : "0.123.0", + "enabled" : true + } ], + "userProfile" : { + "userName" : "joeblogs32", + "userPrincipalName" : "joeblogs32@c.com" + } + } ], + "agentType" : "endpoint", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "batteryMetrics" : { + "batteryHealthNormalizedPercent" : 0.92, + "batteryLevel" : "medium", + "batteryLevelNormalizedPercent" : 0.3 + }, + "publicIP" : "88.45.2.123", + "tcpDriverAvailable" : true, + "platform" : "mac", + "manufacturer" : "Apple, Inc.", + "targetVersion" : "0.123.4", + "cellularProfile" : { + "rssi" : -10, + "advertisedNetworkSubtype" : "LTE/HSPA", + "carrierName" : "T-Mobile", + "rsrq" : -30, + "rsrp" : -30, + "advertisedNetworkGen" : "2g, 3g, 4g, 5g", + "rscp" : -30, + "networkGen" : "2g, 3g, 4g, 5g", + "networkSubtype" : "LTE/HSPA", + "sinr" : 20 + }, + "nicModel" : "Intel(R) Wi-Fi 6 AX200 160MHz", + "createdAt" : "2022-05-26T23:37:16Z", + "numberOfClients" : 3, + "licenseType" : "essentials", + "osVersion" : "Version 10.15.2 (Build 19C57)", + "computerName" : "DESKJET-123", + "freeDiskSpaceNormalized" : 0.41, + "model" : "MacBookAir7,2", + "id" : "861b7557-cd57-4bbb-b648-00bddf88ef49", + "nicDriverVersion" : "22.250.0.9", + "serialNumber" : "xaab2ba4-d40f-4e80-9363-7e4826556055", + "externalMetadata" : [ { + "key" : "anyConnectDeviceId", + "value" : "DF434343D" + }, { + "key" : "anyConnectDeviceId", + "value" : "DF434343D" + } ], + "version" : "0.123.4", + "vpnProfiles" : [ { + "vpnClientNetworkRange" : [ "10.100.0.0/22" ], + "vpnGatewayAddress" : "vpnGatewayAddress", + "vpnType" : "cisco-anyconnect", + "interfaceName" : "interfaceName", + "vpnClientAddresses" : [ "10.100.0.10" ] + }, { + "vpnClientNetworkRange" : [ "10.100.0.0/22" ], + "vpnGatewayAddress" : "vpnGatewayAddress", + "vpnType" : "cisco-anyconnect", + "interfaceName" : "interfaceName", + "vpnClientAddresses" : [ "10.100.0.10" ] + } ], + "lastSeen" : "2022-05-26T23:37:16Z", + "deleted" : true, + "totalMemory" : "16384 MB", + "kernelVersion" : "Darwin 19.2.0", + "name" : "Office Printer", + "location" : { + "locationName" : "London", + "latitude" : 51.51279, + "longitude" : -0.09184 + }, + "aid" : "", + "status" : "enabled", + "networkInterfaceProfiles" : [ { + "ethernetProfile" : { + "linkSpeed" : 0 + }, + "hardwareType" : "wireless", + "interfaceName" : "en0", + "addressProfiles" : [ { + "prefixLength" : 24, + "addressType" : "unique-local", + "ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888", + "routerHardwareAddress" : "5c:b1:3e:46:1c:84", + "gateway" : "192.168.0.254" + }, { + "prefixLength" : 24, + "addressType" : "unique-local", + "ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888", + "routerHardwareAddress" : "5c:b1:3e:46:1c:84", + "gateway" : "192.168.0.254" + } ], + "wirelessProfile" : { + "rssi" : -36, + "bssid" : "00:11:22:aa:bb:cc", + "channel" : 48, + "phyMode" : "802.11ac", + "ssid" : "GuestWiFi" + } + }, { + "ethernetProfile" : { + "linkSpeed" : 0 + }, + "hardwareType" : "wireless", + "interfaceName" : "en0", + "addressProfiles" : [ { + "prefixLength" : 24, + "addressType" : "unique-local", + "ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888", + "routerHardwareAddress" : "5c:b1:3e:46:1c:84", + "gateway" : "192.168.0.254" + }, { + "prefixLength" : 24, + "addressType" : "unique-local", + "ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888", + "routerHardwareAddress" : "5c:b1:3e:46:1c:84", + "gateway" : "192.168.0.254" + } ], + "wirelessProfile" : { + "rssi" : -36, + "bssid" : "00:11:22:aa:bb:cc", + "channel" : 48, + "phyMode" : "802.11ac", + "ssid" : "GuestWiFi" + } + } ] + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "licenseType" : "essentials", + "name" : "Office Printer" + } + + """), + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "transfer_endpoint_agents": OperationExpectation( + operation_id="transfer_endpoint_agents", + method="POST", + path="/endpoint/agents/transfer/bulk", + path_param_examples={ + }, + success_status=207, + success_body=json.loads(""" + + { + "items" : [ { + "status" : 200, + "detail" : "Initiated", + "request" : { + "agentId" : "5d0764ac-7e42-4ec8-a0d4-39fc53edccba", + "fromAid" : "1234", + "toAid" : "12345" + } + }, { + "status" : 400, + "detail" : "Missing from-account id", + "request" : { + "agentId" : "5d0764ac-7e42-4ec8-a0d5-39fc53ed1234", + "fromAid" : "xxx", + "toAid" : "12345" + } + }, { + "status" : 403, + "detail" : "User does not have permission on 'to' aid", + "request" : { + "agentId" : "5d0764ac-7e42-4ec8-a0d5-39fc53ed7890", + "fromAid" : "1234", + "toAid" : "12345" + } + } ] + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "transfers" : [ { + "agentId" : "5d0764ac-7e42-4ec8-a0d4-39fc53edccba", + "fromAid" : "1234", + "toAid" : "12345" + }, { + "agentId" : "5d0764ac-7e42-4ec8-a0d4-39fc53edccba", + "fromAid" : "1234", + "toAid" : "12345" + } ] + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_endpoint_proxies": OperationExpectation( + operation_id="get_endpoint_proxies", + method="GET", + path="/endpoint/proxies", + path_param_examples={ + }, + success_status=200, + success_body=json.loads(""" + + { + "proxies" : [ { + "testIds" : [ "9923667", "9923667" ], + "agentIds" : [ "861b7557-cd57-4bbb-b648-00bddf88ef49", "861b7557-cd57-4bbb-b648-00bddf88ef49" ], + "pac" : "https://example.com/proxy.pac", + "port" : 8080, + "name" : "Local Mitmproxy", + "host" : "localhost", + "type" : "static", + "userName" : "endpoint-proxy-user", + "authType" : "none", + "bypassList" : "localhost,127.0.0.1", + "proxyId" : "101498" + }, { + "testIds" : [ "9923667", "9923667" ], + "agentIds" : [ "861b7557-cd57-4bbb-b648-00bddf88ef49", "861b7557-cd57-4bbb-b648-00bddf88ef49" ], + "pac" : "https://example.com/proxy.pac", + "port" : 8080, + "name" : "Local Mitmproxy", + "host" : "localhost", + "type" : "static", + "userName" : "endpoint-proxy-user", + "authType" : "none", + "bypassList" : "localhost,127.0.0.1", + "proxyId" : "101498" + } ] + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + +} diff --git a/thousandeyes-sdk-endpoint-agents/test/test_endpoint_agent_log_items_api_integration.py b/thousandeyes-sdk-endpoint-agents/test/test_endpoint_agent_log_items_api_integration.py new file mode 100644 index 00000000..d48de450 --- /dev/null +++ b/thousandeyes-sdk-endpoint-agents/test/test_endpoint_agent_log_items_api_integration.py @@ -0,0 +1,421 @@ +# coding: utf-8 + +""" + Endpoint Agents API + + **Note:** The Endpoint Agents Transfer APIs are not available for ThousandEyes for Government instance. Manage ThousandEyes Endpoint Agents using this API. For more information about Endpoint Agents, see [Endpoint Agents](https://docs.thousandeyes.com/product-documentation/global-vantage-points/endpoint-agents). + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.endpoint_agents.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.endpoint_agents.api.endpoint_agent_log_items_api import EndpointAgentLogItemsApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestEndpointAgentLogItemsApiIntegration(IntegrationTestBase): + """EndpointAgentLogItemsApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = EndpointAgentLogItemsApi(self.api_client) + + + def test_get_endpoint_agent_log_items_happy_path(self) -> None: + """Integration test for get_endpoint_agent_log_items success path""" + agent_id = 'agent_id_example' + aid = '1234' + max = 1000 + cursor = 'WyIxNzA5MjQwMDAwMDAwIl0=' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + response_body_json = """ + { + "_links" : { + "next" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "logs" : [ { + "wifiLogItem" : { + "bssidFrom" : "00:11:22:33:44:54", + "bssid" : "00:11:22:33:44:55", + "failure" : { + "code" : 4, + "context" : "WPA authentication failed", + "type" : "auth" + }, + "logItemType" : "wifi-connect", + "channel" : "36", + "physicalMode" : "802.11ac", + "physicalModeFrom" : "802.11n", + "ssid" : "CorpWiFi", + "channelFrom" : "11" + }, + "agentLogItemType" : "wifi", + "onlineOfflineLogItem" : { + "logItemType" : "online" + }, + "id" : "8d23f1b7-74ef-4e0c-925c-58601fc0662d", + "vpnLogItem" : { + "logItemType" : "vpn-connect", + "vpnServerName" : "vpn-us-west", + "vpnType" : "cisco-anyconnect", + "vpnServerAddress" : "192.0.2.10" + }, + "stateChangesLogItem" : { + "logItemType" : "enabled" + }, + "timestampMs" : 1709240000000 + }, { + "wifiLogItem" : { + "bssidFrom" : "00:11:22:33:44:54", + "bssid" : "00:11:22:33:44:55", + "failure" : { + "code" : 4, + "context" : "WPA authentication failed", + "type" : "auth" + }, + "logItemType" : "wifi-connect", + "channel" : "36", + "physicalMode" : "802.11ac", + "physicalModeFrom" : "802.11n", + "ssid" : "CorpWiFi", + "channelFrom" : "11" + }, + "agentLogItemType" : "wifi", + "onlineOfflineLogItem" : { + "logItemType" : "online" + }, + "id" : "8d23f1b7-74ef-4e0c-925c-58601fc0662d", + "vpnLogItem" : { + "logItemType" : "vpn-connect", + "vpnServerName" : "vpn-us-west", + "vpnType" : "cisco-anyconnect", + "vpnServerAddress" : "192.0.2.10" + }, + "stateChangesLogItem" : { + "logItemType" : "enabled" + }, + "timestampMs" : 1709240000000 + } ] + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_endpoint_agent_log_items( + + agent_id=agent_id, + + aid=aid, + + max=max, + + cursor=cursor, + + window=window, + + start_date=start_date, + + end_date=end_date, + + _headers=self.te_headers("get_endpoint_agent_log_items"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_endpoint_agent_log_items_error_400(self) -> None: + """Integration test for get_endpoint_agent_log_items error path (HTTP 400)""" + agent_id = 'agent_id_example' + aid = '1234' + max = 1000 + cursor = 'WyIxNzA5MjQwMDAwMDAwIl0=' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.get_endpoint_agent_log_items( + + agent_id=agent_id, + + aid=aid, + + max=max, + + cursor=cursor, + + window=window, + + start_date=start_date, + + end_date=end_date, + + _headers=self.te_headers("get_endpoint_agent_log_items", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_endpoint_agent_log_items_error_401(self) -> None: + """Integration test for get_endpoint_agent_log_items error path (HTTP 401)""" + agent_id = 'agent_id_example' + aid = '1234' + max = 1000 + cursor = 'WyIxNzA5MjQwMDAwMDAwIl0=' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_endpoint_agent_log_items( + + agent_id=agent_id, + + aid=aid, + + max=max, + + cursor=cursor, + + window=window, + + start_date=start_date, + + end_date=end_date, + + _headers=self.te_headers("get_endpoint_agent_log_items", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_endpoint_agent_log_items_error_403(self) -> None: + """Integration test for get_endpoint_agent_log_items error path (HTTP 403)""" + agent_id = 'agent_id_example' + aid = '1234' + max = 1000 + cursor = 'WyIxNzA5MjQwMDAwMDAwIl0=' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_endpoint_agent_log_items( + + agent_id=agent_id, + + aid=aid, + + max=max, + + cursor=cursor, + + window=window, + + start_date=start_date, + + end_date=end_date, + + _headers=self.te_headers("get_endpoint_agent_log_items", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_endpoint_agent_log_items_error_429(self) -> None: + """Integration test for get_endpoint_agent_log_items error path (HTTP 429)""" + agent_id = 'agent_id_example' + aid = '1234' + max = 1000 + cursor = 'WyIxNzA5MjQwMDAwMDAwIl0=' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_endpoint_agent_log_items( + + agent_id=agent_id, + + aid=aid, + + max=max, + + cursor=cursor, + + window=window, + + start_date=start_date, + + end_date=end_date, + + _headers=self.te_headers("get_endpoint_agent_log_items", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_endpoint_agent_log_items_error_500(self) -> None: + """Integration test for get_endpoint_agent_log_items error path (HTTP 500)""" + agent_id = 'agent_id_example' + aid = '1234' + max = 1000 + cursor = 'WyIxNzA5MjQwMDAwMDAwIl0=' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_endpoint_agent_log_items( + + agent_id=agent_id, + + aid=aid, + + max=max, + + cursor=cursor, + + window=window, + + start_date=start_date, + + end_date=end_date, + + _headers=self.te_headers("get_endpoint_agent_log_items", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_endpoint_agent_log_items_error_502(self) -> None: + """Integration test for get_endpoint_agent_log_items error path (HTTP 502)""" + agent_id = 'agent_id_example' + aid = '1234' + max = 1000 + cursor = 'WyIxNzA5MjQwMDAwMDAwIl0=' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.get_endpoint_agent_log_items( + + agent_id=agent_id, + + aid=aid, + + max=max, + + cursor=cursor, + + window=window, + + start_date=start_date, + + end_date=end_date, + + _headers=self.te_headers("get_endpoint_agent_log_items", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-endpoint-agents/test/test_endpoint_agents_api_integration.py b/thousandeyes-sdk-endpoint-agents/test/test_endpoint_agents_api_integration.py new file mode 100644 index 00000000..9fa0ce7c --- /dev/null +++ b/thousandeyes-sdk-endpoint-agents/test/test_endpoint_agents_api_integration.py @@ -0,0 +1,2874 @@ +# coding: utf-8 + +""" + Endpoint Agents API + + **Note:** The Endpoint Agents Transfer APIs are not available for ThousandEyes for Government instance. Manage ThousandEyes Endpoint Agents using this API. For more information about Endpoint Agents, see [Endpoint Agents](https://docs.thousandeyes.com/product-documentation/global-vantage-points/endpoint-agents). + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.endpoint_agents.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.endpoint_agents.api.endpoint_agents_api import EndpointAgentsApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestEndpointAgentsApiIntegration(IntegrationTestBase): + """EndpointAgentsApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = EndpointAgentsApi(self.api_client) + + + def test_delete_endpoint_agent_happy_path(self) -> None: + """Integration test for delete_endpoint_agent success path""" + agent_id = 'agent_id_example' + aid = '1234' + response = self.api.delete_endpoint_agent_with_http_info( + + agent_id=agent_id, + + aid=aid, + + _headers=self.te_headers("delete_endpoint_agent"), + ) + self.assertEqual(204, response.status_code) + self.assertIsNone(response.data) + + + def test_delete_endpoint_agent_error_401(self) -> None: + """Integration test for delete_endpoint_agent error path (HTTP 401)""" + agent_id = 'agent_id_example' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.delete_endpoint_agent( + + agent_id=agent_id, + + aid=aid, + + _headers=self.te_headers("delete_endpoint_agent", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_endpoint_agent_error_403(self) -> None: + """Integration test for delete_endpoint_agent error path (HTTP 403)""" + agent_id = 'agent_id_example' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.delete_endpoint_agent( + + agent_id=agent_id, + + aid=aid, + + _headers=self.te_headers("delete_endpoint_agent", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_endpoint_agent_error_404(self) -> None: + """Integration test for delete_endpoint_agent error path (HTTP 404)""" + agent_id = 'agent_id_example' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.delete_endpoint_agent( + + agent_id=agent_id, + + aid=aid, + + _headers=self.te_headers("delete_endpoint_agent", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_endpoint_agent_error_429(self) -> None: + """Integration test for delete_endpoint_agent error path (HTTP 429)""" + agent_id = 'agent_id_example' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.delete_endpoint_agent( + + agent_id=agent_id, + + aid=aid, + + _headers=self.te_headers("delete_endpoint_agent", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_disable_endpoint_agent_happy_path(self) -> None: + """Integration test for disable_endpoint_agent success path""" + agent_id = 'agent_id_example' + aid = '1234' + response_body_json = """ + { + "npcapVersion" : "npcapVersion", + "asnDetails" : { + "asName" : "Virgin Media Limited", + "asNumber" : 5089 + }, + "clients" : [ { + "browserExtensions" : [ { + "browser" : "edge", + "profile" : "Profile 1", + "active" : true, + "error" : "", + "version" : "0.123.0", + "enabled" : true + }, { + "browser" : "edge", + "profile" : "Profile 1", + "active" : true, + "error" : "", + "version" : "0.123.0", + "enabled" : true + } ], + "userProfile" : { + "userName" : "joeblogs32", + "userPrincipalName" : "joeblogs32@c.com" + } + }, { + "browserExtensions" : [ { + "browser" : "edge", + "profile" : "Profile 1", + "active" : true, + "error" : "", + "version" : "0.123.0", + "enabled" : true + }, { + "browser" : "edge", + "profile" : "Profile 1", + "active" : true, + "error" : "", + "version" : "0.123.0", + "enabled" : true + } ], + "userProfile" : { + "userName" : "joeblogs32", + "userPrincipalName" : "joeblogs32@c.com" + } + } ], + "agentType" : "endpoint", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "batteryMetrics" : { + "batteryHealthNormalizedPercent" : 0.92, + "batteryLevel" : "medium", + "batteryLevelNormalizedPercent" : 0.3 + }, + "publicIP" : "88.45.2.123", + "tcpDriverAvailable" : true, + "platform" : "mac", + "manufacturer" : "Apple, Inc.", + "targetVersion" : "0.123.4", + "cellularProfile" : { + "rssi" : -10, + "advertisedNetworkSubtype" : "LTE/HSPA", + "carrierName" : "T-Mobile", + "rsrq" : -30, + "rsrp" : -30, + "advertisedNetworkGen" : "2g, 3g, 4g, 5g", + "rscp" : -30, + "networkGen" : "2g, 3g, 4g, 5g", + "networkSubtype" : "LTE/HSPA", + "sinr" : 20 + }, + "nicModel" : "Intel(R) Wi-Fi 6 AX200 160MHz", + "createdAt" : "2022-05-26T23:37:16Z", + "numberOfClients" : 3, + "licenseType" : "essentials", + "osVersion" : "Version 10.15.2 (Build 19C57)", + "computerName" : "DESKJET-123", + "freeDiskSpaceNormalized" : 0.41, + "model" : "MacBookAir7,2", + "id" : "861b7557-cd57-4bbb-b648-00bddf88ef49", + "nicDriverVersion" : "22.250.0.9", + "serialNumber" : "xaab2ba4-d40f-4e80-9363-7e4826556055", + "externalMetadata" : [ { + "key" : "anyConnectDeviceId", + "value" : "DF434343D" + }, { + "key" : "anyConnectDeviceId", + "value" : "DF434343D" + } ], + "version" : "0.123.4", + "vpnProfiles" : [ { + "vpnClientNetworkRange" : [ "10.100.0.0/22" ], + "vpnGatewayAddress" : "vpnGatewayAddress", + "vpnType" : "cisco-anyconnect", + "interfaceName" : "interfaceName", + "vpnClientAddresses" : [ "10.100.0.10" ] + }, { + "vpnClientNetworkRange" : [ "10.100.0.0/22" ], + "vpnGatewayAddress" : "vpnGatewayAddress", + "vpnType" : "cisco-anyconnect", + "interfaceName" : "interfaceName", + "vpnClientAddresses" : [ "10.100.0.10" ] + } ], + "lastSeen" : "2022-05-26T23:37:16Z", + "deleted" : true, + "totalMemory" : "16384 MB", + "kernelVersion" : "Darwin 19.2.0", + "name" : "Office Printer", + "location" : { + "locationName" : "London", + "latitude" : 51.51279, + "longitude" : -0.09184 + }, + "aid" : "", + "status" : "enabled", + "networkInterfaceProfiles" : [ { + "ethernetProfile" : { + "linkSpeed" : 0 + }, + "hardwareType" : "wireless", + "interfaceName" : "en0", + "addressProfiles" : [ { + "prefixLength" : 24, + "addressType" : "unique-local", + "ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888", + "routerHardwareAddress" : "5c:b1:3e:46:1c:84", + "gateway" : "192.168.0.254" + }, { + "prefixLength" : 24, + "addressType" : "unique-local", + "ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888", + "routerHardwareAddress" : "5c:b1:3e:46:1c:84", + "gateway" : "192.168.0.254" + } ], + "wirelessProfile" : { + "rssi" : -36, + "bssid" : "00:11:22:aa:bb:cc", + "channel" : 48, + "phyMode" : "802.11ac", + "ssid" : "GuestWiFi" + } + }, { + "ethernetProfile" : { + "linkSpeed" : 0 + }, + "hardwareType" : "wireless", + "interfaceName" : "en0", + "addressProfiles" : [ { + "prefixLength" : 24, + "addressType" : "unique-local", + "ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888", + "routerHardwareAddress" : "5c:b1:3e:46:1c:84", + "gateway" : "192.168.0.254" + }, { + "prefixLength" : 24, + "addressType" : "unique-local", + "ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888", + "routerHardwareAddress" : "5c:b1:3e:46:1c:84", + "gateway" : "192.168.0.254" + } ], + "wirelessProfile" : { + "rssi" : -36, + "bssid" : "00:11:22:aa:bb:cc", + "channel" : 48, + "phyMode" : "802.11ac", + "ssid" : "GuestWiFi" + } + } ] + } + """ + expected_response = json.loads(response_body_json) + response = self.api.disable_endpoint_agent( + + agent_id=agent_id, + + aid=aid, + + _headers=self.te_headers("disable_endpoint_agent"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_disable_endpoint_agent_error_401(self) -> None: + """Integration test for disable_endpoint_agent error path (HTTP 401)""" + agent_id = 'agent_id_example' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.disable_endpoint_agent( + + agent_id=agent_id, + + aid=aid, + + _headers=self.te_headers("disable_endpoint_agent", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_disable_endpoint_agent_error_403(self) -> None: + """Integration test for disable_endpoint_agent error path (HTTP 403)""" + agent_id = 'agent_id_example' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.disable_endpoint_agent( + + agent_id=agent_id, + + aid=aid, + + _headers=self.te_headers("disable_endpoint_agent", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_disable_endpoint_agent_error_404(self) -> None: + """Integration test for disable_endpoint_agent error path (HTTP 404)""" + agent_id = 'agent_id_example' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.disable_endpoint_agent( + + agent_id=agent_id, + + aid=aid, + + _headers=self.te_headers("disable_endpoint_agent", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_disable_endpoint_agent_error_429(self) -> None: + """Integration test for disable_endpoint_agent error path (HTTP 429)""" + agent_id = 'agent_id_example' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.disable_endpoint_agent( + + agent_id=agent_id, + + aid=aid, + + _headers=self.te_headers("disable_endpoint_agent", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_enable_endpoint_agent_happy_path(self) -> None: + """Integration test for enable_endpoint_agent success path""" + agent_id = 'agent_id_example' + aid = '1234' + response_body_json = """ + { + "npcapVersion" : "npcapVersion", + "asnDetails" : { + "asName" : "Virgin Media Limited", + "asNumber" : 5089 + }, + "clients" : [ { + "browserExtensions" : [ { + "browser" : "edge", + "profile" : "Profile 1", + "active" : true, + "error" : "", + "version" : "0.123.0", + "enabled" : true + }, { + "browser" : "edge", + "profile" : "Profile 1", + "active" : true, + "error" : "", + "version" : "0.123.0", + "enabled" : true + } ], + "userProfile" : { + "userName" : "joeblogs32", + "userPrincipalName" : "joeblogs32@c.com" + } + }, { + "browserExtensions" : [ { + "browser" : "edge", + "profile" : "Profile 1", + "active" : true, + "error" : "", + "version" : "0.123.0", + "enabled" : true + }, { + "browser" : "edge", + "profile" : "Profile 1", + "active" : true, + "error" : "", + "version" : "0.123.0", + "enabled" : true + } ], + "userProfile" : { + "userName" : "joeblogs32", + "userPrincipalName" : "joeblogs32@c.com" + } + } ], + "agentType" : "endpoint", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "batteryMetrics" : { + "batteryHealthNormalizedPercent" : 0.92, + "batteryLevel" : "medium", + "batteryLevelNormalizedPercent" : 0.3 + }, + "publicIP" : "88.45.2.123", + "tcpDriverAvailable" : true, + "platform" : "mac", + "manufacturer" : "Apple, Inc.", + "targetVersion" : "0.123.4", + "cellularProfile" : { + "rssi" : -10, + "advertisedNetworkSubtype" : "LTE/HSPA", + "carrierName" : "T-Mobile", + "rsrq" : -30, + "rsrp" : -30, + "advertisedNetworkGen" : "2g, 3g, 4g, 5g", + "rscp" : -30, + "networkGen" : "2g, 3g, 4g, 5g", + "networkSubtype" : "LTE/HSPA", + "sinr" : 20 + }, + "nicModel" : "Intel(R) Wi-Fi 6 AX200 160MHz", + "createdAt" : "2022-05-26T23:37:16Z", + "numberOfClients" : 3, + "licenseType" : "essentials", + "osVersion" : "Version 10.15.2 (Build 19C57)", + "computerName" : "DESKJET-123", + "freeDiskSpaceNormalized" : 0.41, + "model" : "MacBookAir7,2", + "id" : "861b7557-cd57-4bbb-b648-00bddf88ef49", + "nicDriverVersion" : "22.250.0.9", + "serialNumber" : "xaab2ba4-d40f-4e80-9363-7e4826556055", + "externalMetadata" : [ { + "key" : "anyConnectDeviceId", + "value" : "DF434343D" + }, { + "key" : "anyConnectDeviceId", + "value" : "DF434343D" + } ], + "version" : "0.123.4", + "vpnProfiles" : [ { + "vpnClientNetworkRange" : [ "10.100.0.0/22" ], + "vpnGatewayAddress" : "vpnGatewayAddress", + "vpnType" : "cisco-anyconnect", + "interfaceName" : "interfaceName", + "vpnClientAddresses" : [ "10.100.0.10" ] + }, { + "vpnClientNetworkRange" : [ "10.100.0.0/22" ], + "vpnGatewayAddress" : "vpnGatewayAddress", + "vpnType" : "cisco-anyconnect", + "interfaceName" : "interfaceName", + "vpnClientAddresses" : [ "10.100.0.10" ] + } ], + "lastSeen" : "2022-05-26T23:37:16Z", + "deleted" : true, + "totalMemory" : "16384 MB", + "kernelVersion" : "Darwin 19.2.0", + "name" : "Office Printer", + "location" : { + "locationName" : "London", + "latitude" : 51.51279, + "longitude" : -0.09184 + }, + "aid" : "", + "status" : "enabled", + "networkInterfaceProfiles" : [ { + "ethernetProfile" : { + "linkSpeed" : 0 + }, + "hardwareType" : "wireless", + "interfaceName" : "en0", + "addressProfiles" : [ { + "prefixLength" : 24, + "addressType" : "unique-local", + "ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888", + "routerHardwareAddress" : "5c:b1:3e:46:1c:84", + "gateway" : "192.168.0.254" + }, { + "prefixLength" : 24, + "addressType" : "unique-local", + "ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888", + "routerHardwareAddress" : "5c:b1:3e:46:1c:84", + "gateway" : "192.168.0.254" + } ], + "wirelessProfile" : { + "rssi" : -36, + "bssid" : "00:11:22:aa:bb:cc", + "channel" : 48, + "phyMode" : "802.11ac", + "ssid" : "GuestWiFi" + } + }, { + "ethernetProfile" : { + "linkSpeed" : 0 + }, + "hardwareType" : "wireless", + "interfaceName" : "en0", + "addressProfiles" : [ { + "prefixLength" : 24, + "addressType" : "unique-local", + "ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888", + "routerHardwareAddress" : "5c:b1:3e:46:1c:84", + "gateway" : "192.168.0.254" + }, { + "prefixLength" : 24, + "addressType" : "unique-local", + "ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888", + "routerHardwareAddress" : "5c:b1:3e:46:1c:84", + "gateway" : "192.168.0.254" + } ], + "wirelessProfile" : { + "rssi" : -36, + "bssid" : "00:11:22:aa:bb:cc", + "channel" : 48, + "phyMode" : "802.11ac", + "ssid" : "GuestWiFi" + } + } ] + } + """ + expected_response = json.loads(response_body_json) + response = self.api.enable_endpoint_agent( + + agent_id=agent_id, + + aid=aid, + + _headers=self.te_headers("enable_endpoint_agent"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_enable_endpoint_agent_error_401(self) -> None: + """Integration test for enable_endpoint_agent error path (HTTP 401)""" + agent_id = 'agent_id_example' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.enable_endpoint_agent( + + agent_id=agent_id, + + aid=aid, + + _headers=self.te_headers("enable_endpoint_agent", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_enable_endpoint_agent_error_403(self) -> None: + """Integration test for enable_endpoint_agent error path (HTTP 403)""" + agent_id = 'agent_id_example' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.enable_endpoint_agent( + + agent_id=agent_id, + + aid=aid, + + _headers=self.te_headers("enable_endpoint_agent", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_enable_endpoint_agent_error_404(self) -> None: + """Integration test for enable_endpoint_agent error path (HTTP 404)""" + agent_id = 'agent_id_example' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.enable_endpoint_agent( + + agent_id=agent_id, + + aid=aid, + + _headers=self.te_headers("enable_endpoint_agent", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_enable_endpoint_agent_error_429(self) -> None: + """Integration test for enable_endpoint_agent error path (HTTP 429)""" + agent_id = 'agent_id_example' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.enable_endpoint_agent( + + agent_id=agent_id, + + aid=aid, + + _headers=self.te_headers("enable_endpoint_agent", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_filter_endpoint_agents_happy_path(self) -> None: + """Integration test for filter_endpoint_agents success path""" + request_body_json = """ + + { + "searchSort" : [ { + "sort" : "platform", + "order" : "desc" + }, { + "sort" : "platform", + "order" : "desc" + } ], + "searchFilters" : { + "serialNumber" : [ "xaab2ba4-d40f-4e80-9363-7e4826556055", "xaab2ba4-d40f-4e80-9363-7e4826556055", "xaab2ba4-d40f-4e80-9363-7e4826556055", "xaab2ba4-d40f-4e80-9363-7e4826556055", "xaab2ba4-d40f-4e80-9363-7e4826556055" ], + "anyConnectDeviceId" : [ "JDLKSLFEIJER004334F" ], + "agentName" : [ "myagent-1234", "myagent-1234" ], + "locationSubdivision1Code" : [ "ENG", "ENG" ], + "platform" : [ "mac", "mac" ], + "licenseType" : [ "essentials", "essentials" ], + "osVersion" : [ "Version 10.15.2", "Version 10.15.2" ], + "computerName" : [ "DESKTOP-45AE8", "DESKTOP-45AE8" ], + "locationCountryISO" : [ "FR", "FR" ], + "id" : [ "861b7557-cd57-4bbb-b648-00bddf88ef49", "861b7557-cd57-4bbb-b648-00bddf88ef49" ], + "userPrincipalName" : [ "picard@c.com" ], + "locationCity" : [ "Paris", "Paris" ], + "username" : [ "picard" ] + }, + "thresholdFilter" : { + "conditionalOperator" : "and", + "filters" : [ { + "name" : "last-seen-ms", + "value" : 0.8008281904610115, + "operator" : "gte" + }, { + "name" : "last-seen-ms", + "value" : 0.8008281904610115, + "operator" : "gte" + } ] + } + } + + """ + agent_search_request = thousandeyes_sdk.endpoint_agents.models.AgentSearchRequest.from_json(request_body_json) + max = 5 + cursor = 'cursor_example' + aid = '1234' + include_deleted = False + response_body_json = """ + { + "_links" : { + "next" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "totalAgents" : 1, + "agents" : [ { + "npcapVersion" : "npcapVersion", + "asnDetails" : { + "asName" : "Virgin Media Limited", + "asNumber" : 5089 + }, + "clients" : [ { + "browserExtensions" : [ { + "browser" : "edge", + "profile" : "Profile 1", + "active" : true, + "error" : "", + "version" : "0.123.0", + "enabled" : true + }, { + "browser" : "edge", + "profile" : "Profile 1", + "active" : true, + "error" : "", + "version" : "0.123.0", + "enabled" : true + } ], + "userProfile" : { + "userName" : "joeblogs32", + "userPrincipalName" : "joeblogs32@c.com" + } + }, { + "browserExtensions" : [ { + "browser" : "edge", + "profile" : "Profile 1", + "active" : true, + "error" : "", + "version" : "0.123.0", + "enabled" : true + }, { + "browser" : "edge", + "profile" : "Profile 1", + "active" : true, + "error" : "", + "version" : "0.123.0", + "enabled" : true + } ], + "userProfile" : { + "userName" : "joeblogs32", + "userPrincipalName" : "joeblogs32@c.com" + } + } ], + "agentType" : "endpoint", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "batteryMetrics" : { + "batteryHealthNormalizedPercent" : 0.92, + "batteryLevel" : "medium", + "batteryLevelNormalizedPercent" : 0.3 + }, + "publicIP" : "88.45.2.123", + "tcpDriverAvailable" : true, + "platform" : "mac", + "manufacturer" : "Apple, Inc.", + "targetVersion" : "0.123.4", + "cellularProfile" : { + "rssi" : -10, + "advertisedNetworkSubtype" : "LTE/HSPA", + "carrierName" : "T-Mobile", + "rsrq" : -30, + "rsrp" : -30, + "advertisedNetworkGen" : "2g, 3g, 4g, 5g", + "rscp" : -30, + "networkGen" : "2g, 3g, 4g, 5g", + "networkSubtype" : "LTE/HSPA", + "sinr" : 20 + }, + "nicModel" : "Intel(R) Wi-Fi 6 AX200 160MHz", + "createdAt" : "2022-05-26T23:37:16Z", + "numberOfClients" : 3, + "licenseType" : "essentials", + "osVersion" : "Version 10.15.2 (Build 19C57)", + "computerName" : "DESKJET-123", + "freeDiskSpaceNormalized" : 0.41, + "model" : "MacBookAir7,2", + "id" : "861b7557-cd57-4bbb-b648-00bddf88ef49", + "nicDriverVersion" : "22.250.0.9", + "serialNumber" : "xaab2ba4-d40f-4e80-9363-7e4826556055", + "externalMetadata" : [ { + "key" : "anyConnectDeviceId", + "value" : "DF434343D" + }, { + "key" : "anyConnectDeviceId", + "value" : "DF434343D" + } ], + "version" : "0.123.4", + "vpnProfiles" : [ { + "vpnClientNetworkRange" : [ "10.100.0.0/22" ], + "vpnGatewayAddress" : "vpnGatewayAddress", + "vpnType" : "cisco-anyconnect", + "interfaceName" : "interfaceName", + "vpnClientAddresses" : [ "10.100.0.10" ] + }, { + "vpnClientNetworkRange" : [ "10.100.0.0/22" ], + "vpnGatewayAddress" : "vpnGatewayAddress", + "vpnType" : "cisco-anyconnect", + "interfaceName" : "interfaceName", + "vpnClientAddresses" : [ "10.100.0.10" ] + } ], + "lastSeen" : "2022-05-26T23:37:16Z", + "deleted" : true, + "totalMemory" : "16384 MB", + "kernelVersion" : "Darwin 19.2.0", + "name" : "Office Printer", + "location" : { + "locationName" : "London", + "latitude" : 51.51279, + "longitude" : -0.09184 + }, + "aid" : "", + "status" : "enabled", + "networkInterfaceProfiles" : [ { + "ethernetProfile" : { + "linkSpeed" : 0 + }, + "hardwareType" : "wireless", + "interfaceName" : "en0", + "addressProfiles" : [ { + "prefixLength" : 24, + "addressType" : "unique-local", + "ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888", + "routerHardwareAddress" : "5c:b1:3e:46:1c:84", + "gateway" : "192.168.0.254" + }, { + "prefixLength" : 24, + "addressType" : "unique-local", + "ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888", + "routerHardwareAddress" : "5c:b1:3e:46:1c:84", + "gateway" : "192.168.0.254" + } ], + "wirelessProfile" : { + "rssi" : -36, + "bssid" : "00:11:22:aa:bb:cc", + "channel" : 48, + "phyMode" : "802.11ac", + "ssid" : "GuestWiFi" + } + }, { + "ethernetProfile" : { + "linkSpeed" : 0 + }, + "hardwareType" : "wireless", + "interfaceName" : "en0", + "addressProfiles" : [ { + "prefixLength" : 24, + "addressType" : "unique-local", + "ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888", + "routerHardwareAddress" : "5c:b1:3e:46:1c:84", + "gateway" : "192.168.0.254" + }, { + "prefixLength" : 24, + "addressType" : "unique-local", + "ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888", + "routerHardwareAddress" : "5c:b1:3e:46:1c:84", + "gateway" : "192.168.0.254" + } ], + "wirelessProfile" : { + "rssi" : -36, + "bssid" : "00:11:22:aa:bb:cc", + "channel" : 48, + "phyMode" : "802.11ac", + "ssid" : "GuestWiFi" + } + } ] + }, { + "npcapVersion" : "npcapVersion", + "asnDetails" : { + "asName" : "Virgin Media Limited", + "asNumber" : 5089 + }, + "clients" : [ { + "browserExtensions" : [ { + "browser" : "edge", + "profile" : "Profile 1", + "active" : true, + "error" : "", + "version" : "0.123.0", + "enabled" : true + }, { + "browser" : "edge", + "profile" : "Profile 1", + "active" : true, + "error" : "", + "version" : "0.123.0", + "enabled" : true + } ], + "userProfile" : { + "userName" : "joeblogs32", + "userPrincipalName" : "joeblogs32@c.com" + } + }, { + "browserExtensions" : [ { + "browser" : "edge", + "profile" : "Profile 1", + "active" : true, + "error" : "", + "version" : "0.123.0", + "enabled" : true + }, { + "browser" : "edge", + "profile" : "Profile 1", + "active" : true, + "error" : "", + "version" : "0.123.0", + "enabled" : true + } ], + "userProfile" : { + "userName" : "joeblogs32", + "userPrincipalName" : "joeblogs32@c.com" + } + } ], + "agentType" : "endpoint", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "batteryMetrics" : { + "batteryHealthNormalizedPercent" : 0.92, + "batteryLevel" : "medium", + "batteryLevelNormalizedPercent" : 0.3 + }, + "publicIP" : "88.45.2.123", + "tcpDriverAvailable" : true, + "platform" : "mac", + "manufacturer" : "Apple, Inc.", + "targetVersion" : "0.123.4", + "cellularProfile" : { + "rssi" : -10, + "advertisedNetworkSubtype" : "LTE/HSPA", + "carrierName" : "T-Mobile", + "rsrq" : -30, + "rsrp" : -30, + "advertisedNetworkGen" : "2g, 3g, 4g, 5g", + "rscp" : -30, + "networkGen" : "2g, 3g, 4g, 5g", + "networkSubtype" : "LTE/HSPA", + "sinr" : 20 + }, + "nicModel" : "Intel(R) Wi-Fi 6 AX200 160MHz", + "createdAt" : "2022-05-26T23:37:16Z", + "numberOfClients" : 3, + "licenseType" : "essentials", + "osVersion" : "Version 10.15.2 (Build 19C57)", + "computerName" : "DESKJET-123", + "freeDiskSpaceNormalized" : 0.41, + "model" : "MacBookAir7,2", + "id" : "861b7557-cd57-4bbb-b648-00bddf88ef49", + "nicDriverVersion" : "22.250.0.9", + "serialNumber" : "xaab2ba4-d40f-4e80-9363-7e4826556055", + "externalMetadata" : [ { + "key" : "anyConnectDeviceId", + "value" : "DF434343D" + }, { + "key" : "anyConnectDeviceId", + "value" : "DF434343D" + } ], + "version" : "0.123.4", + "vpnProfiles" : [ { + "vpnClientNetworkRange" : [ "10.100.0.0/22" ], + "vpnGatewayAddress" : "vpnGatewayAddress", + "vpnType" : "cisco-anyconnect", + "interfaceName" : "interfaceName", + "vpnClientAddresses" : [ "10.100.0.10" ] + }, { + "vpnClientNetworkRange" : [ "10.100.0.0/22" ], + "vpnGatewayAddress" : "vpnGatewayAddress", + "vpnType" : "cisco-anyconnect", + "interfaceName" : "interfaceName", + "vpnClientAddresses" : [ "10.100.0.10" ] + } ], + "lastSeen" : "2022-05-26T23:37:16Z", + "deleted" : true, + "totalMemory" : "16384 MB", + "kernelVersion" : "Darwin 19.2.0", + "name" : "Office Printer", + "location" : { + "locationName" : "London", + "latitude" : 51.51279, + "longitude" : -0.09184 + }, + "aid" : "", + "status" : "enabled", + "networkInterfaceProfiles" : [ { + "ethernetProfile" : { + "linkSpeed" : 0 + }, + "hardwareType" : "wireless", + "interfaceName" : "en0", + "addressProfiles" : [ { + "prefixLength" : 24, + "addressType" : "unique-local", + "ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888", + "routerHardwareAddress" : "5c:b1:3e:46:1c:84", + "gateway" : "192.168.0.254" + }, { + "prefixLength" : 24, + "addressType" : "unique-local", + "ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888", + "routerHardwareAddress" : "5c:b1:3e:46:1c:84", + "gateway" : "192.168.0.254" + } ], + "wirelessProfile" : { + "rssi" : -36, + "bssid" : "00:11:22:aa:bb:cc", + "channel" : 48, + "phyMode" : "802.11ac", + "ssid" : "GuestWiFi" + } + }, { + "ethernetProfile" : { + "linkSpeed" : 0 + }, + "hardwareType" : "wireless", + "interfaceName" : "en0", + "addressProfiles" : [ { + "prefixLength" : 24, + "addressType" : "unique-local", + "ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888", + "routerHardwareAddress" : "5c:b1:3e:46:1c:84", + "gateway" : "192.168.0.254" + }, { + "prefixLength" : 24, + "addressType" : "unique-local", + "ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888", + "routerHardwareAddress" : "5c:b1:3e:46:1c:84", + "gateway" : "192.168.0.254" + } ], + "wirelessProfile" : { + "rssi" : -36, + "bssid" : "00:11:22:aa:bb:cc", + "channel" : 48, + "phyMode" : "802.11ac", + "ssid" : "GuestWiFi" + } + } ] + } ] + } + """ + expected_response = json.loads(response_body_json) + response = self.api.filter_endpoint_agents( + + agent_search_request=agent_search_request, + + max=max, + + cursor=cursor, + + aid=aid, + + include_deleted=include_deleted, + + _headers=self.te_headers("filter_endpoint_agents"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_filter_endpoint_agents_error_400(self) -> None: + """Integration test for filter_endpoint_agents error path (HTTP 400)""" + request_body_json = """ + + { + "searchSort" : [ { + "sort" : "platform", + "order" : "desc" + }, { + "sort" : "platform", + "order" : "desc" + } ], + "searchFilters" : { + "serialNumber" : [ "xaab2ba4-d40f-4e80-9363-7e4826556055", "xaab2ba4-d40f-4e80-9363-7e4826556055", "xaab2ba4-d40f-4e80-9363-7e4826556055", "xaab2ba4-d40f-4e80-9363-7e4826556055", "xaab2ba4-d40f-4e80-9363-7e4826556055" ], + "anyConnectDeviceId" : [ "JDLKSLFEIJER004334F" ], + "agentName" : [ "myagent-1234", "myagent-1234" ], + "locationSubdivision1Code" : [ "ENG", "ENG" ], + "platform" : [ "mac", "mac" ], + "licenseType" : [ "essentials", "essentials" ], + "osVersion" : [ "Version 10.15.2", "Version 10.15.2" ], + "computerName" : [ "DESKTOP-45AE8", "DESKTOP-45AE8" ], + "locationCountryISO" : [ "FR", "FR" ], + "id" : [ "861b7557-cd57-4bbb-b648-00bddf88ef49", "861b7557-cd57-4bbb-b648-00bddf88ef49" ], + "userPrincipalName" : [ "picard@c.com" ], + "locationCity" : [ "Paris", "Paris" ], + "username" : [ "picard" ] + }, + "thresholdFilter" : { + "conditionalOperator" : "and", + "filters" : [ { + "name" : "last-seen-ms", + "value" : 0.8008281904610115, + "operator" : "gte" + }, { + "name" : "last-seen-ms", + "value" : 0.8008281904610115, + "operator" : "gte" + } ] + } + } + + """ + agent_search_request = thousandeyes_sdk.endpoint_agents.models.AgentSearchRequest.from_json(request_body_json) + max = 5 + cursor = 'cursor_example' + aid = '1234' + include_deleted = False + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.filter_endpoint_agents( + + agent_search_request=agent_search_request, + + max=max, + + cursor=cursor, + + aid=aid, + + include_deleted=include_deleted, + + _headers=self.te_headers("filter_endpoint_agents", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_filter_endpoint_agents_error_401(self) -> None: + """Integration test for filter_endpoint_agents error path (HTTP 401)""" + request_body_json = """ + + { + "searchSort" : [ { + "sort" : "platform", + "order" : "desc" + }, { + "sort" : "platform", + "order" : "desc" + } ], + "searchFilters" : { + "serialNumber" : [ "xaab2ba4-d40f-4e80-9363-7e4826556055", "xaab2ba4-d40f-4e80-9363-7e4826556055", "xaab2ba4-d40f-4e80-9363-7e4826556055", "xaab2ba4-d40f-4e80-9363-7e4826556055", "xaab2ba4-d40f-4e80-9363-7e4826556055" ], + "anyConnectDeviceId" : [ "JDLKSLFEIJER004334F" ], + "agentName" : [ "myagent-1234", "myagent-1234" ], + "locationSubdivision1Code" : [ "ENG", "ENG" ], + "platform" : [ "mac", "mac" ], + "licenseType" : [ "essentials", "essentials" ], + "osVersion" : [ "Version 10.15.2", "Version 10.15.2" ], + "computerName" : [ "DESKTOP-45AE8", "DESKTOP-45AE8" ], + "locationCountryISO" : [ "FR", "FR" ], + "id" : [ "861b7557-cd57-4bbb-b648-00bddf88ef49", "861b7557-cd57-4bbb-b648-00bddf88ef49" ], + "userPrincipalName" : [ "picard@c.com" ], + "locationCity" : [ "Paris", "Paris" ], + "username" : [ "picard" ] + }, + "thresholdFilter" : { + "conditionalOperator" : "and", + "filters" : [ { + "name" : "last-seen-ms", + "value" : 0.8008281904610115, + "operator" : "gte" + }, { + "name" : "last-seen-ms", + "value" : 0.8008281904610115, + "operator" : "gte" + } ] + } + } + + """ + agent_search_request = thousandeyes_sdk.endpoint_agents.models.AgentSearchRequest.from_json(request_body_json) + max = 5 + cursor = 'cursor_example' + aid = '1234' + include_deleted = False + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.filter_endpoint_agents( + + agent_search_request=agent_search_request, + + max=max, + + cursor=cursor, + + aid=aid, + + include_deleted=include_deleted, + + _headers=self.te_headers("filter_endpoint_agents", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_filter_endpoint_agents_error_403(self) -> None: + """Integration test for filter_endpoint_agents error path (HTTP 403)""" + request_body_json = """ + + { + "searchSort" : [ { + "sort" : "platform", + "order" : "desc" + }, { + "sort" : "platform", + "order" : "desc" + } ], + "searchFilters" : { + "serialNumber" : [ "xaab2ba4-d40f-4e80-9363-7e4826556055", "xaab2ba4-d40f-4e80-9363-7e4826556055", "xaab2ba4-d40f-4e80-9363-7e4826556055", "xaab2ba4-d40f-4e80-9363-7e4826556055", "xaab2ba4-d40f-4e80-9363-7e4826556055" ], + "anyConnectDeviceId" : [ "JDLKSLFEIJER004334F" ], + "agentName" : [ "myagent-1234", "myagent-1234" ], + "locationSubdivision1Code" : [ "ENG", "ENG" ], + "platform" : [ "mac", "mac" ], + "licenseType" : [ "essentials", "essentials" ], + "osVersion" : [ "Version 10.15.2", "Version 10.15.2" ], + "computerName" : [ "DESKTOP-45AE8", "DESKTOP-45AE8" ], + "locationCountryISO" : [ "FR", "FR" ], + "id" : [ "861b7557-cd57-4bbb-b648-00bddf88ef49", "861b7557-cd57-4bbb-b648-00bddf88ef49" ], + "userPrincipalName" : [ "picard@c.com" ], + "locationCity" : [ "Paris", "Paris" ], + "username" : [ "picard" ] + }, + "thresholdFilter" : { + "conditionalOperator" : "and", + "filters" : [ { + "name" : "last-seen-ms", + "value" : 0.8008281904610115, + "operator" : "gte" + }, { + "name" : "last-seen-ms", + "value" : 0.8008281904610115, + "operator" : "gte" + } ] + } + } + + """ + agent_search_request = thousandeyes_sdk.endpoint_agents.models.AgentSearchRequest.from_json(request_body_json) + max = 5 + cursor = 'cursor_example' + aid = '1234' + include_deleted = False + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.filter_endpoint_agents( + + agent_search_request=agent_search_request, + + max=max, + + cursor=cursor, + + aid=aid, + + include_deleted=include_deleted, + + _headers=self.te_headers("filter_endpoint_agents", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_filter_endpoint_agents_error_429(self) -> None: + """Integration test for filter_endpoint_agents error path (HTTP 429)""" + request_body_json = """ + + { + "searchSort" : [ { + "sort" : "platform", + "order" : "desc" + }, { + "sort" : "platform", + "order" : "desc" + } ], + "searchFilters" : { + "serialNumber" : [ "xaab2ba4-d40f-4e80-9363-7e4826556055", "xaab2ba4-d40f-4e80-9363-7e4826556055", "xaab2ba4-d40f-4e80-9363-7e4826556055", "xaab2ba4-d40f-4e80-9363-7e4826556055", "xaab2ba4-d40f-4e80-9363-7e4826556055" ], + "anyConnectDeviceId" : [ "JDLKSLFEIJER004334F" ], + "agentName" : [ "myagent-1234", "myagent-1234" ], + "locationSubdivision1Code" : [ "ENG", "ENG" ], + "platform" : [ "mac", "mac" ], + "licenseType" : [ "essentials", "essentials" ], + "osVersion" : [ "Version 10.15.2", "Version 10.15.2" ], + "computerName" : [ "DESKTOP-45AE8", "DESKTOP-45AE8" ], + "locationCountryISO" : [ "FR", "FR" ], + "id" : [ "861b7557-cd57-4bbb-b648-00bddf88ef49", "861b7557-cd57-4bbb-b648-00bddf88ef49" ], + "userPrincipalName" : [ "picard@c.com" ], + "locationCity" : [ "Paris", "Paris" ], + "username" : [ "picard" ] + }, + "thresholdFilter" : { + "conditionalOperator" : "and", + "filters" : [ { + "name" : "last-seen-ms", + "value" : 0.8008281904610115, + "operator" : "gte" + }, { + "name" : "last-seen-ms", + "value" : 0.8008281904610115, + "operator" : "gte" + } ] + } + } + + """ + agent_search_request = thousandeyes_sdk.endpoint_agents.models.AgentSearchRequest.from_json(request_body_json) + max = 5 + cursor = 'cursor_example' + aid = '1234' + include_deleted = False + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.filter_endpoint_agents( + + agent_search_request=agent_search_request, + + max=max, + + cursor=cursor, + + aid=aid, + + include_deleted=include_deleted, + + _headers=self.te_headers("filter_endpoint_agents", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_endpoint_agent_happy_path(self) -> None: + """Integration test for get_endpoint_agent success path""" + agent_id = 'agent_id_example' + aid = '1234' + include_deleted = False + response_body_json = """ + { + "npcapVersion" : "npcapVersion", + "asnDetails" : { + "asName" : "Virgin Media Limited", + "asNumber" : 5089 + }, + "clients" : [ { + "browserExtensions" : [ { + "browser" : "edge", + "profile" : "Profile 1", + "active" : true, + "error" : "", + "version" : "0.123.0", + "enabled" : true + }, { + "browser" : "edge", + "profile" : "Profile 1", + "active" : true, + "error" : "", + "version" : "0.123.0", + "enabled" : true + } ], + "userProfile" : { + "userName" : "joeblogs32", + "userPrincipalName" : "joeblogs32@c.com" + } + }, { + "browserExtensions" : [ { + "browser" : "edge", + "profile" : "Profile 1", + "active" : true, + "error" : "", + "version" : "0.123.0", + "enabled" : true + }, { + "browser" : "edge", + "profile" : "Profile 1", + "active" : true, + "error" : "", + "version" : "0.123.0", + "enabled" : true + } ], + "userProfile" : { + "userName" : "joeblogs32", + "userPrincipalName" : "joeblogs32@c.com" + } + } ], + "agentType" : "endpoint", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "batteryMetrics" : { + "batteryHealthNormalizedPercent" : 0.92, + "batteryLevel" : "medium", + "batteryLevelNormalizedPercent" : 0.3 + }, + "publicIP" : "88.45.2.123", + "tcpDriverAvailable" : true, + "platform" : "mac", + "manufacturer" : "Apple, Inc.", + "targetVersion" : "0.123.4", + "cellularProfile" : { + "rssi" : -10, + "advertisedNetworkSubtype" : "LTE/HSPA", + "carrierName" : "T-Mobile", + "rsrq" : -30, + "rsrp" : -30, + "advertisedNetworkGen" : "2g, 3g, 4g, 5g", + "rscp" : -30, + "networkGen" : "2g, 3g, 4g, 5g", + "networkSubtype" : "LTE/HSPA", + "sinr" : 20 + }, + "nicModel" : "Intel(R) Wi-Fi 6 AX200 160MHz", + "createdAt" : "2022-05-26T23:37:16Z", + "numberOfClients" : 3, + "licenseType" : "essentials", + "osVersion" : "Version 10.15.2 (Build 19C57)", + "computerName" : "DESKJET-123", + "freeDiskSpaceNormalized" : 0.41, + "model" : "MacBookAir7,2", + "id" : "861b7557-cd57-4bbb-b648-00bddf88ef49", + "nicDriverVersion" : "22.250.0.9", + "serialNumber" : "xaab2ba4-d40f-4e80-9363-7e4826556055", + "externalMetadata" : [ { + "key" : "anyConnectDeviceId", + "value" : "DF434343D" + }, { + "key" : "anyConnectDeviceId", + "value" : "DF434343D" + } ], + "version" : "0.123.4", + "vpnProfiles" : [ { + "vpnClientNetworkRange" : [ "10.100.0.0/22" ], + "vpnGatewayAddress" : "vpnGatewayAddress", + "vpnType" : "cisco-anyconnect", + "interfaceName" : "interfaceName", + "vpnClientAddresses" : [ "10.100.0.10" ] + }, { + "vpnClientNetworkRange" : [ "10.100.0.0/22" ], + "vpnGatewayAddress" : "vpnGatewayAddress", + "vpnType" : "cisco-anyconnect", + "interfaceName" : "interfaceName", + "vpnClientAddresses" : [ "10.100.0.10" ] + } ], + "lastSeen" : "2022-05-26T23:37:16Z", + "deleted" : true, + "totalMemory" : "16384 MB", + "kernelVersion" : "Darwin 19.2.0", + "name" : "Office Printer", + "location" : { + "locationName" : "London", + "latitude" : 51.51279, + "longitude" : -0.09184 + }, + "aid" : "", + "status" : "enabled", + "networkInterfaceProfiles" : [ { + "ethernetProfile" : { + "linkSpeed" : 0 + }, + "hardwareType" : "wireless", + "interfaceName" : "en0", + "addressProfiles" : [ { + "prefixLength" : 24, + "addressType" : "unique-local", + "ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888", + "routerHardwareAddress" : "5c:b1:3e:46:1c:84", + "gateway" : "192.168.0.254" + }, { + "prefixLength" : 24, + "addressType" : "unique-local", + "ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888", + "routerHardwareAddress" : "5c:b1:3e:46:1c:84", + "gateway" : "192.168.0.254" + } ], + "wirelessProfile" : { + "rssi" : -36, + "bssid" : "00:11:22:aa:bb:cc", + "channel" : 48, + "phyMode" : "802.11ac", + "ssid" : "GuestWiFi" + } + }, { + "ethernetProfile" : { + "linkSpeed" : 0 + }, + "hardwareType" : "wireless", + "interfaceName" : "en0", + "addressProfiles" : [ { + "prefixLength" : 24, + "addressType" : "unique-local", + "ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888", + "routerHardwareAddress" : "5c:b1:3e:46:1c:84", + "gateway" : "192.168.0.254" + }, { + "prefixLength" : 24, + "addressType" : "unique-local", + "ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888", + "routerHardwareAddress" : "5c:b1:3e:46:1c:84", + "gateway" : "192.168.0.254" + } ], + "wirelessProfile" : { + "rssi" : -36, + "bssid" : "00:11:22:aa:bb:cc", + "channel" : 48, + "phyMode" : "802.11ac", + "ssid" : "GuestWiFi" + } + } ] + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_endpoint_agent( + + agent_id=agent_id, + + aid=aid, + + include_deleted=include_deleted, + + _headers=self.te_headers("get_endpoint_agent"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_endpoint_agent_error_401(self) -> None: + """Integration test for get_endpoint_agent error path (HTTP 401)""" + agent_id = 'agent_id_example' + aid = '1234' + include_deleted = False + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_endpoint_agent( + + agent_id=agent_id, + + aid=aid, + + include_deleted=include_deleted, + + _headers=self.te_headers("get_endpoint_agent", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_endpoint_agent_error_403(self) -> None: + """Integration test for get_endpoint_agent error path (HTTP 403)""" + agent_id = 'agent_id_example' + aid = '1234' + include_deleted = False + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_endpoint_agent( + + agent_id=agent_id, + + aid=aid, + + include_deleted=include_deleted, + + _headers=self.te_headers("get_endpoint_agent", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_endpoint_agent_error_404(self) -> None: + """Integration test for get_endpoint_agent error path (HTTP 404)""" + agent_id = 'agent_id_example' + aid = '1234' + include_deleted = False + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_endpoint_agent( + + agent_id=agent_id, + + aid=aid, + + include_deleted=include_deleted, + + _headers=self.te_headers("get_endpoint_agent", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_endpoint_agent_error_429(self) -> None: + """Integration test for get_endpoint_agent error path (HTTP 429)""" + agent_id = 'agent_id_example' + aid = '1234' + include_deleted = False + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_endpoint_agent( + + agent_id=agent_id, + + aid=aid, + + include_deleted=include_deleted, + + _headers=self.te_headers("get_endpoint_agent", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_endpoint_agents_happy_path(self) -> None: + """Integration test for get_endpoint_agents success path""" + max = 5 + cursor = 'cursor_example' + aid = '1234' + include_deleted = False + use_all_permitted_aids = False + agent_name = 'agent_name_example' + computer_name = 'computer_name_example' + response_body_json = """ + { + "_links" : { + "next" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "totalAgents" : 1, + "agents" : [ { + "npcapVersion" : "npcapVersion", + "asnDetails" : { + "asName" : "Virgin Media Limited", + "asNumber" : 5089 + }, + "clients" : [ { + "browserExtensions" : [ { + "browser" : "edge", + "profile" : "Profile 1", + "active" : true, + "error" : "", + "version" : "0.123.0", + "enabled" : true + }, { + "browser" : "edge", + "profile" : "Profile 1", + "active" : true, + "error" : "", + "version" : "0.123.0", + "enabled" : true + } ], + "userProfile" : { + "userName" : "joeblogs32", + "userPrincipalName" : "joeblogs32@c.com" + } + }, { + "browserExtensions" : [ { + "browser" : "edge", + "profile" : "Profile 1", + "active" : true, + "error" : "", + "version" : "0.123.0", + "enabled" : true + }, { + "browser" : "edge", + "profile" : "Profile 1", + "active" : true, + "error" : "", + "version" : "0.123.0", + "enabled" : true + } ], + "userProfile" : { + "userName" : "joeblogs32", + "userPrincipalName" : "joeblogs32@c.com" + } + } ], + "agentType" : "endpoint", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "batteryMetrics" : { + "batteryHealthNormalizedPercent" : 0.92, + "batteryLevel" : "medium", + "batteryLevelNormalizedPercent" : 0.3 + }, + "publicIP" : "88.45.2.123", + "tcpDriverAvailable" : true, + "platform" : "mac", + "manufacturer" : "Apple, Inc.", + "targetVersion" : "0.123.4", + "cellularProfile" : { + "rssi" : -10, + "advertisedNetworkSubtype" : "LTE/HSPA", + "carrierName" : "T-Mobile", + "rsrq" : -30, + "rsrp" : -30, + "advertisedNetworkGen" : "2g, 3g, 4g, 5g", + "rscp" : -30, + "networkGen" : "2g, 3g, 4g, 5g", + "networkSubtype" : "LTE/HSPA", + "sinr" : 20 + }, + "nicModel" : "Intel(R) Wi-Fi 6 AX200 160MHz", + "createdAt" : "2022-05-26T23:37:16Z", + "numberOfClients" : 3, + "licenseType" : "essentials", + "osVersion" : "Version 10.15.2 (Build 19C57)", + "computerName" : "DESKJET-123", + "freeDiskSpaceNormalized" : 0.41, + "model" : "MacBookAir7,2", + "id" : "861b7557-cd57-4bbb-b648-00bddf88ef49", + "nicDriverVersion" : "22.250.0.9", + "serialNumber" : "xaab2ba4-d40f-4e80-9363-7e4826556055", + "externalMetadata" : [ { + "key" : "anyConnectDeviceId", + "value" : "DF434343D" + }, { + "key" : "anyConnectDeviceId", + "value" : "DF434343D" + } ], + "version" : "0.123.4", + "vpnProfiles" : [ { + "vpnClientNetworkRange" : [ "10.100.0.0/22" ], + "vpnGatewayAddress" : "vpnGatewayAddress", + "vpnType" : "cisco-anyconnect", + "interfaceName" : "interfaceName", + "vpnClientAddresses" : [ "10.100.0.10" ] + }, { + "vpnClientNetworkRange" : [ "10.100.0.0/22" ], + "vpnGatewayAddress" : "vpnGatewayAddress", + "vpnType" : "cisco-anyconnect", + "interfaceName" : "interfaceName", + "vpnClientAddresses" : [ "10.100.0.10" ] + } ], + "lastSeen" : "2022-05-26T23:37:16Z", + "deleted" : true, + "totalMemory" : "16384 MB", + "kernelVersion" : "Darwin 19.2.0", + "name" : "Office Printer", + "location" : { + "locationName" : "London", + "latitude" : 51.51279, + "longitude" : -0.09184 + }, + "aid" : "", + "status" : "enabled", + "networkInterfaceProfiles" : [ { + "ethernetProfile" : { + "linkSpeed" : 0 + }, + "hardwareType" : "wireless", + "interfaceName" : "en0", + "addressProfiles" : [ { + "prefixLength" : 24, + "addressType" : "unique-local", + "ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888", + "routerHardwareAddress" : "5c:b1:3e:46:1c:84", + "gateway" : "192.168.0.254" + }, { + "prefixLength" : 24, + "addressType" : "unique-local", + "ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888", + "routerHardwareAddress" : "5c:b1:3e:46:1c:84", + "gateway" : "192.168.0.254" + } ], + "wirelessProfile" : { + "rssi" : -36, + "bssid" : "00:11:22:aa:bb:cc", + "channel" : 48, + "phyMode" : "802.11ac", + "ssid" : "GuestWiFi" + } + }, { + "ethernetProfile" : { + "linkSpeed" : 0 + }, + "hardwareType" : "wireless", + "interfaceName" : "en0", + "addressProfiles" : [ { + "prefixLength" : 24, + "addressType" : "unique-local", + "ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888", + "routerHardwareAddress" : "5c:b1:3e:46:1c:84", + "gateway" : "192.168.0.254" + }, { + "prefixLength" : 24, + "addressType" : "unique-local", + "ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888", + "routerHardwareAddress" : "5c:b1:3e:46:1c:84", + "gateway" : "192.168.0.254" + } ], + "wirelessProfile" : { + "rssi" : -36, + "bssid" : "00:11:22:aa:bb:cc", + "channel" : 48, + "phyMode" : "802.11ac", + "ssid" : "GuestWiFi" + } + } ] + }, { + "npcapVersion" : "npcapVersion", + "asnDetails" : { + "asName" : "Virgin Media Limited", + "asNumber" : 5089 + }, + "clients" : [ { + "browserExtensions" : [ { + "browser" : "edge", + "profile" : "Profile 1", + "active" : true, + "error" : "", + "version" : "0.123.0", + "enabled" : true + }, { + "browser" : "edge", + "profile" : "Profile 1", + "active" : true, + "error" : "", + "version" : "0.123.0", + "enabled" : true + } ], + "userProfile" : { + "userName" : "joeblogs32", + "userPrincipalName" : "joeblogs32@c.com" + } + }, { + "browserExtensions" : [ { + "browser" : "edge", + "profile" : "Profile 1", + "active" : true, + "error" : "", + "version" : "0.123.0", + "enabled" : true + }, { + "browser" : "edge", + "profile" : "Profile 1", + "active" : true, + "error" : "", + "version" : "0.123.0", + "enabled" : true + } ], + "userProfile" : { + "userName" : "joeblogs32", + "userPrincipalName" : "joeblogs32@c.com" + } + } ], + "agentType" : "endpoint", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "batteryMetrics" : { + "batteryHealthNormalizedPercent" : 0.92, + "batteryLevel" : "medium", + "batteryLevelNormalizedPercent" : 0.3 + }, + "publicIP" : "88.45.2.123", + "tcpDriverAvailable" : true, + "platform" : "mac", + "manufacturer" : "Apple, Inc.", + "targetVersion" : "0.123.4", + "cellularProfile" : { + "rssi" : -10, + "advertisedNetworkSubtype" : "LTE/HSPA", + "carrierName" : "T-Mobile", + "rsrq" : -30, + "rsrp" : -30, + "advertisedNetworkGen" : "2g, 3g, 4g, 5g", + "rscp" : -30, + "networkGen" : "2g, 3g, 4g, 5g", + "networkSubtype" : "LTE/HSPA", + "sinr" : 20 + }, + "nicModel" : "Intel(R) Wi-Fi 6 AX200 160MHz", + "createdAt" : "2022-05-26T23:37:16Z", + "numberOfClients" : 3, + "licenseType" : "essentials", + "osVersion" : "Version 10.15.2 (Build 19C57)", + "computerName" : "DESKJET-123", + "freeDiskSpaceNormalized" : 0.41, + "model" : "MacBookAir7,2", + "id" : "861b7557-cd57-4bbb-b648-00bddf88ef49", + "nicDriverVersion" : "22.250.0.9", + "serialNumber" : "xaab2ba4-d40f-4e80-9363-7e4826556055", + "externalMetadata" : [ { + "key" : "anyConnectDeviceId", + "value" : "DF434343D" + }, { + "key" : "anyConnectDeviceId", + "value" : "DF434343D" + } ], + "version" : "0.123.4", + "vpnProfiles" : [ { + "vpnClientNetworkRange" : [ "10.100.0.0/22" ], + "vpnGatewayAddress" : "vpnGatewayAddress", + "vpnType" : "cisco-anyconnect", + "interfaceName" : "interfaceName", + "vpnClientAddresses" : [ "10.100.0.10" ] + }, { + "vpnClientNetworkRange" : [ "10.100.0.0/22" ], + "vpnGatewayAddress" : "vpnGatewayAddress", + "vpnType" : "cisco-anyconnect", + "interfaceName" : "interfaceName", + "vpnClientAddresses" : [ "10.100.0.10" ] + } ], + "lastSeen" : "2022-05-26T23:37:16Z", + "deleted" : true, + "totalMemory" : "16384 MB", + "kernelVersion" : "Darwin 19.2.0", + "name" : "Office Printer", + "location" : { + "locationName" : "London", + "latitude" : 51.51279, + "longitude" : -0.09184 + }, + "aid" : "", + "status" : "enabled", + "networkInterfaceProfiles" : [ { + "ethernetProfile" : { + "linkSpeed" : 0 + }, + "hardwareType" : "wireless", + "interfaceName" : "en0", + "addressProfiles" : [ { + "prefixLength" : 24, + "addressType" : "unique-local", + "ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888", + "routerHardwareAddress" : "5c:b1:3e:46:1c:84", + "gateway" : "192.168.0.254" + }, { + "prefixLength" : 24, + "addressType" : "unique-local", + "ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888", + "routerHardwareAddress" : "5c:b1:3e:46:1c:84", + "gateway" : "192.168.0.254" + } ], + "wirelessProfile" : { + "rssi" : -36, + "bssid" : "00:11:22:aa:bb:cc", + "channel" : 48, + "phyMode" : "802.11ac", + "ssid" : "GuestWiFi" + } + }, { + "ethernetProfile" : { + "linkSpeed" : 0 + }, + "hardwareType" : "wireless", + "interfaceName" : "en0", + "addressProfiles" : [ { + "prefixLength" : 24, + "addressType" : "unique-local", + "ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888", + "routerHardwareAddress" : "5c:b1:3e:46:1c:84", + "gateway" : "192.168.0.254" + }, { + "prefixLength" : 24, + "addressType" : "unique-local", + "ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888", + "routerHardwareAddress" : "5c:b1:3e:46:1c:84", + "gateway" : "192.168.0.254" + } ], + "wirelessProfile" : { + "rssi" : -36, + "bssid" : "00:11:22:aa:bb:cc", + "channel" : 48, + "phyMode" : "802.11ac", + "ssid" : "GuestWiFi" + } + } ] + } ] + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_endpoint_agents( + + max=max, + + cursor=cursor, + + aid=aid, + + include_deleted=include_deleted, + + use_all_permitted_aids=use_all_permitted_aids, + + agent_name=agent_name, + + computer_name=computer_name, + + _headers=self.te_headers("get_endpoint_agents"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_endpoint_agents_error_401(self) -> None: + """Integration test for get_endpoint_agents error path (HTTP 401)""" + max = 5 + cursor = 'cursor_example' + aid = '1234' + include_deleted = False + use_all_permitted_aids = False + agent_name = 'agent_name_example' + computer_name = 'computer_name_example' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_endpoint_agents( + + max=max, + + cursor=cursor, + + aid=aid, + + include_deleted=include_deleted, + + use_all_permitted_aids=use_all_permitted_aids, + + agent_name=agent_name, + + computer_name=computer_name, + + _headers=self.te_headers("get_endpoint_agents", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_endpoint_agents_error_403(self) -> None: + """Integration test for get_endpoint_agents error path (HTTP 403)""" + max = 5 + cursor = 'cursor_example' + aid = '1234' + include_deleted = False + use_all_permitted_aids = False + agent_name = 'agent_name_example' + computer_name = 'computer_name_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_endpoint_agents( + + max=max, + + cursor=cursor, + + aid=aid, + + include_deleted=include_deleted, + + use_all_permitted_aids=use_all_permitted_aids, + + agent_name=agent_name, + + computer_name=computer_name, + + _headers=self.te_headers("get_endpoint_agents", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_endpoint_agents_error_429(self) -> None: + """Integration test for get_endpoint_agents error path (HTTP 429)""" + max = 5 + cursor = 'cursor_example' + aid = '1234' + include_deleted = False + use_all_permitted_aids = False + agent_name = 'agent_name_example' + computer_name = 'computer_name_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_endpoint_agents( + + max=max, + + cursor=cursor, + + aid=aid, + + include_deleted=include_deleted, + + use_all_permitted_aids=use_all_permitted_aids, + + agent_name=agent_name, + + computer_name=computer_name, + + _headers=self.te_headers("get_endpoint_agents", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_endpoint_agents_connection_string_happy_path(self) -> None: + """Integration test for get_endpoint_agents_connection_string success path""" + aid = '1234' + response_body_json = """ + { + "connectionString" : "D2xZSLlqo64Xe2EnYisklA==", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_endpoint_agents_connection_string( + + aid=aid, + + _headers=self.te_headers("get_endpoint_agents_connection_string"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_endpoint_agents_connection_string_error_401(self) -> None: + """Integration test for get_endpoint_agents_connection_string error path (HTTP 401)""" + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_endpoint_agents_connection_string( + + aid=aid, + + _headers=self.te_headers("get_endpoint_agents_connection_string", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_endpoint_agents_connection_string_error_403(self) -> None: + """Integration test for get_endpoint_agents_connection_string error path (HTTP 403)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_endpoint_agents_connection_string( + + aid=aid, + + _headers=self.te_headers("get_endpoint_agents_connection_string", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_endpoint_agents_connection_string_error_429(self) -> None: + """Integration test for get_endpoint_agents_connection_string error path (HTTP 429)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_endpoint_agents_connection_string( + + aid=aid, + + _headers=self.te_headers("get_endpoint_agents_connection_string", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_update_endpoint_agent_happy_path(self) -> None: + """Integration test for update_endpoint_agent success path""" + request_body_json = """ + + { + "licenseType" : "essentials", + "name" : "Office Printer" + } + + """ + endpoint_agent_update = thousandeyes_sdk.endpoint_agents.models.EndpointAgentUpdate.from_json(request_body_json) + agent_id = 'agent_id_example' + aid = '1234' + response_body_json = """ + { + "npcapVersion" : "npcapVersion", + "asnDetails" : { + "asName" : "Virgin Media Limited", + "asNumber" : 5089 + }, + "clients" : [ { + "browserExtensions" : [ { + "browser" : "edge", + "profile" : "Profile 1", + "active" : true, + "error" : "", + "version" : "0.123.0", + "enabled" : true + }, { + "browser" : "edge", + "profile" : "Profile 1", + "active" : true, + "error" : "", + "version" : "0.123.0", + "enabled" : true + } ], + "userProfile" : { + "userName" : "joeblogs32", + "userPrincipalName" : "joeblogs32@c.com" + } + }, { + "browserExtensions" : [ { + "browser" : "edge", + "profile" : "Profile 1", + "active" : true, + "error" : "", + "version" : "0.123.0", + "enabled" : true + }, { + "browser" : "edge", + "profile" : "Profile 1", + "active" : true, + "error" : "", + "version" : "0.123.0", + "enabled" : true + } ], + "userProfile" : { + "userName" : "joeblogs32", + "userPrincipalName" : "joeblogs32@c.com" + } + } ], + "agentType" : "endpoint", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "batteryMetrics" : { + "batteryHealthNormalizedPercent" : 0.92, + "batteryLevel" : "medium", + "batteryLevelNormalizedPercent" : 0.3 + }, + "publicIP" : "88.45.2.123", + "tcpDriverAvailable" : true, + "platform" : "mac", + "manufacturer" : "Apple, Inc.", + "targetVersion" : "0.123.4", + "cellularProfile" : { + "rssi" : -10, + "advertisedNetworkSubtype" : "LTE/HSPA", + "carrierName" : "T-Mobile", + "rsrq" : -30, + "rsrp" : -30, + "advertisedNetworkGen" : "2g, 3g, 4g, 5g", + "rscp" : -30, + "networkGen" : "2g, 3g, 4g, 5g", + "networkSubtype" : "LTE/HSPA", + "sinr" : 20 + }, + "nicModel" : "Intel(R) Wi-Fi 6 AX200 160MHz", + "createdAt" : "2022-05-26T23:37:16Z", + "numberOfClients" : 3, + "licenseType" : "essentials", + "osVersion" : "Version 10.15.2 (Build 19C57)", + "computerName" : "DESKJET-123", + "freeDiskSpaceNormalized" : 0.41, + "model" : "MacBookAir7,2", + "id" : "861b7557-cd57-4bbb-b648-00bddf88ef49", + "nicDriverVersion" : "22.250.0.9", + "serialNumber" : "xaab2ba4-d40f-4e80-9363-7e4826556055", + "externalMetadata" : [ { + "key" : "anyConnectDeviceId", + "value" : "DF434343D" + }, { + "key" : "anyConnectDeviceId", + "value" : "DF434343D" + } ], + "version" : "0.123.4", + "vpnProfiles" : [ { + "vpnClientNetworkRange" : [ "10.100.0.0/22" ], + "vpnGatewayAddress" : "vpnGatewayAddress", + "vpnType" : "cisco-anyconnect", + "interfaceName" : "interfaceName", + "vpnClientAddresses" : [ "10.100.0.10" ] + }, { + "vpnClientNetworkRange" : [ "10.100.0.0/22" ], + "vpnGatewayAddress" : "vpnGatewayAddress", + "vpnType" : "cisco-anyconnect", + "interfaceName" : "interfaceName", + "vpnClientAddresses" : [ "10.100.0.10" ] + } ], + "lastSeen" : "2022-05-26T23:37:16Z", + "deleted" : true, + "totalMemory" : "16384 MB", + "kernelVersion" : "Darwin 19.2.0", + "name" : "Office Printer", + "location" : { + "locationName" : "London", + "latitude" : 51.51279, + "longitude" : -0.09184 + }, + "aid" : "", + "status" : "enabled", + "networkInterfaceProfiles" : [ { + "ethernetProfile" : { + "linkSpeed" : 0 + }, + "hardwareType" : "wireless", + "interfaceName" : "en0", + "addressProfiles" : [ { + "prefixLength" : 24, + "addressType" : "unique-local", + "ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888", + "routerHardwareAddress" : "5c:b1:3e:46:1c:84", + "gateway" : "192.168.0.254" + }, { + "prefixLength" : 24, + "addressType" : "unique-local", + "ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888", + "routerHardwareAddress" : "5c:b1:3e:46:1c:84", + "gateway" : "192.168.0.254" + } ], + "wirelessProfile" : { + "rssi" : -36, + "bssid" : "00:11:22:aa:bb:cc", + "channel" : 48, + "phyMode" : "802.11ac", + "ssid" : "GuestWiFi" + } + }, { + "ethernetProfile" : { + "linkSpeed" : 0 + }, + "hardwareType" : "wireless", + "interfaceName" : "en0", + "addressProfiles" : [ { + "prefixLength" : 24, + "addressType" : "unique-local", + "ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888", + "routerHardwareAddress" : "5c:b1:3e:46:1c:84", + "gateway" : "192.168.0.254" + }, { + "prefixLength" : 24, + "addressType" : "unique-local", + "ipAddress" : "2001:db8:3333:4444:5555:6666:7777:8888", + "routerHardwareAddress" : "5c:b1:3e:46:1c:84", + "gateway" : "192.168.0.254" + } ], + "wirelessProfile" : { + "rssi" : -36, + "bssid" : "00:11:22:aa:bb:cc", + "channel" : 48, + "phyMode" : "802.11ac", + "ssid" : "GuestWiFi" + } + } ] + } + """ + expected_response = json.loads(response_body_json) + response = self.api.update_endpoint_agent( + + agent_id=agent_id, + + aid=aid, + + endpoint_agent_update=endpoint_agent_update, + + _headers=self.te_headers("update_endpoint_agent"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_update_endpoint_agent_error_401(self) -> None: + """Integration test for update_endpoint_agent error path (HTTP 401)""" + request_body_json = """ + + { + "licenseType" : "essentials", + "name" : "Office Printer" + } + + """ + endpoint_agent_update = thousandeyes_sdk.endpoint_agents.models.EndpointAgentUpdate.from_json(request_body_json) + agent_id = 'agent_id_example' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.update_endpoint_agent( + + agent_id=agent_id, + + aid=aid, + + endpoint_agent_update=endpoint_agent_update, + + _headers=self.te_headers("update_endpoint_agent", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_endpoint_agent_error_403(self) -> None: + """Integration test for update_endpoint_agent error path (HTTP 403)""" + request_body_json = """ + + { + "licenseType" : "essentials", + "name" : "Office Printer" + } + + """ + endpoint_agent_update = thousandeyes_sdk.endpoint_agents.models.EndpointAgentUpdate.from_json(request_body_json) + agent_id = 'agent_id_example' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.update_endpoint_agent( + + agent_id=agent_id, + + aid=aid, + + endpoint_agent_update=endpoint_agent_update, + + _headers=self.te_headers("update_endpoint_agent", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_endpoint_agent_error_404(self) -> None: + """Integration test for update_endpoint_agent error path (HTTP 404)""" + request_body_json = """ + + { + "licenseType" : "essentials", + "name" : "Office Printer" + } + + """ + endpoint_agent_update = thousandeyes_sdk.endpoint_agents.models.EndpointAgentUpdate.from_json(request_body_json) + agent_id = 'agent_id_example' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.update_endpoint_agent( + + agent_id=agent_id, + + aid=aid, + + endpoint_agent_update=endpoint_agent_update, + + _headers=self.te_headers("update_endpoint_agent", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_endpoint_agent_error_429(self) -> None: + """Integration test for update_endpoint_agent error path (HTTP 429)""" + request_body_json = """ + + { + "licenseType" : "essentials", + "name" : "Office Printer" + } + + """ + endpoint_agent_update = thousandeyes_sdk.endpoint_agents.models.EndpointAgentUpdate.from_json(request_body_json) + agent_id = 'agent_id_example' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.update_endpoint_agent( + + agent_id=agent_id, + + aid=aid, + + endpoint_agent_update=endpoint_agent_update, + + _headers=self.te_headers("update_endpoint_agent", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-endpoint-agents/test/test_endpoint_agents_transfer_api_integration.py b/thousandeyes-sdk-endpoint-agents/test/test_endpoint_agents_transfer_api_integration.py new file mode 100644 index 00000000..7203b700 --- /dev/null +++ b/thousandeyes-sdk-endpoint-agents/test/test_endpoint_agents_transfer_api_integration.py @@ -0,0 +1,318 @@ +# coding: utf-8 + +""" + Endpoint Agents API + + **Note:** The Endpoint Agents Transfer APIs are not available for ThousandEyes for Government instance. Manage ThousandEyes Endpoint Agents using this API. For more information about Endpoint Agents, see [Endpoint Agents](https://docs.thousandeyes.com/product-documentation/global-vantage-points/endpoint-agents). + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.endpoint_agents.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.endpoint_agents.api.endpoint_agents_transfer_api import EndpointAgentsTransferApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestEndpointAgentsTransferApiIntegration(IntegrationTestBase): + """EndpointAgentsTransferApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = EndpointAgentsTransferApi(self.api_client) + + + def test_transfer_endpoint_agents_happy_path(self) -> None: + """Integration test for transfer_endpoint_agents success path""" + request_body_json = """ + + { + "transfers" : [ { + "agentId" : "5d0764ac-7e42-4ec8-a0d4-39fc53edccba", + "fromAid" : "1234", + "toAid" : "12345" + }, { + "agentId" : "5d0764ac-7e42-4ec8-a0d4-39fc53edccba", + "fromAid" : "1234", + "toAid" : "12345" + } ] + } + + """ + bulk_agent_transfer_request = thousandeyes_sdk.endpoint_agents.models.BulkAgentTransferRequest.from_json(request_body_json) + aid = '1234' + response_body_json = """ + { + "items" : [ { + "status" : 200, + "detail" : "Initiated", + "request" : { + "agentId" : "5d0764ac-7e42-4ec8-a0d4-39fc53edccba", + "fromAid" : "1234", + "toAid" : "12345" + } + }, { + "status" : 400, + "detail" : "Missing from-account id", + "request" : { + "agentId" : "5d0764ac-7e42-4ec8-a0d5-39fc53ed1234", + "fromAid" : "xxx", + "toAid" : "12345" + } + }, { + "status" : 403, + "detail" : "User does not have permission on 'to' aid", + "request" : { + "agentId" : "5d0764ac-7e42-4ec8-a0d5-39fc53ed7890", + "fromAid" : "1234", + "toAid" : "12345" + } + } ] + } + """ + expected_response = json.loads(response_body_json) + response = self.api.transfer_endpoint_agents( + + aid=aid, + + bulk_agent_transfer_request=bulk_agent_transfer_request, + + _headers=self.te_headers("transfer_endpoint_agents"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_transfer_endpoint_agents_error_400(self) -> None: + """Integration test for transfer_endpoint_agents error path (HTTP 400)""" + request_body_json = """ + + { + "transfers" : [ { + "agentId" : "5d0764ac-7e42-4ec8-a0d4-39fc53edccba", + "fromAid" : "1234", + "toAid" : "12345" + }, { + "agentId" : "5d0764ac-7e42-4ec8-a0d4-39fc53edccba", + "fromAid" : "1234", + "toAid" : "12345" + } ] + } + + """ + bulk_agent_transfer_request = thousandeyes_sdk.endpoint_agents.models.BulkAgentTransferRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.transfer_endpoint_agents( + + aid=aid, + + bulk_agent_transfer_request=bulk_agent_transfer_request, + + _headers=self.te_headers("transfer_endpoint_agents", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_transfer_endpoint_agents_error_401(self) -> None: + """Integration test for transfer_endpoint_agents error path (HTTP 401)""" + request_body_json = """ + + { + "transfers" : [ { + "agentId" : "5d0764ac-7e42-4ec8-a0d4-39fc53edccba", + "fromAid" : "1234", + "toAid" : "12345" + }, { + "agentId" : "5d0764ac-7e42-4ec8-a0d4-39fc53edccba", + "fromAid" : "1234", + "toAid" : "12345" + } ] + } + + """ + bulk_agent_transfer_request = thousandeyes_sdk.endpoint_agents.models.BulkAgentTransferRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.transfer_endpoint_agents( + + aid=aid, + + bulk_agent_transfer_request=bulk_agent_transfer_request, + + _headers=self.te_headers("transfer_endpoint_agents", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_transfer_endpoint_agents_error_403(self) -> None: + """Integration test for transfer_endpoint_agents error path (HTTP 403)""" + request_body_json = """ + + { + "transfers" : [ { + "agentId" : "5d0764ac-7e42-4ec8-a0d4-39fc53edccba", + "fromAid" : "1234", + "toAid" : "12345" + }, { + "agentId" : "5d0764ac-7e42-4ec8-a0d4-39fc53edccba", + "fromAid" : "1234", + "toAid" : "12345" + } ] + } + + """ + bulk_agent_transfer_request = thousandeyes_sdk.endpoint_agents.models.BulkAgentTransferRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.transfer_endpoint_agents( + + aid=aid, + + bulk_agent_transfer_request=bulk_agent_transfer_request, + + _headers=self.te_headers("transfer_endpoint_agents", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_transfer_endpoint_agents_error_404(self) -> None: + """Integration test for transfer_endpoint_agents error path (HTTP 404)""" + request_body_json = """ + + { + "transfers" : [ { + "agentId" : "5d0764ac-7e42-4ec8-a0d4-39fc53edccba", + "fromAid" : "1234", + "toAid" : "12345" + }, { + "agentId" : "5d0764ac-7e42-4ec8-a0d4-39fc53edccba", + "fromAid" : "1234", + "toAid" : "12345" + } ] + } + + """ + bulk_agent_transfer_request = thousandeyes_sdk.endpoint_agents.models.BulkAgentTransferRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.transfer_endpoint_agents( + + aid=aid, + + bulk_agent_transfer_request=bulk_agent_transfer_request, + + _headers=self.te_headers("transfer_endpoint_agents", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_transfer_endpoint_agents_error_429(self) -> None: + """Integration test for transfer_endpoint_agents error path (HTTP 429)""" + request_body_json = """ + + { + "transfers" : [ { + "agentId" : "5d0764ac-7e42-4ec8-a0d4-39fc53edccba", + "fromAid" : "1234", + "toAid" : "12345" + }, { + "agentId" : "5d0764ac-7e42-4ec8-a0d4-39fc53edccba", + "fromAid" : "1234", + "toAid" : "12345" + } ] + } + + """ + bulk_agent_transfer_request = thousandeyes_sdk.endpoint_agents.models.BulkAgentTransferRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.transfer_endpoint_agents( + + aid=aid, + + bulk_agent_transfer_request=bulk_agent_transfer_request, + + _headers=self.te_headers("transfer_endpoint_agents", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-endpoint-agents/test/test_endpoint_proxies_api_integration.py b/thousandeyes-sdk-endpoint-agents/test/test_endpoint_proxies_api_integration.py new file mode 100644 index 00000000..b1afd0b0 --- /dev/null +++ b/thousandeyes-sdk-endpoint-agents/test/test_endpoint_proxies_api_integration.py @@ -0,0 +1,176 @@ +# coding: utf-8 + +""" + Endpoint Agents API + + **Note:** The Endpoint Agents Transfer APIs are not available for ThousandEyes for Government instance. Manage ThousandEyes Endpoint Agents using this API. For more information about Endpoint Agents, see [Endpoint Agents](https://docs.thousandeyes.com/product-documentation/global-vantage-points/endpoint-agents). + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.endpoint_agents.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.endpoint_agents.api.endpoint_proxies_api import EndpointProxiesApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestEndpointProxiesApiIntegration(IntegrationTestBase): + """EndpointProxiesApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = EndpointProxiesApi(self.api_client) + + + def test_get_endpoint_proxies_happy_path(self) -> None: + """Integration test for get_endpoint_proxies success path""" + aid = '1234' + response_body_json = """ + { + "proxies" : [ { + "testIds" : [ "9923667", "9923667" ], + "agentIds" : [ "861b7557-cd57-4bbb-b648-00bddf88ef49", "861b7557-cd57-4bbb-b648-00bddf88ef49" ], + "pac" : "https://example.com/proxy.pac", + "port" : 8080, + "name" : "Local Mitmproxy", + "host" : "localhost", + "type" : "static", + "userName" : "endpoint-proxy-user", + "authType" : "none", + "bypassList" : "localhost,127.0.0.1", + "proxyId" : "101498" + }, { + "testIds" : [ "9923667", "9923667" ], + "agentIds" : [ "861b7557-cd57-4bbb-b648-00bddf88ef49", "861b7557-cd57-4bbb-b648-00bddf88ef49" ], + "pac" : "https://example.com/proxy.pac", + "port" : 8080, + "name" : "Local Mitmproxy", + "host" : "localhost", + "type" : "static", + "userName" : "endpoint-proxy-user", + "authType" : "none", + "bypassList" : "localhost,127.0.0.1", + "proxyId" : "101498" + } ] + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_endpoint_proxies( + + aid=aid, + + _headers=self.te_headers("get_endpoint_proxies"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_endpoint_proxies_error_401(self) -> None: + """Integration test for get_endpoint_proxies error path (HTTP 401)""" + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_endpoint_proxies( + + aid=aid, + + _headers=self.te_headers("get_endpoint_proxies", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_endpoint_proxies_error_403(self) -> None: + """Integration test for get_endpoint_proxies error path (HTTP 403)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_endpoint_proxies( + + aid=aid, + + _headers=self.te_headers("get_endpoint_proxies", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_endpoint_proxies_error_429(self) -> None: + """Integration test for get_endpoint_proxies error path (HTTP 429)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_endpoint_proxies( + + aid=aid, + + _headers=self.te_headers("get_endpoint_proxies", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_endpoint_proxies_error_500(self) -> None: + """Integration test for get_endpoint_proxies error path (HTTP 500)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_endpoint_proxies( + + aid=aid, + + _headers=self.te_headers("get_endpoint_proxies", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-endpoint-agents/test/test_utils.py b/thousandeyes-sdk-endpoint-agents/test/test_utils.py index 930528d9..37913f62 100644 --- a/thousandeyes-sdk-endpoint-agents/test/test_utils.py +++ b/thousandeyes-sdk-endpoint-agents/test/test_utils.py @@ -2,15 +2,36 @@ import json import unittest +from typing import Any from pydantic import BaseModel +def _project_onto_constructed(expected: Any, constructed: Any) -> Any: + """Keep only example fields that appear in the constructed model output.""" + if isinstance(constructed, dict): + if not isinstance(expected, dict): + return expected + return { + key: _project_onto_constructed(expected.get(key), value) + for key, value in constructed.items() + } + if isinstance(constructed, list): + if not isinstance(expected, list): + return expected + return [ + _project_onto_constructed(expected[index], value) + for index, value in enumerate(constructed) + ] + return expected + + def assert_constructed_model_matches_example_json(model: BaseModel, loaded_json: dict): test_case = unittest.TestCase() test_case.maxDiff = None test_case.assertIsNotNone(model) constructed_json = json.loads(model.to_json()) - sorted_loaded_json = json.dumps(loaded_json, sort_keys=True) + projected_loaded_json = _project_onto_constructed(loaded_json, constructed_json) + sorted_loaded_json = json.dumps(projected_loaded_json, sort_keys=True) sorted_constructed_json = json.dumps(constructed_json, sort_keys=True) test_case.assertEqual(sorted_loaded_json, sorted_constructed_json) diff --git a/thousandeyes-sdk-endpoint-instant-tests/test/conftest.py b/thousandeyes-sdk-endpoint-instant-tests/test/conftest.py new file mode 100644 index 00000000..2edba7b3 --- /dev/null +++ b/thousandeyes-sdk-endpoint-instant-tests/test/conftest.py @@ -0,0 +1,7 @@ +import sys +from pathlib import Path + +_repo_root = Path(__file__).resolve().parents[2] +_core_test_support = _repo_root / "thousandeyes-sdk-core" / "test" +if str(_core_test_support) not in sys.path: + sys.path.insert(0, str(_core_test_support)) diff --git a/thousandeyes-sdk-endpoint-instant-tests/test/integration_test_utils.py b/thousandeyes-sdk-endpoint-instant-tests/test/integration_test_utils.py new file mode 100644 index 00000000..fe6515fb --- /dev/null +++ b/thousandeyes-sdk-endpoint-instant-tests/test/integration_test_utils.py @@ -0,0 +1,37 @@ +# coding: utf-8 + +""" + Endpoint Instant Scheduled Tests API + + You can create and execute a new endpoint instant scheduled test within ThousandEyes using this API. The test parameters are specified in the `POST` data. The following applies to the Endpoint Instant Scheduled Tests API: * To initiate the creation and execution of an instant scheduled test, the user must possess the `Edit endpoint tests` permission. * Upon successful creation of an instant scheduled test, the API responds with an HTTP/201 CREATED status code and return the test definition. * It's important to note that the response does not include the results of the instant scheduled test. To retrieve test results, users can utilize the Endpoint Test Data endpoints. The URLs for these API test data endpoints are provided within the test definition output when an instant scheduled test is created. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from thousandeyes_sdk.core.api_client import ApiClient +from thousandeyes_sdk.core.configuration import Configuration +from sdk_test_support.mock_server import ERROR_STATUS_HEADER, OPERATION_ID_HEADER, MockApiServer + +from .mock_manifest import OPERATION_MANIFEST + + +class IntegrationTestBase(unittest.TestCase): + def setUp(self) -> None: + self.server = MockApiServer(OPERATION_MANIFEST) + self.server.start() + configuration = Configuration(host=self.server.base_url, access_token="test-token") + self.api_client = ApiClient(configuration=configuration) + + def tearDown(self) -> None: + self.server.stop() + + def te_headers(self, operation_id: str, error_status=None): + headers = {OPERATION_ID_HEADER: operation_id} + if error_status is not None: + headers[ERROR_STATUS_HEADER] = error_status + return headers diff --git a/thousandeyes-sdk-endpoint-instant-tests/test/mock_manifest.py b/thousandeyes-sdk-endpoint-instant-tests/test/mock_manifest.py new file mode 100644 index 00000000..dffd1438 --- /dev/null +++ b/thousandeyes-sdk-endpoint-instant-tests/test/mock_manifest.py @@ -0,0 +1,499 @@ +# coding: utf-8 + +""" + Endpoint Instant Scheduled Tests API + + You can create and execute a new endpoint instant scheduled test within ThousandEyes using this API. The test parameters are specified in the `POST` data. The following applies to the Endpoint Instant Scheduled Tests API: * To initiate the creation and execution of an instant scheduled test, the user must possess the `Edit endpoint tests` permission. * Upon successful creation of an instant scheduled test, the API responds with an HTTP/201 CREATED status code and return the test definition. * It's important to note that the response does not include the results of the instant scheduled test. To retrieve test results, users can utilize the Endpoint Test Data endpoints. The URLs for these API test data endpoints are provided within the test definition output when an instant scheduled test is created. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json + +from sdk_test_support.mock_server_types import ErrorResponseExpectation, OperationExpectation + +OPERATION_MANIFEST = { + + "create_agent_to_server_scheduled_instant_test": OperationExpectation( + operation_id="create_agent_to_server_scheduled_instant_test", + method="POST", + path="/endpoint/tests/scheduled-tests/agent-to-server/instant", + path_param_examples={ + }, + success_status=201, + success_body=json.loads(""" + + { + "server" : "www.example.com", + "isSavedEvent" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/scheduled-tests/281474976710706/network/filter" + }, { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/scheduled-tests/281474976710706/pathvis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isPrioritized" : false, + "networkMeasurements" : true, + "type" : "agent-to-server", + "tcpProbeMode" : "auto", + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "protocol" : "icmp", + "createdDate" : "2022-07-17T22:00:54Z", + "ipVersion" : "V4_ONLY", + "port" : 443, + "isEnabled" : true, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "aid" : "1234", + "agentSelectorConfig" : { + "agentSelectorType" : "all-agents", + "maxMachines" : 25 + }, + "hasPathTraceInSession" : true, + "testName" : "Test name" + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "server" : "www.example.com", + "ipVersion" : "V4_ONLY", + "port" : 443, + "agentSelectorType" : "all-agents", + "tagIds" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "5aeab5d5-0d34-4d44-a7ac-fb440185295c" ], + "maxMachines" : 25, + "serverName" : "www.example.com", + "endpointAgentLabels" : [ "567", "214" ], + "agents" : [ "0a3b9998-dc3a-4ff2-b50d-ac4a7cd986e1", "66eec0f1-72b4-4755-aa83-3aed61d17f3c" ], + "testName" : "Test name" + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "create_http_server_scheduled_instant_test": OperationExpectation( + operation_id="create_http_server_scheduled_instant_test", + method="POST", + path="/endpoint/tests/scheduled-tests/http-server/instant", + path_param_examples={ + }, + success_status=201, + success_body=json.loads(""" + + { + "server" : "www.example.com", + "isSavedEvent" : false, + "sslVersion" : "Auto", + "useNtlm" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/scheduled-tests/281474976710706/network/filter" + }, { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/scheduled-tests/281474976710706/pathvis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isPrioritized" : false, + "httpTimeLimit" : 5000, + "type" : "http-server", + "protocol" : "icmp", + "httpVersion" : 2, + "followRedirects" : true, + "authType" : "none", + "testName" : "Test name", + "verifyCertificate" : true, + "networkMeasurements" : true, + "tcpProbeMode" : "auto", + "url" : "https://example.com:443", + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "ipVersion" : "V4_ONLY", + "port" : 443, + "isEnabled" : true, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "aid" : "1234", + "agentSelectorConfig" : { + "agentSelectorType" : "all-agents", + "maxMachines" : 25 + }, + "hasPathTraceInSession" : true, + "httpTargetTime" : 100, + "username" : "username", + "sslVersionId" : "0" + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "verifyCertificate" : true, + "hasPing" : true, + "agentSelectorType" : "all-agents", + "tagIds" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "5aeab5d5-0d34-4d44-a7ac-fb440185295c" ], + "maxMachines" : 25, + "httpTimeLimit" : 5000, + "networkMeasurements" : true, + "endpointAgentLabels" : [ "567", "214" ], + "tcpProbeMode" : "auto", + "url" : "https://example.com:443", + "agents" : [ "0a3b9998-dc3a-4ff2-b50d-ac4a7cd986e1", "66eec0f1-72b4-4755-aa83-3aed61d17f3c" ], + "protocol" : "icmp", + "password" : "password", + "ipVersion" : "V4_ONLY", + "hasTraceroute" : true, + "targetResponseTime" : 1000, + "authType" : "none", + "hasPathTraceInSession" : true, + "testName" : "Test name", + "username" : "username", + "sslVersionId" : "0" + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "run_endpoint_scheduled_instant_test": OperationExpectation( + operation_id="run_endpoint_scheduled_instant_test", + method="POST", + path="/endpoint/tests/scheduled-tests/{testId}/run", + path_param_examples={ + "testId": '765231567', + }, + success_status=200, + success_body=json.loads(""" + + { + "message" : "Successfully reran the instant scheduled test with testId=765231567" + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + +} diff --git a/thousandeyes-sdk-endpoint-instant-tests/test/test_agent_to_server_endpoint_instant_scheduled_tests_api_integration.py b/thousandeyes-sdk-endpoint-instant-tests/test/test_agent_to_server_endpoint_instant_scheduled_tests_api_integration.py new file mode 100644 index 00000000..9f16a4ce --- /dev/null +++ b/thousandeyes-sdk-endpoint-instant-tests/test/test_agent_to_server_endpoint_instant_scheduled_tests_api_integration.py @@ -0,0 +1,390 @@ +# coding: utf-8 + +""" + Endpoint Instant Scheduled Tests API + + You can create and execute a new endpoint instant scheduled test within ThousandEyes using this API. The test parameters are specified in the `POST` data. The following applies to the Endpoint Instant Scheduled Tests API: * To initiate the creation and execution of an instant scheduled test, the user must possess the `Edit endpoint tests` permission. * Upon successful creation of an instant scheduled test, the API responds with an HTTP/201 CREATED status code and return the test definition. * It's important to note that the response does not include the results of the instant scheduled test. To retrieve test results, users can utilize the Endpoint Test Data endpoints. The URLs for these API test data endpoints are provided within the test definition output when an instant scheduled test is created. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.endpoint_instant_tests.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.endpoint_instant_tests.api.agent_to_server_endpoint_instant_scheduled_tests_api import AgentToServerEndpointInstantScheduledTestsApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestAgentToServerEndpointInstantScheduledTestsApiIntegration(IntegrationTestBase): + """AgentToServerEndpointInstantScheduledTestsApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = AgentToServerEndpointInstantScheduledTestsApi(self.api_client) + + + def test_create_agent_to_server_scheduled_instant_test_happy_path(self) -> None: + """Integration test for create_agent_to_server_scheduled_instant_test success path""" + request_body_json = """ + + { + "server" : "www.example.com", + "ipVersion" : "V4_ONLY", + "port" : 443, + "agentSelectorType" : "all-agents", + "tagIds" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "5aeab5d5-0d34-4d44-a7ac-fb440185295c" ], + "maxMachines" : 25, + "serverName" : "www.example.com", + "endpointAgentLabels" : [ "567", "214" ], + "agents" : [ "0a3b9998-dc3a-4ff2-b50d-ac4a7cd986e1", "66eec0f1-72b4-4755-aa83-3aed61d17f3c" ], + "testName" : "Test name" + } + + """ + endpoint_agent_to_server_instant_test = thousandeyes_sdk.endpoint_instant_tests.models.EndpointAgentToServerInstantTest.from_json(request_body_json) + aid = '1234' + response_body_json = """ + { + "server" : "www.example.com", + "isSavedEvent" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/scheduled-tests/281474976710706/network/filter" + }, { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/scheduled-tests/281474976710706/pathvis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isPrioritized" : false, + "networkMeasurements" : true, + "type" : "agent-to-server", + "tcpProbeMode" : "auto", + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "protocol" : "icmp", + "createdDate" : "2022-07-17T22:00:54Z", + "ipVersion" : "V4_ONLY", + "port" : 443, + "isEnabled" : true, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "aid" : "1234", + "agentSelectorConfig" : { + "agentSelectorType" : "all-agents", + "maxMachines" : 25 + }, + "hasPathTraceInSession" : true, + "testName" : "Test name" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.create_agent_to_server_scheduled_instant_test( + + endpoint_agent_to_server_instant_test=endpoint_agent_to_server_instant_test, + + aid=aid, + + _headers=self.te_headers("create_agent_to_server_scheduled_instant_test"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_create_agent_to_server_scheduled_instant_test_error_400(self) -> None: + """Integration test for create_agent_to_server_scheduled_instant_test error path (HTTP 400)""" + request_body_json = """ + + { + "server" : "www.example.com", + "ipVersion" : "V4_ONLY", + "port" : 443, + "agentSelectorType" : "all-agents", + "tagIds" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "5aeab5d5-0d34-4d44-a7ac-fb440185295c" ], + "maxMachines" : 25, + "serverName" : "www.example.com", + "endpointAgentLabels" : [ "567", "214" ], + "agents" : [ "0a3b9998-dc3a-4ff2-b50d-ac4a7cd986e1", "66eec0f1-72b4-4755-aa83-3aed61d17f3c" ], + "testName" : "Test name" + } + + """ + endpoint_agent_to_server_instant_test = thousandeyes_sdk.endpoint_instant_tests.models.EndpointAgentToServerInstantTest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.create_agent_to_server_scheduled_instant_test( + + endpoint_agent_to_server_instant_test=endpoint_agent_to_server_instant_test, + + aid=aid, + + _headers=self.te_headers("create_agent_to_server_scheduled_instant_test", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_agent_to_server_scheduled_instant_test_error_401(self) -> None: + """Integration test for create_agent_to_server_scheduled_instant_test error path (HTTP 401)""" + request_body_json = """ + + { + "server" : "www.example.com", + "ipVersion" : "V4_ONLY", + "port" : 443, + "agentSelectorType" : "all-agents", + "tagIds" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "5aeab5d5-0d34-4d44-a7ac-fb440185295c" ], + "maxMachines" : 25, + "serverName" : "www.example.com", + "endpointAgentLabels" : [ "567", "214" ], + "agents" : [ "0a3b9998-dc3a-4ff2-b50d-ac4a7cd986e1", "66eec0f1-72b4-4755-aa83-3aed61d17f3c" ], + "testName" : "Test name" + } + + """ + endpoint_agent_to_server_instant_test = thousandeyes_sdk.endpoint_instant_tests.models.EndpointAgentToServerInstantTest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.create_agent_to_server_scheduled_instant_test( + + endpoint_agent_to_server_instant_test=endpoint_agent_to_server_instant_test, + + aid=aid, + + _headers=self.te_headers("create_agent_to_server_scheduled_instant_test", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_agent_to_server_scheduled_instant_test_error_403(self) -> None: + """Integration test for create_agent_to_server_scheduled_instant_test error path (HTTP 403)""" + request_body_json = """ + + { + "server" : "www.example.com", + "ipVersion" : "V4_ONLY", + "port" : 443, + "agentSelectorType" : "all-agents", + "tagIds" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "5aeab5d5-0d34-4d44-a7ac-fb440185295c" ], + "maxMachines" : 25, + "serverName" : "www.example.com", + "endpointAgentLabels" : [ "567", "214" ], + "agents" : [ "0a3b9998-dc3a-4ff2-b50d-ac4a7cd986e1", "66eec0f1-72b4-4755-aa83-3aed61d17f3c" ], + "testName" : "Test name" + } + + """ + endpoint_agent_to_server_instant_test = thousandeyes_sdk.endpoint_instant_tests.models.EndpointAgentToServerInstantTest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.create_agent_to_server_scheduled_instant_test( + + endpoint_agent_to_server_instant_test=endpoint_agent_to_server_instant_test, + + aid=aid, + + _headers=self.te_headers("create_agent_to_server_scheduled_instant_test", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_agent_to_server_scheduled_instant_test_error_429(self) -> None: + """Integration test for create_agent_to_server_scheduled_instant_test error path (HTTP 429)""" + request_body_json = """ + + { + "server" : "www.example.com", + "ipVersion" : "V4_ONLY", + "port" : 443, + "agentSelectorType" : "all-agents", + "tagIds" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "5aeab5d5-0d34-4d44-a7ac-fb440185295c" ], + "maxMachines" : 25, + "serverName" : "www.example.com", + "endpointAgentLabels" : [ "567", "214" ], + "agents" : [ "0a3b9998-dc3a-4ff2-b50d-ac4a7cd986e1", "66eec0f1-72b4-4755-aa83-3aed61d17f3c" ], + "testName" : "Test name" + } + + """ + endpoint_agent_to_server_instant_test = thousandeyes_sdk.endpoint_instant_tests.models.EndpointAgentToServerInstantTest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.create_agent_to_server_scheduled_instant_test( + + endpoint_agent_to_server_instant_test=endpoint_agent_to_server_instant_test, + + aid=aid, + + _headers=self.te_headers("create_agent_to_server_scheduled_instant_test", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_agent_to_server_scheduled_instant_test_error_500(self) -> None: + """Integration test for create_agent_to_server_scheduled_instant_test error path (HTTP 500)""" + request_body_json = """ + + { + "server" : "www.example.com", + "ipVersion" : "V4_ONLY", + "port" : 443, + "agentSelectorType" : "all-agents", + "tagIds" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "5aeab5d5-0d34-4d44-a7ac-fb440185295c" ], + "maxMachines" : 25, + "serverName" : "www.example.com", + "endpointAgentLabels" : [ "567", "214" ], + "agents" : [ "0a3b9998-dc3a-4ff2-b50d-ac4a7cd986e1", "66eec0f1-72b4-4755-aa83-3aed61d17f3c" ], + "testName" : "Test name" + } + + """ + endpoint_agent_to_server_instant_test = thousandeyes_sdk.endpoint_instant_tests.models.EndpointAgentToServerInstantTest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.create_agent_to_server_scheduled_instant_test( + + endpoint_agent_to_server_instant_test=endpoint_agent_to_server_instant_test, + + aid=aid, + + _headers=self.te_headers("create_agent_to_server_scheduled_instant_test", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_agent_to_server_scheduled_instant_test_error_502(self) -> None: + """Integration test for create_agent_to_server_scheduled_instant_test error path (HTTP 502)""" + request_body_json = """ + + { + "server" : "www.example.com", + "ipVersion" : "V4_ONLY", + "port" : 443, + "agentSelectorType" : "all-agents", + "tagIds" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "5aeab5d5-0d34-4d44-a7ac-fb440185295c" ], + "maxMachines" : 25, + "serverName" : "www.example.com", + "endpointAgentLabels" : [ "567", "214" ], + "agents" : [ "0a3b9998-dc3a-4ff2-b50d-ac4a7cd986e1", "66eec0f1-72b4-4755-aa83-3aed61d17f3c" ], + "testName" : "Test name" + } + + """ + endpoint_agent_to_server_instant_test = thousandeyes_sdk.endpoint_instant_tests.models.EndpointAgentToServerInstantTest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.create_agent_to_server_scheduled_instant_test( + + endpoint_agent_to_server_instant_test=endpoint_agent_to_server_instant_test, + + aid=aid, + + _headers=self.te_headers("create_agent_to_server_scheduled_instant_test", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-endpoint-instant-tests/test/test_http_server_endpoint_instant_scheduled_tests_api_integration.py b/thousandeyes-sdk-endpoint-instant-tests/test/test_http_server_endpoint_instant_scheduled_tests_api_integration.py new file mode 100644 index 00000000..5a328fba --- /dev/null +++ b/thousandeyes-sdk-endpoint-instant-tests/test/test_http_server_endpoint_instant_scheduled_tests_api_integration.py @@ -0,0 +1,478 @@ +# coding: utf-8 + +""" + Endpoint Instant Scheduled Tests API + + You can create and execute a new endpoint instant scheduled test within ThousandEyes using this API. The test parameters are specified in the `POST` data. The following applies to the Endpoint Instant Scheduled Tests API: * To initiate the creation and execution of an instant scheduled test, the user must possess the `Edit endpoint tests` permission. * Upon successful creation of an instant scheduled test, the API responds with an HTTP/201 CREATED status code and return the test definition. * It's important to note that the response does not include the results of the instant scheduled test. To retrieve test results, users can utilize the Endpoint Test Data endpoints. The URLs for these API test data endpoints are provided within the test definition output when an instant scheduled test is created. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.endpoint_instant_tests.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.endpoint_instant_tests.api.http_server_endpoint_instant_scheduled_tests_api import HTTPServerEndpointInstantScheduledTestsApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestHTTPServerEndpointInstantScheduledTestsApiIntegration(IntegrationTestBase): + """HTTPServerEndpointInstantScheduledTestsApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = HTTPServerEndpointInstantScheduledTestsApi(self.api_client) + + + def test_create_http_server_scheduled_instant_test_happy_path(self) -> None: + """Integration test for create_http_server_scheduled_instant_test success path""" + request_body_json = """ + + { + "verifyCertificate" : true, + "hasPing" : true, + "agentSelectorType" : "all-agents", + "tagIds" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "5aeab5d5-0d34-4d44-a7ac-fb440185295c" ], + "maxMachines" : 25, + "httpTimeLimit" : 5000, + "networkMeasurements" : true, + "endpointAgentLabels" : [ "567", "214" ], + "tcpProbeMode" : "auto", + "url" : "https://example.com:443", + "agents" : [ "0a3b9998-dc3a-4ff2-b50d-ac4a7cd986e1", "66eec0f1-72b4-4755-aa83-3aed61d17f3c" ], + "protocol" : "icmp", + "password" : "password", + "ipVersion" : "V4_ONLY", + "hasTraceroute" : true, + "targetResponseTime" : 1000, + "authType" : "none", + "hasPathTraceInSession" : true, + "testName" : "Test name", + "username" : "username", + "sslVersionId" : "0" + } + + """ + endpoint_http_server_instant_test = thousandeyes_sdk.endpoint_instant_tests.models.EndpointHttpServerInstantTest.from_json(request_body_json) + aid = '1234' + response_body_json = """ + { + "server" : "www.example.com", + "isSavedEvent" : false, + "sslVersion" : "Auto", + "useNtlm" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/scheduled-tests/281474976710706/network/filter" + }, { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/scheduled-tests/281474976710706/pathvis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isPrioritized" : false, + "httpTimeLimit" : 5000, + "type" : "http-server", + "protocol" : "icmp", + "httpVersion" : 2, + "followRedirects" : true, + "authType" : "none", + "testName" : "Test name", + "verifyCertificate" : true, + "networkMeasurements" : true, + "tcpProbeMode" : "auto", + "url" : "https://example.com:443", + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "ipVersion" : "V4_ONLY", + "port" : 443, + "isEnabled" : true, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "aid" : "1234", + "agentSelectorConfig" : { + "agentSelectorType" : "all-agents", + "maxMachines" : 25 + }, + "hasPathTraceInSession" : true, + "httpTargetTime" : 100, + "username" : "username", + "sslVersionId" : "0" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.create_http_server_scheduled_instant_test( + + endpoint_http_server_instant_test=endpoint_http_server_instant_test, + + aid=aid, + + _headers=self.te_headers("create_http_server_scheduled_instant_test"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_create_http_server_scheduled_instant_test_error_400(self) -> None: + """Integration test for create_http_server_scheduled_instant_test error path (HTTP 400)""" + request_body_json = """ + + { + "verifyCertificate" : true, + "hasPing" : true, + "agentSelectorType" : "all-agents", + "tagIds" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "5aeab5d5-0d34-4d44-a7ac-fb440185295c" ], + "maxMachines" : 25, + "httpTimeLimit" : 5000, + "networkMeasurements" : true, + "endpointAgentLabels" : [ "567", "214" ], + "tcpProbeMode" : "auto", + "url" : "https://example.com:443", + "agents" : [ "0a3b9998-dc3a-4ff2-b50d-ac4a7cd986e1", "66eec0f1-72b4-4755-aa83-3aed61d17f3c" ], + "protocol" : "icmp", + "password" : "password", + "ipVersion" : "V4_ONLY", + "hasTraceroute" : true, + "targetResponseTime" : 1000, + "authType" : "none", + "hasPathTraceInSession" : true, + "testName" : "Test name", + "username" : "username", + "sslVersionId" : "0" + } + + """ + endpoint_http_server_instant_test = thousandeyes_sdk.endpoint_instant_tests.models.EndpointHttpServerInstantTest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.create_http_server_scheduled_instant_test( + + endpoint_http_server_instant_test=endpoint_http_server_instant_test, + + aid=aid, + + _headers=self.te_headers("create_http_server_scheduled_instant_test", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_http_server_scheduled_instant_test_error_401(self) -> None: + """Integration test for create_http_server_scheduled_instant_test error path (HTTP 401)""" + request_body_json = """ + + { + "verifyCertificate" : true, + "hasPing" : true, + "agentSelectorType" : "all-agents", + "tagIds" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "5aeab5d5-0d34-4d44-a7ac-fb440185295c" ], + "maxMachines" : 25, + "httpTimeLimit" : 5000, + "networkMeasurements" : true, + "endpointAgentLabels" : [ "567", "214" ], + "tcpProbeMode" : "auto", + "url" : "https://example.com:443", + "agents" : [ "0a3b9998-dc3a-4ff2-b50d-ac4a7cd986e1", "66eec0f1-72b4-4755-aa83-3aed61d17f3c" ], + "protocol" : "icmp", + "password" : "password", + "ipVersion" : "V4_ONLY", + "hasTraceroute" : true, + "targetResponseTime" : 1000, + "authType" : "none", + "hasPathTraceInSession" : true, + "testName" : "Test name", + "username" : "username", + "sslVersionId" : "0" + } + + """ + endpoint_http_server_instant_test = thousandeyes_sdk.endpoint_instant_tests.models.EndpointHttpServerInstantTest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.create_http_server_scheduled_instant_test( + + endpoint_http_server_instant_test=endpoint_http_server_instant_test, + + aid=aid, + + _headers=self.te_headers("create_http_server_scheduled_instant_test", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_http_server_scheduled_instant_test_error_403(self) -> None: + """Integration test for create_http_server_scheduled_instant_test error path (HTTP 403)""" + request_body_json = """ + + { + "verifyCertificate" : true, + "hasPing" : true, + "agentSelectorType" : "all-agents", + "tagIds" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "5aeab5d5-0d34-4d44-a7ac-fb440185295c" ], + "maxMachines" : 25, + "httpTimeLimit" : 5000, + "networkMeasurements" : true, + "endpointAgentLabels" : [ "567", "214" ], + "tcpProbeMode" : "auto", + "url" : "https://example.com:443", + "agents" : [ "0a3b9998-dc3a-4ff2-b50d-ac4a7cd986e1", "66eec0f1-72b4-4755-aa83-3aed61d17f3c" ], + "protocol" : "icmp", + "password" : "password", + "ipVersion" : "V4_ONLY", + "hasTraceroute" : true, + "targetResponseTime" : 1000, + "authType" : "none", + "hasPathTraceInSession" : true, + "testName" : "Test name", + "username" : "username", + "sslVersionId" : "0" + } + + """ + endpoint_http_server_instant_test = thousandeyes_sdk.endpoint_instant_tests.models.EndpointHttpServerInstantTest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.create_http_server_scheduled_instant_test( + + endpoint_http_server_instant_test=endpoint_http_server_instant_test, + + aid=aid, + + _headers=self.te_headers("create_http_server_scheduled_instant_test", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_http_server_scheduled_instant_test_error_429(self) -> None: + """Integration test for create_http_server_scheduled_instant_test error path (HTTP 429)""" + request_body_json = """ + + { + "verifyCertificate" : true, + "hasPing" : true, + "agentSelectorType" : "all-agents", + "tagIds" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "5aeab5d5-0d34-4d44-a7ac-fb440185295c" ], + "maxMachines" : 25, + "httpTimeLimit" : 5000, + "networkMeasurements" : true, + "endpointAgentLabels" : [ "567", "214" ], + "tcpProbeMode" : "auto", + "url" : "https://example.com:443", + "agents" : [ "0a3b9998-dc3a-4ff2-b50d-ac4a7cd986e1", "66eec0f1-72b4-4755-aa83-3aed61d17f3c" ], + "protocol" : "icmp", + "password" : "password", + "ipVersion" : "V4_ONLY", + "hasTraceroute" : true, + "targetResponseTime" : 1000, + "authType" : "none", + "hasPathTraceInSession" : true, + "testName" : "Test name", + "username" : "username", + "sslVersionId" : "0" + } + + """ + endpoint_http_server_instant_test = thousandeyes_sdk.endpoint_instant_tests.models.EndpointHttpServerInstantTest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.create_http_server_scheduled_instant_test( + + endpoint_http_server_instant_test=endpoint_http_server_instant_test, + + aid=aid, + + _headers=self.te_headers("create_http_server_scheduled_instant_test", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_http_server_scheduled_instant_test_error_500(self) -> None: + """Integration test for create_http_server_scheduled_instant_test error path (HTTP 500)""" + request_body_json = """ + + { + "verifyCertificate" : true, + "hasPing" : true, + "agentSelectorType" : "all-agents", + "tagIds" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "5aeab5d5-0d34-4d44-a7ac-fb440185295c" ], + "maxMachines" : 25, + "httpTimeLimit" : 5000, + "networkMeasurements" : true, + "endpointAgentLabels" : [ "567", "214" ], + "tcpProbeMode" : "auto", + "url" : "https://example.com:443", + "agents" : [ "0a3b9998-dc3a-4ff2-b50d-ac4a7cd986e1", "66eec0f1-72b4-4755-aa83-3aed61d17f3c" ], + "protocol" : "icmp", + "password" : "password", + "ipVersion" : "V4_ONLY", + "hasTraceroute" : true, + "targetResponseTime" : 1000, + "authType" : "none", + "hasPathTraceInSession" : true, + "testName" : "Test name", + "username" : "username", + "sslVersionId" : "0" + } + + """ + endpoint_http_server_instant_test = thousandeyes_sdk.endpoint_instant_tests.models.EndpointHttpServerInstantTest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.create_http_server_scheduled_instant_test( + + endpoint_http_server_instant_test=endpoint_http_server_instant_test, + + aid=aid, + + _headers=self.te_headers("create_http_server_scheduled_instant_test", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_http_server_scheduled_instant_test_error_502(self) -> None: + """Integration test for create_http_server_scheduled_instant_test error path (HTTP 502)""" + request_body_json = """ + + { + "verifyCertificate" : true, + "hasPing" : true, + "agentSelectorType" : "all-agents", + "tagIds" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "5aeab5d5-0d34-4d44-a7ac-fb440185295c" ], + "maxMachines" : 25, + "httpTimeLimit" : 5000, + "networkMeasurements" : true, + "endpointAgentLabels" : [ "567", "214" ], + "tcpProbeMode" : "auto", + "url" : "https://example.com:443", + "agents" : [ "0a3b9998-dc3a-4ff2-b50d-ac4a7cd986e1", "66eec0f1-72b4-4755-aa83-3aed61d17f3c" ], + "protocol" : "icmp", + "password" : "password", + "ipVersion" : "V4_ONLY", + "hasTraceroute" : true, + "targetResponseTime" : 1000, + "authType" : "none", + "hasPathTraceInSession" : true, + "testName" : "Test name", + "username" : "username", + "sslVersionId" : "0" + } + + """ + endpoint_http_server_instant_test = thousandeyes_sdk.endpoint_instant_tests.models.EndpointHttpServerInstantTest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.create_http_server_scheduled_instant_test( + + endpoint_http_server_instant_test=endpoint_http_server_instant_test, + + aid=aid, + + _headers=self.te_headers("create_http_server_scheduled_instant_test", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-endpoint-instant-tests/test/test_run_endpoint_instant_scheduled_tests_api_integration.py b/thousandeyes-sdk-endpoint-instant-tests/test/test_run_endpoint_instant_scheduled_tests_api_integration.py new file mode 100644 index 00000000..afb8fb88 --- /dev/null +++ b/thousandeyes-sdk-endpoint-instant-tests/test/test_run_endpoint_instant_scheduled_tests_api_integration.py @@ -0,0 +1,260 @@ +# coding: utf-8 + +""" + Endpoint Instant Scheduled Tests API + + You can create and execute a new endpoint instant scheduled test within ThousandEyes using this API. The test parameters are specified in the `POST` data. The following applies to the Endpoint Instant Scheduled Tests API: * To initiate the creation and execution of an instant scheduled test, the user must possess the `Edit endpoint tests` permission. * Upon successful creation of an instant scheduled test, the API responds with an HTTP/201 CREATED status code and return the test definition. * It's important to note that the response does not include the results of the instant scheduled test. To retrieve test results, users can utilize the Endpoint Test Data endpoints. The URLs for these API test data endpoints are provided within the test definition output when an instant scheduled test is created. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.endpoint_instant_tests.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.endpoint_instant_tests.api.run_endpoint_instant_scheduled_tests_api import RunEndpointInstantScheduledTestsApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestRunEndpointInstantScheduledTestsApiIntegration(IntegrationTestBase): + """RunEndpointInstantScheduledTestsApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = RunEndpointInstantScheduledTestsApi(self.api_client) + + + def test_run_endpoint_scheduled_instant_test_happy_path(self) -> None: + """Integration test for run_endpoint_scheduled_instant_test success path""" + test_id = '765231567' + aid = '1234' + response_body_json = """ + { + "message" : "Successfully reran the instant scheduled test with testId=765231567" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.run_endpoint_scheduled_instant_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("run_endpoint_scheduled_instant_test"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_run_endpoint_scheduled_instant_test_error_400(self) -> None: + """Integration test for run_endpoint_scheduled_instant_test error path (HTTP 400)""" + test_id = '765231567' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.run_endpoint_scheduled_instant_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("run_endpoint_scheduled_instant_test", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_run_endpoint_scheduled_instant_test_error_401(self) -> None: + """Integration test for run_endpoint_scheduled_instant_test error path (HTTP 401)""" + test_id = '765231567' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.run_endpoint_scheduled_instant_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("run_endpoint_scheduled_instant_test", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_run_endpoint_scheduled_instant_test_error_403(self) -> None: + """Integration test for run_endpoint_scheduled_instant_test error path (HTTP 403)""" + test_id = '765231567' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.run_endpoint_scheduled_instant_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("run_endpoint_scheduled_instant_test", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_run_endpoint_scheduled_instant_test_error_404(self) -> None: + """Integration test for run_endpoint_scheduled_instant_test error path (HTTP 404)""" + test_id = '765231567' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.run_endpoint_scheduled_instant_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("run_endpoint_scheduled_instant_test", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_run_endpoint_scheduled_instant_test_error_429(self) -> None: + """Integration test for run_endpoint_scheduled_instant_test error path (HTTP 429)""" + test_id = '765231567' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.run_endpoint_scheduled_instant_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("run_endpoint_scheduled_instant_test", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_run_endpoint_scheduled_instant_test_error_500(self) -> None: + """Integration test for run_endpoint_scheduled_instant_test error path (HTTP 500)""" + test_id = '765231567' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.run_endpoint_scheduled_instant_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("run_endpoint_scheduled_instant_test", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_run_endpoint_scheduled_instant_test_error_502(self) -> None: + """Integration test for run_endpoint_scheduled_instant_test error path (HTTP 502)""" + test_id = '765231567' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.run_endpoint_scheduled_instant_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("run_endpoint_scheduled_instant_test", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-endpoint-instant-tests/test/test_utils.py b/thousandeyes-sdk-endpoint-instant-tests/test/test_utils.py index 930528d9..37913f62 100644 --- a/thousandeyes-sdk-endpoint-instant-tests/test/test_utils.py +++ b/thousandeyes-sdk-endpoint-instant-tests/test/test_utils.py @@ -2,15 +2,36 @@ import json import unittest +from typing import Any from pydantic import BaseModel +def _project_onto_constructed(expected: Any, constructed: Any) -> Any: + """Keep only example fields that appear in the constructed model output.""" + if isinstance(constructed, dict): + if not isinstance(expected, dict): + return expected + return { + key: _project_onto_constructed(expected.get(key), value) + for key, value in constructed.items() + } + if isinstance(constructed, list): + if not isinstance(expected, list): + return expected + return [ + _project_onto_constructed(expected[index], value) + for index, value in enumerate(constructed) + ] + return expected + + def assert_constructed_model_matches_example_json(model: BaseModel, loaded_json: dict): test_case = unittest.TestCase() test_case.maxDiff = None test_case.assertIsNotNone(model) constructed_json = json.loads(model.to_json()) - sorted_loaded_json = json.dumps(loaded_json, sort_keys=True) + projected_loaded_json = _project_onto_constructed(loaded_json, constructed_json) + sorted_loaded_json = json.dumps(projected_loaded_json, sort_keys=True) sorted_constructed_json = json.dumps(constructed_json, sort_keys=True) test_case.assertEqual(sorted_loaded_json, sorted_constructed_json) diff --git a/thousandeyes-sdk-endpoint-labels/test/conftest.py b/thousandeyes-sdk-endpoint-labels/test/conftest.py new file mode 100644 index 00000000..2edba7b3 --- /dev/null +++ b/thousandeyes-sdk-endpoint-labels/test/conftest.py @@ -0,0 +1,7 @@ +import sys +from pathlib import Path + +_repo_root = Path(__file__).resolve().parents[2] +_core_test_support = _repo_root / "thousandeyes-sdk-core" / "test" +if str(_core_test_support) not in sys.path: + sys.path.insert(0, str(_core_test_support)) diff --git a/thousandeyes-sdk-endpoint-labels/test/integration_test_utils.py b/thousandeyes-sdk-endpoint-labels/test/integration_test_utils.py new file mode 100644 index 00000000..19d6418c --- /dev/null +++ b/thousandeyes-sdk-endpoint-labels/test/integration_test_utils.py @@ -0,0 +1,37 @@ +# coding: utf-8 + +""" + Endpoint Agent Labels API + + Manage labels applied to endpoint agents using this API. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from thousandeyes_sdk.core.api_client import ApiClient +from thousandeyes_sdk.core.configuration import Configuration +from sdk_test_support.mock_server import ERROR_STATUS_HEADER, OPERATION_ID_HEADER, MockApiServer + +from .mock_manifest import OPERATION_MANIFEST + + +class IntegrationTestBase(unittest.TestCase): + def setUp(self) -> None: + self.server = MockApiServer(OPERATION_MANIFEST) + self.server.start() + configuration = Configuration(host=self.server.base_url, access_token="test-token") + self.api_client = ApiClient(configuration=configuration) + + def tearDown(self) -> None: + self.server.stop() + + def te_headers(self, operation_id: str, error_status=None): + headers = {OPERATION_ID_HEADER: operation_id} + if error_status is not None: + headers[ERROR_STATUS_HEADER] = error_status + return headers diff --git a/thousandeyes-sdk-endpoint-labels/test/mock_manifest.py b/thousandeyes-sdk-endpoint-labels/test/mock_manifest.py new file mode 100644 index 00000000..0174c17a --- /dev/null +++ b/thousandeyes-sdk-endpoint-labels/test/mock_manifest.py @@ -0,0 +1,575 @@ +# coding: utf-8 + +""" + Endpoint Agent Labels API + + Manage labels applied to endpoint agents using this API. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json + +from sdk_test_support.mock_server_types import ErrorResponseExpectation, OperationExpectation + +OPERATION_MANIFEST = { + + "create_endpoint_label": OperationExpectation( + operation_id="create_endpoint_label", + method="POST", + path="/endpoint/labels", + path_param_examples={ + }, + success_status=201, + success_body=json.loads(""" + + { + "color" : "#ff3333", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "matchType" : "and", + "name" : "Head office meeting rooms", + "id" : "abc-123-def", + "filters" : [ { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "key" : "vpn-client-network" + }, { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "key" : "vpn-client-network" + } ] + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "color" : "#ff3333", + "matchType" : "and", + "name" : "Head office meeting rooms", + "id" : "abc-123-def", + "filters" : [ { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "key" : "vpn-client-network" + }, { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "key" : "vpn-client-network" + } ] + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "delete_endpoint_label": OperationExpectation( + operation_id="delete_endpoint_label", + method="DELETE", + path="/endpoint/labels/{id}", + path_param_examples={ + "id": 'id_example', + }, + success_status=204, + success_body=None, + success_content_type="application/json", + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_endpoint_label": OperationExpectation( + operation_id="get_endpoint_label", + method="GET", + path="/endpoint/labels/{id}", + path_param_examples={ + "id": 'id_example', + }, + success_status=200, + success_body=json.loads(""" + + { + "color" : "#ff3333", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "matchType" : "and", + "name" : "Head office meeting rooms", + "id" : "abc-123-def", + "filters" : [ { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "key" : "vpn-client-network" + }, { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "key" : "vpn-client-network" + } ] + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_endpoint_labels": OperationExpectation( + operation_id="get_endpoint_labels", + method="GET", + path="/endpoint/labels", + path_param_examples={ + }, + success_status=200, + success_body=json.loads(""" + + { + "_links" : { + "next" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "labels" : [ { + "color" : "#ff3333", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "matchType" : "and", + "name" : "Head office meeting rooms", + "id" : "abc-123-def", + "filters" : [ { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "key" : "vpn-client-network" + }, { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "key" : "vpn-client-network" + } ] + }, { + "color" : "#ff3333", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "matchType" : "and", + "name" : "Head office meeting rooms", + "id" : "abc-123-def", + "filters" : [ { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "key" : "vpn-client-network" + }, { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "key" : "vpn-client-network" + } ] + } ] + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "update_endpoint_label": OperationExpectation( + operation_id="update_endpoint_label", + method="PATCH", + path="/endpoint/labels/{id}", + path_param_examples={ + "id": 'id_example', + }, + success_status=200, + success_body=json.loads(""" + + { + "color" : "#ff3333", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "matchType" : "and", + "name" : "Head office meeting rooms", + "id" : "abc-123-def", + "filters" : [ { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "key" : "vpn-client-network" + }, { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "key" : "vpn-client-network" + } ] + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "color" : "#ff3333", + "matchType" : "and", + "name" : "Head office meeting rooms", + "id" : "abc-123-def", + "filters" : [ { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "key" : "vpn-client-network" + }, { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "key" : "vpn-client-network" + } ] + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + +} diff --git a/thousandeyes-sdk-endpoint-labels/test/test_endpoint_agent_labels_api_integration.py b/thousandeyes-sdk-endpoint-labels/test/test_endpoint_agent_labels_api_integration.py new file mode 100644 index 00000000..ed40b1b1 --- /dev/null +++ b/thousandeyes-sdk-endpoint-labels/test/test_endpoint_agent_labels_api_integration.py @@ -0,0 +1,1093 @@ +# coding: utf-8 + +""" + Endpoint Agent Labels API + + Manage labels applied to endpoint agents using this API. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.endpoint_labels.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.endpoint_labels.api.endpoint_agent_labels_api import EndpointAgentLabelsApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestEndpointAgentLabelsApiIntegration(IntegrationTestBase): + """EndpointAgentLabelsApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = EndpointAgentLabelsApi(self.api_client) + + + def test_create_endpoint_label_happy_path(self) -> None: + """Integration test for create_endpoint_label success path""" + request_body_json = """ + + { + "color" : "#ff3333", + "matchType" : "and", + "name" : "Head office meeting rooms", + "id" : "abc-123-def", + "filters" : [ { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "key" : "vpn-client-network" + }, { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "key" : "vpn-client-network" + } ] + } + + """ + label_request = thousandeyes_sdk.endpoint_labels.models.LabelRequest.from_json(request_body_json) + aid = '1234' + response_body_json = """ + { + "color" : "#ff3333", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "matchType" : "and", + "name" : "Head office meeting rooms", + "id" : "abc-123-def", + "filters" : [ { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "key" : "vpn-client-network" + }, { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "key" : "vpn-client-network" + } ] + } + """ + expected_response = json.loads(response_body_json) + response = self.api.create_endpoint_label( + + aid=aid, + + label_request=label_request, + + _headers=self.te_headers("create_endpoint_label"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_create_endpoint_label_error_400(self) -> None: + """Integration test for create_endpoint_label error path (HTTP 400)""" + request_body_json = """ + + { + "color" : "#ff3333", + "matchType" : "and", + "name" : "Head office meeting rooms", + "id" : "abc-123-def", + "filters" : [ { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "key" : "vpn-client-network" + }, { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "key" : "vpn-client-network" + } ] + } + + """ + label_request = thousandeyes_sdk.endpoint_labels.models.LabelRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.create_endpoint_label( + + aid=aid, + + label_request=label_request, + + _headers=self.te_headers("create_endpoint_label", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_endpoint_label_error_401(self) -> None: + """Integration test for create_endpoint_label error path (HTTP 401)""" + request_body_json = """ + + { + "color" : "#ff3333", + "matchType" : "and", + "name" : "Head office meeting rooms", + "id" : "abc-123-def", + "filters" : [ { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "key" : "vpn-client-network" + }, { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "key" : "vpn-client-network" + } ] + } + + """ + label_request = thousandeyes_sdk.endpoint_labels.models.LabelRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.create_endpoint_label( + + aid=aid, + + label_request=label_request, + + _headers=self.te_headers("create_endpoint_label", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_endpoint_label_error_403(self) -> None: + """Integration test for create_endpoint_label error path (HTTP 403)""" + request_body_json = """ + + { + "color" : "#ff3333", + "matchType" : "and", + "name" : "Head office meeting rooms", + "id" : "abc-123-def", + "filters" : [ { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "key" : "vpn-client-network" + }, { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "key" : "vpn-client-network" + } ] + } + + """ + label_request = thousandeyes_sdk.endpoint_labels.models.LabelRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.create_endpoint_label( + + aid=aid, + + label_request=label_request, + + _headers=self.te_headers("create_endpoint_label", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_endpoint_label_error_429(self) -> None: + """Integration test for create_endpoint_label error path (HTTP 429)""" + request_body_json = """ + + { + "color" : "#ff3333", + "matchType" : "and", + "name" : "Head office meeting rooms", + "id" : "abc-123-def", + "filters" : [ { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "key" : "vpn-client-network" + }, { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "key" : "vpn-client-network" + } ] + } + + """ + label_request = thousandeyes_sdk.endpoint_labels.models.LabelRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.create_endpoint_label( + + aid=aid, + + label_request=label_request, + + _headers=self.te_headers("create_endpoint_label", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_delete_endpoint_label_happy_path(self) -> None: + """Integration test for delete_endpoint_label success path""" + id = 'id_example' + aid = '1234' + response = self.api.delete_endpoint_label_with_http_info( + + id=id, + + aid=aid, + + _headers=self.te_headers("delete_endpoint_label"), + ) + self.assertEqual(204, response.status_code) + self.assertIsNone(response.data) + + + def test_delete_endpoint_label_error_401(self) -> None: + """Integration test for delete_endpoint_label error path (HTTP 401)""" + id = 'id_example' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.delete_endpoint_label( + + id=id, + + aid=aid, + + _headers=self.te_headers("delete_endpoint_label", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_endpoint_label_error_403(self) -> None: + """Integration test for delete_endpoint_label error path (HTTP 403)""" + id = 'id_example' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.delete_endpoint_label( + + id=id, + + aid=aid, + + _headers=self.te_headers("delete_endpoint_label", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_endpoint_label_error_404(self) -> None: + """Integration test for delete_endpoint_label error path (HTTP 404)""" + id = 'id_example' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.delete_endpoint_label( + + id=id, + + aid=aid, + + _headers=self.te_headers("delete_endpoint_label", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_endpoint_label_error_429(self) -> None: + """Integration test for delete_endpoint_label error path (HTTP 429)""" + id = 'id_example' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.delete_endpoint_label( + + id=id, + + aid=aid, + + _headers=self.te_headers("delete_endpoint_label", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_endpoint_label_happy_path(self) -> None: + """Integration test for get_endpoint_label success path""" + id = 'id_example' + aid = '1234' + response_body_json = """ + { + "color" : "#ff3333", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "matchType" : "and", + "name" : "Head office meeting rooms", + "id" : "abc-123-def", + "filters" : [ { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "key" : "vpn-client-network" + }, { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "key" : "vpn-client-network" + } ] + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_endpoint_label( + + id=id, + + aid=aid, + + _headers=self.te_headers("get_endpoint_label"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_endpoint_label_error_401(self) -> None: + """Integration test for get_endpoint_label error path (HTTP 401)""" + id = 'id_example' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_endpoint_label( + + id=id, + + aid=aid, + + _headers=self.te_headers("get_endpoint_label", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_endpoint_label_error_403(self) -> None: + """Integration test for get_endpoint_label error path (HTTP 403)""" + id = 'id_example' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_endpoint_label( + + id=id, + + aid=aid, + + _headers=self.te_headers("get_endpoint_label", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_endpoint_label_error_404(self) -> None: + """Integration test for get_endpoint_label error path (HTTP 404)""" + id = 'id_example' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_endpoint_label( + + id=id, + + aid=aid, + + _headers=self.te_headers("get_endpoint_label", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_endpoint_label_error_429(self) -> None: + """Integration test for get_endpoint_label error path (HTTP 429)""" + id = 'id_example' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_endpoint_label( + + id=id, + + aid=aid, + + _headers=self.te_headers("get_endpoint_label", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_endpoint_labels_happy_path(self) -> None: + """Integration test for get_endpoint_labels success path""" + max = 5 + cursor = 'cursor_example' + aid = '1234' + response_body_json = """ + { + "_links" : { + "next" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "labels" : [ { + "color" : "#ff3333", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "matchType" : "and", + "name" : "Head office meeting rooms", + "id" : "abc-123-def", + "filters" : [ { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "key" : "vpn-client-network" + }, { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "key" : "vpn-client-network" + } ] + }, { + "color" : "#ff3333", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "matchType" : "and", + "name" : "Head office meeting rooms", + "id" : "abc-123-def", + "filters" : [ { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "key" : "vpn-client-network" + }, { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "key" : "vpn-client-network" + } ] + } ] + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_endpoint_labels( + + max=max, + + cursor=cursor, + + aid=aid, + + _headers=self.te_headers("get_endpoint_labels"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_endpoint_labels_error_401(self) -> None: + """Integration test for get_endpoint_labels error path (HTTP 401)""" + max = 5 + cursor = 'cursor_example' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_endpoint_labels( + + max=max, + + cursor=cursor, + + aid=aid, + + _headers=self.te_headers("get_endpoint_labels", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_endpoint_labels_error_403(self) -> None: + """Integration test for get_endpoint_labels error path (HTTP 403)""" + max = 5 + cursor = 'cursor_example' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_endpoint_labels( + + max=max, + + cursor=cursor, + + aid=aid, + + _headers=self.te_headers("get_endpoint_labels", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_endpoint_labels_error_429(self) -> None: + """Integration test for get_endpoint_labels error path (HTTP 429)""" + max = 5 + cursor = 'cursor_example' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_endpoint_labels( + + max=max, + + cursor=cursor, + + aid=aid, + + _headers=self.te_headers("get_endpoint_labels", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_update_endpoint_label_happy_path(self) -> None: + """Integration test for update_endpoint_label success path""" + request_body_json = """ + + { + "color" : "#ff3333", + "matchType" : "and", + "name" : "Head office meeting rooms", + "id" : "abc-123-def", + "filters" : [ { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "key" : "vpn-client-network" + }, { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "key" : "vpn-client-network" + } ] + } + + """ + label = thousandeyes_sdk.endpoint_labels.models.Label.from_json(request_body_json) + id = 'id_example' + aid = '1234' + response_body_json = """ + { + "color" : "#ff3333", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "matchType" : "and", + "name" : "Head office meeting rooms", + "id" : "abc-123-def", + "filters" : [ { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "key" : "vpn-client-network" + }, { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "key" : "vpn-client-network" + } ] + } + """ + expected_response = json.loads(response_body_json) + response = self.api.update_endpoint_label( + + id=id, + + aid=aid, + + label=label, + + _headers=self.te_headers("update_endpoint_label"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_update_endpoint_label_error_400(self) -> None: + """Integration test for update_endpoint_label error path (HTTP 400)""" + request_body_json = """ + + { + "color" : "#ff3333", + "matchType" : "and", + "name" : "Head office meeting rooms", + "id" : "abc-123-def", + "filters" : [ { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "key" : "vpn-client-network" + }, { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "key" : "vpn-client-network" + } ] + } + + """ + label = thousandeyes_sdk.endpoint_labels.models.Label.from_json(request_body_json) + id = 'id_example' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.update_endpoint_label( + + id=id, + + aid=aid, + + label=label, + + _headers=self.te_headers("update_endpoint_label", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_endpoint_label_error_401(self) -> None: + """Integration test for update_endpoint_label error path (HTTP 401)""" + request_body_json = """ + + { + "color" : "#ff3333", + "matchType" : "and", + "name" : "Head office meeting rooms", + "id" : "abc-123-def", + "filters" : [ { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "key" : "vpn-client-network" + }, { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "key" : "vpn-client-network" + } ] + } + + """ + label = thousandeyes_sdk.endpoint_labels.models.Label.from_json(request_body_json) + id = 'id_example' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.update_endpoint_label( + + id=id, + + aid=aid, + + label=label, + + _headers=self.te_headers("update_endpoint_label", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_endpoint_label_error_403(self) -> None: + """Integration test for update_endpoint_label error path (HTTP 403)""" + request_body_json = """ + + { + "color" : "#ff3333", + "matchType" : "and", + "name" : "Head office meeting rooms", + "id" : "abc-123-def", + "filters" : [ { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "key" : "vpn-client-network" + }, { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "key" : "vpn-client-network" + } ] + } + + """ + label = thousandeyes_sdk.endpoint_labels.models.Label.from_json(request_body_json) + id = 'id_example' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.update_endpoint_label( + + id=id, + + aid=aid, + + label=label, + + _headers=self.te_headers("update_endpoint_label", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_endpoint_label_error_404(self) -> None: + """Integration test for update_endpoint_label error path (HTTP 404)""" + request_body_json = """ + + { + "color" : "#ff3333", + "matchType" : "and", + "name" : "Head office meeting rooms", + "id" : "abc-123-def", + "filters" : [ { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "key" : "vpn-client-network" + }, { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "key" : "vpn-client-network" + } ] + } + + """ + label = thousandeyes_sdk.endpoint_labels.models.Label.from_json(request_body_json) + id = 'id_example' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.update_endpoint_label( + + id=id, + + aid=aid, + + label=label, + + _headers=self.te_headers("update_endpoint_label", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_endpoint_label_error_429(self) -> None: + """Integration test for update_endpoint_label error path (HTTP 429)""" + request_body_json = """ + + { + "color" : "#ff3333", + "matchType" : "and", + "name" : "Head office meeting rooms", + "id" : "abc-123-def", + "filters" : [ { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "key" : "vpn-client-network" + }, { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "key" : "vpn-client-network" + } ] + } + + """ + label = thousandeyes_sdk.endpoint_labels.models.Label.from_json(request_body_json) + id = 'id_example' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.update_endpoint_label( + + id=id, + + aid=aid, + + label=label, + + _headers=self.te_headers("update_endpoint_label", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-endpoint-labels/test/test_utils.py b/thousandeyes-sdk-endpoint-labels/test/test_utils.py index 930528d9..37913f62 100644 --- a/thousandeyes-sdk-endpoint-labels/test/test_utils.py +++ b/thousandeyes-sdk-endpoint-labels/test/test_utils.py @@ -2,15 +2,36 @@ import json import unittest +from typing import Any from pydantic import BaseModel +def _project_onto_constructed(expected: Any, constructed: Any) -> Any: + """Keep only example fields that appear in the constructed model output.""" + if isinstance(constructed, dict): + if not isinstance(expected, dict): + return expected + return { + key: _project_onto_constructed(expected.get(key), value) + for key, value in constructed.items() + } + if isinstance(constructed, list): + if not isinstance(expected, list): + return expected + return [ + _project_onto_constructed(expected[index], value) + for index, value in enumerate(constructed) + ] + return expected + + def assert_constructed_model_matches_example_json(model: BaseModel, loaded_json: dict): test_case = unittest.TestCase() test_case.maxDiff = None test_case.assertIsNotNone(model) constructed_json = json.loads(model.to_json()) - sorted_loaded_json = json.dumps(loaded_json, sort_keys=True) + projected_loaded_json = _project_onto_constructed(loaded_json, constructed_json) + sorted_loaded_json = json.dumps(projected_loaded_json, sort_keys=True) sorted_constructed_json = json.dumps(constructed_json, sort_keys=True) test_case.assertEqual(sorted_loaded_json, sorted_constructed_json) diff --git a/thousandeyes-sdk-endpoint-test-results/test/conftest.py b/thousandeyes-sdk-endpoint-test-results/test/conftest.py new file mode 100644 index 00000000..2edba7b3 --- /dev/null +++ b/thousandeyes-sdk-endpoint-test-results/test/conftest.py @@ -0,0 +1,7 @@ +import sys +from pathlib import Path + +_repo_root = Path(__file__).resolve().parents[2] +_core_test_support = _repo_root / "thousandeyes-sdk-core" / "test" +if str(_core_test_support) not in sys.path: + sys.path.insert(0, str(_core_test_support)) diff --git a/thousandeyes-sdk-endpoint-test-results/test/integration_test_utils.py b/thousandeyes-sdk-endpoint-test-results/test/integration_test_utils.py new file mode 100644 index 00000000..5565044a --- /dev/null +++ b/thousandeyes-sdk-endpoint-test-results/test/integration_test_utils.py @@ -0,0 +1,37 @@ +# coding: utf-8 + +""" + Endpoint Test Results API + + Retrieve results for scheduled and dynamic tests on endpoint agents. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from thousandeyes_sdk.core.api_client import ApiClient +from thousandeyes_sdk.core.configuration import Configuration +from sdk_test_support.mock_server import ERROR_STATUS_HEADER, OPERATION_ID_HEADER, MockApiServer + +from .mock_manifest import OPERATION_MANIFEST + + +class IntegrationTestBase(unittest.TestCase): + def setUp(self) -> None: + self.server = MockApiServer(OPERATION_MANIFEST) + self.server.start() + configuration = Configuration(host=self.server.base_url, access_token="test-token") + self.api_client = ApiClient(configuration=configuration) + + def tearDown(self) -> None: + self.server.stop() + + def te_headers(self, operation_id: str, error_status=None): + headers = {OPERATION_ID_HEADER: operation_id} + if error_status is not None: + headers[ERROR_STATUS_HEADER] = error_status + return headers diff --git a/thousandeyes-sdk-endpoint-test-results/test/mock_manifest.py b/thousandeyes-sdk-endpoint-test-results/test/mock_manifest.py new file mode 100644 index 00000000..e8e13b7f --- /dev/null +++ b/thousandeyes-sdk-endpoint-test-results/test/mock_manifest.py @@ -0,0 +1,7512 @@ +# coding: utf-8 + +""" + Endpoint Test Results API + + Retrieve results for scheduled and dynamic tests on endpoint agents. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json + +from sdk_test_support.mock_server_types import ErrorResponseExpectation, OperationExpectation + +OPERATION_MANIFEST = { + + "get_http_server_scheduled_test_results": OperationExpectation( + operation_id="get_http_server_scheduled_test_results", + method="GET", + path="/endpoint/test-results/scheduled-tests/{testId}/http-server", + path_param_examples={ + "testId": '202701', + }, + success_status=200, + success_body=json.loads(""" + + { + "test" : { + "server" : "www.example.com", + "isSavedEvent" : false, + "sslVersion" : "Auto", + "useNtlm" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/scheduled-tests/281474976710706/network/filter" + }, { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/scheduled-tests/281474976710706/pathvis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isPrioritized" : false, + "httpTimeLimit" : 5000, + "type" : "http-server", + "protocol" : "icmp", + "httpVersion" : 2, + "followRedirects" : true, + "authType" : "none", + "testName" : "Test name", + "verifyCertificate" : true, + "networkMeasurements" : true, + "tcpProbeMode" : "auto", + "url" : "https://example.com:443", + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "ipVersion" : "V4_ONLY", + "port" : 443, + "isEnabled" : true, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "aid" : "1234", + "agentSelectorConfig" : { + "agentSelectorType" : "all-agents", + "maxMachines" : 25 + }, + "hasPathTraceInSession" : true, + "httpTargetTime" : 100, + "username" : "username", + "sslVersionId" : "0" + }, + "totalHits" : 12, + "endDate" : "2022-07-18T22:00:54Z", + "_links" : { + "next" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "results" : [ { + "originalTargetProfile" : { + "protocol" : "tcp", + "remotePort" : 80, + "remoteIpAddress" : "120.98.134.7" + }, + "agentId" : "861b7557-cd57-4bbb-b648-00bddf88ef49", + "numRedirects" : 0, + "vpnProfile" : { + "vpnClientNetworkRange" : [ "9.88.37.27", "9.88.37.27" ], + "vpnGatewayAddress" : "120.98.134.7", + "vpnType" : "cisco-anyconnect", + "vpnClientAddresses" : [ "184.81.113.85", "13.129.91.62" ] + }, + "errorType" : "connect", + "batteryMetrics" : { + "batteryHealthNormalizedPercent" : 0.92, + "batteryLevel" : "medium", + "batteryLevelNormalizedPercent" : 0.3 + }, + "userProfile" : { + "userName" : "joeblogs32", + "userPrincipalName" : "joeblogs32@c.com" + }, + "platform" : "mac", + "responseCode" : 200, + "cellularProfile" : { + "rssi" : -10, + "advertisedNetworkSubtype" : "LTE/HSPA", + "carrierName" : "T-Mobile", + "rsrq" : -30, + "rsrp" : -30, + "advertisedNetworkGen" : "2g, 3g, 4g, 5g", + "rscp" : -30, + "networkGen" : "2g, 3g, 4g, 5g", + "networkSubtype" : "LTE/HSPA", + "sinr" : 20 + }, + "score" : { + "applicationScore" : 100, + "quality" : "great" + }, + "connectTime" : 2, + "networkProfile" : { + "previousInterface" : { + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "interfaceName" : "en0", + "subnetMask" : "255.255.255.0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ] + }, + "ethernetProfile" : { + "linkSpeed" : 860 + }, + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "proxyProfile" : { + "method" : "System", + "proxies" : [ { + "bypass" : "*.local;169.254/16", + "proxy" : "" + }, { + "bypass" : "*.local;169.254/16", + "proxy" : "" + } ] + }, + "subnetMask" : "255.255.255.0", + "error" : "An operation timed out.", + "wirelessProfile" : { + "rssi" : -38, + "bssid" : "4c:ba:ba:f4:fa:fa", + "snr" : 57, + "vendor" : "Cisco", + "txRate" : 130, + "channel" : 1, + "noise" : -95, + "phyMode" : "802.11n", + "ssid" : "Internet for the masses", + "quality" : 100 + }, + "interfaceName" : "en0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ], + "gateway" : "10.0.0.1" + }, + "throughput" : 190, + "roundId" : 1384309800, + "headers" : { + "requestHeaders" : "GET / HTTP/1.1\\r\\nHost: www.thousandeyes.com\\r\\nUser-Agent: curl/7.58.0-DEV\\r\\nAccept: */*\\r\\nAccept-Encoding: deflate, gzip\\r\\nX-ThousandEyes-Agent: yes\\r\\n", + "responseHeaders" : "HTTP/1.1 200 OK\\r\\nContent-Type: text/html;charset=UTF-8\\r\\nContent-Length: 9993\\r\\nConnection: keep-alive\\r\\nDate: Mon, 04 May 2020 16:13:00 GMT\\r\\nServer: Apache\\r\\nContent-Language: en-US\\r\\nContent-Encoding: gzip\\r\\nX-Frame-Options: sameorigin\\r\\nCache-Control: max-age=600, must-revalidate\\r\\nStrict-Transport-Security: max-age=31536000\\r\\nX-Content-Type-Options: nosniff\\r\\nX-XSS-Protection: 1; mode=block\\r\\nVary: Accept-Encoding\\r\\nX-Cache: Hit from cloudfront\\r\\nVia: 1.1 7ba3caf71ae7a52dd411d1a543e80cd8.cloudfront.net (CloudFront)\\r\\nX-Amz-Cf-Pop: SFO5-C3\\r\\nX-Amz-Cf-Id: w4h42tkoJD-rEpkRDZUvnQBmy26GVGe6pUsuRr1Dphf7oajYbjXaOA==\\r\\nAge: 132\\r\\n" + }, + "redirectTime" : 10, + "responseTime" : 14, + "totalTime" : 15, + "receiveTime" : 1, + "systemMetrics" : { + "cpuUtilization" : { + "min" : 0.22, + "median" : 0.61, + "max" : 0.75, + "mean" : 0.55, + "count" : 150, + "stdDev" : 0.01 + }, + "physicalMemoryTotalBytes" : 1024, + "startTimeMs" : 1581508857327, + "physicalMemoryUsedBytes" : { + "min" : 1.2, + "median" : 1.85, + "max" : 2.5, + "mean" : 1.77, + "count" : 155, + "stdDev" : 0.25 + }, + "endTimeMs" : 1581508867333 + }, + "dnsTime" : 0, + "serverIp" : "193.2.1.88", + "testId" : "584739201", + "sslTime" : 9, + "aid" : "1234", + "waitTime" : 3, + "errorDetails" : "errorDetails", + "wireSize" : 9993 + }, { + "originalTargetProfile" : { + "protocol" : "tcp", + "remotePort" : 80, + "remoteIpAddress" : "120.98.134.7" + }, + "agentId" : "861b7557-cd57-4bbb-b648-00bddf88ef49", + "numRedirects" : 0, + "vpnProfile" : { + "vpnClientNetworkRange" : [ "9.88.37.27", "9.88.37.27" ], + "vpnGatewayAddress" : "120.98.134.7", + "vpnType" : "cisco-anyconnect", + "vpnClientAddresses" : [ "184.81.113.85", "13.129.91.62" ] + }, + "errorType" : "connect", + "batteryMetrics" : { + "batteryHealthNormalizedPercent" : 0.92, + "batteryLevel" : "medium", + "batteryLevelNormalizedPercent" : 0.3 + }, + "userProfile" : { + "userName" : "joeblogs32", + "userPrincipalName" : "joeblogs32@c.com" + }, + "platform" : "mac", + "responseCode" : 200, + "cellularProfile" : { + "rssi" : -10, + "advertisedNetworkSubtype" : "LTE/HSPA", + "carrierName" : "T-Mobile", + "rsrq" : -30, + "rsrp" : -30, + "advertisedNetworkGen" : "2g, 3g, 4g, 5g", + "rscp" : -30, + "networkGen" : "2g, 3g, 4g, 5g", + "networkSubtype" : "LTE/HSPA", + "sinr" : 20 + }, + "score" : { + "applicationScore" : 100, + "quality" : "great" + }, + "connectTime" : 2, + "networkProfile" : { + "previousInterface" : { + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "interfaceName" : "en0", + "subnetMask" : "255.255.255.0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ] + }, + "ethernetProfile" : { + "linkSpeed" : 860 + }, + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "proxyProfile" : { + "method" : "System", + "proxies" : [ { + "bypass" : "*.local;169.254/16", + "proxy" : "" + }, { + "bypass" : "*.local;169.254/16", + "proxy" : "" + } ] + }, + "subnetMask" : "255.255.255.0", + "error" : "An operation timed out.", + "wirelessProfile" : { + "rssi" : -38, + "bssid" : "4c:ba:ba:f4:fa:fa", + "snr" : 57, + "vendor" : "Cisco", + "txRate" : 130, + "channel" : 1, + "noise" : -95, + "phyMode" : "802.11n", + "ssid" : "Internet for the masses", + "quality" : 100 + }, + "interfaceName" : "en0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ], + "gateway" : "10.0.0.1" + }, + "throughput" : 190, + "roundId" : 1384309800, + "headers" : { + "requestHeaders" : "GET / HTTP/1.1\\r\\nHost: www.thousandeyes.com\\r\\nUser-Agent: curl/7.58.0-DEV\\r\\nAccept: */*\\r\\nAccept-Encoding: deflate, gzip\\r\\nX-ThousandEyes-Agent: yes\\r\\n", + "responseHeaders" : "HTTP/1.1 200 OK\\r\\nContent-Type: text/html;charset=UTF-8\\r\\nContent-Length: 9993\\r\\nConnection: keep-alive\\r\\nDate: Mon, 04 May 2020 16:13:00 GMT\\r\\nServer: Apache\\r\\nContent-Language: en-US\\r\\nContent-Encoding: gzip\\r\\nX-Frame-Options: sameorigin\\r\\nCache-Control: max-age=600, must-revalidate\\r\\nStrict-Transport-Security: max-age=31536000\\r\\nX-Content-Type-Options: nosniff\\r\\nX-XSS-Protection: 1; mode=block\\r\\nVary: Accept-Encoding\\r\\nX-Cache: Hit from cloudfront\\r\\nVia: 1.1 7ba3caf71ae7a52dd411d1a543e80cd8.cloudfront.net (CloudFront)\\r\\nX-Amz-Cf-Pop: SFO5-C3\\r\\nX-Amz-Cf-Id: w4h42tkoJD-rEpkRDZUvnQBmy26GVGe6pUsuRr1Dphf7oajYbjXaOA==\\r\\nAge: 132\\r\\n" + }, + "redirectTime" : 10, + "responseTime" : 14, + "totalTime" : 15, + "receiveTime" : 1, + "systemMetrics" : { + "cpuUtilization" : { + "min" : 0.22, + "median" : 0.61, + "max" : 0.75, + "mean" : 0.55, + "count" : 150, + "stdDev" : 0.01 + }, + "physicalMemoryTotalBytes" : 1024, + "startTimeMs" : 1581508857327, + "physicalMemoryUsedBytes" : { + "min" : 1.2, + "median" : 1.85, + "max" : 2.5, + "mean" : 1.77, + "count" : 155, + "stdDev" : 0.25 + }, + "endTimeMs" : 1581508867333 + }, + "dnsTime" : 0, + "serverIp" : "193.2.1.88", + "testId" : "584739201", + "sslTime" : 9, + "aid" : "1234", + "waitTime" : 3, + "errorDetails" : "errorDetails", + "wireSize" : 9993 + } ], + "startDate" : "2022-07-17T22:00:54Z" + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_multi_test_filtered_http_server_scheduled_test_results": OperationExpectation( + operation_id="get_multi_test_filtered_http_server_scheduled_test_results", + method="POST", + path="/endpoint/test-results/scheduled-tests/http-server/filter", + path_param_examples={ + }, + success_status=200, + success_body=json.loads(""" + + { + "totalHits" : 12, + "endDate" : "2022-07-18T22:00:54Z", + "_links" : { + "next" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "results" : [ { + "originalTargetProfile" : { + "protocol" : "tcp", + "remotePort" : 80, + "remoteIpAddress" : "120.98.134.7" + }, + "agentId" : "861b7557-cd57-4bbb-b648-00bddf88ef49", + "numRedirects" : 0, + "vpnProfile" : { + "vpnClientNetworkRange" : [ "9.88.37.27", "9.88.37.27" ], + "vpnGatewayAddress" : "120.98.134.7", + "vpnType" : "cisco-anyconnect", + "vpnClientAddresses" : [ "184.81.113.85", "13.129.91.62" ] + }, + "errorType" : "connect", + "batteryMetrics" : { + "batteryHealthNormalizedPercent" : 0.92, + "batteryLevel" : "medium", + "batteryLevelNormalizedPercent" : 0.3 + }, + "userProfile" : { + "userName" : "joeblogs32", + "userPrincipalName" : "joeblogs32@c.com" + }, + "platform" : "mac", + "responseCode" : 200, + "cellularProfile" : { + "rssi" : -10, + "advertisedNetworkSubtype" : "LTE/HSPA", + "carrierName" : "T-Mobile", + "rsrq" : -30, + "rsrp" : -30, + "advertisedNetworkGen" : "2g, 3g, 4g, 5g", + "rscp" : -30, + "networkGen" : "2g, 3g, 4g, 5g", + "networkSubtype" : "LTE/HSPA", + "sinr" : 20 + }, + "score" : { + "applicationScore" : 100, + "quality" : "great" + }, + "connectTime" : 2, + "networkProfile" : { + "previousInterface" : { + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "interfaceName" : "en0", + "subnetMask" : "255.255.255.0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ] + }, + "ethernetProfile" : { + "linkSpeed" : 860 + }, + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "proxyProfile" : { + "method" : "System", + "proxies" : [ { + "bypass" : "*.local;169.254/16", + "proxy" : "" + }, { + "bypass" : "*.local;169.254/16", + "proxy" : "" + } ] + }, + "subnetMask" : "255.255.255.0", + "error" : "An operation timed out.", + "wirelessProfile" : { + "rssi" : -38, + "bssid" : "4c:ba:ba:f4:fa:fa", + "snr" : 57, + "vendor" : "Cisco", + "txRate" : 130, + "channel" : 1, + "noise" : -95, + "phyMode" : "802.11n", + "ssid" : "Internet for the masses", + "quality" : 100 + }, + "interfaceName" : "en0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ], + "gateway" : "10.0.0.1" + }, + "throughput" : 190, + "roundId" : 1384309800, + "headers" : { + "requestHeaders" : "GET / HTTP/1.1\\r\\nHost: www.thousandeyes.com\\r\\nUser-Agent: curl/7.58.0-DEV\\r\\nAccept: */*\\r\\nAccept-Encoding: deflate, gzip\\r\\nX-ThousandEyes-Agent: yes\\r\\n", + "responseHeaders" : "HTTP/1.1 200 OK\\r\\nContent-Type: text/html;charset=UTF-8\\r\\nContent-Length: 9993\\r\\nConnection: keep-alive\\r\\nDate: Mon, 04 May 2020 16:13:00 GMT\\r\\nServer: Apache\\r\\nContent-Language: en-US\\r\\nContent-Encoding: gzip\\r\\nX-Frame-Options: sameorigin\\r\\nCache-Control: max-age=600, must-revalidate\\r\\nStrict-Transport-Security: max-age=31536000\\r\\nX-Content-Type-Options: nosniff\\r\\nX-XSS-Protection: 1; mode=block\\r\\nVary: Accept-Encoding\\r\\nX-Cache: Hit from cloudfront\\r\\nVia: 1.1 7ba3caf71ae7a52dd411d1a543e80cd8.cloudfront.net (CloudFront)\\r\\nX-Amz-Cf-Pop: SFO5-C3\\r\\nX-Amz-Cf-Id: w4h42tkoJD-rEpkRDZUvnQBmy26GVGe6pUsuRr1Dphf7oajYbjXaOA==\\r\\nAge: 132\\r\\n" + }, + "redirectTime" : 10, + "responseTime" : 14, + "totalTime" : 15, + "receiveTime" : 1, + "systemMetrics" : { + "cpuUtilization" : { + "min" : 0.22, + "median" : 0.61, + "max" : 0.75, + "mean" : 0.55, + "count" : 150, + "stdDev" : 0.01 + }, + "physicalMemoryTotalBytes" : 1024, + "startTimeMs" : 1581508857327, + "physicalMemoryUsedBytes" : { + "min" : 1.2, + "median" : 1.85, + "max" : 2.5, + "mean" : 1.77, + "count" : 155, + "stdDev" : 0.25 + }, + "endTimeMs" : 1581508867333 + }, + "dnsTime" : 0, + "serverIp" : "193.2.1.88", + "testId" : "584739201", + "sslTime" : 9, + "aid" : "1234", + "waitTime" : 3, + "errorDetails" : "errorDetails", + "wireSize" : 9993 + }, { + "originalTargetProfile" : { + "protocol" : "tcp", + "remotePort" : 80, + "remoteIpAddress" : "120.98.134.7" + }, + "agentId" : "861b7557-cd57-4bbb-b648-00bddf88ef49", + "numRedirects" : 0, + "vpnProfile" : { + "vpnClientNetworkRange" : [ "9.88.37.27", "9.88.37.27" ], + "vpnGatewayAddress" : "120.98.134.7", + "vpnType" : "cisco-anyconnect", + "vpnClientAddresses" : [ "184.81.113.85", "13.129.91.62" ] + }, + "errorType" : "connect", + "batteryMetrics" : { + "batteryHealthNormalizedPercent" : 0.92, + "batteryLevel" : "medium", + "batteryLevelNormalizedPercent" : 0.3 + }, + "userProfile" : { + "userName" : "joeblogs32", + "userPrincipalName" : "joeblogs32@c.com" + }, + "platform" : "mac", + "responseCode" : 200, + "cellularProfile" : { + "rssi" : -10, + "advertisedNetworkSubtype" : "LTE/HSPA", + "carrierName" : "T-Mobile", + "rsrq" : -30, + "rsrp" : -30, + "advertisedNetworkGen" : "2g, 3g, 4g, 5g", + "rscp" : -30, + "networkGen" : "2g, 3g, 4g, 5g", + "networkSubtype" : "LTE/HSPA", + "sinr" : 20 + }, + "score" : { + "applicationScore" : 100, + "quality" : "great" + }, + "connectTime" : 2, + "networkProfile" : { + "previousInterface" : { + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "interfaceName" : "en0", + "subnetMask" : "255.255.255.0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ] + }, + "ethernetProfile" : { + "linkSpeed" : 860 + }, + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "proxyProfile" : { + "method" : "System", + "proxies" : [ { + "bypass" : "*.local;169.254/16", + "proxy" : "" + }, { + "bypass" : "*.local;169.254/16", + "proxy" : "" + } ] + }, + "subnetMask" : "255.255.255.0", + "error" : "An operation timed out.", + "wirelessProfile" : { + "rssi" : -38, + "bssid" : "4c:ba:ba:f4:fa:fa", + "snr" : 57, + "vendor" : "Cisco", + "txRate" : 130, + "channel" : 1, + "noise" : -95, + "phyMode" : "802.11n", + "ssid" : "Internet for the masses", + "quality" : 100 + }, + "interfaceName" : "en0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ], + "gateway" : "10.0.0.1" + }, + "throughput" : 190, + "roundId" : 1384309800, + "headers" : { + "requestHeaders" : "GET / HTTP/1.1\\r\\nHost: www.thousandeyes.com\\r\\nUser-Agent: curl/7.58.0-DEV\\r\\nAccept: */*\\r\\nAccept-Encoding: deflate, gzip\\r\\nX-ThousandEyes-Agent: yes\\r\\n", + "responseHeaders" : "HTTP/1.1 200 OK\\r\\nContent-Type: text/html;charset=UTF-8\\r\\nContent-Length: 9993\\r\\nConnection: keep-alive\\r\\nDate: Mon, 04 May 2020 16:13:00 GMT\\r\\nServer: Apache\\r\\nContent-Language: en-US\\r\\nContent-Encoding: gzip\\r\\nX-Frame-Options: sameorigin\\r\\nCache-Control: max-age=600, must-revalidate\\r\\nStrict-Transport-Security: max-age=31536000\\r\\nX-Content-Type-Options: nosniff\\r\\nX-XSS-Protection: 1; mode=block\\r\\nVary: Accept-Encoding\\r\\nX-Cache: Hit from cloudfront\\r\\nVia: 1.1 7ba3caf71ae7a52dd411d1a543e80cd8.cloudfront.net (CloudFront)\\r\\nX-Amz-Cf-Pop: SFO5-C3\\r\\nX-Amz-Cf-Id: w4h42tkoJD-rEpkRDZUvnQBmy26GVGe6pUsuRr1Dphf7oajYbjXaOA==\\r\\nAge: 132\\r\\n" + }, + "redirectTime" : 10, + "responseTime" : 14, + "totalTime" : 15, + "receiveTime" : 1, + "systemMetrics" : { + "cpuUtilization" : { + "min" : 0.22, + "median" : 0.61, + "max" : 0.75, + "mean" : 0.55, + "count" : 150, + "stdDev" : 0.01 + }, + "physicalMemoryTotalBytes" : 1024, + "startTimeMs" : 1581508857327, + "physicalMemoryUsedBytes" : { + "min" : 1.2, + "median" : 1.85, + "max" : 2.5, + "mean" : 1.77, + "count" : 155, + "stdDev" : 0.25 + }, + "endTimeMs" : 1581508867333 + }, + "dnsTime" : 0, + "serverIp" : "193.2.1.88", + "testId" : "584739201", + "sslTime" : 9, + "aid" : "1234", + "waitTime" : 3, + "errorDetails" : "errorDetails", + "wireSize" : 9993 + } ], + "startDate" : "2022-07-17T22:00:54Z" + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "searchSort" : [ { + "sort" : "round-id", + "order" : "desc" + }, { + "sort" : "round-id", + "order" : "desc" + } ], + "searchFilters" : { + "agentId" : [ "52455b09-ff1b-4849-8194-99026cc890e0", "52455b09-ff1b-4849-8194-99026cc890e0" ], + "testId" : [ "5", "5" ], + "userPrincipalName" : [ "joeblogs32@c.com", "joeblogs32@c.com" ] + }, + "thresholdFilter" : { + "conditionalOperator" : "and", + "filters" : [ { + "name" : "response-time", + "value" : 10, + "operator" : "gte" + }, { + "name" : "response-time", + "value" : 10, + "operator" : "gte" + } ] + } + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_single_test_filtered_http_server_scheduled_test_results": OperationExpectation( + operation_id="get_single_test_filtered_http_server_scheduled_test_results", + method="POST", + path="/endpoint/test-results/scheduled-tests/{testId}/http-server/filter", + path_param_examples={ + "testId": '202701', + }, + success_status=200, + success_body=json.loads(""" + + { + "totalHits" : 12, + "endDate" : "2022-07-18T22:00:54Z", + "_links" : { + "next" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "results" : [ { + "originalTargetProfile" : { + "protocol" : "tcp", + "remotePort" : 80, + "remoteIpAddress" : "120.98.134.7" + }, + "agentId" : "861b7557-cd57-4bbb-b648-00bddf88ef49", + "numRedirects" : 0, + "vpnProfile" : { + "vpnClientNetworkRange" : [ "9.88.37.27", "9.88.37.27" ], + "vpnGatewayAddress" : "120.98.134.7", + "vpnType" : "cisco-anyconnect", + "vpnClientAddresses" : [ "184.81.113.85", "13.129.91.62" ] + }, + "errorType" : "connect", + "batteryMetrics" : { + "batteryHealthNormalizedPercent" : 0.92, + "batteryLevel" : "medium", + "batteryLevelNormalizedPercent" : 0.3 + }, + "userProfile" : { + "userName" : "joeblogs32", + "userPrincipalName" : "joeblogs32@c.com" + }, + "platform" : "mac", + "responseCode" : 200, + "cellularProfile" : { + "rssi" : -10, + "advertisedNetworkSubtype" : "LTE/HSPA", + "carrierName" : "T-Mobile", + "rsrq" : -30, + "rsrp" : -30, + "advertisedNetworkGen" : "2g, 3g, 4g, 5g", + "rscp" : -30, + "networkGen" : "2g, 3g, 4g, 5g", + "networkSubtype" : "LTE/HSPA", + "sinr" : 20 + }, + "score" : { + "applicationScore" : 100, + "quality" : "great" + }, + "connectTime" : 2, + "networkProfile" : { + "previousInterface" : { + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "interfaceName" : "en0", + "subnetMask" : "255.255.255.0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ] + }, + "ethernetProfile" : { + "linkSpeed" : 860 + }, + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "proxyProfile" : { + "method" : "System", + "proxies" : [ { + "bypass" : "*.local;169.254/16", + "proxy" : "" + }, { + "bypass" : "*.local;169.254/16", + "proxy" : "" + } ] + }, + "subnetMask" : "255.255.255.0", + "error" : "An operation timed out.", + "wirelessProfile" : { + "rssi" : -38, + "bssid" : "4c:ba:ba:f4:fa:fa", + "snr" : 57, + "vendor" : "Cisco", + "txRate" : 130, + "channel" : 1, + "noise" : -95, + "phyMode" : "802.11n", + "ssid" : "Internet for the masses", + "quality" : 100 + }, + "interfaceName" : "en0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ], + "gateway" : "10.0.0.1" + }, + "throughput" : 190, + "roundId" : 1384309800, + "headers" : { + "requestHeaders" : "GET / HTTP/1.1\\r\\nHost: www.thousandeyes.com\\r\\nUser-Agent: curl/7.58.0-DEV\\r\\nAccept: */*\\r\\nAccept-Encoding: deflate, gzip\\r\\nX-ThousandEyes-Agent: yes\\r\\n", + "responseHeaders" : "HTTP/1.1 200 OK\\r\\nContent-Type: text/html;charset=UTF-8\\r\\nContent-Length: 9993\\r\\nConnection: keep-alive\\r\\nDate: Mon, 04 May 2020 16:13:00 GMT\\r\\nServer: Apache\\r\\nContent-Language: en-US\\r\\nContent-Encoding: gzip\\r\\nX-Frame-Options: sameorigin\\r\\nCache-Control: max-age=600, must-revalidate\\r\\nStrict-Transport-Security: max-age=31536000\\r\\nX-Content-Type-Options: nosniff\\r\\nX-XSS-Protection: 1; mode=block\\r\\nVary: Accept-Encoding\\r\\nX-Cache: Hit from cloudfront\\r\\nVia: 1.1 7ba3caf71ae7a52dd411d1a543e80cd8.cloudfront.net (CloudFront)\\r\\nX-Amz-Cf-Pop: SFO5-C3\\r\\nX-Amz-Cf-Id: w4h42tkoJD-rEpkRDZUvnQBmy26GVGe6pUsuRr1Dphf7oajYbjXaOA==\\r\\nAge: 132\\r\\n" + }, + "redirectTime" : 10, + "responseTime" : 14, + "totalTime" : 15, + "receiveTime" : 1, + "systemMetrics" : { + "cpuUtilization" : { + "min" : 0.22, + "median" : 0.61, + "max" : 0.75, + "mean" : 0.55, + "count" : 150, + "stdDev" : 0.01 + }, + "physicalMemoryTotalBytes" : 1024, + "startTimeMs" : 1581508857327, + "physicalMemoryUsedBytes" : { + "min" : 1.2, + "median" : 1.85, + "max" : 2.5, + "mean" : 1.77, + "count" : 155, + "stdDev" : 0.25 + }, + "endTimeMs" : 1581508867333 + }, + "dnsTime" : 0, + "serverIp" : "193.2.1.88", + "testId" : "584739201", + "sslTime" : 9, + "aid" : "1234", + "waitTime" : 3, + "errorDetails" : "errorDetails", + "wireSize" : 9993 + }, { + "originalTargetProfile" : { + "protocol" : "tcp", + "remotePort" : 80, + "remoteIpAddress" : "120.98.134.7" + }, + "agentId" : "861b7557-cd57-4bbb-b648-00bddf88ef49", + "numRedirects" : 0, + "vpnProfile" : { + "vpnClientNetworkRange" : [ "9.88.37.27", "9.88.37.27" ], + "vpnGatewayAddress" : "120.98.134.7", + "vpnType" : "cisco-anyconnect", + "vpnClientAddresses" : [ "184.81.113.85", "13.129.91.62" ] + }, + "errorType" : "connect", + "batteryMetrics" : { + "batteryHealthNormalizedPercent" : 0.92, + "batteryLevel" : "medium", + "batteryLevelNormalizedPercent" : 0.3 + }, + "userProfile" : { + "userName" : "joeblogs32", + "userPrincipalName" : "joeblogs32@c.com" + }, + "platform" : "mac", + "responseCode" : 200, + "cellularProfile" : { + "rssi" : -10, + "advertisedNetworkSubtype" : "LTE/HSPA", + "carrierName" : "T-Mobile", + "rsrq" : -30, + "rsrp" : -30, + "advertisedNetworkGen" : "2g, 3g, 4g, 5g", + "rscp" : -30, + "networkGen" : "2g, 3g, 4g, 5g", + "networkSubtype" : "LTE/HSPA", + "sinr" : 20 + }, + "score" : { + "applicationScore" : 100, + "quality" : "great" + }, + "connectTime" : 2, + "networkProfile" : { + "previousInterface" : { + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "interfaceName" : "en0", + "subnetMask" : "255.255.255.0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ] + }, + "ethernetProfile" : { + "linkSpeed" : 860 + }, + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "proxyProfile" : { + "method" : "System", + "proxies" : [ { + "bypass" : "*.local;169.254/16", + "proxy" : "" + }, { + "bypass" : "*.local;169.254/16", + "proxy" : "" + } ] + }, + "subnetMask" : "255.255.255.0", + "error" : "An operation timed out.", + "wirelessProfile" : { + "rssi" : -38, + "bssid" : "4c:ba:ba:f4:fa:fa", + "snr" : 57, + "vendor" : "Cisco", + "txRate" : 130, + "channel" : 1, + "noise" : -95, + "phyMode" : "802.11n", + "ssid" : "Internet for the masses", + "quality" : 100 + }, + "interfaceName" : "en0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ], + "gateway" : "10.0.0.1" + }, + "throughput" : 190, + "roundId" : 1384309800, + "headers" : { + "requestHeaders" : "GET / HTTP/1.1\\r\\nHost: www.thousandeyes.com\\r\\nUser-Agent: curl/7.58.0-DEV\\r\\nAccept: */*\\r\\nAccept-Encoding: deflate, gzip\\r\\nX-ThousandEyes-Agent: yes\\r\\n", + "responseHeaders" : "HTTP/1.1 200 OK\\r\\nContent-Type: text/html;charset=UTF-8\\r\\nContent-Length: 9993\\r\\nConnection: keep-alive\\r\\nDate: Mon, 04 May 2020 16:13:00 GMT\\r\\nServer: Apache\\r\\nContent-Language: en-US\\r\\nContent-Encoding: gzip\\r\\nX-Frame-Options: sameorigin\\r\\nCache-Control: max-age=600, must-revalidate\\r\\nStrict-Transport-Security: max-age=31536000\\r\\nX-Content-Type-Options: nosniff\\r\\nX-XSS-Protection: 1; mode=block\\r\\nVary: Accept-Encoding\\r\\nX-Cache: Hit from cloudfront\\r\\nVia: 1.1 7ba3caf71ae7a52dd411d1a543e80cd8.cloudfront.net (CloudFront)\\r\\nX-Amz-Cf-Pop: SFO5-C3\\r\\nX-Amz-Cf-Id: w4h42tkoJD-rEpkRDZUvnQBmy26GVGe6pUsuRr1Dphf7oajYbjXaOA==\\r\\nAge: 132\\r\\n" + }, + "redirectTime" : 10, + "responseTime" : 14, + "totalTime" : 15, + "receiveTime" : 1, + "systemMetrics" : { + "cpuUtilization" : { + "min" : 0.22, + "median" : 0.61, + "max" : 0.75, + "mean" : 0.55, + "count" : 150, + "stdDev" : 0.01 + }, + "physicalMemoryTotalBytes" : 1024, + "startTimeMs" : 1581508857327, + "physicalMemoryUsedBytes" : { + "min" : 1.2, + "median" : 1.85, + "max" : 2.5, + "mean" : 1.77, + "count" : 155, + "stdDev" : 0.25 + }, + "endTimeMs" : 1581508867333 + }, + "dnsTime" : 0, + "serverIp" : "193.2.1.88", + "testId" : "584739201", + "sslTime" : 9, + "aid" : "1234", + "waitTime" : 3, + "errorDetails" : "errorDetails", + "wireSize" : 9993 + } ], + "startDate" : "2022-07-17T22:00:54Z" + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "searchSort" : [ { + "sort" : "round-id", + "order" : "desc" + }, { + "sort" : "round-id", + "order" : "desc" + } ], + "searchFilters" : { + "agentId" : [ "52455b09-ff1b-4849-8194-99026cc890e0", "52455b09-ff1b-4849-8194-99026cc890e0" ], + "testId" : [ "5", "5" ], + "userPrincipalName" : [ "joeblogs32@c.com", "joeblogs32@c.com" ] + }, + "thresholdFilter" : { + "conditionalOperator" : "and", + "filters" : [ { + "name" : "response-time", + "value" : 10, + "operator" : "gte" + }, { + "name" : "response-time", + "value" : 10, + "operator" : "gte" + } ] + } + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "filter_local_networks_test_results_topologies": OperationExpectation( + operation_id="filter_local_networks_test_results_topologies", + method="POST", + path="/endpoint/test-results/local-networks/topologies/filter", + path_param_examples={ + }, + success_status=200, + success_body=json.loads(""" + + { + "endDate" : "2022-07-18T22:00:54Z", + "_links" : { + "next" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "results" : [ { + "date" : "2022-07-17T22:00:54Z", + "agentId" : "861b7557-cd57-4bbb-b648-00bddf88ef49", + "dnsServerTest" : { + "resolutionTime" : 3 + }, + "isIcmpBlocked" : true, + "gatewayScore" : { + "score" : 100, + "quality" : "great" + }, + "tcpConnect" : { + "rtt" : 77.777, + "errorCode" : "ERR_TIMED_OUT", + "error" : "An operation timed out.", + "infoFlags" : [ "TE_INFO_ICMP_BLOCKED_BY_FIREWALL" ] + }, + "vpnScore" : { + "score" : 100, + "quality" : "great" + }, + "proxyScore" : { + "score" : 100, + "quality" : "great" + }, + "batteryMetrics" : { + "batteryHealthNormalizedPercent" : 0.92, + "batteryLevel" : "medium", + "batteryLevelNormalizedPercent" : 0.3 + }, + "type" : "vpn", + "targetPort" : 80, + "platform" : "mac", + "target" : "10.0.2.2", + "cellularProfile" : { + "rssi" : -10, + "advertisedNetworkSubtype" : "LTE/HSPA", + "carrierName" : "T-Mobile", + "rsrq" : -30, + "rsrp" : -30, + "advertisedNetworkGen" : "2g, 3g, 4g, 5g", + "rscp" : -30, + "networkGen" : "2g, 3g, 4g, 5g", + "networkSubtype" : "LTE/HSPA", + "sinr" : 20 + }, + "systemMetrics" : { + "cpuUtilization" : { + "min" : 0.22, + "median" : 0.61, + "max" : 0.75, + "mean" : 0.55, + "count" : 150, + "stdDev" : 0.01 + }, + "physicalMemoryTotalBytes" : 1024, + "startTimeMs" : 1581508857327, + "physicalMemoryUsedBytes" : { + "min" : 1.2, + "median" : 1.85, + "max" : 2.5, + "mean" : 1.77, + "count" : 155, + "stdDev" : 0.25 + }, + "endTimeMs" : 1581508867333 + }, + "systemMetricDetails" : { + "topCpuApplications" : [ { + "totalMemoryBytes" : 1023334, + "processes" : [ { + "memoryBytes" : 1023334, + "memoryPercentage" : 0.22, + "name" : "Webex background", + "cpu" : 0.5, + "pid" : 15632 + }, { + "memoryBytes" : 1023334, + "memoryPercentage" : 0.22, + "name" : "Webex background", + "cpu" : 0.5, + "pid" : 15632 + } ], + "totalCpu" : 0.5, + "name" : "Webex", + "totalMemoryPercentage" : 0.22 + }, { + "totalMemoryBytes" : 1023334, + "processes" : [ { + "memoryBytes" : 1023334, + "memoryPercentage" : 0.22, + "name" : "Webex background", + "cpu" : 0.5, + "pid" : 15632 + }, { + "memoryBytes" : 1023334, + "memoryPercentage" : 0.22, + "name" : "Webex background", + "cpu" : 0.5, + "pid" : 15632 + } ], + "totalCpu" : 0.5, + "name" : "Webex", + "totalMemoryPercentage" : 0.22 + } ], + "topMemoryApplications" : [ { + "totalMemoryBytes" : 1023334, + "processes" : [ { + "memoryBytes" : 1023334, + "memoryPercentage" : 0.22, + "name" : "Webex background", + "cpu" : 0.5, + "pid" : 15632 + }, { + "memoryBytes" : 1023334, + "memoryPercentage" : 0.22, + "name" : "Webex background", + "cpu" : 0.5, + "pid" : 15632 + } ], + "totalCpu" : 0.5, + "name" : "Webex", + "totalMemoryPercentage" : 0.22 + }, { + "totalMemoryBytes" : 1023334, + "processes" : [ { + "memoryBytes" : 1023334, + "memoryPercentage" : 0.22, + "name" : "Webex background", + "cpu" : 0.5, + "pid" : 15632 + }, { + "memoryBytes" : 1023334, + "memoryPercentage" : 0.22, + "name" : "Webex background", + "cpu" : 0.5, + "pid" : 15632 + } ], + "totalCpu" : 0.5, + "name" : "Webex", + "totalMemoryPercentage" : 0.22 + } ] + }, + "connectionScore" : { + "score" : 100, + "quality" : "great" + }, + "icmpPing" : { + "maxRtt" : 66, + "loss" : 1, + "pktsReceived" : 10, + "avgRtt" : 7, + "meanDevRtt" : 11, + "minRtt" : 1, + "error" : "An operation timed out.", + "infoFlags" : [ "TE_INFO_ICMP_BLOCKED_BY_FIREWALL" ], + "pktsSent" : 10 + }, + "networkTopologyId" : "00160:54c3a4b180c6:1490536500:c7a58c49", + "roundId" : 1384309800, + "agentScore" : { + "score" : 100, + "quality" : "great" + } + }, { + "date" : "2022-07-17T22:00:54Z", + "agentId" : "861b7557-cd57-4bbb-b648-00bddf88ef49", + "dnsServerTest" : { + "resolutionTime" : 3 + }, + "isIcmpBlocked" : true, + "gatewayScore" : { + "score" : 100, + "quality" : "great" + }, + "tcpConnect" : { + "rtt" : 77.777, + "errorCode" : "ERR_TIMED_OUT", + "error" : "An operation timed out.", + "infoFlags" : [ "TE_INFO_ICMP_BLOCKED_BY_FIREWALL" ] + }, + "vpnScore" : { + "score" : 100, + "quality" : "great" + }, + "proxyScore" : { + "score" : 100, + "quality" : "great" + }, + "batteryMetrics" : { + "batteryHealthNormalizedPercent" : 0.92, + "batteryLevel" : "medium", + "batteryLevelNormalizedPercent" : 0.3 + }, + "type" : "vpn", + "targetPort" : 80, + "platform" : "mac", + "target" : "10.0.2.2", + "cellularProfile" : { + "rssi" : -10, + "advertisedNetworkSubtype" : "LTE/HSPA", + "carrierName" : "T-Mobile", + "rsrq" : -30, + "rsrp" : -30, + "advertisedNetworkGen" : "2g, 3g, 4g, 5g", + "rscp" : -30, + "networkGen" : "2g, 3g, 4g, 5g", + "networkSubtype" : "LTE/HSPA", + "sinr" : 20 + }, + "systemMetrics" : { + "cpuUtilization" : { + "min" : 0.22, + "median" : 0.61, + "max" : 0.75, + "mean" : 0.55, + "count" : 150, + "stdDev" : 0.01 + }, + "physicalMemoryTotalBytes" : 1024, + "startTimeMs" : 1581508857327, + "physicalMemoryUsedBytes" : { + "min" : 1.2, + "median" : 1.85, + "max" : 2.5, + "mean" : 1.77, + "count" : 155, + "stdDev" : 0.25 + }, + "endTimeMs" : 1581508867333 + }, + "systemMetricDetails" : { + "topCpuApplications" : [ { + "totalMemoryBytes" : 1023334, + "processes" : [ { + "memoryBytes" : 1023334, + "memoryPercentage" : 0.22, + "name" : "Webex background", + "cpu" : 0.5, + "pid" : 15632 + }, { + "memoryBytes" : 1023334, + "memoryPercentage" : 0.22, + "name" : "Webex background", + "cpu" : 0.5, + "pid" : 15632 + } ], + "totalCpu" : 0.5, + "name" : "Webex", + "totalMemoryPercentage" : 0.22 + }, { + "totalMemoryBytes" : 1023334, + "processes" : [ { + "memoryBytes" : 1023334, + "memoryPercentage" : 0.22, + "name" : "Webex background", + "cpu" : 0.5, + "pid" : 15632 + }, { + "memoryBytes" : 1023334, + "memoryPercentage" : 0.22, + "name" : "Webex background", + "cpu" : 0.5, + "pid" : 15632 + } ], + "totalCpu" : 0.5, + "name" : "Webex", + "totalMemoryPercentage" : 0.22 + } ], + "topMemoryApplications" : [ { + "totalMemoryBytes" : 1023334, + "processes" : [ { + "memoryBytes" : 1023334, + "memoryPercentage" : 0.22, + "name" : "Webex background", + "cpu" : 0.5, + "pid" : 15632 + }, { + "memoryBytes" : 1023334, + "memoryPercentage" : 0.22, + "name" : "Webex background", + "cpu" : 0.5, + "pid" : 15632 + } ], + "totalCpu" : 0.5, + "name" : "Webex", + "totalMemoryPercentage" : 0.22 + }, { + "totalMemoryBytes" : 1023334, + "processes" : [ { + "memoryBytes" : 1023334, + "memoryPercentage" : 0.22, + "name" : "Webex background", + "cpu" : 0.5, + "pid" : 15632 + }, { + "memoryBytes" : 1023334, + "memoryPercentage" : 0.22, + "name" : "Webex background", + "cpu" : 0.5, + "pid" : 15632 + } ], + "totalCpu" : 0.5, + "name" : "Webex", + "totalMemoryPercentage" : 0.22 + } ] + }, + "connectionScore" : { + "score" : 100, + "quality" : "great" + }, + "icmpPing" : { + "maxRtt" : 66, + "loss" : 1, + "pktsReceived" : 10, + "avgRtt" : 7, + "meanDevRtt" : 11, + "minRtt" : 1, + "error" : "An operation timed out.", + "infoFlags" : [ "TE_INFO_ICMP_BLOCKED_BY_FIREWALL" ], + "pktsSent" : 10 + }, + "networkTopologyId" : "00160:54c3a4b180c6:1490536500:c7a58c49", + "roundId" : 1384309800, + "agentScore" : { + "score" : 100, + "quality" : "great" + } + } ], + "startDate" : "2022-07-17T22:00:54Z" + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "searchFilters" : { + "agentId" : [ "3fde6422-f119-40e1-ae32-d08a1243c038", "236e6f18-9637-4a2f-b15f-7aa6a29c9fce" ], + "bssid" : [ "8c:68:c8:a5:0a:8c", "0c:51:01:e4:3e:d0" ], + "location" : [ "San Francisco Bay Area", "Germany" ], + "connection" : [ "wireless", "wireless" ], + "vpnTarget" : [ "78.153.54.204", "78.153.54.206" ], + "networkId" : [ "660b34109d12", "660b34109d15" ], + "type" : [ "vpn", "proxy" ], + "ssid" : [ "wifi-name", "other-room-wifi" ], + "platform" : [ "mac", "mac" ], + "gateway" : [ "78.153.54.204", "78.153.54.206" ], + "proxyTarget" : [ "78.153.54.204", "78.153.54.206" ] + }, + "thresholdFilter" : { + "conditionalOperator" : "and", + "filters" : [ { + "name" : "loss", + "value" : 10, + "operator" : "gte" + }, { + "name" : "loss", + "value" : 10, + "operator" : "gte" + } ] + } + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_local_networks_test_results": OperationExpectation( + operation_id="get_local_networks_test_results", + method="GET", + path="/endpoint/test-results/local-networks", + path_param_examples={ + }, + success_status=200, + success_body=json.loads(""" + + { + "localNetworks" : [ { + "publicIpRange" : "178.216.56.0-178.216.63.255", + "networkName" : "10.5.51.0 (in 178.216.56.0/21)", + "networkId" : "006c4fa7a054", + "localPrefix" : "10.5.51.0" + }, { + "publicIpRange" : "178.216.56.0-178.216.63.255", + "networkName" : "10.5.51.0 (in 178.216.56.0/21)", + "networkId" : "006c4fa7a054", + "localPrefix" : "10.5.51.0" + } ], + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_local_networks_test_results_topology": OperationExpectation( + operation_id="get_local_networks_test_results_topology", + method="GET", + path="/endpoint/test-results/local-networks/topologies/{networkTopologyId}", + path_param_examples={ + "networkTopologyId": '00160:39c518560de9:1491651900:236e6f18', + }, + success_status=200, + success_body=json.loads(""" + + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "results" : [ { + "date" : "2022-07-17T22:00:54Z", + "agentId" : "861b7557-cd57-4bbb-b648-00bddf88ef49", + "dnsServerTest" : { + "resolutionTime" : 3 + }, + "vpnScore" : { + "score" : 100, + "quality" : "great" + }, + "batteryMetrics" : { + "batteryHealthNormalizedPercent" : 0.92, + "batteryLevel" : "medium", + "batteryLevelNormalizedPercent" : 0.3 + }, + "type" : "vpn", + "targetPort" : 80, + "platform" : "mac", + "cellularProfile" : { + "rssi" : -10, + "advertisedNetworkSubtype" : "LTE/HSPA", + "carrierName" : "T-Mobile", + "rsrq" : -30, + "rsrp" : -30, + "advertisedNetworkGen" : "2g, 3g, 4g, 5g", + "rscp" : -30, + "networkGen" : "2g, 3g, 4g, 5g", + "networkSubtype" : "LTE/HSPA", + "sinr" : 20 + }, + "icmpTraceroute" : { + "destination" : "13.32.22.232", + "hops" : [ { + "delay" : 5, + "prefix" : "196.40.96.0/20", + "hop" : 1, + "ipAddress" : "196.40.106.237", + "name" : "89-210-88-65.access.t-2.net", + "mpls" : [ "L=301472,E=0,S=1,T=1" ], + "asn" : 34779 + }, { + "delay" : 5, + "prefix" : "196.40.96.0/20", + "hop" : 1, + "ipAddress" : "196.40.106.237", + "name" : "89-210-88-65.access.t-2.net", + "mpls" : [ "L=301472,E=0,S=1,T=1" ], + "asn" : 34779 + } ], + "error" : "An operation timed out.", + "infoFlags" : [ "TE_INFO_ICMP_BLOCKED_BY_FIREWALL" ], + "internalErrors" : [ "TE_INFO_ICMP_BLOCKED_BY_FIREWALL" ] + }, + "networkProfile" : { + "previousInterface" : { + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "interfaceName" : "en0", + "subnetMask" : "255.255.255.0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ] + }, + "ethernetProfile" : { + "linkSpeed" : 860 + }, + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "proxyProfile" : { + "method" : "System", + "proxies" : [ { + "bypass" : "*.local;169.254/16", + "proxy" : "" + }, { + "bypass" : "*.local;169.254/16", + "proxy" : "" + } ] + }, + "subnetMask" : "255.255.255.0", + "error" : "An operation timed out.", + "wirelessProfile" : { + "rssi" : -38, + "bssid" : "4c:ba:ba:f4:fa:fa", + "snr" : 57, + "vendor" : "Cisco", + "txRate" : 130, + "channel" : 1, + "noise" : -95, + "phyMode" : "802.11n", + "ssid" : "Internet for the masses", + "quality" : 100 + }, + "interfaceName" : "en0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ], + "gateway" : "10.0.0.1" + }, + "roundId" : 1384309800, + "agentScore" : { + "score" : 100, + "quality" : "great" + }, + "isIcmpBlocked" : true, + "gatewayScore" : { + "score" : 100, + "quality" : "great" + }, + "tcpConnect" : { + "rtt" : 77.777, + "errorCode" : "ERR_TIMED_OUT", + "error" : "An operation timed out.", + "infoFlags" : [ "TE_INFO_ICMP_BLOCKED_BY_FIREWALL" ] + }, + "proxyScore" : { + "score" : 100, + "quality" : "great" + }, + "coordinates" : { + "latitude" : 46.0552778, + "location" : "Slovenia", + "longitude" : 14.5144444 + }, + "icmpTraceroutes" : [ { + "destination" : "13.32.22.232", + "hops" : [ { + "delay" : 5, + "prefix" : "196.40.96.0/20", + "hop" : 1, + "ipAddress" : "196.40.106.237", + "name" : "89-210-88-65.access.t-2.net", + "mpls" : [ "L=301472,E=0,S=1,T=1" ], + "asn" : 34779 + }, { + "delay" : 5, + "prefix" : "196.40.96.0/20", + "hop" : 1, + "ipAddress" : "196.40.106.237", + "name" : "89-210-88-65.access.t-2.net", + "mpls" : [ "L=301472,E=0,S=1,T=1" ], + "asn" : 34779 + } ], + "error" : "An operation timed out.", + "infoFlags" : [ "TE_INFO_ICMP_BLOCKED_BY_FIREWALL" ], + "internalErrors" : [ "TE_INFO_ICMP_BLOCKED_BY_FIREWALL" ] + }, { + "destination" : "13.32.22.232", + "hops" : [ { + "delay" : 5, + "prefix" : "196.40.96.0/20", + "hop" : 1, + "ipAddress" : "196.40.106.237", + "name" : "89-210-88-65.access.t-2.net", + "mpls" : [ "L=301472,E=0,S=1,T=1" ], + "asn" : 34779 + }, { + "delay" : 5, + "prefix" : "196.40.96.0/20", + "hop" : 1, + "ipAddress" : "196.40.106.237", + "name" : "89-210-88-65.access.t-2.net", + "mpls" : [ "L=301472,E=0,S=1,T=1" ], + "asn" : 34779 + } ], + "error" : "An operation timed out.", + "infoFlags" : [ "TE_INFO_ICMP_BLOCKED_BY_FIREWALL" ], + "internalErrors" : [ "TE_INFO_ICMP_BLOCKED_BY_FIREWALL" ] + } ], + "target" : "10.0.2.2", + "systemMetrics" : { + "cpuUtilization" : { + "min" : 0.22, + "median" : 0.61, + "max" : 0.75, + "mean" : 0.55, + "count" : 150, + "stdDev" : 0.01 + }, + "physicalMemoryTotalBytes" : 1024, + "startTimeMs" : 1581508857327, + "physicalMemoryUsedBytes" : { + "min" : 1.2, + "median" : 1.85, + "max" : 2.5, + "mean" : 1.77, + "count" : 155, + "stdDev" : 0.25 + }, + "endTimeMs" : 1581508867333 + }, + "systemMetricDetails" : { + "topCpuApplications" : [ { + "totalMemoryBytes" : 1023334, + "processes" : [ { + "memoryBytes" : 1023334, + "memoryPercentage" : 0.22, + "name" : "Webex background", + "cpu" : 0.5, + "pid" : 15632 + }, { + "memoryBytes" : 1023334, + "memoryPercentage" : 0.22, + "name" : "Webex background", + "cpu" : 0.5, + "pid" : 15632 + } ], + "totalCpu" : 0.5, + "name" : "Webex", + "totalMemoryPercentage" : 0.22 + }, { + "totalMemoryBytes" : 1023334, + "processes" : [ { + "memoryBytes" : 1023334, + "memoryPercentage" : 0.22, + "name" : "Webex background", + "cpu" : 0.5, + "pid" : 15632 + }, { + "memoryBytes" : 1023334, + "memoryPercentage" : 0.22, + "name" : "Webex background", + "cpu" : 0.5, + "pid" : 15632 + } ], + "totalCpu" : 0.5, + "name" : "Webex", + "totalMemoryPercentage" : 0.22 + } ], + "topMemoryApplications" : [ { + "totalMemoryBytes" : 1023334, + "processes" : [ { + "memoryBytes" : 1023334, + "memoryPercentage" : 0.22, + "name" : "Webex background", + "cpu" : 0.5, + "pid" : 15632 + }, { + "memoryBytes" : 1023334, + "memoryPercentage" : 0.22, + "name" : "Webex background", + "cpu" : 0.5, + "pid" : 15632 + } ], + "totalCpu" : 0.5, + "name" : "Webex", + "totalMemoryPercentage" : 0.22 + }, { + "totalMemoryBytes" : 1023334, + "processes" : [ { + "memoryBytes" : 1023334, + "memoryPercentage" : 0.22, + "name" : "Webex background", + "cpu" : 0.5, + "pid" : 15632 + }, { + "memoryBytes" : 1023334, + "memoryPercentage" : 0.22, + "name" : "Webex background", + "cpu" : 0.5, + "pid" : 15632 + } ], + "totalCpu" : 0.5, + "name" : "Webex", + "totalMemoryPercentage" : 0.22 + } ] + }, + "connectionScore" : { + "score" : 100, + "quality" : "great" + }, + "icmpPing" : { + "maxRtt" : 66, + "loss" : 1, + "pktsReceived" : 10, + "avgRtt" : 7, + "meanDevRtt" : 11, + "minRtt" : 1, + "error" : "An operation timed out.", + "infoFlags" : [ "TE_INFO_ICMP_BLOCKED_BY_FIREWALL" ], + "pktsSent" : 10 + }, + "networkTopologyId" : "00160:54c3a4b180c6:1490536500:c7a58c49" + }, { + "date" : "2022-07-17T22:00:54Z", + "agentId" : "861b7557-cd57-4bbb-b648-00bddf88ef49", + "dnsServerTest" : { + "resolutionTime" : 3 + }, + "vpnScore" : { + "score" : 100, + "quality" : "great" + }, + "batteryMetrics" : { + "batteryHealthNormalizedPercent" : 0.92, + "batteryLevel" : "medium", + "batteryLevelNormalizedPercent" : 0.3 + }, + "type" : "vpn", + "targetPort" : 80, + "platform" : "mac", + "cellularProfile" : { + "rssi" : -10, + "advertisedNetworkSubtype" : "LTE/HSPA", + "carrierName" : "T-Mobile", + "rsrq" : -30, + "rsrp" : -30, + "advertisedNetworkGen" : "2g, 3g, 4g, 5g", + "rscp" : -30, + "networkGen" : "2g, 3g, 4g, 5g", + "networkSubtype" : "LTE/HSPA", + "sinr" : 20 + }, + "icmpTraceroute" : { + "destination" : "13.32.22.232", + "hops" : [ { + "delay" : 5, + "prefix" : "196.40.96.0/20", + "hop" : 1, + "ipAddress" : "196.40.106.237", + "name" : "89-210-88-65.access.t-2.net", + "mpls" : [ "L=301472,E=0,S=1,T=1" ], + "asn" : 34779 + }, { + "delay" : 5, + "prefix" : "196.40.96.0/20", + "hop" : 1, + "ipAddress" : "196.40.106.237", + "name" : "89-210-88-65.access.t-2.net", + "mpls" : [ "L=301472,E=0,S=1,T=1" ], + "asn" : 34779 + } ], + "error" : "An operation timed out.", + "infoFlags" : [ "TE_INFO_ICMP_BLOCKED_BY_FIREWALL" ], + "internalErrors" : [ "TE_INFO_ICMP_BLOCKED_BY_FIREWALL" ] + }, + "networkProfile" : { + "previousInterface" : { + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "interfaceName" : "en0", + "subnetMask" : "255.255.255.0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ] + }, + "ethernetProfile" : { + "linkSpeed" : 860 + }, + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "proxyProfile" : { + "method" : "System", + "proxies" : [ { + "bypass" : "*.local;169.254/16", + "proxy" : "" + }, { + "bypass" : "*.local;169.254/16", + "proxy" : "" + } ] + }, + "subnetMask" : "255.255.255.0", + "error" : "An operation timed out.", + "wirelessProfile" : { + "rssi" : -38, + "bssid" : "4c:ba:ba:f4:fa:fa", + "snr" : 57, + "vendor" : "Cisco", + "txRate" : 130, + "channel" : 1, + "noise" : -95, + "phyMode" : "802.11n", + "ssid" : "Internet for the masses", + "quality" : 100 + }, + "interfaceName" : "en0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ], + "gateway" : "10.0.0.1" + }, + "roundId" : 1384309800, + "agentScore" : { + "score" : 100, + "quality" : "great" + }, + "isIcmpBlocked" : true, + "gatewayScore" : { + "score" : 100, + "quality" : "great" + }, + "tcpConnect" : { + "rtt" : 77.777, + "errorCode" : "ERR_TIMED_OUT", + "error" : "An operation timed out.", + "infoFlags" : [ "TE_INFO_ICMP_BLOCKED_BY_FIREWALL" ] + }, + "proxyScore" : { + "score" : 100, + "quality" : "great" + }, + "coordinates" : { + "latitude" : 46.0552778, + "location" : "Slovenia", + "longitude" : 14.5144444 + }, + "icmpTraceroutes" : [ { + "destination" : "13.32.22.232", + "hops" : [ { + "delay" : 5, + "prefix" : "196.40.96.0/20", + "hop" : 1, + "ipAddress" : "196.40.106.237", + "name" : "89-210-88-65.access.t-2.net", + "mpls" : [ "L=301472,E=0,S=1,T=1" ], + "asn" : 34779 + }, { + "delay" : 5, + "prefix" : "196.40.96.0/20", + "hop" : 1, + "ipAddress" : "196.40.106.237", + "name" : "89-210-88-65.access.t-2.net", + "mpls" : [ "L=301472,E=0,S=1,T=1" ], + "asn" : 34779 + } ], + "error" : "An operation timed out.", + "infoFlags" : [ "TE_INFO_ICMP_BLOCKED_BY_FIREWALL" ], + "internalErrors" : [ "TE_INFO_ICMP_BLOCKED_BY_FIREWALL" ] + }, { + "destination" : "13.32.22.232", + "hops" : [ { + "delay" : 5, + "prefix" : "196.40.96.0/20", + "hop" : 1, + "ipAddress" : "196.40.106.237", + "name" : "89-210-88-65.access.t-2.net", + "mpls" : [ "L=301472,E=0,S=1,T=1" ], + "asn" : 34779 + }, { + "delay" : 5, + "prefix" : "196.40.96.0/20", + "hop" : 1, + "ipAddress" : "196.40.106.237", + "name" : "89-210-88-65.access.t-2.net", + "mpls" : [ "L=301472,E=0,S=1,T=1" ], + "asn" : 34779 + } ], + "error" : "An operation timed out.", + "infoFlags" : [ "TE_INFO_ICMP_BLOCKED_BY_FIREWALL" ], + "internalErrors" : [ "TE_INFO_ICMP_BLOCKED_BY_FIREWALL" ] + } ], + "target" : "10.0.2.2", + "systemMetrics" : { + "cpuUtilization" : { + "min" : 0.22, + "median" : 0.61, + "max" : 0.75, + "mean" : 0.55, + "count" : 150, + "stdDev" : 0.01 + }, + "physicalMemoryTotalBytes" : 1024, + "startTimeMs" : 1581508857327, + "physicalMemoryUsedBytes" : { + "min" : 1.2, + "median" : 1.85, + "max" : 2.5, + "mean" : 1.77, + "count" : 155, + "stdDev" : 0.25 + }, + "endTimeMs" : 1581508867333 + }, + "systemMetricDetails" : { + "topCpuApplications" : [ { + "totalMemoryBytes" : 1023334, + "processes" : [ { + "memoryBytes" : 1023334, + "memoryPercentage" : 0.22, + "name" : "Webex background", + "cpu" : 0.5, + "pid" : 15632 + }, { + "memoryBytes" : 1023334, + "memoryPercentage" : 0.22, + "name" : "Webex background", + "cpu" : 0.5, + "pid" : 15632 + } ], + "totalCpu" : 0.5, + "name" : "Webex", + "totalMemoryPercentage" : 0.22 + }, { + "totalMemoryBytes" : 1023334, + "processes" : [ { + "memoryBytes" : 1023334, + "memoryPercentage" : 0.22, + "name" : "Webex background", + "cpu" : 0.5, + "pid" : 15632 + }, { + "memoryBytes" : 1023334, + "memoryPercentage" : 0.22, + "name" : "Webex background", + "cpu" : 0.5, + "pid" : 15632 + } ], + "totalCpu" : 0.5, + "name" : "Webex", + "totalMemoryPercentage" : 0.22 + } ], + "topMemoryApplications" : [ { + "totalMemoryBytes" : 1023334, + "processes" : [ { + "memoryBytes" : 1023334, + "memoryPercentage" : 0.22, + "name" : "Webex background", + "cpu" : 0.5, + "pid" : 15632 + }, { + "memoryBytes" : 1023334, + "memoryPercentage" : 0.22, + "name" : "Webex background", + "cpu" : 0.5, + "pid" : 15632 + } ], + "totalCpu" : 0.5, + "name" : "Webex", + "totalMemoryPercentage" : 0.22 + }, { + "totalMemoryBytes" : 1023334, + "processes" : [ { + "memoryBytes" : 1023334, + "memoryPercentage" : 0.22, + "name" : "Webex background", + "cpu" : 0.5, + "pid" : 15632 + }, { + "memoryBytes" : 1023334, + "memoryPercentage" : 0.22, + "name" : "Webex background", + "cpu" : 0.5, + "pid" : 15632 + } ], + "totalCpu" : 0.5, + "name" : "Webex", + "totalMemoryPercentage" : 0.22 + } ] + }, + "connectionScore" : { + "score" : 100, + "quality" : "great" + }, + "icmpPing" : { + "maxRtt" : 66, + "loss" : 1, + "pktsReceived" : 10, + "avgRtt" : 7, + "meanDevRtt" : 11, + "minRtt" : 1, + "error" : "An operation timed out.", + "infoFlags" : [ "TE_INFO_ICMP_BLOCKED_BY_FIREWALL" ], + "pktsSent" : 10 + }, + "networkTopologyId" : "00160:54c3a4b180c6:1490536500:c7a58c49" + } ] + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "filter_dynamic_test_network_results": OperationExpectation( + operation_id="filter_dynamic_test_network_results", + method="POST", + path="/endpoint/test-results/dynamic-tests/{testId}/network/filter", + path_param_examples={ + "testId": '202701', + }, + success_status=200, + success_body=json.loads(""" + + { + "test" : { + "hasPing" : true, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/dynamic-tests/281474976710706/network/filter" + }, { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/dynamic-tests/281474976710706/pathvis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isPrioritized" : false, + "networkMeasurements" : true, + "tcpProbeMode" : "auto", + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "protocol" : "icmp", + "createdDate" : "2022-07-17T22:00:54Z", + "ipVersion" : "V4_ONLY", + "application" : "webex", + "hasTraceroute" : true, + "isEnabled" : true, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "aid" : "1234", + "agentSelectorConfig" : { + "agentSelectorType" : "all-agents", + "maxMachines" : 25 + }, + "hasPathTraceInSession" : true, + "testName" : "Test name" + }, + "totalHits" : 12, + "endDate" : "2022-07-18T22:00:54Z", + "_links" : { + "next" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "results" : [ { + "originalTargetProfile" : { + "protocol" : "tcp", + "remotePort" : 80, + "remoteIpAddress" : "120.98.134.7" + }, + "agentId" : "861b7557-cd57-4bbb-b648-00bddf88ef49", + "minLatency" : 167, + "vpnProfile" : { + "vpnClientNetworkRange" : [ "9.88.37.27", "9.88.37.27" ], + "vpnGatewayAddress" : "120.98.134.7", + "vpnType" : "cisco-anyconnect", + "vpnClientAddresses" : [ "184.81.113.85", "13.129.91.62" ] + }, + "maxLatency" : 168, + "batteryMetrics" : { + "batteryHealthNormalizedPercent" : 0.92, + "batteryLevel" : "medium", + "batteryLevelNormalizedPercent" : 0.3 + }, + "userProfile" : { + "userName" : "joeblogs32", + "userPrincipalName" : "joeblogs32@c.com" + }, + "platform" : "mac", + "cellularProfile" : { + "rssi" : -10, + "advertisedNetworkSubtype" : "LTE/HSPA", + "carrierName" : "T-Mobile", + "rsrq" : -30, + "rsrp" : -30, + "advertisedNetworkGen" : "2g, 3g, 4g, 5g", + "rscp" : -30, + "networkGen" : "2g, 3g, 4g, 5g", + "networkSubtype" : "LTE/HSPA", + "sinr" : 20 + }, + "score" : { + "applicationScore" : 100, + "quality" : "great" + }, + "loss" : 0, + "protocol" : "tcp", + "networkProfile" : { + "previousInterface" : { + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "interfaceName" : "en0", + "subnetMask" : "255.255.255.0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ] + }, + "ethernetProfile" : { + "linkSpeed" : 860 + }, + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "proxyProfile" : { + "method" : "System", + "proxies" : [ { + "bypass" : "*.local;169.254/16", + "proxy" : "" + }, { + "bypass" : "*.local;169.254/16", + "proxy" : "" + } ] + }, + "subnetMask" : "255.255.255.0", + "error" : "An operation timed out.", + "wirelessProfile" : { + "rssi" : -38, + "bssid" : "4c:ba:ba:f4:fa:fa", + "snr" : 57, + "vendor" : "Cisco", + "txRate" : 130, + "channel" : 1, + "noise" : -95, + "phyMode" : "802.11n", + "ssid" : "Internet for the masses", + "quality" : 100 + }, + "interfaceName" : "en0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ], + "gateway" : "10.0.0.1" + }, + "ztaMetrics" : [ { + "loss" : 50, + "jitter" : 5, + "avgLatency" : 3, + "errorMessage" : "ERR_NAME_NOT_RESOLVED", + "type" : "zta_service" + }, { + "loss" : 50, + "jitter" : 5, + "avgLatency" : 3, + "errorMessage" : "ERR_NAME_NOT_RESOLVED", + "type" : "zta_service" + } ], + "roundId" : 1384309800, + "udpProbeMode" : "unknown", + "isIcmpBlocked" : true, + "avgLatency" : 167.04, + "tcpProbeMode" : "auto", + "systemMetrics" : { + "cpuUtilization" : { + "min" : 0.22, + "median" : 0.61, + "max" : 0.75, + "mean" : 0.55, + "count" : 150, + "stdDev" : 0.01 + }, + "physicalMemoryTotalBytes" : 1024, + "startTimeMs" : 1581508857327, + "physicalMemoryUsedBytes" : { + "min" : 1.2, + "median" : 1.85, + "max" : 2.5, + "mean" : 1.77, + "count" : 155, + "stdDev" : 0.25 + }, + "endTimeMs" : 1581508867333 + }, + "jitter" : 0.076808, + "application" : "webex", + "serverIp" : "185.199.108.153", + "testId" : "584739201", + "webex" : { + "remoteSipSessionId" : "22581707460321454", + "localSipSessionId" : "c124ba2b012050008000aa0c26c4bf0f", + "conferenceId" : "225817074608419375", + "correlationId" : "4e57c97e-abdf-4ec8-a78c-95bac9719896", + "meetingApp" : "ZoomCRC" + }, + "aid" : "1234", + "errorDetails" : "Error" + }, { + "originalTargetProfile" : { + "protocol" : "tcp", + "remotePort" : 80, + "remoteIpAddress" : "120.98.134.7" + }, + "agentId" : "861b7557-cd57-4bbb-b648-00bddf88ef49", + "minLatency" : 167, + "vpnProfile" : { + "vpnClientNetworkRange" : [ "9.88.37.27", "9.88.37.27" ], + "vpnGatewayAddress" : "120.98.134.7", + "vpnType" : "cisco-anyconnect", + "vpnClientAddresses" : [ "184.81.113.85", "13.129.91.62" ] + }, + "maxLatency" : 168, + "batteryMetrics" : { + "batteryHealthNormalizedPercent" : 0.92, + "batteryLevel" : "medium", + "batteryLevelNormalizedPercent" : 0.3 + }, + "userProfile" : { + "userName" : "joeblogs32", + "userPrincipalName" : "joeblogs32@c.com" + }, + "platform" : "mac", + "cellularProfile" : { + "rssi" : -10, + "advertisedNetworkSubtype" : "LTE/HSPA", + "carrierName" : "T-Mobile", + "rsrq" : -30, + "rsrp" : -30, + "advertisedNetworkGen" : "2g, 3g, 4g, 5g", + "rscp" : -30, + "networkGen" : "2g, 3g, 4g, 5g", + "networkSubtype" : "LTE/HSPA", + "sinr" : 20 + }, + "score" : { + "applicationScore" : 100, + "quality" : "great" + }, + "loss" : 0, + "protocol" : "tcp", + "networkProfile" : { + "previousInterface" : { + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "interfaceName" : "en0", + "subnetMask" : "255.255.255.0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ] + }, + "ethernetProfile" : { + "linkSpeed" : 860 + }, + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "proxyProfile" : { + "method" : "System", + "proxies" : [ { + "bypass" : "*.local;169.254/16", + "proxy" : "" + }, { + "bypass" : "*.local;169.254/16", + "proxy" : "" + } ] + }, + "subnetMask" : "255.255.255.0", + "error" : "An operation timed out.", + "wirelessProfile" : { + "rssi" : -38, + "bssid" : "4c:ba:ba:f4:fa:fa", + "snr" : 57, + "vendor" : "Cisco", + "txRate" : 130, + "channel" : 1, + "noise" : -95, + "phyMode" : "802.11n", + "ssid" : "Internet for the masses", + "quality" : 100 + }, + "interfaceName" : "en0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ], + "gateway" : "10.0.0.1" + }, + "ztaMetrics" : [ { + "loss" : 50, + "jitter" : 5, + "avgLatency" : 3, + "errorMessage" : "ERR_NAME_NOT_RESOLVED", + "type" : "zta_service" + }, { + "loss" : 50, + "jitter" : 5, + "avgLatency" : 3, + "errorMessage" : "ERR_NAME_NOT_RESOLVED", + "type" : "zta_service" + } ], + "roundId" : 1384309800, + "udpProbeMode" : "unknown", + "isIcmpBlocked" : true, + "avgLatency" : 167.04, + "tcpProbeMode" : "auto", + "systemMetrics" : { + "cpuUtilization" : { + "min" : 0.22, + "median" : 0.61, + "max" : 0.75, + "mean" : 0.55, + "count" : 150, + "stdDev" : 0.01 + }, + "physicalMemoryTotalBytes" : 1024, + "startTimeMs" : 1581508857327, + "physicalMemoryUsedBytes" : { + "min" : 1.2, + "median" : 1.85, + "max" : 2.5, + "mean" : 1.77, + "count" : 155, + "stdDev" : 0.25 + }, + "endTimeMs" : 1581508867333 + }, + "jitter" : 0.076808, + "application" : "webex", + "serverIp" : "185.199.108.153", + "testId" : "584739201", + "webex" : { + "remoteSipSessionId" : "22581707460321454", + "localSipSessionId" : "c124ba2b012050008000aa0c26c4bf0f", + "conferenceId" : "225817074608419375", + "correlationId" : "4e57c97e-abdf-4ec8-a78c-95bac9719896", + "meetingApp" : "ZoomCRC" + }, + "aid" : "1234", + "errorDetails" : "Error" + } ], + "startDate" : "2022-07-17T22:00:54Z" + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "searchSort" : [ { + "sort" : "round-id", + "order" : "desc" + }, { + "sort" : "round-id", + "order" : "desc" + } ], + "searchFilters" : { + "agentId" : [ "52455b09-ff1b-4849-8194-99026cc890e0", "52455b09-ff1b-4849-8194-99026cc890e0" ], + "webexConferenceId" : [ "719057112996612360", "719057112996612360" ], + "webexLocalSipSessionId" : [ "c124ba2b012050008000aa0c26c4bf0f", "c124ba2b012050008000aa0c26c4bf0f" ], + "userPrincipalName" : [ "joeblogs32@c.com", "joeblogs32@c.com" ], + "webexCorrelationId" : [ "f7d73641-8673-4547-be62-9521f78d9888", "f7d73641-8673-4547-be62-9521f78d9888" ] + }, + "thresholdFilter" : { + "conditionalOperator" : "and", + "filters" : [ { + "name" : "loss", + "value" : 10, + "operator" : "gte" + }, { + "name" : "loss", + "value" : 10, + "operator" : "gte" + } ] + } + } + + """), + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_dynamic_test_path_vis_agent_round_results": OperationExpectation( + operation_id="get_dynamic_test_path_vis_agent_round_results", + method="GET", + path="/endpoint/test-results/dynamic-tests/{testId}/path-vis/agent/{agentId}/round/{roundId}", + path_param_examples={ + "testId": '202701', + "agentId": '11', + "roundId": '1384309800', + }, + success_status=200, + success_body=json.loads(""" + + { + "test" : { + "hasPing" : true, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/dynamic-tests/281474976710706/network/filter" + }, { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/dynamic-tests/281474976710706/pathvis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isPrioritized" : false, + "networkMeasurements" : true, + "tcpProbeMode" : "auto", + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "protocol" : "icmp", + "createdDate" : "2022-07-17T22:00:54Z", + "ipVersion" : "V4_ONLY", + "application" : "webex", + "hasTraceroute" : true, + "isEnabled" : true, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "aid" : "1234", + "agentSelectorConfig" : { + "agentSelectorType" : "all-agents", + "maxMachines" : 25 + }, + "hasPathTraceInSession" : true, + "testName" : "Test name" + }, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "results" : [ { + "originalTargetProfile" : { + "protocol" : "tcp", + "remotePort" : 80, + "remoteIpAddress" : "120.98.134.7" + }, + "server" : "www.google.com:443", + "udpProbeMode" : "unknown", + "agentId" : "861b7557-cd57-4bbb-b648-00bddf88ef49", + "asnDetails" : { + "asName" : "ThousandEyes, Inc", + "asNumber" : 394101 + }, + "vpnProfile" : { + "vpnClientNetworkRange" : [ "9.88.37.27", "9.88.37.27" ], + "vpnGatewayAddress" : "120.98.134.7", + "vpnType" : "cisco-anyconnect", + "vpnClientAddresses" : [ "184.81.113.85", "13.129.91.62" ] + }, + "batteryMetrics" : { + "batteryHealthNormalizedPercent" : 0.92, + "batteryLevel" : "medium", + "batteryLevelNormalizedPercent" : 0.3 + }, + "sourcePrefix" : "196.40.96.0/20", + "userProfile" : { + "userName" : "joeblogs32", + "userPrincipalName" : "joeblogs32@c.com" + }, + "platform" : "mac", + "tcpProbeMode" : "auto", + "cellularProfile" : { + "rssi" : -10, + "advertisedNetworkSubtype" : "LTE/HSPA", + "carrierName" : "T-Mobile", + "rsrq" : -30, + "rsrp" : -30, + "advertisedNetworkGen" : "2g, 3g, 4g, 5g", + "rscp" : -30, + "networkGen" : "2g, 3g, 4g, 5g", + "networkSubtype" : "LTE/HSPA", + "sinr" : 20 + }, + "protocol" : "tcp", + "systemMetrics" : { + "cpuUtilization" : { + "min" : 0.22, + "median" : 0.61, + "max" : 0.75, + "mean" : 0.55, + "count" : 150, + "stdDev" : 0.01 + }, + "physicalMemoryTotalBytes" : 1024, + "startTimeMs" : 1581508857327, + "physicalMemoryUsedBytes" : { + "min" : 1.2, + "median" : 1.85, + "max" : 2.5, + "mean" : 1.77, + "count" : 155, + "stdDev" : 0.25 + }, + "endTimeMs" : 1581508867333 + }, + "sourceIp" : "196.40.106.237", + "application" : "webex", + "pathTraces" : [ { + "protocol" : "tcp", + "udpPathTraceMode" : "unknown", + "hops" : [ { + "rdns" : "core-router1.cpt2.host-h.net", + "prefix" : "196.40.96.0/20", + "responseTime" : 1, + "hop" : 1, + "ipAddress" : "196.40.106.237", + "location" : "Cape Town, South Africa", + "network" : "HETZNER (Pty) Ltd (AS 37153)" + }, { + "rdns" : "core-router1.cpt2.host-h.net", + "prefix" : "196.40.96.0/20", + "responseTime" : 1, + "hop" : 1, + "ipAddress" : "196.40.106.237", + "location" : "Cape Town, South Africa", + "network" : "HETZNER (Pty) Ltd (AS 37153)" + } ], + "pathId" : "4711301366345855606023718047703941305741293841502186803", + "tcpPathTraceMode" : "syn-pcap" + }, { + "protocol" : "tcp", + "udpPathTraceMode" : "unknown", + "hops" : [ { + "rdns" : "core-router1.cpt2.host-h.net", + "prefix" : "196.40.96.0/20", + "responseTime" : 1, + "hop" : 1, + "ipAddress" : "196.40.106.237", + "location" : "Cape Town, South Africa", + "network" : "HETZNER (Pty) Ltd (AS 37153)" + }, { + "rdns" : "core-router1.cpt2.host-h.net", + "prefix" : "196.40.96.0/20", + "responseTime" : 1, + "hop" : 1, + "ipAddress" : "196.40.106.237", + "location" : "Cape Town, South Africa", + "network" : "HETZNER (Pty) Ltd (AS 37153)" + } ], + "pathId" : "4711301366345855606023718047703941305741293841502186803", + "tcpPathTraceMode" : "syn-pcap" + } ], + "vpnPathTraces" : [ { + "protocol" : "tcp", + "udpPathTraceMode" : "unknown", + "hops" : [ { + "rdns" : "core-router1.cpt2.host-h.net", + "prefix" : "196.40.96.0/20", + "responseTime" : 1, + "hop" : 1, + "ipAddress" : "196.40.106.237", + "location" : "Cape Town, South Africa", + "network" : "HETZNER (Pty) Ltd (AS 37153)" + }, { + "rdns" : "core-router1.cpt2.host-h.net", + "prefix" : "196.40.96.0/20", + "responseTime" : 1, + "hop" : 1, + "ipAddress" : "196.40.106.237", + "location" : "Cape Town, South Africa", + "network" : "HETZNER (Pty) Ltd (AS 37153)" + } ], + "pathId" : "4711301366345855606023718047703941305741293841502186803", + "tcpPathTraceMode" : "syn-pcap" + }, { + "protocol" : "tcp", + "udpPathTraceMode" : "unknown", + "hops" : [ { + "rdns" : "core-router1.cpt2.host-h.net", + "prefix" : "196.40.96.0/20", + "responseTime" : 1, + "hop" : 1, + "ipAddress" : "196.40.106.237", + "location" : "Cape Town, South Africa", + "network" : "HETZNER (Pty) Ltd (AS 37153)" + }, { + "rdns" : "core-router1.cpt2.host-h.net", + "prefix" : "196.40.96.0/20", + "responseTime" : 1, + "hop" : 1, + "ipAddress" : "196.40.106.237", + "location" : "Cape Town, South Africa", + "network" : "HETZNER (Pty) Ltd (AS 37153)" + } ], + "pathId" : "4711301366345855606023718047703941305741293841502186803", + "tcpPathTraceMode" : "syn-pcap" + } ], + "serverIp" : "185.199.108.153", + "networkProfile" : { + "previousInterface" : { + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "interfaceName" : "en0", + "subnetMask" : "255.255.255.0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ] + }, + "ethernetProfile" : { + "linkSpeed" : 860 + }, + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "proxyProfile" : { + "method" : "System", + "proxies" : [ { + "bypass" : "*.local;169.254/16", + "proxy" : "" + }, { + "bypass" : "*.local;169.254/16", + "proxy" : "" + } ] + }, + "subnetMask" : "255.255.255.0", + "error" : "An operation timed out.", + "wirelessProfile" : { + "rssi" : -38, + "bssid" : "4c:ba:ba:f4:fa:fa", + "snr" : 57, + "vendor" : "Cisco", + "txRate" : 130, + "channel" : 1, + "noise" : -95, + "phyMode" : "802.11n", + "ssid" : "Internet for the masses", + "quality" : 100 + }, + "interfaceName" : "en0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ], + "gateway" : "10.0.0.1" + }, + "testId" : "584739201", + "webex" : { + "remoteSipSessionId" : "22581707460321454", + "localSipSessionId" : "c124ba2b012050008000aa0c26c4bf0f", + "conferenceId" : "225817074608419375", + "correlationId" : "4e57c97e-abdf-4ec8-a78c-95bac9719896", + "meetingApp" : "ZoomCRC" + }, + "aid" : "1234", + "roundId" : 1384309800 + }, { + "originalTargetProfile" : { + "protocol" : "tcp", + "remotePort" : 80, + "remoteIpAddress" : "120.98.134.7" + }, + "server" : "www.google.com:443", + "udpProbeMode" : "unknown", + "agentId" : "861b7557-cd57-4bbb-b648-00bddf88ef49", + "asnDetails" : { + "asName" : "ThousandEyes, Inc", + "asNumber" : 394101 + }, + "vpnProfile" : { + "vpnClientNetworkRange" : [ "9.88.37.27", "9.88.37.27" ], + "vpnGatewayAddress" : "120.98.134.7", + "vpnType" : "cisco-anyconnect", + "vpnClientAddresses" : [ "184.81.113.85", "13.129.91.62" ] + }, + "batteryMetrics" : { + "batteryHealthNormalizedPercent" : 0.92, + "batteryLevel" : "medium", + "batteryLevelNormalizedPercent" : 0.3 + }, + "sourcePrefix" : "196.40.96.0/20", + "userProfile" : { + "userName" : "joeblogs32", + "userPrincipalName" : "joeblogs32@c.com" + }, + "platform" : "mac", + "tcpProbeMode" : "auto", + "cellularProfile" : { + "rssi" : -10, + "advertisedNetworkSubtype" : "LTE/HSPA", + "carrierName" : "T-Mobile", + "rsrq" : -30, + "rsrp" : -30, + "advertisedNetworkGen" : "2g, 3g, 4g, 5g", + "rscp" : -30, + "networkGen" : "2g, 3g, 4g, 5g", + "networkSubtype" : "LTE/HSPA", + "sinr" : 20 + }, + "protocol" : "tcp", + "systemMetrics" : { + "cpuUtilization" : { + "min" : 0.22, + "median" : 0.61, + "max" : 0.75, + "mean" : 0.55, + "count" : 150, + "stdDev" : 0.01 + }, + "physicalMemoryTotalBytes" : 1024, + "startTimeMs" : 1581508857327, + "physicalMemoryUsedBytes" : { + "min" : 1.2, + "median" : 1.85, + "max" : 2.5, + "mean" : 1.77, + "count" : 155, + "stdDev" : 0.25 + }, + "endTimeMs" : 1581508867333 + }, + "sourceIp" : "196.40.106.237", + "application" : "webex", + "pathTraces" : [ { + "protocol" : "tcp", + "udpPathTraceMode" : "unknown", + "hops" : [ { + "rdns" : "core-router1.cpt2.host-h.net", + "prefix" : "196.40.96.0/20", + "responseTime" : 1, + "hop" : 1, + "ipAddress" : "196.40.106.237", + "location" : "Cape Town, South Africa", + "network" : "HETZNER (Pty) Ltd (AS 37153)" + }, { + "rdns" : "core-router1.cpt2.host-h.net", + "prefix" : "196.40.96.0/20", + "responseTime" : 1, + "hop" : 1, + "ipAddress" : "196.40.106.237", + "location" : "Cape Town, South Africa", + "network" : "HETZNER (Pty) Ltd (AS 37153)" + } ], + "pathId" : "4711301366345855606023718047703941305741293841502186803", + "tcpPathTraceMode" : "syn-pcap" + }, { + "protocol" : "tcp", + "udpPathTraceMode" : "unknown", + "hops" : [ { + "rdns" : "core-router1.cpt2.host-h.net", + "prefix" : "196.40.96.0/20", + "responseTime" : 1, + "hop" : 1, + "ipAddress" : "196.40.106.237", + "location" : "Cape Town, South Africa", + "network" : "HETZNER (Pty) Ltd (AS 37153)" + }, { + "rdns" : "core-router1.cpt2.host-h.net", + "prefix" : "196.40.96.0/20", + "responseTime" : 1, + "hop" : 1, + "ipAddress" : "196.40.106.237", + "location" : "Cape Town, South Africa", + "network" : "HETZNER (Pty) Ltd (AS 37153)" + } ], + "pathId" : "4711301366345855606023718047703941305741293841502186803", + "tcpPathTraceMode" : "syn-pcap" + } ], + "vpnPathTraces" : [ { + "protocol" : "tcp", + "udpPathTraceMode" : "unknown", + "hops" : [ { + "rdns" : "core-router1.cpt2.host-h.net", + "prefix" : "196.40.96.0/20", + "responseTime" : 1, + "hop" : 1, + "ipAddress" : "196.40.106.237", + "location" : "Cape Town, South Africa", + "network" : "HETZNER (Pty) Ltd (AS 37153)" + }, { + "rdns" : "core-router1.cpt2.host-h.net", + "prefix" : "196.40.96.0/20", + "responseTime" : 1, + "hop" : 1, + "ipAddress" : "196.40.106.237", + "location" : "Cape Town, South Africa", + "network" : "HETZNER (Pty) Ltd (AS 37153)" + } ], + "pathId" : "4711301366345855606023718047703941305741293841502186803", + "tcpPathTraceMode" : "syn-pcap" + }, { + "protocol" : "tcp", + "udpPathTraceMode" : "unknown", + "hops" : [ { + "rdns" : "core-router1.cpt2.host-h.net", + "prefix" : "196.40.96.0/20", + "responseTime" : 1, + "hop" : 1, + "ipAddress" : "196.40.106.237", + "location" : "Cape Town, South Africa", + "network" : "HETZNER (Pty) Ltd (AS 37153)" + }, { + "rdns" : "core-router1.cpt2.host-h.net", + "prefix" : "196.40.96.0/20", + "responseTime" : 1, + "hop" : 1, + "ipAddress" : "196.40.106.237", + "location" : "Cape Town, South Africa", + "network" : "HETZNER (Pty) Ltd (AS 37153)" + } ], + "pathId" : "4711301366345855606023718047703941305741293841502186803", + "tcpPathTraceMode" : "syn-pcap" + } ], + "serverIp" : "185.199.108.153", + "networkProfile" : { + "previousInterface" : { + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "interfaceName" : "en0", + "subnetMask" : "255.255.255.0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ] + }, + "ethernetProfile" : { + "linkSpeed" : 860 + }, + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "proxyProfile" : { + "method" : "System", + "proxies" : [ { + "bypass" : "*.local;169.254/16", + "proxy" : "" + }, { + "bypass" : "*.local;169.254/16", + "proxy" : "" + } ] + }, + "subnetMask" : "255.255.255.0", + "error" : "An operation timed out.", + "wirelessProfile" : { + "rssi" : -38, + "bssid" : "4c:ba:ba:f4:fa:fa", + "snr" : 57, + "vendor" : "Cisco", + "txRate" : 130, + "channel" : 1, + "noise" : -95, + "phyMode" : "802.11n", + "ssid" : "Internet for the masses", + "quality" : 100 + }, + "interfaceName" : "en0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ], + "gateway" : "10.0.0.1" + }, + "testId" : "584739201", + "webex" : { + "remoteSipSessionId" : "22581707460321454", + "localSipSessionId" : "c124ba2b012050008000aa0c26c4bf0f", + "conferenceId" : "225817074608419375", + "correlationId" : "4e57c97e-abdf-4ec8-a78c-95bac9719896", + "meetingApp" : "ZoomCRC" + }, + "aid" : "1234", + "roundId" : 1384309800 + } ] + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_dynamic_test_path_vis_results": OperationExpectation( + operation_id="get_dynamic_test_path_vis_results", + method="GET", + path="/endpoint/test-results/dynamic-tests/{testId}/path-vis", + path_param_examples={ + "testId": '202701', + }, + success_status=200, + success_body=json.loads(""" + + { + "test" : { + "hasPing" : true, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/dynamic-tests/281474976710706/network/filter" + }, { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/dynamic-tests/281474976710706/pathvis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isPrioritized" : false, + "networkMeasurements" : true, + "tcpProbeMode" : "auto", + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "protocol" : "icmp", + "createdDate" : "2022-07-17T22:00:54Z", + "ipVersion" : "V4_ONLY", + "application" : "webex", + "hasTraceroute" : true, + "isEnabled" : true, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "aid" : "1234", + "agentSelectorConfig" : { + "agentSelectorType" : "all-agents", + "maxMachines" : 25 + }, + "hasPathTraceInSession" : true, + "testName" : "Test name" + }, + "endDate" : "2022-07-18T22:00:54Z", + "totalHits" : 12, + "_links" : { + "next" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "results" : [ { + "originalTargetProfile" : { + "protocol" : "tcp", + "remotePort" : 80, + "remoteIpAddress" : "120.98.134.7" + }, + "server" : "www.google.com:443", + "udpProbeMode" : "unknown", + "agentId" : "861b7557-cd57-4bbb-b648-00bddf88ef49", + "asnDetails" : { + "asName" : "ThousandEyes, Inc", + "asNumber" : 394101 + }, + "vpnProfile" : { + "vpnClientNetworkRange" : [ "9.88.37.27", "9.88.37.27" ], + "vpnGatewayAddress" : "120.98.134.7", + "vpnType" : "cisco-anyconnect", + "vpnClientAddresses" : [ "184.81.113.85", "13.129.91.62" ] + }, + "batteryMetrics" : { + "batteryHealthNormalizedPercent" : 0.92, + "batteryLevel" : "medium", + "batteryLevelNormalizedPercent" : 0.3 + }, + "sourcePrefix" : "196.40.96.0/20", + "userProfile" : { + "userName" : "joeblogs32", + "userPrincipalName" : "joeblogs32@c.com" + }, + "platform" : "mac", + "tcpProbeMode" : "auto", + "cellularProfile" : { + "rssi" : -10, + "advertisedNetworkSubtype" : "LTE/HSPA", + "carrierName" : "T-Mobile", + "rsrq" : -30, + "rsrp" : -30, + "advertisedNetworkGen" : "2g, 3g, 4g, 5g", + "rscp" : -30, + "networkGen" : "2g, 3g, 4g, 5g", + "networkSubtype" : "LTE/HSPA", + "sinr" : 20 + }, + "protocol" : "tcp", + "systemMetrics" : { + "cpuUtilization" : { + "min" : 0.22, + "median" : 0.61, + "max" : 0.75, + "mean" : 0.55, + "count" : 150, + "stdDev" : 0.01 + }, + "physicalMemoryTotalBytes" : 1024, + "startTimeMs" : 1581508857327, + "physicalMemoryUsedBytes" : { + "min" : 1.2, + "median" : 1.85, + "max" : 2.5, + "mean" : 1.77, + "count" : 155, + "stdDev" : 0.25 + }, + "endTimeMs" : 1581508867333 + }, + "sourceIp" : "196.40.106.237", + "application" : "webex", + "pathTraces" : [ { + "protocol" : "tcp", + "numberOfHops" : 15, + "responseTime" : 1500, + "ipAddress" : "196.40.106.237", + "udpPathTraceMode" : "unknown", + "pathId" : "1230899668701775614109128428722974545787322404682781961521", + "tcpPathTraceMode" : "syn-pcap" + }, { + "protocol" : "tcp", + "numberOfHops" : 15, + "responseTime" : 1500, + "ipAddress" : "196.40.106.237", + "udpPathTraceMode" : "unknown", + "pathId" : "1230899668701775614109128428722974545787322404682781961521", + "tcpPathTraceMode" : "syn-pcap" + } ], + "serverIp" : "185.199.108.153", + "networkProfile" : { + "previousInterface" : { + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "interfaceName" : "en0", + "subnetMask" : "255.255.255.0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ] + }, + "ethernetProfile" : { + "linkSpeed" : 860 + }, + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "proxyProfile" : { + "method" : "System", + "proxies" : [ { + "bypass" : "*.local;169.254/16", + "proxy" : "" + }, { + "bypass" : "*.local;169.254/16", + "proxy" : "" + } ] + }, + "subnetMask" : "255.255.255.0", + "error" : "An operation timed out.", + "wirelessProfile" : { + "rssi" : -38, + "bssid" : "4c:ba:ba:f4:fa:fa", + "snr" : 57, + "vendor" : "Cisco", + "txRate" : 130, + "channel" : 1, + "noise" : -95, + "phyMode" : "802.11n", + "ssid" : "Internet for the masses", + "quality" : 100 + }, + "interfaceName" : "en0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ], + "gateway" : "10.0.0.1" + }, + "testId" : "584739201", + "location" : "San Francisco Area", + "webex" : { + "remoteSipSessionId" : "22581707460321454", + "localSipSessionId" : "c124ba2b012050008000aa0c26c4bf0f", + "conferenceId" : "225817074608419375", + "correlationId" : "4e57c97e-abdf-4ec8-a78c-95bac9719896", + "meetingApp" : "ZoomCRC" + }, + "aid" : "1234", + "roundId" : 1384309800 + }, { + "originalTargetProfile" : { + "protocol" : "tcp", + "remotePort" : 80, + "remoteIpAddress" : "120.98.134.7" + }, + "server" : "www.google.com:443", + "udpProbeMode" : "unknown", + "agentId" : "861b7557-cd57-4bbb-b648-00bddf88ef49", + "asnDetails" : { + "asName" : "ThousandEyes, Inc", + "asNumber" : 394101 + }, + "vpnProfile" : { + "vpnClientNetworkRange" : [ "9.88.37.27", "9.88.37.27" ], + "vpnGatewayAddress" : "120.98.134.7", + "vpnType" : "cisco-anyconnect", + "vpnClientAddresses" : [ "184.81.113.85", "13.129.91.62" ] + }, + "batteryMetrics" : { + "batteryHealthNormalizedPercent" : 0.92, + "batteryLevel" : "medium", + "batteryLevelNormalizedPercent" : 0.3 + }, + "sourcePrefix" : "196.40.96.0/20", + "userProfile" : { + "userName" : "joeblogs32", + "userPrincipalName" : "joeblogs32@c.com" + }, + "platform" : "mac", + "tcpProbeMode" : "auto", + "cellularProfile" : { + "rssi" : -10, + "advertisedNetworkSubtype" : "LTE/HSPA", + "carrierName" : "T-Mobile", + "rsrq" : -30, + "rsrp" : -30, + "advertisedNetworkGen" : "2g, 3g, 4g, 5g", + "rscp" : -30, + "networkGen" : "2g, 3g, 4g, 5g", + "networkSubtype" : "LTE/HSPA", + "sinr" : 20 + }, + "protocol" : "tcp", + "systemMetrics" : { + "cpuUtilization" : { + "min" : 0.22, + "median" : 0.61, + "max" : 0.75, + "mean" : 0.55, + "count" : 150, + "stdDev" : 0.01 + }, + "physicalMemoryTotalBytes" : 1024, + "startTimeMs" : 1581508857327, + "physicalMemoryUsedBytes" : { + "min" : 1.2, + "median" : 1.85, + "max" : 2.5, + "mean" : 1.77, + "count" : 155, + "stdDev" : 0.25 + }, + "endTimeMs" : 1581508867333 + }, + "sourceIp" : "196.40.106.237", + "application" : "webex", + "pathTraces" : [ { + "protocol" : "tcp", + "numberOfHops" : 15, + "responseTime" : 1500, + "ipAddress" : "196.40.106.237", + "udpPathTraceMode" : "unknown", + "pathId" : "1230899668701775614109128428722974545787322404682781961521", + "tcpPathTraceMode" : "syn-pcap" + }, { + "protocol" : "tcp", + "numberOfHops" : 15, + "responseTime" : 1500, + "ipAddress" : "196.40.106.237", + "udpPathTraceMode" : "unknown", + "pathId" : "1230899668701775614109128428722974545787322404682781961521", + "tcpPathTraceMode" : "syn-pcap" + } ], + "serverIp" : "185.199.108.153", + "networkProfile" : { + "previousInterface" : { + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "interfaceName" : "en0", + "subnetMask" : "255.255.255.0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ] + }, + "ethernetProfile" : { + "linkSpeed" : 860 + }, + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "proxyProfile" : { + "method" : "System", + "proxies" : [ { + "bypass" : "*.local;169.254/16", + "proxy" : "" + }, { + "bypass" : "*.local;169.254/16", + "proxy" : "" + } ] + }, + "subnetMask" : "255.255.255.0", + "error" : "An operation timed out.", + "wirelessProfile" : { + "rssi" : -38, + "bssid" : "4c:ba:ba:f4:fa:fa", + "snr" : 57, + "vendor" : "Cisco", + "txRate" : 130, + "channel" : 1, + "noise" : -95, + "phyMode" : "802.11n", + "ssid" : "Internet for the masses", + "quality" : 100 + }, + "interfaceName" : "en0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ], + "gateway" : "10.0.0.1" + }, + "testId" : "584739201", + "location" : "San Francisco Area", + "webex" : { + "remoteSipSessionId" : "22581707460321454", + "localSipSessionId" : "c124ba2b012050008000aa0c26c4bf0f", + "conferenceId" : "225817074608419375", + "correlationId" : "4e57c97e-abdf-4ec8-a78c-95bac9719896", + "meetingApp" : "ZoomCRC" + }, + "aid" : "1234", + "roundId" : 1384309800 + } ], + "startDate" : "2022-07-17T22:00:54Z" + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "filter_scheduled_test_network_results": OperationExpectation( + operation_id="filter_scheduled_test_network_results", + method="POST", + path="/endpoint/test-results/scheduled-tests/{testId}/network/filter", + path_param_examples={ + "testId": '202701', + }, + success_status=200, + success_body=json.loads(""" + + { + "test" : { + "server" : "www.example.com", + "isSavedEvent" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/scheduled-tests/281474976710706/network/filter" + }, { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/scheduled-tests/281474976710706/pathvis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isPrioritized" : false, + "networkMeasurements" : true, + "type" : "agent-to-server", + "tcpProbeMode" : "auto", + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "protocol" : "icmp", + "createdDate" : "2022-07-17T22:00:54Z", + "ipVersion" : "V4_ONLY", + "port" : 443, + "isEnabled" : true, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "aid" : "1234", + "agentSelectorConfig" : { + "agentSelectorType" : "all-agents", + "maxMachines" : 25 + }, + "hasPathTraceInSession" : true, + "testName" : "Test name" + }, + "totalHits" : 12, + "endDate" : "2022-07-18T22:00:54Z", + "_links" : { + "next" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "results" : [ { + "originalTargetProfile" : { + "protocol" : "tcp", + "remotePort" : 80, + "remoteIpAddress" : "120.98.134.7" + }, + "agentId" : "861b7557-cd57-4bbb-b648-00bddf88ef49", + "isIcmpBlocked" : true, + "avgLatency" : 167.04, + "minLatency" : 167, + "vpnProfile" : { + "vpnClientNetworkRange" : [ "9.88.37.27", "9.88.37.27" ], + "vpnGatewayAddress" : "120.98.134.7", + "vpnType" : "cisco-anyconnect", + "vpnClientAddresses" : [ "184.81.113.85", "13.129.91.62" ] + }, + "maxLatency" : 168, + "batteryMetrics" : { + "batteryHealthNormalizedPercent" : 0.92, + "batteryLevel" : "medium", + "batteryLevelNormalizedPercent" : 0.3 + }, + "userProfile" : { + "userName" : "joeblogs32", + "userPrincipalName" : "joeblogs32@c.com" + }, + "platform" : "mac", + "cellularProfile" : { + "rssi" : -10, + "advertisedNetworkSubtype" : "LTE/HSPA", + "carrierName" : "T-Mobile", + "rsrq" : -30, + "rsrp" : -30, + "advertisedNetworkGen" : "2g, 3g, 4g, 5g", + "rscp" : -30, + "networkGen" : "2g, 3g, 4g, 5g", + "networkSubtype" : "LTE/HSPA", + "sinr" : 20 + }, + "score" : { + "applicationScore" : 100, + "quality" : "great" + }, + "loss" : 0, + "systemMetrics" : { + "cpuUtilization" : { + "min" : 0.22, + "median" : 0.61, + "max" : 0.75, + "mean" : 0.55, + "count" : 150, + "stdDev" : 0.01 + }, + "physicalMemoryTotalBytes" : 1024, + "startTimeMs" : 1581508857327, + "physicalMemoryUsedBytes" : { + "min" : 1.2, + "median" : 1.85, + "max" : 2.5, + "mean" : 1.77, + "count" : 155, + "stdDev" : 0.25 + }, + "endTimeMs" : 1581508867333 + }, + "jitter" : 0.076808, + "serverIp" : "185.199.108.153", + "networkProfile" : { + "previousInterface" : { + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "interfaceName" : "en0", + "subnetMask" : "255.255.255.0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ] + }, + "ethernetProfile" : { + "linkSpeed" : 860 + }, + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "proxyProfile" : { + "method" : "System", + "proxies" : [ { + "bypass" : "*.local;169.254/16", + "proxy" : "" + }, { + "bypass" : "*.local;169.254/16", + "proxy" : "" + } ] + }, + "subnetMask" : "255.255.255.0", + "error" : "An operation timed out.", + "wirelessProfile" : { + "rssi" : -38, + "bssid" : "4c:ba:ba:f4:fa:fa", + "snr" : 57, + "vendor" : "Cisco", + "txRate" : 130, + "channel" : 1, + "noise" : -95, + "phyMode" : "802.11n", + "ssid" : "Internet for the masses", + "quality" : 100 + }, + "interfaceName" : "en0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ], + "gateway" : "10.0.0.1" + }, + "ztaMetrics" : [ { + "loss" : 50, + "jitter" : 5, + "avgLatency" : 3, + "errorMessage" : "ERR_NAME_NOT_RESOLVED", + "type" : "zta_service" + }, { + "loss" : 50, + "jitter" : 5, + "avgLatency" : 3, + "errorMessage" : "ERR_NAME_NOT_RESOLVED", + "type" : "zta_service" + } ], + "testId" : "584739201", + "aid" : "1234", + "roundId" : 1384309800, + "errorDetails" : "Error" + }, { + "originalTargetProfile" : { + "protocol" : "tcp", + "remotePort" : 80, + "remoteIpAddress" : "120.98.134.7" + }, + "agentId" : "861b7557-cd57-4bbb-b648-00bddf88ef49", + "isIcmpBlocked" : true, + "avgLatency" : 167.04, + "minLatency" : 167, + "vpnProfile" : { + "vpnClientNetworkRange" : [ "9.88.37.27", "9.88.37.27" ], + "vpnGatewayAddress" : "120.98.134.7", + "vpnType" : "cisco-anyconnect", + "vpnClientAddresses" : [ "184.81.113.85", "13.129.91.62" ] + }, + "maxLatency" : 168, + "batteryMetrics" : { + "batteryHealthNormalizedPercent" : 0.92, + "batteryLevel" : "medium", + "batteryLevelNormalizedPercent" : 0.3 + }, + "userProfile" : { + "userName" : "joeblogs32", + "userPrincipalName" : "joeblogs32@c.com" + }, + "platform" : "mac", + "cellularProfile" : { + "rssi" : -10, + "advertisedNetworkSubtype" : "LTE/HSPA", + "carrierName" : "T-Mobile", + "rsrq" : -30, + "rsrp" : -30, + "advertisedNetworkGen" : "2g, 3g, 4g, 5g", + "rscp" : -30, + "networkGen" : "2g, 3g, 4g, 5g", + "networkSubtype" : "LTE/HSPA", + "sinr" : 20 + }, + "score" : { + "applicationScore" : 100, + "quality" : "great" + }, + "loss" : 0, + "systemMetrics" : { + "cpuUtilization" : { + "min" : 0.22, + "median" : 0.61, + "max" : 0.75, + "mean" : 0.55, + "count" : 150, + "stdDev" : 0.01 + }, + "physicalMemoryTotalBytes" : 1024, + "startTimeMs" : 1581508857327, + "physicalMemoryUsedBytes" : { + "min" : 1.2, + "median" : 1.85, + "max" : 2.5, + "mean" : 1.77, + "count" : 155, + "stdDev" : 0.25 + }, + "endTimeMs" : 1581508867333 + }, + "jitter" : 0.076808, + "serverIp" : "185.199.108.153", + "networkProfile" : { + "previousInterface" : { + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "interfaceName" : "en0", + "subnetMask" : "255.255.255.0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ] + }, + "ethernetProfile" : { + "linkSpeed" : 860 + }, + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "proxyProfile" : { + "method" : "System", + "proxies" : [ { + "bypass" : "*.local;169.254/16", + "proxy" : "" + }, { + "bypass" : "*.local;169.254/16", + "proxy" : "" + } ] + }, + "subnetMask" : "255.255.255.0", + "error" : "An operation timed out.", + "wirelessProfile" : { + "rssi" : -38, + "bssid" : "4c:ba:ba:f4:fa:fa", + "snr" : 57, + "vendor" : "Cisco", + "txRate" : 130, + "channel" : 1, + "noise" : -95, + "phyMode" : "802.11n", + "ssid" : "Internet for the masses", + "quality" : 100 + }, + "interfaceName" : "en0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ], + "gateway" : "10.0.0.1" + }, + "ztaMetrics" : [ { + "loss" : 50, + "jitter" : 5, + "avgLatency" : 3, + "errorMessage" : "ERR_NAME_NOT_RESOLVED", + "type" : "zta_service" + }, { + "loss" : 50, + "jitter" : 5, + "avgLatency" : 3, + "errorMessage" : "ERR_NAME_NOT_RESOLVED", + "type" : "zta_service" + } ], + "testId" : "584739201", + "aid" : "1234", + "roundId" : 1384309800, + "errorDetails" : "Error" + } ], + "startDate" : "2022-07-17T22:00:54Z" + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "searchSort" : [ { + "sort" : "round-id", + "order" : "desc" + }, { + "sort" : "round-id", + "order" : "desc" + } ], + "searchFilters" : { + "agentId" : [ "52455b09-ff1b-4849-8194-99026cc890e0", "52455b09-ff1b-4849-8194-99026cc890e0" ], + "userPrincipalName" : [ "joeblogs32@c.com", "joeblogs32@c.com" ] + }, + "thresholdFilter" : { + "conditionalOperator" : "and", + "filters" : [ { + "name" : "loss", + "value" : 10, + "operator" : "gte" + }, { + "name" : "loss", + "value" : 10, + "operator" : "gte" + } ] + } + } + + """), + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "filter_scheduled_tests_network_results": OperationExpectation( + operation_id="filter_scheduled_tests_network_results", + method="POST", + path="/endpoint/test-results/scheduled-tests/network/filter", + path_param_examples={ + }, + success_status=200, + success_body=json.loads(""" + + { + "totalHits" : 12, + "endDate" : "2022-07-18T22:00:54Z", + "_links" : { + "next" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "results" : [ { + "originalTargetProfile" : { + "protocol" : "tcp", + "remotePort" : 80, + "remoteIpAddress" : "120.98.134.7" + }, + "agentId" : "861b7557-cd57-4bbb-b648-00bddf88ef49", + "isIcmpBlocked" : true, + "avgLatency" : 167.04, + "minLatency" : 167, + "vpnProfile" : { + "vpnClientNetworkRange" : [ "9.88.37.27", "9.88.37.27" ], + "vpnGatewayAddress" : "120.98.134.7", + "vpnType" : "cisco-anyconnect", + "vpnClientAddresses" : [ "184.81.113.85", "13.129.91.62" ] + }, + "maxLatency" : 168, + "batteryMetrics" : { + "batteryHealthNormalizedPercent" : 0.92, + "batteryLevel" : "medium", + "batteryLevelNormalizedPercent" : 0.3 + }, + "userProfile" : { + "userName" : "joeblogs32", + "userPrincipalName" : "joeblogs32@c.com" + }, + "platform" : "mac", + "cellularProfile" : { + "rssi" : -10, + "advertisedNetworkSubtype" : "LTE/HSPA", + "carrierName" : "T-Mobile", + "rsrq" : -30, + "rsrp" : -30, + "advertisedNetworkGen" : "2g, 3g, 4g, 5g", + "rscp" : -30, + "networkGen" : "2g, 3g, 4g, 5g", + "networkSubtype" : "LTE/HSPA", + "sinr" : 20 + }, + "score" : { + "applicationScore" : 100, + "quality" : "great" + }, + "loss" : 0, + "systemMetrics" : { + "cpuUtilization" : { + "min" : 0.22, + "median" : 0.61, + "max" : 0.75, + "mean" : 0.55, + "count" : 150, + "stdDev" : 0.01 + }, + "physicalMemoryTotalBytes" : 1024, + "startTimeMs" : 1581508857327, + "physicalMemoryUsedBytes" : { + "min" : 1.2, + "median" : 1.85, + "max" : 2.5, + "mean" : 1.77, + "count" : 155, + "stdDev" : 0.25 + }, + "endTimeMs" : 1581508867333 + }, + "jitter" : 0.076808, + "serverIp" : "185.199.108.153", + "networkProfile" : { + "previousInterface" : { + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "interfaceName" : "en0", + "subnetMask" : "255.255.255.0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ] + }, + "ethernetProfile" : { + "linkSpeed" : 860 + }, + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "proxyProfile" : { + "method" : "System", + "proxies" : [ { + "bypass" : "*.local;169.254/16", + "proxy" : "" + }, { + "bypass" : "*.local;169.254/16", + "proxy" : "" + } ] + }, + "subnetMask" : "255.255.255.0", + "error" : "An operation timed out.", + "wirelessProfile" : { + "rssi" : -38, + "bssid" : "4c:ba:ba:f4:fa:fa", + "snr" : 57, + "vendor" : "Cisco", + "txRate" : 130, + "channel" : 1, + "noise" : -95, + "phyMode" : "802.11n", + "ssid" : "Internet for the masses", + "quality" : 100 + }, + "interfaceName" : "en0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ], + "gateway" : "10.0.0.1" + }, + "ztaMetrics" : [ { + "loss" : 50, + "jitter" : 5, + "avgLatency" : 3, + "errorMessage" : "ERR_NAME_NOT_RESOLVED", + "type" : "zta_service" + }, { + "loss" : 50, + "jitter" : 5, + "avgLatency" : 3, + "errorMessage" : "ERR_NAME_NOT_RESOLVED", + "type" : "zta_service" + } ], + "testId" : "584739201", + "aid" : "1234", + "roundId" : 1384309800, + "errorDetails" : "Error" + }, { + "originalTargetProfile" : { + "protocol" : "tcp", + "remotePort" : 80, + "remoteIpAddress" : "120.98.134.7" + }, + "agentId" : "861b7557-cd57-4bbb-b648-00bddf88ef49", + "isIcmpBlocked" : true, + "avgLatency" : 167.04, + "minLatency" : 167, + "vpnProfile" : { + "vpnClientNetworkRange" : [ "9.88.37.27", "9.88.37.27" ], + "vpnGatewayAddress" : "120.98.134.7", + "vpnType" : "cisco-anyconnect", + "vpnClientAddresses" : [ "184.81.113.85", "13.129.91.62" ] + }, + "maxLatency" : 168, + "batteryMetrics" : { + "batteryHealthNormalizedPercent" : 0.92, + "batteryLevel" : "medium", + "batteryLevelNormalizedPercent" : 0.3 + }, + "userProfile" : { + "userName" : "joeblogs32", + "userPrincipalName" : "joeblogs32@c.com" + }, + "platform" : "mac", + "cellularProfile" : { + "rssi" : -10, + "advertisedNetworkSubtype" : "LTE/HSPA", + "carrierName" : "T-Mobile", + "rsrq" : -30, + "rsrp" : -30, + "advertisedNetworkGen" : "2g, 3g, 4g, 5g", + "rscp" : -30, + "networkGen" : "2g, 3g, 4g, 5g", + "networkSubtype" : "LTE/HSPA", + "sinr" : 20 + }, + "score" : { + "applicationScore" : 100, + "quality" : "great" + }, + "loss" : 0, + "systemMetrics" : { + "cpuUtilization" : { + "min" : 0.22, + "median" : 0.61, + "max" : 0.75, + "mean" : 0.55, + "count" : 150, + "stdDev" : 0.01 + }, + "physicalMemoryTotalBytes" : 1024, + "startTimeMs" : 1581508857327, + "physicalMemoryUsedBytes" : { + "min" : 1.2, + "median" : 1.85, + "max" : 2.5, + "mean" : 1.77, + "count" : 155, + "stdDev" : 0.25 + }, + "endTimeMs" : 1581508867333 + }, + "jitter" : 0.076808, + "serverIp" : "185.199.108.153", + "networkProfile" : { + "previousInterface" : { + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "interfaceName" : "en0", + "subnetMask" : "255.255.255.0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ] + }, + "ethernetProfile" : { + "linkSpeed" : 860 + }, + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "proxyProfile" : { + "method" : "System", + "proxies" : [ { + "bypass" : "*.local;169.254/16", + "proxy" : "" + }, { + "bypass" : "*.local;169.254/16", + "proxy" : "" + } ] + }, + "subnetMask" : "255.255.255.0", + "error" : "An operation timed out.", + "wirelessProfile" : { + "rssi" : -38, + "bssid" : "4c:ba:ba:f4:fa:fa", + "snr" : 57, + "vendor" : "Cisco", + "txRate" : 130, + "channel" : 1, + "noise" : -95, + "phyMode" : "802.11n", + "ssid" : "Internet for the masses", + "quality" : 100 + }, + "interfaceName" : "en0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ], + "gateway" : "10.0.0.1" + }, + "ztaMetrics" : [ { + "loss" : 50, + "jitter" : 5, + "avgLatency" : 3, + "errorMessage" : "ERR_NAME_NOT_RESOLVED", + "type" : "zta_service" + }, { + "loss" : 50, + "jitter" : 5, + "avgLatency" : 3, + "errorMessage" : "ERR_NAME_NOT_RESOLVED", + "type" : "zta_service" + } ], + "testId" : "584739201", + "aid" : "1234", + "roundId" : 1384309800, + "errorDetails" : "Error" + } ], + "startDate" : "2022-07-17T22:00:54Z" + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "searchSort" : [ { + "sort" : "round-id", + "order" : "desc" + }, { + "sort" : "round-id", + "order" : "desc" + } ], + "searchFilters" : { + "agentId" : [ "52455b09-ff1b-4849-8194-99026cc890e0", "52455b09-ff1b-4849-8194-99026cc890e0" ], + "testId" : [ "5", "5" ] + }, + "thresholdFilter" : { + "conditionalOperator" : "and", + "filters" : [ { + "name" : "loss", + "value" : 10, + "operator" : "gte" + }, { + "name" : "loss", + "value" : 10, + "operator" : "gte" + } ] + } + } + + """), + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_scheduled_test_path_vis_agent_round_results": OperationExpectation( + operation_id="get_scheduled_test_path_vis_agent_round_results", + method="GET", + path="/endpoint/test-results/scheduled-tests/{testId}/path-vis/agent/{agentId}/round/{roundId}", + path_param_examples={ + "testId": '202701', + "agentId": '11', + "roundId": '1384309800', + }, + success_status=200, + success_body=json.loads(""" + + { + "test" : { + "server" : "www.example.com", + "isSavedEvent" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/scheduled-tests/281474976710706/network/filter" + }, { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/scheduled-tests/281474976710706/pathvis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isPrioritized" : false, + "networkMeasurements" : true, + "type" : "agent-to-server", + "tcpProbeMode" : "auto", + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "protocol" : "icmp", + "createdDate" : "2022-07-17T22:00:54Z", + "ipVersion" : "V4_ONLY", + "port" : 443, + "isEnabled" : true, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "aid" : "1234", + "agentSelectorConfig" : { + "agentSelectorType" : "all-agents", + "maxMachines" : 25 + }, + "hasPathTraceInSession" : true, + "testName" : "Test name" + }, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "results" : [ { + "originalTargetProfile" : { + "protocol" : "tcp", + "remotePort" : 80, + "remoteIpAddress" : "120.98.134.7" + }, + "server" : "www.google.com:443", + "agentId" : "861b7557-cd57-4bbb-b648-00bddf88ef49", + "asnDetails" : { + "asName" : "ThousandEyes, Inc", + "asNumber" : 394101 + }, + "vpnProfile" : { + "vpnClientNetworkRange" : [ "9.88.37.27", "9.88.37.27" ], + "vpnGatewayAddress" : "120.98.134.7", + "vpnType" : "cisco-anyconnect", + "vpnClientAddresses" : [ "184.81.113.85", "13.129.91.62" ] + }, + "batteryMetrics" : { + "batteryHealthNormalizedPercent" : 0.92, + "batteryLevel" : "medium", + "batteryLevelNormalizedPercent" : 0.3 + }, + "sourcePrefix" : "196.40.96.0/20", + "userProfile" : { + "userName" : "joeblogs32", + "userPrincipalName" : "joeblogs32@c.com" + }, + "platform" : "mac", + "cellularProfile" : { + "rssi" : -10, + "advertisedNetworkSubtype" : "LTE/HSPA", + "carrierName" : "T-Mobile", + "rsrq" : -30, + "rsrp" : -30, + "advertisedNetworkGen" : "2g, 3g, 4g, 5g", + "rscp" : -30, + "networkGen" : "2g, 3g, 4g, 5g", + "networkSubtype" : "LTE/HSPA", + "sinr" : 20 + }, + "systemMetrics" : { + "cpuUtilization" : { + "min" : 0.22, + "median" : 0.61, + "max" : 0.75, + "mean" : 0.55, + "count" : 150, + "stdDev" : 0.01 + }, + "physicalMemoryTotalBytes" : 1024, + "startTimeMs" : 1581508857327, + "physicalMemoryUsedBytes" : { + "min" : 1.2, + "median" : 1.85, + "max" : 2.5, + "mean" : 1.77, + "count" : 155, + "stdDev" : 0.25 + }, + "endTimeMs" : 1581508867333 + }, + "sourceIp" : "196.40.106.237", + "pathTraces" : [ { + "protocol" : "tcp", + "udpPathTraceMode" : "unknown", + "hops" : [ { + "rdns" : "core-router1.cpt2.host-h.net", + "prefix" : "196.40.96.0/20", + "responseTime" : 1, + "hop" : 1, + "ipAddress" : "196.40.106.237", + "location" : "Cape Town, South Africa", + "network" : "HETZNER (Pty) Ltd (AS 37153)" + }, { + "rdns" : "core-router1.cpt2.host-h.net", + "prefix" : "196.40.96.0/20", + "responseTime" : 1, + "hop" : 1, + "ipAddress" : "196.40.106.237", + "location" : "Cape Town, South Africa", + "network" : "HETZNER (Pty) Ltd (AS 37153)" + } ], + "pathId" : "4711301366345855606023718047703941305741293841502186803", + "tcpPathTraceMode" : "syn-pcap" + }, { + "protocol" : "tcp", + "udpPathTraceMode" : "unknown", + "hops" : [ { + "rdns" : "core-router1.cpt2.host-h.net", + "prefix" : "196.40.96.0/20", + "responseTime" : 1, + "hop" : 1, + "ipAddress" : "196.40.106.237", + "location" : "Cape Town, South Africa", + "network" : "HETZNER (Pty) Ltd (AS 37153)" + }, { + "rdns" : "core-router1.cpt2.host-h.net", + "prefix" : "196.40.96.0/20", + "responseTime" : 1, + "hop" : 1, + "ipAddress" : "196.40.106.237", + "location" : "Cape Town, South Africa", + "network" : "HETZNER (Pty) Ltd (AS 37153)" + } ], + "pathId" : "4711301366345855606023718047703941305741293841502186803", + "tcpPathTraceMode" : "syn-pcap" + } ], + "vpnPathTraces" : [ { + "protocol" : "tcp", + "udpPathTraceMode" : "unknown", + "hops" : [ { + "rdns" : "core-router1.cpt2.host-h.net", + "prefix" : "196.40.96.0/20", + "responseTime" : 1, + "hop" : 1, + "ipAddress" : "196.40.106.237", + "location" : "Cape Town, South Africa", + "network" : "HETZNER (Pty) Ltd (AS 37153)" + }, { + "rdns" : "core-router1.cpt2.host-h.net", + "prefix" : "196.40.96.0/20", + "responseTime" : 1, + "hop" : 1, + "ipAddress" : "196.40.106.237", + "location" : "Cape Town, South Africa", + "network" : "HETZNER (Pty) Ltd (AS 37153)" + } ], + "pathId" : "4711301366345855606023718047703941305741293841502186803", + "tcpPathTraceMode" : "syn-pcap" + }, { + "protocol" : "tcp", + "udpPathTraceMode" : "unknown", + "hops" : [ { + "rdns" : "core-router1.cpt2.host-h.net", + "prefix" : "196.40.96.0/20", + "responseTime" : 1, + "hop" : 1, + "ipAddress" : "196.40.106.237", + "location" : "Cape Town, South Africa", + "network" : "HETZNER (Pty) Ltd (AS 37153)" + }, { + "rdns" : "core-router1.cpt2.host-h.net", + "prefix" : "196.40.96.0/20", + "responseTime" : 1, + "hop" : 1, + "ipAddress" : "196.40.106.237", + "location" : "Cape Town, South Africa", + "network" : "HETZNER (Pty) Ltd (AS 37153)" + } ], + "pathId" : "4711301366345855606023718047703941305741293841502186803", + "tcpPathTraceMode" : "syn-pcap" + } ], + "serverIp" : "185.199.108.153", + "networkProfile" : { + "previousInterface" : { + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "interfaceName" : "en0", + "subnetMask" : "255.255.255.0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ] + }, + "ethernetProfile" : { + "linkSpeed" : 860 + }, + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "proxyProfile" : { + "method" : "System", + "proxies" : [ { + "bypass" : "*.local;169.254/16", + "proxy" : "" + }, { + "bypass" : "*.local;169.254/16", + "proxy" : "" + } ] + }, + "subnetMask" : "255.255.255.0", + "error" : "An operation timed out.", + "wirelessProfile" : { + "rssi" : -38, + "bssid" : "4c:ba:ba:f4:fa:fa", + "snr" : 57, + "vendor" : "Cisco", + "txRate" : 130, + "channel" : 1, + "noise" : -95, + "phyMode" : "802.11n", + "ssid" : "Internet for the masses", + "quality" : 100 + }, + "interfaceName" : "en0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ], + "gateway" : "10.0.0.1" + }, + "testId" : "584739201", + "aid" : "1234", + "roundId" : 1384309800 + }, { + "originalTargetProfile" : { + "protocol" : "tcp", + "remotePort" : 80, + "remoteIpAddress" : "120.98.134.7" + }, + "server" : "www.google.com:443", + "agentId" : "861b7557-cd57-4bbb-b648-00bddf88ef49", + "asnDetails" : { + "asName" : "ThousandEyes, Inc", + "asNumber" : 394101 + }, + "vpnProfile" : { + "vpnClientNetworkRange" : [ "9.88.37.27", "9.88.37.27" ], + "vpnGatewayAddress" : "120.98.134.7", + "vpnType" : "cisco-anyconnect", + "vpnClientAddresses" : [ "184.81.113.85", "13.129.91.62" ] + }, + "batteryMetrics" : { + "batteryHealthNormalizedPercent" : 0.92, + "batteryLevel" : "medium", + "batteryLevelNormalizedPercent" : 0.3 + }, + "sourcePrefix" : "196.40.96.0/20", + "userProfile" : { + "userName" : "joeblogs32", + "userPrincipalName" : "joeblogs32@c.com" + }, + "platform" : "mac", + "cellularProfile" : { + "rssi" : -10, + "advertisedNetworkSubtype" : "LTE/HSPA", + "carrierName" : "T-Mobile", + "rsrq" : -30, + "rsrp" : -30, + "advertisedNetworkGen" : "2g, 3g, 4g, 5g", + "rscp" : -30, + "networkGen" : "2g, 3g, 4g, 5g", + "networkSubtype" : "LTE/HSPA", + "sinr" : 20 + }, + "systemMetrics" : { + "cpuUtilization" : { + "min" : 0.22, + "median" : 0.61, + "max" : 0.75, + "mean" : 0.55, + "count" : 150, + "stdDev" : 0.01 + }, + "physicalMemoryTotalBytes" : 1024, + "startTimeMs" : 1581508857327, + "physicalMemoryUsedBytes" : { + "min" : 1.2, + "median" : 1.85, + "max" : 2.5, + "mean" : 1.77, + "count" : 155, + "stdDev" : 0.25 + }, + "endTimeMs" : 1581508867333 + }, + "sourceIp" : "196.40.106.237", + "pathTraces" : [ { + "protocol" : "tcp", + "udpPathTraceMode" : "unknown", + "hops" : [ { + "rdns" : "core-router1.cpt2.host-h.net", + "prefix" : "196.40.96.0/20", + "responseTime" : 1, + "hop" : 1, + "ipAddress" : "196.40.106.237", + "location" : "Cape Town, South Africa", + "network" : "HETZNER (Pty) Ltd (AS 37153)" + }, { + "rdns" : "core-router1.cpt2.host-h.net", + "prefix" : "196.40.96.0/20", + "responseTime" : 1, + "hop" : 1, + "ipAddress" : "196.40.106.237", + "location" : "Cape Town, South Africa", + "network" : "HETZNER (Pty) Ltd (AS 37153)" + } ], + "pathId" : "4711301366345855606023718047703941305741293841502186803", + "tcpPathTraceMode" : "syn-pcap" + }, { + "protocol" : "tcp", + "udpPathTraceMode" : "unknown", + "hops" : [ { + "rdns" : "core-router1.cpt2.host-h.net", + "prefix" : "196.40.96.0/20", + "responseTime" : 1, + "hop" : 1, + "ipAddress" : "196.40.106.237", + "location" : "Cape Town, South Africa", + "network" : "HETZNER (Pty) Ltd (AS 37153)" + }, { + "rdns" : "core-router1.cpt2.host-h.net", + "prefix" : "196.40.96.0/20", + "responseTime" : 1, + "hop" : 1, + "ipAddress" : "196.40.106.237", + "location" : "Cape Town, South Africa", + "network" : "HETZNER (Pty) Ltd (AS 37153)" + } ], + "pathId" : "4711301366345855606023718047703941305741293841502186803", + "tcpPathTraceMode" : "syn-pcap" + } ], + "vpnPathTraces" : [ { + "protocol" : "tcp", + "udpPathTraceMode" : "unknown", + "hops" : [ { + "rdns" : "core-router1.cpt2.host-h.net", + "prefix" : "196.40.96.0/20", + "responseTime" : 1, + "hop" : 1, + "ipAddress" : "196.40.106.237", + "location" : "Cape Town, South Africa", + "network" : "HETZNER (Pty) Ltd (AS 37153)" + }, { + "rdns" : "core-router1.cpt2.host-h.net", + "prefix" : "196.40.96.0/20", + "responseTime" : 1, + "hop" : 1, + "ipAddress" : "196.40.106.237", + "location" : "Cape Town, South Africa", + "network" : "HETZNER (Pty) Ltd (AS 37153)" + } ], + "pathId" : "4711301366345855606023718047703941305741293841502186803", + "tcpPathTraceMode" : "syn-pcap" + }, { + "protocol" : "tcp", + "udpPathTraceMode" : "unknown", + "hops" : [ { + "rdns" : "core-router1.cpt2.host-h.net", + "prefix" : "196.40.96.0/20", + "responseTime" : 1, + "hop" : 1, + "ipAddress" : "196.40.106.237", + "location" : "Cape Town, South Africa", + "network" : "HETZNER (Pty) Ltd (AS 37153)" + }, { + "rdns" : "core-router1.cpt2.host-h.net", + "prefix" : "196.40.96.0/20", + "responseTime" : 1, + "hop" : 1, + "ipAddress" : "196.40.106.237", + "location" : "Cape Town, South Africa", + "network" : "HETZNER (Pty) Ltd (AS 37153)" + } ], + "pathId" : "4711301366345855606023718047703941305741293841502186803", + "tcpPathTraceMode" : "syn-pcap" + } ], + "serverIp" : "185.199.108.153", + "networkProfile" : { + "previousInterface" : { + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "interfaceName" : "en0", + "subnetMask" : "255.255.255.0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ] + }, + "ethernetProfile" : { + "linkSpeed" : 860 + }, + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "proxyProfile" : { + "method" : "System", + "proxies" : [ { + "bypass" : "*.local;169.254/16", + "proxy" : "" + }, { + "bypass" : "*.local;169.254/16", + "proxy" : "" + } ] + }, + "subnetMask" : "255.255.255.0", + "error" : "An operation timed out.", + "wirelessProfile" : { + "rssi" : -38, + "bssid" : "4c:ba:ba:f4:fa:fa", + "snr" : 57, + "vendor" : "Cisco", + "txRate" : 130, + "channel" : 1, + "noise" : -95, + "phyMode" : "802.11n", + "ssid" : "Internet for the masses", + "quality" : 100 + }, + "interfaceName" : "en0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ], + "gateway" : "10.0.0.1" + }, + "testId" : "584739201", + "aid" : "1234", + "roundId" : 1384309800 + } ] + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_scheduled_test_path_vis_results": OperationExpectation( + operation_id="get_scheduled_test_path_vis_results", + method="GET", + path="/endpoint/test-results/scheduled-tests/{testId}/path-vis", + path_param_examples={ + "testId": '202701', + }, + success_status=200, + success_body=json.loads(""" + + { + "test" : { + "server" : "www.example.com", + "isSavedEvent" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/scheduled-tests/281474976710706/network/filter" + }, { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/scheduled-tests/281474976710706/pathvis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isPrioritized" : false, + "networkMeasurements" : true, + "type" : "agent-to-server", + "tcpProbeMode" : "auto", + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "protocol" : "icmp", + "createdDate" : "2022-07-17T22:00:54Z", + "ipVersion" : "V4_ONLY", + "port" : 443, + "isEnabled" : true, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "aid" : "1234", + "agentSelectorConfig" : { + "agentSelectorType" : "all-agents", + "maxMachines" : 25 + }, + "hasPathTraceInSession" : true, + "testName" : "Test name" + }, + "endDate" : "2022-07-18T22:00:54Z", + "_links" : { + "next" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "results" : [ { + "originalTargetProfile" : { + "protocol" : "tcp", + "remotePort" : 80, + "remoteIpAddress" : "120.98.134.7" + }, + "server" : "www.google.com:443", + "agentId" : "861b7557-cd57-4bbb-b648-00bddf88ef49", + "asnDetails" : { + "asName" : "ThousandEyes, Inc", + "asNumber" : 394101 + }, + "vpnProfile" : { + "vpnClientNetworkRange" : [ "9.88.37.27", "9.88.37.27" ], + "vpnGatewayAddress" : "120.98.134.7", + "vpnType" : "cisco-anyconnect", + "vpnClientAddresses" : [ "184.81.113.85", "13.129.91.62" ] + }, + "batteryMetrics" : { + "batteryHealthNormalizedPercent" : 0.92, + "batteryLevel" : "medium", + "batteryLevelNormalizedPercent" : 0.3 + }, + "sourcePrefix" : "196.40.96.0/20", + "userProfile" : { + "userName" : "joeblogs32", + "userPrincipalName" : "joeblogs32@c.com" + }, + "platform" : "mac", + "cellularProfile" : { + "rssi" : -10, + "advertisedNetworkSubtype" : "LTE/HSPA", + "carrierName" : "T-Mobile", + "rsrq" : -30, + "rsrp" : -30, + "advertisedNetworkGen" : "2g, 3g, 4g, 5g", + "rscp" : -30, + "networkGen" : "2g, 3g, 4g, 5g", + "networkSubtype" : "LTE/HSPA", + "sinr" : 20 + }, + "systemMetrics" : { + "cpuUtilization" : { + "min" : 0.22, + "median" : 0.61, + "max" : 0.75, + "mean" : 0.55, + "count" : 150, + "stdDev" : 0.01 + }, + "physicalMemoryTotalBytes" : 1024, + "startTimeMs" : 1581508857327, + "physicalMemoryUsedBytes" : { + "min" : 1.2, + "median" : 1.85, + "max" : 2.5, + "mean" : 1.77, + "count" : 155, + "stdDev" : 0.25 + }, + "endTimeMs" : 1581508867333 + }, + "sourceIp" : "196.40.106.237", + "pathTraces" : [ { + "protocol" : "tcp", + "numberOfHops" : 15, + "responseTime" : 1500, + "ipAddress" : "196.40.106.237", + "udpPathTraceMode" : "unknown", + "pathId" : "1230899668701775614109128428722974545787322404682781961521", + "tcpPathTraceMode" : "syn-pcap" + }, { + "protocol" : "tcp", + "numberOfHops" : 15, + "responseTime" : 1500, + "ipAddress" : "196.40.106.237", + "udpPathTraceMode" : "unknown", + "pathId" : "1230899668701775614109128428722974545787322404682781961521", + "tcpPathTraceMode" : "syn-pcap" + } ], + "serverIp" : "185.199.108.153", + "networkProfile" : { + "previousInterface" : { + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "interfaceName" : "en0", + "subnetMask" : "255.255.255.0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ] + }, + "ethernetProfile" : { + "linkSpeed" : 860 + }, + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "proxyProfile" : { + "method" : "System", + "proxies" : [ { + "bypass" : "*.local;169.254/16", + "proxy" : "" + }, { + "bypass" : "*.local;169.254/16", + "proxy" : "" + } ] + }, + "subnetMask" : "255.255.255.0", + "error" : "An operation timed out.", + "wirelessProfile" : { + "rssi" : -38, + "bssid" : "4c:ba:ba:f4:fa:fa", + "snr" : 57, + "vendor" : "Cisco", + "txRate" : 130, + "channel" : 1, + "noise" : -95, + "phyMode" : "802.11n", + "ssid" : "Internet for the masses", + "quality" : 100 + }, + "interfaceName" : "en0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ], + "gateway" : "10.0.0.1" + }, + "testId" : "584739201", + "location" : "San Francisco Area", + "aid" : "1234", + "roundId" : 1384309800 + }, { + "originalTargetProfile" : { + "protocol" : "tcp", + "remotePort" : 80, + "remoteIpAddress" : "120.98.134.7" + }, + "server" : "www.google.com:443", + "agentId" : "861b7557-cd57-4bbb-b648-00bddf88ef49", + "asnDetails" : { + "asName" : "ThousandEyes, Inc", + "asNumber" : 394101 + }, + "vpnProfile" : { + "vpnClientNetworkRange" : [ "9.88.37.27", "9.88.37.27" ], + "vpnGatewayAddress" : "120.98.134.7", + "vpnType" : "cisco-anyconnect", + "vpnClientAddresses" : [ "184.81.113.85", "13.129.91.62" ] + }, + "batteryMetrics" : { + "batteryHealthNormalizedPercent" : 0.92, + "batteryLevel" : "medium", + "batteryLevelNormalizedPercent" : 0.3 + }, + "sourcePrefix" : "196.40.96.0/20", + "userProfile" : { + "userName" : "joeblogs32", + "userPrincipalName" : "joeblogs32@c.com" + }, + "platform" : "mac", + "cellularProfile" : { + "rssi" : -10, + "advertisedNetworkSubtype" : "LTE/HSPA", + "carrierName" : "T-Mobile", + "rsrq" : -30, + "rsrp" : -30, + "advertisedNetworkGen" : "2g, 3g, 4g, 5g", + "rscp" : -30, + "networkGen" : "2g, 3g, 4g, 5g", + "networkSubtype" : "LTE/HSPA", + "sinr" : 20 + }, + "systemMetrics" : { + "cpuUtilization" : { + "min" : 0.22, + "median" : 0.61, + "max" : 0.75, + "mean" : 0.55, + "count" : 150, + "stdDev" : 0.01 + }, + "physicalMemoryTotalBytes" : 1024, + "startTimeMs" : 1581508857327, + "physicalMemoryUsedBytes" : { + "min" : 1.2, + "median" : 1.85, + "max" : 2.5, + "mean" : 1.77, + "count" : 155, + "stdDev" : 0.25 + }, + "endTimeMs" : 1581508867333 + }, + "sourceIp" : "196.40.106.237", + "pathTraces" : [ { + "protocol" : "tcp", + "numberOfHops" : 15, + "responseTime" : 1500, + "ipAddress" : "196.40.106.237", + "udpPathTraceMode" : "unknown", + "pathId" : "1230899668701775614109128428722974545787322404682781961521", + "tcpPathTraceMode" : "syn-pcap" + }, { + "protocol" : "tcp", + "numberOfHops" : 15, + "responseTime" : 1500, + "ipAddress" : "196.40.106.237", + "udpPathTraceMode" : "unknown", + "pathId" : "1230899668701775614109128428722974545787322404682781961521", + "tcpPathTraceMode" : "syn-pcap" + } ], + "serverIp" : "185.199.108.153", + "networkProfile" : { + "previousInterface" : { + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "interfaceName" : "en0", + "subnetMask" : "255.255.255.0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ] + }, + "ethernetProfile" : { + "linkSpeed" : 860 + }, + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "proxyProfile" : { + "method" : "System", + "proxies" : [ { + "bypass" : "*.local;169.254/16", + "proxy" : "" + }, { + "bypass" : "*.local;169.254/16", + "proxy" : "" + } ] + }, + "subnetMask" : "255.255.255.0", + "error" : "An operation timed out.", + "wirelessProfile" : { + "rssi" : -38, + "bssid" : "4c:ba:ba:f4:fa:fa", + "snr" : 57, + "vendor" : "Cisco", + "txRate" : 130, + "channel" : 1, + "noise" : -95, + "phyMode" : "802.11n", + "ssid" : "Internet for the masses", + "quality" : 100 + }, + "interfaceName" : "en0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ], + "gateway" : "10.0.0.1" + }, + "testId" : "584739201", + "location" : "San Francisco Area", + "aid" : "1234", + "roundId" : 1384309800 + } ], + "startDate" : "2022-07-17T22:00:54Z" + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "filter_real_user_tests_network_results": OperationExpectation( + operation_id="filter_real_user_tests_network_results", + method="POST", + path="/endpoint/test-results/real-user-tests/networks/filter", + path_param_examples={ + }, + success_status=200, + success_body=json.loads(""" + + { + "endDate" : "2022-07-18T22:00:54Z", + "_links" : { + "next" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "results" : [ { + "date" : "2022-07-17T22:00:54Z", + "proxy" : { + "loss" : 0.1, + "jitter" : 46, + "latency" : 150, + "target" : "54.208.6.220" + }, + "agentId" : "861b7557-cd57-4bbb-b648-00bddf88ef49", + "systemMetrics" : { + "cpuUtilization" : { + "min" : 0.22, + "median" : 0.61, + "max" : 0.75, + "mean" : 0.55, + "count" : 150, + "stdDev" : 0.01 + }, + "physicalMemoryTotalBytes" : 1024, + "startTimeMs" : 1581508857327, + "physicalMemoryUsedBytes" : { + "min" : 1.2, + "median" : 1.85, + "max" : 2.5, + "mean" : 1.77, + "count" : 155, + "stdDev" : 0.25 + }, + "endTimeMs" : 1581508867333 + }, + "vpn" : { + "loss" : 0.1, + "jitter" : 46, + "latency" : 150, + "target" : "54.208.6.220" + }, + "destination" : { + "loss" : 0.1, + "jitter" : 46, + "latency" : 150, + "target" : "54.208.6.220" + }, + "id" : "07625:1490529480:aVDViw0i", + "roundId" : 1384309800 + }, { + "date" : "2022-07-17T22:00:54Z", + "proxy" : { + "loss" : 0.1, + "jitter" : 46, + "latency" : 150, + "target" : "54.208.6.220" + }, + "agentId" : "861b7557-cd57-4bbb-b648-00bddf88ef49", + "systemMetrics" : { + "cpuUtilization" : { + "min" : 0.22, + "median" : 0.61, + "max" : 0.75, + "mean" : 0.55, + "count" : 150, + "stdDev" : 0.01 + }, + "physicalMemoryTotalBytes" : 1024, + "startTimeMs" : 1581508857327, + "physicalMemoryUsedBytes" : { + "min" : 1.2, + "median" : 1.85, + "max" : 2.5, + "mean" : 1.77, + "count" : 155, + "stdDev" : 0.25 + }, + "endTimeMs" : 1581508867333 + }, + "vpn" : { + "loss" : 0.1, + "jitter" : 46, + "latency" : 150, + "target" : "54.208.6.220" + }, + "destination" : { + "loss" : 0.1, + "jitter" : 46, + "latency" : 150, + "target" : "54.208.6.220" + }, + "id" : "07625:1490529480:aVDViw0i", + "roundId" : 1384309800 + } ], + "startDate" : "2022-07-17T22:00:54Z" + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "searchFilters" : { + "agentId" : [ "3fde6422-f119-40e1-ae32-d08a1243c038", "236e6f18-9637-4a2f-b15f-7aa6a29c9fce" ], + "bssid" : [ "8c:68:c8:a5:0a:8c", "0c:51:01:e4:3e:d0" ], + "visitedSite" : [ "app.thousandeyes.com" ], + "trigger" : [ "user" ], + "ssid" : [ "wifi-name", "other-room-wifi" ], + "platform" : [ "mac", "mac" ], + "proxyTarget" : [ "78.153.54.204", "78.153.54.206" ], + "destinationIp" : [ "84.255.241.1", "193.2.1.88" ], + "domain" : [ "thousandeyes.com" ], + "location" : [ "San Francisco Bay Area", "Germany" ], + "connection" : [ "wireless", "wireless" ], + "vpnTarget" : [ "78.153.54.204", "78.153.54.206" ], + "networkId" : [ "660b34109d12", "660b34109d15" ], + "gateway" : [ "78.153.54.204", "78.153.54.206" ] + } + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "filter_real_user_tests_results": OperationExpectation( + operation_id="filter_real_user_tests_results", + method="POST", + path="/endpoint/test-results/real-user-tests/filter", + path_param_examples={ + }, + success_status=200, + success_body=json.loads(""" + + { + "endDate" : "2022-07-18T22:00:54Z", + "_links" : { + "next" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "results" : [ { + "date" : "2022-07-17T22:00:54Z", + "agentId" : "861b7557-cd57-4bbb-b648-00bddf88ef49", + "committed" : "2022-07-17T22:00:54Z", + "experienceScore" : 0.5, + "sourceAddress" : "84.255.241.1", + "organizationName" : "T-2 Access Network", + "visitedSite" : "www.thousandeyes.com", + "pageId" : "C31gBrYJ", + "protocol" : "https", + "numberOfPages" : 2, + "port" : 443, + "id" : "07625:1490529480:aVDViw0i", + "roundId" : 1384309800 + }, { + "date" : "2022-07-17T22:00:54Z", + "agentId" : "861b7557-cd57-4bbb-b648-00bddf88ef49", + "committed" : "2022-07-17T22:00:54Z", + "experienceScore" : 0.5, + "sourceAddress" : "84.255.241.1", + "organizationName" : "T-2 Access Network", + "visitedSite" : "www.thousandeyes.com", + "pageId" : "C31gBrYJ", + "protocol" : "https", + "numberOfPages" : 2, + "port" : 443, + "id" : "07625:1490529480:aVDViw0i", + "roundId" : 1384309800 + } ], + "startDate" : "2022-07-17T22:00:54Z" + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "searchFilters" : { + "agentId" : [ "3fde6422-f119-40e1-ae32-d08a1243c038", "236e6f18-9637-4a2f-b15f-7aa6a29c9fce" ], + "bssid" : [ "8c:68:c8:a5:0a:8c", "0c:51:01:e4:3e:d0" ], + "visitedSite" : [ "app.thousandeyes.com" ], + "trigger" : [ "user" ], + "ssid" : [ "wifi-name", "other-room-wifi" ], + "platform" : [ "mac", "mac" ], + "proxyTarget" : [ "78.153.54.204", "78.153.54.206" ], + "destinationIp" : [ "84.255.241.1", "193.2.1.88" ], + "domain" : [ "thousandeyes.com" ], + "location" : [ "San Francisco Bay Area", "Germany" ], + "connection" : [ "wireless", "wireless" ], + "vpnTarget" : [ "78.153.54.204", "78.153.54.206" ], + "networkId" : [ "660b34109d12", "660b34109d15" ], + "gateway" : [ "78.153.54.204", "78.153.54.206" ] + } + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "filter_real_user_tests_visited_pages_results": OperationExpectation( + operation_id="filter_real_user_tests_visited_pages_results", + method="POST", + path="/endpoint/test-results/real-user-tests/pages/filter", + path_param_examples={ + }, + success_status=200, + success_body=json.loads(""" + + { + "endDate" : "2022-07-18T22:00:54Z", + "_links" : { + "next" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "results" : [ { + "pageTimings" : { + "onContentLoad" : 1483, + "onLoad" : 4569 + }, + "agentId" : "861b7557-cd57-4bbb-b648-00bddf88ef49", + "systemMetrics" : { + "cpuUtilization" : { + "min" : 0.22, + "median" : 0.61, + "max" : 0.75, + "mean" : 0.55, + "count" : 150, + "stdDev" : 0.01 + }, + "physicalMemoryTotalBytes" : 1024, + "startTimeMs" : 1581508857327, + "physicalMemoryUsedBytes" : { + "min" : 1.2, + "median" : 1.85, + "max" : 2.5, + "mean" : 1.77, + "count" : 155, + "stdDev" : 0.25 + }, + "endTimeMs" : 1581508867333 + }, + "pageTitle" : "Network Performance Resources | ThousandEyes", + "responseTime" : 240, + "pageUrl" : "https://app.thousandeyes.com/settings/integrations", + "id" : "07625:1490529480:aVDViw0i", + "pageId" : "C31gBrYJ", + "roundId" : 1384309800, + "loadDate" : "2022-07-17T22:00:54Z", + "responseCode" : 200 + }, { + "pageTimings" : { + "onContentLoad" : 1483, + "onLoad" : 4569 + }, + "agentId" : "861b7557-cd57-4bbb-b648-00bddf88ef49", + "systemMetrics" : { + "cpuUtilization" : { + "min" : 0.22, + "median" : 0.61, + "max" : 0.75, + "mean" : 0.55, + "count" : 150, + "stdDev" : 0.01 + }, + "physicalMemoryTotalBytes" : 1024, + "startTimeMs" : 1581508857327, + "physicalMemoryUsedBytes" : { + "min" : 1.2, + "median" : 1.85, + "max" : 2.5, + "mean" : 1.77, + "count" : 155, + "stdDev" : 0.25 + }, + "endTimeMs" : 1581508867333 + }, + "pageTitle" : "Network Performance Resources | ThousandEyes", + "responseTime" : 240, + "pageUrl" : "https://app.thousandeyes.com/settings/integrations", + "id" : "07625:1490529480:aVDViw0i", + "pageId" : "C31gBrYJ", + "roundId" : 1384309800, + "loadDate" : "2022-07-17T22:00:54Z", + "responseCode" : 200 + } ], + "startDate" : "2022-07-17T22:00:54Z" + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "agentId" : [ "3fde6422-f119-40e1-ae32-d08a1243c038", "236e6f18-9637-4a2f-b15f-7aa6a29c9fce" ], + "bssid" : [ "8c:68:c8:a5:0a:8c", "0c:51:01:e4:3e:d0" ], + "visitedSite" : [ "app.thousandeyes.com" ], + "trigger" : [ "user" ], + "ssid" : [ "wifi-name", "other-room-wifi" ], + "platform" : [ "mac", "mac" ], + "proxyTarget" : [ "78.153.54.204", "78.153.54.206" ], + "destinationIp" : [ "84.255.241.1", "193.2.1.88" ], + "domain" : [ "thousandeyes.com" ], + "location" : [ "San Francisco Bay Area", "Germany" ], + "connection" : [ "wireless", "wireless" ], + "vpnTarget" : [ "78.153.54.204", "78.153.54.206" ], + "networkId" : [ "660b34109d12", "660b34109d15" ], + "gateway" : [ "78.153.54.204", "78.153.54.206" ] + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_real_user_test_page_results": OperationExpectation( + operation_id="get_real_user_test_page_results", + method="GET", + path="/endpoint/test-results/real-user-tests/{id}/pages/{pageId}", + path_param_examples={ + "id": '07625:1490529480:h3qJQTpl', + "pageId": '281474976710706', + }, + success_status=200, + success_body=json.loads(""" + + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "har" : { + "log" : { + "browser" : { + "name" : "Google Chrome", + "version" : "57.0.2987.98" + }, + "creator" : { + "name" : "ThousandEyes Endpoint Agent", + "version" : "0.47.0" + }, + "entries" : [ { + "pageref" : "page_1", + "request" : { + "headers" : [ { + "name" : "Upgrade-Insecure-Requests", + "value" : "1" + }, { + "name" : "User-Agent", + "value" : "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.98 Safari/537.36" + }, { + "name" : "Accept", + "value" : "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8" + }, { + "name" : "Referer", + "value" : "https://www.thousandeyes.com/" + }, { + "name" : "Accept-Encoding", + "value" : "gzip, deflate, sdch, br" + }, { + "name" : "Accept-Language", + "value" : "en-US,en;q=0.6" + }, { + "name" : "Cookie", + "value" : "(removed)" + } ], + "method" : "GET", + "queryString" : [ { + "name" : "locale", + "value" : "en-US" + } ], + "url" : "https://www.thousandeyes.com/resources" + }, + "response" : { + "bodySize" : 17776, + "content" : { + "mimeType" : "text/html;charset=ISO-8859-1", + "size" : 17776 + }, + "headers" : [ { + "name" : "Content-Type", + "value" : "text/html;charset=ISO-8859-1" + }, { + "name" : "Content-Length", + "value" : "17776" + }, { + "name" : "Connection", + "value" : "keep-alive" + }, { + "name" : "Date", + "value" : "Sun, 26 Mar 2017 11:58:54 GMT" + }, { + "name" : "Server", + "value" : "Apache" + }, { + "name" : "Cache-Control", + "value" : "max-age=600, must-revalidate" + }, { + "name" : "Content-Language", + "value" : "en-US" + }, { + "name" : "Content-Encoding", + "value" : "gzip" + }, { + "name" : "X-Frame-Options", + "value" : "sameorigin" + }, { + "name" : "Strict-Transport-Security", + "value" : "max-age=31536000" + }, { + "name" : "Vary", + "value" : "Accept-Encoding" + }, { + "name" : "X-Cache", + "value" : "Miss from cloudfront" + }, { + "name" : "Via", + "value" : "1.1 5dbe09af3a2c87121e31ffa67f174f66.cloudfront.net (CloudFront)" + }, { + "name" : "X-Amz-Cf-Id", + "value" : "YkvlkBNKgHt5aMu9vcS22Z8kHn1MUr-8adupwhDk3j9vF-TpSyIxZA==" + } ], + "headersSize" : 527, + "redirectURL" : "", + "status" : 200, + "statusText" : "OK" + }, + "serverIPAddress" : "13.32.22.80", + "startedDateTime" : "2017-03-22T11:58:54.123+02:00", + "time" : 177, + "timings" : { + "blocked" : -1, + "connect" : -1, + "dns" : -1, + "receive" : 27, + "send" : -1, + "ssl" : -1, + "wait" : 150 + } + }, { + "pageref" : "page_1", + "request" : { + "headers" : [ { + "name" : "User-Agent", + "value" : "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.98 Safari/537.36" + }, { + "name" : "Accept", + "value" : "*/*" + }, { + "name" : "Referer", + "value" : "https://www.thousandeyes.com/resources" + }, { + "name" : "Accept-Encoding", + "value" : "gzip, deflate, sdch, br" + }, { + "name" : "Accept-Language", + "value" : "en-US,en;q=0.6" + } ], + "method" : "GET", + "queryString" : [ ], + "url" : "https://use.typekit.net/cjy5myw.js" + }, + "response" : { + "bodySize" : 0, + "content" : { + "mimeType" : "text/javascript;charset=utf-8", + "size" : 7814 + }, + "headers" : [ { + "name" : "status", + "value" : "200" + }, { + "name" : "access-control-allow-origin", + "value" : "*" + }, { + "name" : "cache-control", + "value" : "public, max-age=600, stale-while-revalidate=604800" + }, { + "name" : "content-encoding", + "value" : "gzip" + }, { + "name" : "content-type", + "value" : "text/javascript;charset=utf-8" + }, { + "name" : "server", + "value" : "nginx" + }, { + "name" : "status", + "value" : "200 OK" + }, { + "name" : "timing-allow-origin", + "value" : "*" + }, { + "name" : "vary", + "value" : "Accept-Encoding" + }, { + "name" : "content-length", + "value" : "7814" + }, { + "name" : "date", + "value" : "Sun, 26 Mar 2017 11:58:43 GMT" + } ], + "headersSize" : 334, + "redirectURL" : "", + "status" : 200, + "statusText" : "OK" + }, + "serverIPAddress" : "104.103.103.234", + "startedDateTime" : "2017-03-22T11:58:54.123+02:00", + "time" : 72, + "timings" : { + "blocked" : -1, + "connect" : -1, + "dns" : -1, + "receive" : 10, + "send" : -1, + "ssl" : -1, + "wait" : 62 + } + } ], + "pages" : [ { + "id" : "page_1", + "pageTimings" : { + "onContentLoad" : 874, + "onLoad" : 3492 + }, + "responseCode" : 200, + "startedDateTime" : "2017-03-22T11:58:54.123+02:00", + "title" : "Network Performance Resources | ThousandEyes" + } ], + "version" : "1.2", + "systemMetrics" : { + "startTimeMs" : 1581508857327, + "endTimeMs" : 1581508867333, + "cpuUtilization" : { + "min" : 0.30859375, + "max" : 0.5625, + "mean" : 0.38931831001805056, + "median" : 0.353515625, + "stdDev" : 0.08389194281742307, + "count" : 10 + }, + "physicalMemoryUsedBytes" : { + "min" : 12805128192, + "max" : 12825530368, + "mean" : 1.281914582109091E10, + "median" : 12818219008, + "stdDev" : 5741124.05691331, + "count" : 11 + }, + "physicalMemoryTotalBytes" : 17069891584 + } + } + } + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_real_user_test_results": OperationExpectation( + operation_id="get_real_user_test_results", + method="GET", + path="/endpoint/test-results/real-user-tests/{id}", + path_param_examples={ + "id": '07625:1490529480:h3qJQTpl', + }, + success_status=200, + success_body=json.loads(""" + + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "results" : [ { + "date" : "2022-07-17T22:00:54Z", + "agentId" : "861b7557-cd57-4bbb-b648-00bddf88ef49", + "committed" : "2022-07-17T22:00:54Z", + "experienceScore" : 0.5, + "sourceAddress" : "84.255.241.1", + "organizationName" : "T-2 Access Network", + "visitedSite" : "www.thousandeyes.com", + "coordinates" : { + "latitude" : 46.0552778, + "location" : "Slovenia", + "longitude" : 14.5144444 + }, + "network" : { + "systemMetrics" : { + "cpuUtilization" : { + "min" : 0.22, + "median" : 0.61, + "max" : 0.75, + "mean" : 0.55, + "count" : 150, + "stdDev" : 0.01 + }, + "physicalMemoryTotalBytes" : 1024, + "startTimeMs" : 1581508857327, + "physicalMemoryUsedBytes" : { + "min" : 1.2, + "median" : 1.85, + "max" : 2.5, + "mean" : 1.77, + "count" : 155, + "stdDev" : 0.25 + }, + "endTimeMs" : 1581508867333 + }, + "isIcmpBlocked" : true, + "vpnPing" : { + "maxRtt" : 66, + "loss" : 1, + "pktsReceived" : 10, + "avgRtt" : 7, + "meanDevRtt" : 11, + "minRtt" : 1, + "error" : "An operation timed out.", + "infoFlags" : [ "TE_INFO_ICMP_BLOCKED_BY_FIREWALL" ], + "pktsSent" : 10 + }, + "ping" : { + "maxRtt" : 66, + "loss" : 1, + "pktsReceived" : 10, + "avgRtt" : 7, + "meanDevRtt" : 11, + "minRtt" : 1, + "error" : "An operation timed out.", + "infoFlags" : [ "TE_INFO_ICMP_BLOCKED_BY_FIREWALL" ], + "pktsSent" : 10 + }, + "networkProfile" : { + "previousInterface" : { + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "interfaceName" : "en0", + "subnetMask" : "255.255.255.0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ] + }, + "ethernetProfile" : { + "linkSpeed" : 860 + }, + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "proxyProfile" : { + "method" : "System", + "proxies" : [ { + "bypass" : "*.local;169.254/16", + "proxy" : "" + }, { + "bypass" : "*.local;169.254/16", + "proxy" : "" + } ] + }, + "subnetMask" : "255.255.255.0", + "error" : "An operation timed out.", + "wirelessProfile" : { + "rssi" : -38, + "bssid" : "4c:ba:ba:f4:fa:fa", + "snr" : 57, + "vendor" : "Cisco", + "txRate" : 130, + "channel" : 1, + "noise" : -95, + "phyMode" : "802.11n", + "ssid" : "Internet for the masses", + "quality" : 100 + }, + "interfaceName" : "en0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ], + "gateway" : "10.0.0.1" + }, + "traceroute" : { + "destination" : "13.32.22.232", + "hops" : [ { + "delay" : 5, + "prefix" : "196.40.96.0/20", + "hop" : 1, + "ipAddress" : "196.40.106.237", + "name" : "89-210-88-65.access.t-2.net", + "mpls" : [ "L=301472,E=0,S=1,T=1" ], + "asn" : 34779 + }, { + "delay" : 5, + "prefix" : "196.40.96.0/20", + "hop" : 1, + "ipAddress" : "196.40.106.237", + "name" : "89-210-88-65.access.t-2.net", + "mpls" : [ "L=301472,E=0,S=1,T=1" ], + "asn" : 34779 + } ], + "error" : "An operation timed out.", + "infoFlags" : [ "TE_INFO_ICMP_BLOCKED_BY_FIREWALL" ], + "internalErrors" : [ "TE_INFO_ICMP_BLOCKED_BY_FIREWALL" ] + }, + "vpnTraceroute" : { + "destination" : "13.32.22.232", + "hops" : [ { + "delay" : 5, + "prefix" : "196.40.96.0/20", + "hop" : 1, + "ipAddress" : "196.40.106.237", + "name" : "89-210-88-65.access.t-2.net", + "mpls" : [ "L=301472,E=0,S=1,T=1" ], + "asn" : 34779 + }, { + "delay" : 5, + "prefix" : "196.40.96.0/20", + "hop" : 1, + "ipAddress" : "196.40.106.237", + "name" : "89-210-88-65.access.t-2.net", + "mpls" : [ "L=301472,E=0,S=1,T=1" ], + "asn" : 34779 + } ], + "error" : "An operation timed out.", + "infoFlags" : [ "TE_INFO_ICMP_BLOCKED_BY_FIREWALL" ], + "internalErrors" : [ "TE_INFO_ICMP_BLOCKED_BY_FIREWALL" ] + }, + "connectRtt" : 77.777, + "gatewayPing" : { + "maxRtt" : 66, + "loss" : 1, + "pktsReceived" : 10, + "avgRtt" : 7, + "meanDevRtt" : 11, + "minRtt" : 1, + "error" : "An operation timed out.", + "infoFlags" : [ "TE_INFO_ICMP_BLOCKED_BY_FIREWALL" ], + "pktsSent" : 10 + }, + "errors" : [ "ping: Request timed out before getting response" ] + }, + "protocol" : "https", + "pages" : [ { + "pageTimings" : { + "onContentLoad" : 1483, + "onLoad" : 4569 + }, + "pageTitle" : "Network Performance Resources | ThousandEyes", + "pageUrl" : "https://app.thousandeyes.com/settings/integrations", + "pageId" : "C31gBrYJ", + "loadDate" : "2022-07-17T22:00:54Z", + "responseCode" : 200 + }, { + "pageTimings" : { + "onContentLoad" : 1483, + "onLoad" : 4569 + }, + "pageTitle" : "Network Performance Resources | ThousandEyes", + "pageUrl" : "https://app.thousandeyes.com/settings/integrations", + "pageId" : "C31gBrYJ", + "loadDate" : "2022-07-17T22:00:54Z", + "responseCode" : 200 + } ], + "numberOfPages" : 2, + "port" : 443, + "browser" : { + "name" : "Google Chrome", + "version" : "116.0.0.0" + }, + "id" : "07625:1490529480:aVDViw0i", + "roundId" : 1384309800 + }, { + "date" : "2022-07-17T22:00:54Z", + "agentId" : "861b7557-cd57-4bbb-b648-00bddf88ef49", + "committed" : "2022-07-17T22:00:54Z", + "experienceScore" : 0.5, + "sourceAddress" : "84.255.241.1", + "organizationName" : "T-2 Access Network", + "visitedSite" : "www.thousandeyes.com", + "coordinates" : { + "latitude" : 46.0552778, + "location" : "Slovenia", + "longitude" : 14.5144444 + }, + "network" : { + "systemMetrics" : { + "cpuUtilization" : { + "min" : 0.22, + "median" : 0.61, + "max" : 0.75, + "mean" : 0.55, + "count" : 150, + "stdDev" : 0.01 + }, + "physicalMemoryTotalBytes" : 1024, + "startTimeMs" : 1581508857327, + "physicalMemoryUsedBytes" : { + "min" : 1.2, + "median" : 1.85, + "max" : 2.5, + "mean" : 1.77, + "count" : 155, + "stdDev" : 0.25 + }, + "endTimeMs" : 1581508867333 + }, + "isIcmpBlocked" : true, + "vpnPing" : { + "maxRtt" : 66, + "loss" : 1, + "pktsReceived" : 10, + "avgRtt" : 7, + "meanDevRtt" : 11, + "minRtt" : 1, + "error" : "An operation timed out.", + "infoFlags" : [ "TE_INFO_ICMP_BLOCKED_BY_FIREWALL" ], + "pktsSent" : 10 + }, + "ping" : { + "maxRtt" : 66, + "loss" : 1, + "pktsReceived" : 10, + "avgRtt" : 7, + "meanDevRtt" : 11, + "minRtt" : 1, + "error" : "An operation timed out.", + "infoFlags" : [ "TE_INFO_ICMP_BLOCKED_BY_FIREWALL" ], + "pktsSent" : 10 + }, + "networkProfile" : { + "previousInterface" : { + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "interfaceName" : "en0", + "subnetMask" : "255.255.255.0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ] + }, + "ethernetProfile" : { + "linkSpeed" : 860 + }, + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "proxyProfile" : { + "method" : "System", + "proxies" : [ { + "bypass" : "*.local;169.254/16", + "proxy" : "" + }, { + "bypass" : "*.local;169.254/16", + "proxy" : "" + } ] + }, + "subnetMask" : "255.255.255.0", + "error" : "An operation timed out.", + "wirelessProfile" : { + "rssi" : -38, + "bssid" : "4c:ba:ba:f4:fa:fa", + "snr" : 57, + "vendor" : "Cisco", + "txRate" : 130, + "channel" : 1, + "noise" : -95, + "phyMode" : "802.11n", + "ssid" : "Internet for the masses", + "quality" : 100 + }, + "interfaceName" : "en0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ], + "gateway" : "10.0.0.1" + }, + "traceroute" : { + "destination" : "13.32.22.232", + "hops" : [ { + "delay" : 5, + "prefix" : "196.40.96.0/20", + "hop" : 1, + "ipAddress" : "196.40.106.237", + "name" : "89-210-88-65.access.t-2.net", + "mpls" : [ "L=301472,E=0,S=1,T=1" ], + "asn" : 34779 + }, { + "delay" : 5, + "prefix" : "196.40.96.0/20", + "hop" : 1, + "ipAddress" : "196.40.106.237", + "name" : "89-210-88-65.access.t-2.net", + "mpls" : [ "L=301472,E=0,S=1,T=1" ], + "asn" : 34779 + } ], + "error" : "An operation timed out.", + "infoFlags" : [ "TE_INFO_ICMP_BLOCKED_BY_FIREWALL" ], + "internalErrors" : [ "TE_INFO_ICMP_BLOCKED_BY_FIREWALL" ] + }, + "vpnTraceroute" : { + "destination" : "13.32.22.232", + "hops" : [ { + "delay" : 5, + "prefix" : "196.40.96.0/20", + "hop" : 1, + "ipAddress" : "196.40.106.237", + "name" : "89-210-88-65.access.t-2.net", + "mpls" : [ "L=301472,E=0,S=1,T=1" ], + "asn" : 34779 + }, { + "delay" : 5, + "prefix" : "196.40.96.0/20", + "hop" : 1, + "ipAddress" : "196.40.106.237", + "name" : "89-210-88-65.access.t-2.net", + "mpls" : [ "L=301472,E=0,S=1,T=1" ], + "asn" : 34779 + } ], + "error" : "An operation timed out.", + "infoFlags" : [ "TE_INFO_ICMP_BLOCKED_BY_FIREWALL" ], + "internalErrors" : [ "TE_INFO_ICMP_BLOCKED_BY_FIREWALL" ] + }, + "connectRtt" : 77.777, + "gatewayPing" : { + "maxRtt" : 66, + "loss" : 1, + "pktsReceived" : 10, + "avgRtt" : 7, + "meanDevRtt" : 11, + "minRtt" : 1, + "error" : "An operation timed out.", + "infoFlags" : [ "TE_INFO_ICMP_BLOCKED_BY_FIREWALL" ], + "pktsSent" : 10 + }, + "errors" : [ "ping: Request timed out before getting response" ] + }, + "protocol" : "https", + "pages" : [ { + "pageTimings" : { + "onContentLoad" : 1483, + "onLoad" : 4569 + }, + "pageTitle" : "Network Performance Resources | ThousandEyes", + "pageUrl" : "https://app.thousandeyes.com/settings/integrations", + "pageId" : "C31gBrYJ", + "loadDate" : "2022-07-17T22:00:54Z", + "responseCode" : 200 + }, { + "pageTimings" : { + "onContentLoad" : 1483, + "onLoad" : 4569 + }, + "pageTitle" : "Network Performance Resources | ThousandEyes", + "pageUrl" : "https://app.thousandeyes.com/settings/integrations", + "pageId" : "C31gBrYJ", + "loadDate" : "2022-07-17T22:00:54Z", + "responseCode" : 200 + } ], + "numberOfPages" : 2, + "port" : 443, + "browser" : { + "name" : "Google Chrome", + "version" : "116.0.0.0" + }, + "id" : "07625:1490529480:aVDViw0i", + "roundId" : 1384309800 + } ] + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + +} diff --git a/thousandeyes-sdk-endpoint-test-results/test/test_http_server_endpoint_scheduled_test_results_api_integration.py b/thousandeyes-sdk-endpoint-test-results/test/test_http_server_endpoint_scheduled_test_results_api_integration.py new file mode 100644 index 00000000..2b2f5860 --- /dev/null +++ b/thousandeyes-sdk-endpoint-test-results/test/test_http_server_endpoint_scheduled_test_results_api_integration.py @@ -0,0 +1,2386 @@ +# coding: utf-8 + +""" + Endpoint Test Results API + + Retrieve results for scheduled and dynamic tests on endpoint agents. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.endpoint_test_results.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.endpoint_test_results.api.http_server_endpoint_scheduled_test_results_api import HTTPServerEndpointScheduledTestResultsApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestHTTPServerEndpointScheduledTestResultsApiIntegration(IntegrationTestBase): + """HTTPServerEndpointScheduledTestResultsApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = HTTPServerEndpointScheduledTestResultsApi(self.api_client) + + + def test_get_http_server_scheduled_test_results_happy_path(self) -> None: + """Integration test for get_http_server_scheduled_test_results success path""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + response_body_json = """ + { + "test" : { + "server" : "www.example.com", + "isSavedEvent" : false, + "sslVersion" : "Auto", + "useNtlm" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/scheduled-tests/281474976710706/network/filter" + }, { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/scheduled-tests/281474976710706/pathvis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isPrioritized" : false, + "httpTimeLimit" : 5000, + "type" : "http-server", + "protocol" : "icmp", + "httpVersion" : 2, + "followRedirects" : true, + "authType" : "none", + "testName" : "Test name", + "verifyCertificate" : true, + "networkMeasurements" : true, + "tcpProbeMode" : "auto", + "url" : "https://example.com:443", + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "ipVersion" : "V4_ONLY", + "port" : 443, + "isEnabled" : true, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "aid" : "1234", + "agentSelectorConfig" : { + "agentSelectorType" : "all-agents", + "maxMachines" : 25 + }, + "hasPathTraceInSession" : true, + "httpTargetTime" : 100, + "username" : "username", + "sslVersionId" : "0" + }, + "totalHits" : 12, + "endDate" : "2022-07-18T22:00:54Z", + "_links" : { + "next" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "results" : [ { + "originalTargetProfile" : { + "protocol" : "tcp", + "remotePort" : 80, + "remoteIpAddress" : "120.98.134.7" + }, + "agentId" : "861b7557-cd57-4bbb-b648-00bddf88ef49", + "numRedirects" : 0, + "vpnProfile" : { + "vpnClientNetworkRange" : [ "9.88.37.27", "9.88.37.27" ], + "vpnGatewayAddress" : "120.98.134.7", + "vpnType" : "cisco-anyconnect", + "vpnClientAddresses" : [ "184.81.113.85", "13.129.91.62" ] + }, + "errorType" : "connect", + "batteryMetrics" : { + "batteryHealthNormalizedPercent" : 0.92, + "batteryLevel" : "medium", + "batteryLevelNormalizedPercent" : 0.3 + }, + "userProfile" : { + "userName" : "joeblogs32", + "userPrincipalName" : "joeblogs32@c.com" + }, + "platform" : "mac", + "responseCode" : 200, + "cellularProfile" : { + "rssi" : -10, + "advertisedNetworkSubtype" : "LTE/HSPA", + "carrierName" : "T-Mobile", + "rsrq" : -30, + "rsrp" : -30, + "advertisedNetworkGen" : "2g, 3g, 4g, 5g", + "rscp" : -30, + "networkGen" : "2g, 3g, 4g, 5g", + "networkSubtype" : "LTE/HSPA", + "sinr" : 20 + }, + "score" : { + "applicationScore" : 100, + "quality" : "great" + }, + "connectTime" : 2, + "networkProfile" : { + "previousInterface" : { + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "interfaceName" : "en0", + "subnetMask" : "255.255.255.0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ] + }, + "ethernetProfile" : { + "linkSpeed" : 860 + }, + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "proxyProfile" : { + "method" : "System", + "proxies" : [ { + "bypass" : "*.local;169.254/16", + "proxy" : "" + }, { + "bypass" : "*.local;169.254/16", + "proxy" : "" + } ] + }, + "subnetMask" : "255.255.255.0", + "error" : "An operation timed out.", + "wirelessProfile" : { + "rssi" : -38, + "bssid" : "4c:ba:ba:f4:fa:fa", + "snr" : 57, + "vendor" : "Cisco", + "txRate" : 130, + "channel" : 1, + "noise" : -95, + "phyMode" : "802.11n", + "ssid" : "Internet for the masses", + "quality" : 100 + }, + "interfaceName" : "en0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ], + "gateway" : "10.0.0.1" + }, + "throughput" : 190, + "roundId" : 1384309800, + "headers" : { + "requestHeaders" : "GET / HTTP/1.1\\r\\nHost: www.thousandeyes.com\\r\\nUser-Agent: curl/7.58.0-DEV\\r\\nAccept: */*\\r\\nAccept-Encoding: deflate, gzip\\r\\nX-ThousandEyes-Agent: yes\\r\\n", + "responseHeaders" : "HTTP/1.1 200 OK\\r\\nContent-Type: text/html;charset=UTF-8\\r\\nContent-Length: 9993\\r\\nConnection: keep-alive\\r\\nDate: Mon, 04 May 2020 16:13:00 GMT\\r\\nServer: Apache\\r\\nContent-Language: en-US\\r\\nContent-Encoding: gzip\\r\\nX-Frame-Options: sameorigin\\r\\nCache-Control: max-age=600, must-revalidate\\r\\nStrict-Transport-Security: max-age=31536000\\r\\nX-Content-Type-Options: nosniff\\r\\nX-XSS-Protection: 1; mode=block\\r\\nVary: Accept-Encoding\\r\\nX-Cache: Hit from cloudfront\\r\\nVia: 1.1 7ba3caf71ae7a52dd411d1a543e80cd8.cloudfront.net (CloudFront)\\r\\nX-Amz-Cf-Pop: SFO5-C3\\r\\nX-Amz-Cf-Id: w4h42tkoJD-rEpkRDZUvnQBmy26GVGe6pUsuRr1Dphf7oajYbjXaOA==\\r\\nAge: 132\\r\\n" + }, + "redirectTime" : 10, + "responseTime" : 14, + "totalTime" : 15, + "receiveTime" : 1, + "systemMetrics" : { + "cpuUtilization" : { + "min" : 0.22, + "median" : 0.61, + "max" : 0.75, + "mean" : 0.55, + "count" : 150, + "stdDev" : 0.01 + }, + "physicalMemoryTotalBytes" : 1024, + "startTimeMs" : 1581508857327, + "physicalMemoryUsedBytes" : { + "min" : 1.2, + "median" : 1.85, + "max" : 2.5, + "mean" : 1.77, + "count" : 155, + "stdDev" : 0.25 + }, + "endTimeMs" : 1581508867333 + }, + "dnsTime" : 0, + "serverIp" : "193.2.1.88", + "testId" : "584739201", + "sslTime" : 9, + "aid" : "1234", + "waitTime" : 3, + "errorDetails" : "errorDetails", + "wireSize" : 9993 + }, { + "originalTargetProfile" : { + "protocol" : "tcp", + "remotePort" : 80, + "remoteIpAddress" : "120.98.134.7" + }, + "agentId" : "861b7557-cd57-4bbb-b648-00bddf88ef49", + "numRedirects" : 0, + "vpnProfile" : { + "vpnClientNetworkRange" : [ "9.88.37.27", "9.88.37.27" ], + "vpnGatewayAddress" : "120.98.134.7", + "vpnType" : "cisco-anyconnect", + "vpnClientAddresses" : [ "184.81.113.85", "13.129.91.62" ] + }, + "errorType" : "connect", + "batteryMetrics" : { + "batteryHealthNormalizedPercent" : 0.92, + "batteryLevel" : "medium", + "batteryLevelNormalizedPercent" : 0.3 + }, + "userProfile" : { + "userName" : "joeblogs32", + "userPrincipalName" : "joeblogs32@c.com" + }, + "platform" : "mac", + "responseCode" : 200, + "cellularProfile" : { + "rssi" : -10, + "advertisedNetworkSubtype" : "LTE/HSPA", + "carrierName" : "T-Mobile", + "rsrq" : -30, + "rsrp" : -30, + "advertisedNetworkGen" : "2g, 3g, 4g, 5g", + "rscp" : -30, + "networkGen" : "2g, 3g, 4g, 5g", + "networkSubtype" : "LTE/HSPA", + "sinr" : 20 + }, + "score" : { + "applicationScore" : 100, + "quality" : "great" + }, + "connectTime" : 2, + "networkProfile" : { + "previousInterface" : { + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "interfaceName" : "en0", + "subnetMask" : "255.255.255.0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ] + }, + "ethernetProfile" : { + "linkSpeed" : 860 + }, + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "proxyProfile" : { + "method" : "System", + "proxies" : [ { + "bypass" : "*.local;169.254/16", + "proxy" : "" + }, { + "bypass" : "*.local;169.254/16", + "proxy" : "" + } ] + }, + "subnetMask" : "255.255.255.0", + "error" : "An operation timed out.", + "wirelessProfile" : { + "rssi" : -38, + "bssid" : "4c:ba:ba:f4:fa:fa", + "snr" : 57, + "vendor" : "Cisco", + "txRate" : 130, + "channel" : 1, + "noise" : -95, + "phyMode" : "802.11n", + "ssid" : "Internet for the masses", + "quality" : 100 + }, + "interfaceName" : "en0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ], + "gateway" : "10.0.0.1" + }, + "throughput" : 190, + "roundId" : 1384309800, + "headers" : { + "requestHeaders" : "GET / HTTP/1.1\\r\\nHost: www.thousandeyes.com\\r\\nUser-Agent: curl/7.58.0-DEV\\r\\nAccept: */*\\r\\nAccept-Encoding: deflate, gzip\\r\\nX-ThousandEyes-Agent: yes\\r\\n", + "responseHeaders" : "HTTP/1.1 200 OK\\r\\nContent-Type: text/html;charset=UTF-8\\r\\nContent-Length: 9993\\r\\nConnection: keep-alive\\r\\nDate: Mon, 04 May 2020 16:13:00 GMT\\r\\nServer: Apache\\r\\nContent-Language: en-US\\r\\nContent-Encoding: gzip\\r\\nX-Frame-Options: sameorigin\\r\\nCache-Control: max-age=600, must-revalidate\\r\\nStrict-Transport-Security: max-age=31536000\\r\\nX-Content-Type-Options: nosniff\\r\\nX-XSS-Protection: 1; mode=block\\r\\nVary: Accept-Encoding\\r\\nX-Cache: Hit from cloudfront\\r\\nVia: 1.1 7ba3caf71ae7a52dd411d1a543e80cd8.cloudfront.net (CloudFront)\\r\\nX-Amz-Cf-Pop: SFO5-C3\\r\\nX-Amz-Cf-Id: w4h42tkoJD-rEpkRDZUvnQBmy26GVGe6pUsuRr1Dphf7oajYbjXaOA==\\r\\nAge: 132\\r\\n" + }, + "redirectTime" : 10, + "responseTime" : 14, + "totalTime" : 15, + "receiveTime" : 1, + "systemMetrics" : { + "cpuUtilization" : { + "min" : 0.22, + "median" : 0.61, + "max" : 0.75, + "mean" : 0.55, + "count" : 150, + "stdDev" : 0.01 + }, + "physicalMemoryTotalBytes" : 1024, + "startTimeMs" : 1581508857327, + "physicalMemoryUsedBytes" : { + "min" : 1.2, + "median" : 1.85, + "max" : 2.5, + "mean" : 1.77, + "count" : 155, + "stdDev" : 0.25 + }, + "endTimeMs" : 1581508867333 + }, + "dnsTime" : 0, + "serverIp" : "193.2.1.88", + "testId" : "584739201", + "sslTime" : 9, + "aid" : "1234", + "waitTime" : 3, + "errorDetails" : "errorDetails", + "wireSize" : 9993 + } ], + "startDate" : "2022-07-17T22:00:54Z" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_http_server_scheduled_test_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_http_server_scheduled_test_results"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_http_server_scheduled_test_results_error_401(self) -> None: + """Integration test for get_http_server_scheduled_test_results error path (HTTP 401)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_http_server_scheduled_test_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_http_server_scheduled_test_results", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_http_server_scheduled_test_results_error_403(self) -> None: + """Integration test for get_http_server_scheduled_test_results error path (HTTP 403)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_http_server_scheduled_test_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_http_server_scheduled_test_results", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_http_server_scheduled_test_results_error_404(self) -> None: + """Integration test for get_http_server_scheduled_test_results error path (HTTP 404)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_http_server_scheduled_test_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_http_server_scheduled_test_results", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_http_server_scheduled_test_results_error_429(self) -> None: + """Integration test for get_http_server_scheduled_test_results error path (HTTP 429)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_http_server_scheduled_test_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_http_server_scheduled_test_results", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_http_server_scheduled_test_results_error_500(self) -> None: + """Integration test for get_http_server_scheduled_test_results error path (HTTP 500)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_http_server_scheduled_test_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_http_server_scheduled_test_results", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_http_server_scheduled_test_results_error_502(self) -> None: + """Integration test for get_http_server_scheduled_test_results error path (HTTP 502)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.get_http_server_scheduled_test_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_http_server_scheduled_test_results", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_multi_test_filtered_http_server_scheduled_test_results_happy_path(self) -> None: + """Integration test for get_multi_test_filtered_http_server_scheduled_test_results success path""" + request_body_json = """ + + { + "searchSort" : [ { + "sort" : "round-id", + "order" : "desc" + }, { + "sort" : "round-id", + "order" : "desc" + } ], + "searchFilters" : { + "agentId" : [ "52455b09-ff1b-4849-8194-99026cc890e0", "52455b09-ff1b-4849-8194-99026cc890e0" ], + "testId" : [ "5", "5" ], + "userPrincipalName" : [ "joeblogs32@c.com", "joeblogs32@c.com" ] + }, + "thresholdFilter" : { + "conditionalOperator" : "and", + "filters" : [ { + "name" : "response-time", + "value" : 10, + "operator" : "gte" + }, { + "name" : "response-time", + "value" : 10, + "operator" : "gte" + } ] + } + } + + """ + http_endpoint_tests_data_rounds_search = thousandeyes_sdk.endpoint_test_results.models.HttpEndpointTestsDataRoundsSearch.from_json(request_body_json) + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + use_all_permitted_aids = False + response_body_json = """ + { + "totalHits" : 12, + "endDate" : "2022-07-18T22:00:54Z", + "_links" : { + "next" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "results" : [ { + "originalTargetProfile" : { + "protocol" : "tcp", + "remotePort" : 80, + "remoteIpAddress" : "120.98.134.7" + }, + "agentId" : "861b7557-cd57-4bbb-b648-00bddf88ef49", + "numRedirects" : 0, + "vpnProfile" : { + "vpnClientNetworkRange" : [ "9.88.37.27", "9.88.37.27" ], + "vpnGatewayAddress" : "120.98.134.7", + "vpnType" : "cisco-anyconnect", + "vpnClientAddresses" : [ "184.81.113.85", "13.129.91.62" ] + }, + "errorType" : "connect", + "batteryMetrics" : { + "batteryHealthNormalizedPercent" : 0.92, + "batteryLevel" : "medium", + "batteryLevelNormalizedPercent" : 0.3 + }, + "userProfile" : { + "userName" : "joeblogs32", + "userPrincipalName" : "joeblogs32@c.com" + }, + "platform" : "mac", + "responseCode" : 200, + "cellularProfile" : { + "rssi" : -10, + "advertisedNetworkSubtype" : "LTE/HSPA", + "carrierName" : "T-Mobile", + "rsrq" : -30, + "rsrp" : -30, + "advertisedNetworkGen" : "2g, 3g, 4g, 5g", + "rscp" : -30, + "networkGen" : "2g, 3g, 4g, 5g", + "networkSubtype" : "LTE/HSPA", + "sinr" : 20 + }, + "score" : { + "applicationScore" : 100, + "quality" : "great" + }, + "connectTime" : 2, + "networkProfile" : { + "previousInterface" : { + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "interfaceName" : "en0", + "subnetMask" : "255.255.255.0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ] + }, + "ethernetProfile" : { + "linkSpeed" : 860 + }, + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "proxyProfile" : { + "method" : "System", + "proxies" : [ { + "bypass" : "*.local;169.254/16", + "proxy" : "" + }, { + "bypass" : "*.local;169.254/16", + "proxy" : "" + } ] + }, + "subnetMask" : "255.255.255.0", + "error" : "An operation timed out.", + "wirelessProfile" : { + "rssi" : -38, + "bssid" : "4c:ba:ba:f4:fa:fa", + "snr" : 57, + "vendor" : "Cisco", + "txRate" : 130, + "channel" : 1, + "noise" : -95, + "phyMode" : "802.11n", + "ssid" : "Internet for the masses", + "quality" : 100 + }, + "interfaceName" : "en0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ], + "gateway" : "10.0.0.1" + }, + "throughput" : 190, + "roundId" : 1384309800, + "headers" : { + "requestHeaders" : "GET / HTTP/1.1\\r\\nHost: www.thousandeyes.com\\r\\nUser-Agent: curl/7.58.0-DEV\\r\\nAccept: */*\\r\\nAccept-Encoding: deflate, gzip\\r\\nX-ThousandEyes-Agent: yes\\r\\n", + "responseHeaders" : "HTTP/1.1 200 OK\\r\\nContent-Type: text/html;charset=UTF-8\\r\\nContent-Length: 9993\\r\\nConnection: keep-alive\\r\\nDate: Mon, 04 May 2020 16:13:00 GMT\\r\\nServer: Apache\\r\\nContent-Language: en-US\\r\\nContent-Encoding: gzip\\r\\nX-Frame-Options: sameorigin\\r\\nCache-Control: max-age=600, must-revalidate\\r\\nStrict-Transport-Security: max-age=31536000\\r\\nX-Content-Type-Options: nosniff\\r\\nX-XSS-Protection: 1; mode=block\\r\\nVary: Accept-Encoding\\r\\nX-Cache: Hit from cloudfront\\r\\nVia: 1.1 7ba3caf71ae7a52dd411d1a543e80cd8.cloudfront.net (CloudFront)\\r\\nX-Amz-Cf-Pop: SFO5-C3\\r\\nX-Amz-Cf-Id: w4h42tkoJD-rEpkRDZUvnQBmy26GVGe6pUsuRr1Dphf7oajYbjXaOA==\\r\\nAge: 132\\r\\n" + }, + "redirectTime" : 10, + "responseTime" : 14, + "totalTime" : 15, + "receiveTime" : 1, + "systemMetrics" : { + "cpuUtilization" : { + "min" : 0.22, + "median" : 0.61, + "max" : 0.75, + "mean" : 0.55, + "count" : 150, + "stdDev" : 0.01 + }, + "physicalMemoryTotalBytes" : 1024, + "startTimeMs" : 1581508857327, + "physicalMemoryUsedBytes" : { + "min" : 1.2, + "median" : 1.85, + "max" : 2.5, + "mean" : 1.77, + "count" : 155, + "stdDev" : 0.25 + }, + "endTimeMs" : 1581508867333 + }, + "dnsTime" : 0, + "serverIp" : "193.2.1.88", + "testId" : "584739201", + "sslTime" : 9, + "aid" : "1234", + "waitTime" : 3, + "errorDetails" : "errorDetails", + "wireSize" : 9993 + }, { + "originalTargetProfile" : { + "protocol" : "tcp", + "remotePort" : 80, + "remoteIpAddress" : "120.98.134.7" + }, + "agentId" : "861b7557-cd57-4bbb-b648-00bddf88ef49", + "numRedirects" : 0, + "vpnProfile" : { + "vpnClientNetworkRange" : [ "9.88.37.27", "9.88.37.27" ], + "vpnGatewayAddress" : "120.98.134.7", + "vpnType" : "cisco-anyconnect", + "vpnClientAddresses" : [ "184.81.113.85", "13.129.91.62" ] + }, + "errorType" : "connect", + "batteryMetrics" : { + "batteryHealthNormalizedPercent" : 0.92, + "batteryLevel" : "medium", + "batteryLevelNormalizedPercent" : 0.3 + }, + "userProfile" : { + "userName" : "joeblogs32", + "userPrincipalName" : "joeblogs32@c.com" + }, + "platform" : "mac", + "responseCode" : 200, + "cellularProfile" : { + "rssi" : -10, + "advertisedNetworkSubtype" : "LTE/HSPA", + "carrierName" : "T-Mobile", + "rsrq" : -30, + "rsrp" : -30, + "advertisedNetworkGen" : "2g, 3g, 4g, 5g", + "rscp" : -30, + "networkGen" : "2g, 3g, 4g, 5g", + "networkSubtype" : "LTE/HSPA", + "sinr" : 20 + }, + "score" : { + "applicationScore" : 100, + "quality" : "great" + }, + "connectTime" : 2, + "networkProfile" : { + "previousInterface" : { + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "interfaceName" : "en0", + "subnetMask" : "255.255.255.0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ] + }, + "ethernetProfile" : { + "linkSpeed" : 860 + }, + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "proxyProfile" : { + "method" : "System", + "proxies" : [ { + "bypass" : "*.local;169.254/16", + "proxy" : "" + }, { + "bypass" : "*.local;169.254/16", + "proxy" : "" + } ] + }, + "subnetMask" : "255.255.255.0", + "error" : "An operation timed out.", + "wirelessProfile" : { + "rssi" : -38, + "bssid" : "4c:ba:ba:f4:fa:fa", + "snr" : 57, + "vendor" : "Cisco", + "txRate" : 130, + "channel" : 1, + "noise" : -95, + "phyMode" : "802.11n", + "ssid" : "Internet for the masses", + "quality" : 100 + }, + "interfaceName" : "en0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ], + "gateway" : "10.0.0.1" + }, + "throughput" : 190, + "roundId" : 1384309800, + "headers" : { + "requestHeaders" : "GET / HTTP/1.1\\r\\nHost: www.thousandeyes.com\\r\\nUser-Agent: curl/7.58.0-DEV\\r\\nAccept: */*\\r\\nAccept-Encoding: deflate, gzip\\r\\nX-ThousandEyes-Agent: yes\\r\\n", + "responseHeaders" : "HTTP/1.1 200 OK\\r\\nContent-Type: text/html;charset=UTF-8\\r\\nContent-Length: 9993\\r\\nConnection: keep-alive\\r\\nDate: Mon, 04 May 2020 16:13:00 GMT\\r\\nServer: Apache\\r\\nContent-Language: en-US\\r\\nContent-Encoding: gzip\\r\\nX-Frame-Options: sameorigin\\r\\nCache-Control: max-age=600, must-revalidate\\r\\nStrict-Transport-Security: max-age=31536000\\r\\nX-Content-Type-Options: nosniff\\r\\nX-XSS-Protection: 1; mode=block\\r\\nVary: Accept-Encoding\\r\\nX-Cache: Hit from cloudfront\\r\\nVia: 1.1 7ba3caf71ae7a52dd411d1a543e80cd8.cloudfront.net (CloudFront)\\r\\nX-Amz-Cf-Pop: SFO5-C3\\r\\nX-Amz-Cf-Id: w4h42tkoJD-rEpkRDZUvnQBmy26GVGe6pUsuRr1Dphf7oajYbjXaOA==\\r\\nAge: 132\\r\\n" + }, + "redirectTime" : 10, + "responseTime" : 14, + "totalTime" : 15, + "receiveTime" : 1, + "systemMetrics" : { + "cpuUtilization" : { + "min" : 0.22, + "median" : 0.61, + "max" : 0.75, + "mean" : 0.55, + "count" : 150, + "stdDev" : 0.01 + }, + "physicalMemoryTotalBytes" : 1024, + "startTimeMs" : 1581508857327, + "physicalMemoryUsedBytes" : { + "min" : 1.2, + "median" : 1.85, + "max" : 2.5, + "mean" : 1.77, + "count" : 155, + "stdDev" : 0.25 + }, + "endTimeMs" : 1581508867333 + }, + "dnsTime" : 0, + "serverIp" : "193.2.1.88", + "testId" : "584739201", + "sslTime" : 9, + "aid" : "1234", + "waitTime" : 3, + "errorDetails" : "errorDetails", + "wireSize" : 9993 + } ], + "startDate" : "2022-07-17T22:00:54Z" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_multi_test_filtered_http_server_scheduled_test_results( + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + use_all_permitted_aids=use_all_permitted_aids, + + http_endpoint_tests_data_rounds_search=http_endpoint_tests_data_rounds_search, + + _headers=self.te_headers("get_multi_test_filtered_http_server_scheduled_test_results"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_multi_test_filtered_http_server_scheduled_test_results_error_400(self) -> None: + """Integration test for get_multi_test_filtered_http_server_scheduled_test_results error path (HTTP 400)""" + request_body_json = """ + + { + "searchSort" : [ { + "sort" : "round-id", + "order" : "desc" + }, { + "sort" : "round-id", + "order" : "desc" + } ], + "searchFilters" : { + "agentId" : [ "52455b09-ff1b-4849-8194-99026cc890e0", "52455b09-ff1b-4849-8194-99026cc890e0" ], + "testId" : [ "5", "5" ], + "userPrincipalName" : [ "joeblogs32@c.com", "joeblogs32@c.com" ] + }, + "thresholdFilter" : { + "conditionalOperator" : "and", + "filters" : [ { + "name" : "response-time", + "value" : 10, + "operator" : "gte" + }, { + "name" : "response-time", + "value" : 10, + "operator" : "gte" + } ] + } + } + + """ + http_endpoint_tests_data_rounds_search = thousandeyes_sdk.endpoint_test_results.models.HttpEndpointTestsDataRoundsSearch.from_json(request_body_json) + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + use_all_permitted_aids = False + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.get_multi_test_filtered_http_server_scheduled_test_results( + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + use_all_permitted_aids=use_all_permitted_aids, + + http_endpoint_tests_data_rounds_search=http_endpoint_tests_data_rounds_search, + + _headers=self.te_headers("get_multi_test_filtered_http_server_scheduled_test_results", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_multi_test_filtered_http_server_scheduled_test_results_error_401(self) -> None: + """Integration test for get_multi_test_filtered_http_server_scheduled_test_results error path (HTTP 401)""" + request_body_json = """ + + { + "searchSort" : [ { + "sort" : "round-id", + "order" : "desc" + }, { + "sort" : "round-id", + "order" : "desc" + } ], + "searchFilters" : { + "agentId" : [ "52455b09-ff1b-4849-8194-99026cc890e0", "52455b09-ff1b-4849-8194-99026cc890e0" ], + "testId" : [ "5", "5" ], + "userPrincipalName" : [ "joeblogs32@c.com", "joeblogs32@c.com" ] + }, + "thresholdFilter" : { + "conditionalOperator" : "and", + "filters" : [ { + "name" : "response-time", + "value" : 10, + "operator" : "gte" + }, { + "name" : "response-time", + "value" : 10, + "operator" : "gte" + } ] + } + } + + """ + http_endpoint_tests_data_rounds_search = thousandeyes_sdk.endpoint_test_results.models.HttpEndpointTestsDataRoundsSearch.from_json(request_body_json) + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + use_all_permitted_aids = False + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_multi_test_filtered_http_server_scheduled_test_results( + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + use_all_permitted_aids=use_all_permitted_aids, + + http_endpoint_tests_data_rounds_search=http_endpoint_tests_data_rounds_search, + + _headers=self.te_headers("get_multi_test_filtered_http_server_scheduled_test_results", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_multi_test_filtered_http_server_scheduled_test_results_error_403(self) -> None: + """Integration test for get_multi_test_filtered_http_server_scheduled_test_results error path (HTTP 403)""" + request_body_json = """ + + { + "searchSort" : [ { + "sort" : "round-id", + "order" : "desc" + }, { + "sort" : "round-id", + "order" : "desc" + } ], + "searchFilters" : { + "agentId" : [ "52455b09-ff1b-4849-8194-99026cc890e0", "52455b09-ff1b-4849-8194-99026cc890e0" ], + "testId" : [ "5", "5" ], + "userPrincipalName" : [ "joeblogs32@c.com", "joeblogs32@c.com" ] + }, + "thresholdFilter" : { + "conditionalOperator" : "and", + "filters" : [ { + "name" : "response-time", + "value" : 10, + "operator" : "gte" + }, { + "name" : "response-time", + "value" : 10, + "operator" : "gte" + } ] + } + } + + """ + http_endpoint_tests_data_rounds_search = thousandeyes_sdk.endpoint_test_results.models.HttpEndpointTestsDataRoundsSearch.from_json(request_body_json) + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + use_all_permitted_aids = False + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_multi_test_filtered_http_server_scheduled_test_results( + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + use_all_permitted_aids=use_all_permitted_aids, + + http_endpoint_tests_data_rounds_search=http_endpoint_tests_data_rounds_search, + + _headers=self.te_headers("get_multi_test_filtered_http_server_scheduled_test_results", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_multi_test_filtered_http_server_scheduled_test_results_error_404(self) -> None: + """Integration test for get_multi_test_filtered_http_server_scheduled_test_results error path (HTTP 404)""" + request_body_json = """ + + { + "searchSort" : [ { + "sort" : "round-id", + "order" : "desc" + }, { + "sort" : "round-id", + "order" : "desc" + } ], + "searchFilters" : { + "agentId" : [ "52455b09-ff1b-4849-8194-99026cc890e0", "52455b09-ff1b-4849-8194-99026cc890e0" ], + "testId" : [ "5", "5" ], + "userPrincipalName" : [ "joeblogs32@c.com", "joeblogs32@c.com" ] + }, + "thresholdFilter" : { + "conditionalOperator" : "and", + "filters" : [ { + "name" : "response-time", + "value" : 10, + "operator" : "gte" + }, { + "name" : "response-time", + "value" : 10, + "operator" : "gte" + } ] + } + } + + """ + http_endpoint_tests_data_rounds_search = thousandeyes_sdk.endpoint_test_results.models.HttpEndpointTestsDataRoundsSearch.from_json(request_body_json) + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + use_all_permitted_aids = False + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_multi_test_filtered_http_server_scheduled_test_results( + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + use_all_permitted_aids=use_all_permitted_aids, + + http_endpoint_tests_data_rounds_search=http_endpoint_tests_data_rounds_search, + + _headers=self.te_headers("get_multi_test_filtered_http_server_scheduled_test_results", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_multi_test_filtered_http_server_scheduled_test_results_error_429(self) -> None: + """Integration test for get_multi_test_filtered_http_server_scheduled_test_results error path (HTTP 429)""" + request_body_json = """ + + { + "searchSort" : [ { + "sort" : "round-id", + "order" : "desc" + }, { + "sort" : "round-id", + "order" : "desc" + } ], + "searchFilters" : { + "agentId" : [ "52455b09-ff1b-4849-8194-99026cc890e0", "52455b09-ff1b-4849-8194-99026cc890e0" ], + "testId" : [ "5", "5" ], + "userPrincipalName" : [ "joeblogs32@c.com", "joeblogs32@c.com" ] + }, + "thresholdFilter" : { + "conditionalOperator" : "and", + "filters" : [ { + "name" : "response-time", + "value" : 10, + "operator" : "gte" + }, { + "name" : "response-time", + "value" : 10, + "operator" : "gte" + } ] + } + } + + """ + http_endpoint_tests_data_rounds_search = thousandeyes_sdk.endpoint_test_results.models.HttpEndpointTestsDataRoundsSearch.from_json(request_body_json) + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + use_all_permitted_aids = False + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_multi_test_filtered_http_server_scheduled_test_results( + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + use_all_permitted_aids=use_all_permitted_aids, + + http_endpoint_tests_data_rounds_search=http_endpoint_tests_data_rounds_search, + + _headers=self.te_headers("get_multi_test_filtered_http_server_scheduled_test_results", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_multi_test_filtered_http_server_scheduled_test_results_error_500(self) -> None: + """Integration test for get_multi_test_filtered_http_server_scheduled_test_results error path (HTTP 500)""" + request_body_json = """ + + { + "searchSort" : [ { + "sort" : "round-id", + "order" : "desc" + }, { + "sort" : "round-id", + "order" : "desc" + } ], + "searchFilters" : { + "agentId" : [ "52455b09-ff1b-4849-8194-99026cc890e0", "52455b09-ff1b-4849-8194-99026cc890e0" ], + "testId" : [ "5", "5" ], + "userPrincipalName" : [ "joeblogs32@c.com", "joeblogs32@c.com" ] + }, + "thresholdFilter" : { + "conditionalOperator" : "and", + "filters" : [ { + "name" : "response-time", + "value" : 10, + "operator" : "gte" + }, { + "name" : "response-time", + "value" : 10, + "operator" : "gte" + } ] + } + } + + """ + http_endpoint_tests_data_rounds_search = thousandeyes_sdk.endpoint_test_results.models.HttpEndpointTestsDataRoundsSearch.from_json(request_body_json) + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + use_all_permitted_aids = False + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_multi_test_filtered_http_server_scheduled_test_results( + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + use_all_permitted_aids=use_all_permitted_aids, + + http_endpoint_tests_data_rounds_search=http_endpoint_tests_data_rounds_search, + + _headers=self.te_headers("get_multi_test_filtered_http_server_scheduled_test_results", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_multi_test_filtered_http_server_scheduled_test_results_error_502(self) -> None: + """Integration test for get_multi_test_filtered_http_server_scheduled_test_results error path (HTTP 502)""" + request_body_json = """ + + { + "searchSort" : [ { + "sort" : "round-id", + "order" : "desc" + }, { + "sort" : "round-id", + "order" : "desc" + } ], + "searchFilters" : { + "agentId" : [ "52455b09-ff1b-4849-8194-99026cc890e0", "52455b09-ff1b-4849-8194-99026cc890e0" ], + "testId" : [ "5", "5" ], + "userPrincipalName" : [ "joeblogs32@c.com", "joeblogs32@c.com" ] + }, + "thresholdFilter" : { + "conditionalOperator" : "and", + "filters" : [ { + "name" : "response-time", + "value" : 10, + "operator" : "gte" + }, { + "name" : "response-time", + "value" : 10, + "operator" : "gte" + } ] + } + } + + """ + http_endpoint_tests_data_rounds_search = thousandeyes_sdk.endpoint_test_results.models.HttpEndpointTestsDataRoundsSearch.from_json(request_body_json) + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + use_all_permitted_aids = False + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.get_multi_test_filtered_http_server_scheduled_test_results( + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + use_all_permitted_aids=use_all_permitted_aids, + + http_endpoint_tests_data_rounds_search=http_endpoint_tests_data_rounds_search, + + _headers=self.te_headers("get_multi_test_filtered_http_server_scheduled_test_results", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_single_test_filtered_http_server_scheduled_test_results_happy_path(self) -> None: + """Integration test for get_single_test_filtered_http_server_scheduled_test_results success path""" + request_body_json = """ + + { + "searchSort" : [ { + "sort" : "round-id", + "order" : "desc" + }, { + "sort" : "round-id", + "order" : "desc" + } ], + "searchFilters" : { + "agentId" : [ "52455b09-ff1b-4849-8194-99026cc890e0", "52455b09-ff1b-4849-8194-99026cc890e0" ], + "testId" : [ "5", "5" ], + "userPrincipalName" : [ "joeblogs32@c.com", "joeblogs32@c.com" ] + }, + "thresholdFilter" : { + "conditionalOperator" : "and", + "filters" : [ { + "name" : "response-time", + "value" : 10, + "operator" : "gte" + }, { + "name" : "response-time", + "value" : 10, + "operator" : "gte" + } ] + } + } + + """ + http_endpoint_tests_data_rounds_search = thousandeyes_sdk.endpoint_test_results.models.HttpEndpointTestsDataRoundsSearch.from_json(request_body_json) + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + response_body_json = """ + { + "totalHits" : 12, + "endDate" : "2022-07-18T22:00:54Z", + "_links" : { + "next" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "results" : [ { + "originalTargetProfile" : { + "protocol" : "tcp", + "remotePort" : 80, + "remoteIpAddress" : "120.98.134.7" + }, + "agentId" : "861b7557-cd57-4bbb-b648-00bddf88ef49", + "numRedirects" : 0, + "vpnProfile" : { + "vpnClientNetworkRange" : [ "9.88.37.27", "9.88.37.27" ], + "vpnGatewayAddress" : "120.98.134.7", + "vpnType" : "cisco-anyconnect", + "vpnClientAddresses" : [ "184.81.113.85", "13.129.91.62" ] + }, + "errorType" : "connect", + "batteryMetrics" : { + "batteryHealthNormalizedPercent" : 0.92, + "batteryLevel" : "medium", + "batteryLevelNormalizedPercent" : 0.3 + }, + "userProfile" : { + "userName" : "joeblogs32", + "userPrincipalName" : "joeblogs32@c.com" + }, + "platform" : "mac", + "responseCode" : 200, + "cellularProfile" : { + "rssi" : -10, + "advertisedNetworkSubtype" : "LTE/HSPA", + "carrierName" : "T-Mobile", + "rsrq" : -30, + "rsrp" : -30, + "advertisedNetworkGen" : "2g, 3g, 4g, 5g", + "rscp" : -30, + "networkGen" : "2g, 3g, 4g, 5g", + "networkSubtype" : "LTE/HSPA", + "sinr" : 20 + }, + "score" : { + "applicationScore" : 100, + "quality" : "great" + }, + "connectTime" : 2, + "networkProfile" : { + "previousInterface" : { + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "interfaceName" : "en0", + "subnetMask" : "255.255.255.0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ] + }, + "ethernetProfile" : { + "linkSpeed" : 860 + }, + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "proxyProfile" : { + "method" : "System", + "proxies" : [ { + "bypass" : "*.local;169.254/16", + "proxy" : "" + }, { + "bypass" : "*.local;169.254/16", + "proxy" : "" + } ] + }, + "subnetMask" : "255.255.255.0", + "error" : "An operation timed out.", + "wirelessProfile" : { + "rssi" : -38, + "bssid" : "4c:ba:ba:f4:fa:fa", + "snr" : 57, + "vendor" : "Cisco", + "txRate" : 130, + "channel" : 1, + "noise" : -95, + "phyMode" : "802.11n", + "ssid" : "Internet for the masses", + "quality" : 100 + }, + "interfaceName" : "en0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ], + "gateway" : "10.0.0.1" + }, + "throughput" : 190, + "roundId" : 1384309800, + "headers" : { + "requestHeaders" : "GET / HTTP/1.1\\r\\nHost: www.thousandeyes.com\\r\\nUser-Agent: curl/7.58.0-DEV\\r\\nAccept: */*\\r\\nAccept-Encoding: deflate, gzip\\r\\nX-ThousandEyes-Agent: yes\\r\\n", + "responseHeaders" : "HTTP/1.1 200 OK\\r\\nContent-Type: text/html;charset=UTF-8\\r\\nContent-Length: 9993\\r\\nConnection: keep-alive\\r\\nDate: Mon, 04 May 2020 16:13:00 GMT\\r\\nServer: Apache\\r\\nContent-Language: en-US\\r\\nContent-Encoding: gzip\\r\\nX-Frame-Options: sameorigin\\r\\nCache-Control: max-age=600, must-revalidate\\r\\nStrict-Transport-Security: max-age=31536000\\r\\nX-Content-Type-Options: nosniff\\r\\nX-XSS-Protection: 1; mode=block\\r\\nVary: Accept-Encoding\\r\\nX-Cache: Hit from cloudfront\\r\\nVia: 1.1 7ba3caf71ae7a52dd411d1a543e80cd8.cloudfront.net (CloudFront)\\r\\nX-Amz-Cf-Pop: SFO5-C3\\r\\nX-Amz-Cf-Id: w4h42tkoJD-rEpkRDZUvnQBmy26GVGe6pUsuRr1Dphf7oajYbjXaOA==\\r\\nAge: 132\\r\\n" + }, + "redirectTime" : 10, + "responseTime" : 14, + "totalTime" : 15, + "receiveTime" : 1, + "systemMetrics" : { + "cpuUtilization" : { + "min" : 0.22, + "median" : 0.61, + "max" : 0.75, + "mean" : 0.55, + "count" : 150, + "stdDev" : 0.01 + }, + "physicalMemoryTotalBytes" : 1024, + "startTimeMs" : 1581508857327, + "physicalMemoryUsedBytes" : { + "min" : 1.2, + "median" : 1.85, + "max" : 2.5, + "mean" : 1.77, + "count" : 155, + "stdDev" : 0.25 + }, + "endTimeMs" : 1581508867333 + }, + "dnsTime" : 0, + "serverIp" : "193.2.1.88", + "testId" : "584739201", + "sslTime" : 9, + "aid" : "1234", + "waitTime" : 3, + "errorDetails" : "errorDetails", + "wireSize" : 9993 + }, { + "originalTargetProfile" : { + "protocol" : "tcp", + "remotePort" : 80, + "remoteIpAddress" : "120.98.134.7" + }, + "agentId" : "861b7557-cd57-4bbb-b648-00bddf88ef49", + "numRedirects" : 0, + "vpnProfile" : { + "vpnClientNetworkRange" : [ "9.88.37.27", "9.88.37.27" ], + "vpnGatewayAddress" : "120.98.134.7", + "vpnType" : "cisco-anyconnect", + "vpnClientAddresses" : [ "184.81.113.85", "13.129.91.62" ] + }, + "errorType" : "connect", + "batteryMetrics" : { + "batteryHealthNormalizedPercent" : 0.92, + "batteryLevel" : "medium", + "batteryLevelNormalizedPercent" : 0.3 + }, + "userProfile" : { + "userName" : "joeblogs32", + "userPrincipalName" : "joeblogs32@c.com" + }, + "platform" : "mac", + "responseCode" : 200, + "cellularProfile" : { + "rssi" : -10, + "advertisedNetworkSubtype" : "LTE/HSPA", + "carrierName" : "T-Mobile", + "rsrq" : -30, + "rsrp" : -30, + "advertisedNetworkGen" : "2g, 3g, 4g, 5g", + "rscp" : -30, + "networkGen" : "2g, 3g, 4g, 5g", + "networkSubtype" : "LTE/HSPA", + "sinr" : 20 + }, + "score" : { + "applicationScore" : 100, + "quality" : "great" + }, + "connectTime" : 2, + "networkProfile" : { + "previousInterface" : { + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "interfaceName" : "en0", + "subnetMask" : "255.255.255.0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ] + }, + "ethernetProfile" : { + "linkSpeed" : 860 + }, + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "proxyProfile" : { + "method" : "System", + "proxies" : [ { + "bypass" : "*.local;169.254/16", + "proxy" : "" + }, { + "bypass" : "*.local;169.254/16", + "proxy" : "" + } ] + }, + "subnetMask" : "255.255.255.0", + "error" : "An operation timed out.", + "wirelessProfile" : { + "rssi" : -38, + "bssid" : "4c:ba:ba:f4:fa:fa", + "snr" : 57, + "vendor" : "Cisco", + "txRate" : 130, + "channel" : 1, + "noise" : -95, + "phyMode" : "802.11n", + "ssid" : "Internet for the masses", + "quality" : 100 + }, + "interfaceName" : "en0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ], + "gateway" : "10.0.0.1" + }, + "throughput" : 190, + "roundId" : 1384309800, + "headers" : { + "requestHeaders" : "GET / HTTP/1.1\\r\\nHost: www.thousandeyes.com\\r\\nUser-Agent: curl/7.58.0-DEV\\r\\nAccept: */*\\r\\nAccept-Encoding: deflate, gzip\\r\\nX-ThousandEyes-Agent: yes\\r\\n", + "responseHeaders" : "HTTP/1.1 200 OK\\r\\nContent-Type: text/html;charset=UTF-8\\r\\nContent-Length: 9993\\r\\nConnection: keep-alive\\r\\nDate: Mon, 04 May 2020 16:13:00 GMT\\r\\nServer: Apache\\r\\nContent-Language: en-US\\r\\nContent-Encoding: gzip\\r\\nX-Frame-Options: sameorigin\\r\\nCache-Control: max-age=600, must-revalidate\\r\\nStrict-Transport-Security: max-age=31536000\\r\\nX-Content-Type-Options: nosniff\\r\\nX-XSS-Protection: 1; mode=block\\r\\nVary: Accept-Encoding\\r\\nX-Cache: Hit from cloudfront\\r\\nVia: 1.1 7ba3caf71ae7a52dd411d1a543e80cd8.cloudfront.net (CloudFront)\\r\\nX-Amz-Cf-Pop: SFO5-C3\\r\\nX-Amz-Cf-Id: w4h42tkoJD-rEpkRDZUvnQBmy26GVGe6pUsuRr1Dphf7oajYbjXaOA==\\r\\nAge: 132\\r\\n" + }, + "redirectTime" : 10, + "responseTime" : 14, + "totalTime" : 15, + "receiveTime" : 1, + "systemMetrics" : { + "cpuUtilization" : { + "min" : 0.22, + "median" : 0.61, + "max" : 0.75, + "mean" : 0.55, + "count" : 150, + "stdDev" : 0.01 + }, + "physicalMemoryTotalBytes" : 1024, + "startTimeMs" : 1581508857327, + "physicalMemoryUsedBytes" : { + "min" : 1.2, + "median" : 1.85, + "max" : 2.5, + "mean" : 1.77, + "count" : 155, + "stdDev" : 0.25 + }, + "endTimeMs" : 1581508867333 + }, + "dnsTime" : 0, + "serverIp" : "193.2.1.88", + "testId" : "584739201", + "sslTime" : 9, + "aid" : "1234", + "waitTime" : 3, + "errorDetails" : "errorDetails", + "wireSize" : 9993 + } ], + "startDate" : "2022-07-17T22:00:54Z" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_single_test_filtered_http_server_scheduled_test_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + http_endpoint_tests_data_rounds_search=http_endpoint_tests_data_rounds_search, + + _headers=self.te_headers("get_single_test_filtered_http_server_scheduled_test_results"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_single_test_filtered_http_server_scheduled_test_results_error_400(self) -> None: + """Integration test for get_single_test_filtered_http_server_scheduled_test_results error path (HTTP 400)""" + request_body_json = """ + + { + "searchSort" : [ { + "sort" : "round-id", + "order" : "desc" + }, { + "sort" : "round-id", + "order" : "desc" + } ], + "searchFilters" : { + "agentId" : [ "52455b09-ff1b-4849-8194-99026cc890e0", "52455b09-ff1b-4849-8194-99026cc890e0" ], + "testId" : [ "5", "5" ], + "userPrincipalName" : [ "joeblogs32@c.com", "joeblogs32@c.com" ] + }, + "thresholdFilter" : { + "conditionalOperator" : "and", + "filters" : [ { + "name" : "response-time", + "value" : 10, + "operator" : "gte" + }, { + "name" : "response-time", + "value" : 10, + "operator" : "gte" + } ] + } + } + + """ + http_endpoint_tests_data_rounds_search = thousandeyes_sdk.endpoint_test_results.models.HttpEndpointTestsDataRoundsSearch.from_json(request_body_json) + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.get_single_test_filtered_http_server_scheduled_test_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + http_endpoint_tests_data_rounds_search=http_endpoint_tests_data_rounds_search, + + _headers=self.te_headers("get_single_test_filtered_http_server_scheduled_test_results", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_single_test_filtered_http_server_scheduled_test_results_error_401(self) -> None: + """Integration test for get_single_test_filtered_http_server_scheduled_test_results error path (HTTP 401)""" + request_body_json = """ + + { + "searchSort" : [ { + "sort" : "round-id", + "order" : "desc" + }, { + "sort" : "round-id", + "order" : "desc" + } ], + "searchFilters" : { + "agentId" : [ "52455b09-ff1b-4849-8194-99026cc890e0", "52455b09-ff1b-4849-8194-99026cc890e0" ], + "testId" : [ "5", "5" ], + "userPrincipalName" : [ "joeblogs32@c.com", "joeblogs32@c.com" ] + }, + "thresholdFilter" : { + "conditionalOperator" : "and", + "filters" : [ { + "name" : "response-time", + "value" : 10, + "operator" : "gte" + }, { + "name" : "response-time", + "value" : 10, + "operator" : "gte" + } ] + } + } + + """ + http_endpoint_tests_data_rounds_search = thousandeyes_sdk.endpoint_test_results.models.HttpEndpointTestsDataRoundsSearch.from_json(request_body_json) + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_single_test_filtered_http_server_scheduled_test_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + http_endpoint_tests_data_rounds_search=http_endpoint_tests_data_rounds_search, + + _headers=self.te_headers("get_single_test_filtered_http_server_scheduled_test_results", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_single_test_filtered_http_server_scheduled_test_results_error_403(self) -> None: + """Integration test for get_single_test_filtered_http_server_scheduled_test_results error path (HTTP 403)""" + request_body_json = """ + + { + "searchSort" : [ { + "sort" : "round-id", + "order" : "desc" + }, { + "sort" : "round-id", + "order" : "desc" + } ], + "searchFilters" : { + "agentId" : [ "52455b09-ff1b-4849-8194-99026cc890e0", "52455b09-ff1b-4849-8194-99026cc890e0" ], + "testId" : [ "5", "5" ], + "userPrincipalName" : [ "joeblogs32@c.com", "joeblogs32@c.com" ] + }, + "thresholdFilter" : { + "conditionalOperator" : "and", + "filters" : [ { + "name" : "response-time", + "value" : 10, + "operator" : "gte" + }, { + "name" : "response-time", + "value" : 10, + "operator" : "gte" + } ] + } + } + + """ + http_endpoint_tests_data_rounds_search = thousandeyes_sdk.endpoint_test_results.models.HttpEndpointTestsDataRoundsSearch.from_json(request_body_json) + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_single_test_filtered_http_server_scheduled_test_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + http_endpoint_tests_data_rounds_search=http_endpoint_tests_data_rounds_search, + + _headers=self.te_headers("get_single_test_filtered_http_server_scheduled_test_results", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_single_test_filtered_http_server_scheduled_test_results_error_404(self) -> None: + """Integration test for get_single_test_filtered_http_server_scheduled_test_results error path (HTTP 404)""" + request_body_json = """ + + { + "searchSort" : [ { + "sort" : "round-id", + "order" : "desc" + }, { + "sort" : "round-id", + "order" : "desc" + } ], + "searchFilters" : { + "agentId" : [ "52455b09-ff1b-4849-8194-99026cc890e0", "52455b09-ff1b-4849-8194-99026cc890e0" ], + "testId" : [ "5", "5" ], + "userPrincipalName" : [ "joeblogs32@c.com", "joeblogs32@c.com" ] + }, + "thresholdFilter" : { + "conditionalOperator" : "and", + "filters" : [ { + "name" : "response-time", + "value" : 10, + "operator" : "gte" + }, { + "name" : "response-time", + "value" : 10, + "operator" : "gte" + } ] + } + } + + """ + http_endpoint_tests_data_rounds_search = thousandeyes_sdk.endpoint_test_results.models.HttpEndpointTestsDataRoundsSearch.from_json(request_body_json) + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_single_test_filtered_http_server_scheduled_test_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + http_endpoint_tests_data_rounds_search=http_endpoint_tests_data_rounds_search, + + _headers=self.te_headers("get_single_test_filtered_http_server_scheduled_test_results", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_single_test_filtered_http_server_scheduled_test_results_error_429(self) -> None: + """Integration test for get_single_test_filtered_http_server_scheduled_test_results error path (HTTP 429)""" + request_body_json = """ + + { + "searchSort" : [ { + "sort" : "round-id", + "order" : "desc" + }, { + "sort" : "round-id", + "order" : "desc" + } ], + "searchFilters" : { + "agentId" : [ "52455b09-ff1b-4849-8194-99026cc890e0", "52455b09-ff1b-4849-8194-99026cc890e0" ], + "testId" : [ "5", "5" ], + "userPrincipalName" : [ "joeblogs32@c.com", "joeblogs32@c.com" ] + }, + "thresholdFilter" : { + "conditionalOperator" : "and", + "filters" : [ { + "name" : "response-time", + "value" : 10, + "operator" : "gte" + }, { + "name" : "response-time", + "value" : 10, + "operator" : "gte" + } ] + } + } + + """ + http_endpoint_tests_data_rounds_search = thousandeyes_sdk.endpoint_test_results.models.HttpEndpointTestsDataRoundsSearch.from_json(request_body_json) + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_single_test_filtered_http_server_scheduled_test_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + http_endpoint_tests_data_rounds_search=http_endpoint_tests_data_rounds_search, + + _headers=self.te_headers("get_single_test_filtered_http_server_scheduled_test_results", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_single_test_filtered_http_server_scheduled_test_results_error_500(self) -> None: + """Integration test for get_single_test_filtered_http_server_scheduled_test_results error path (HTTP 500)""" + request_body_json = """ + + { + "searchSort" : [ { + "sort" : "round-id", + "order" : "desc" + }, { + "sort" : "round-id", + "order" : "desc" + } ], + "searchFilters" : { + "agentId" : [ "52455b09-ff1b-4849-8194-99026cc890e0", "52455b09-ff1b-4849-8194-99026cc890e0" ], + "testId" : [ "5", "5" ], + "userPrincipalName" : [ "joeblogs32@c.com", "joeblogs32@c.com" ] + }, + "thresholdFilter" : { + "conditionalOperator" : "and", + "filters" : [ { + "name" : "response-time", + "value" : 10, + "operator" : "gte" + }, { + "name" : "response-time", + "value" : 10, + "operator" : "gte" + } ] + } + } + + """ + http_endpoint_tests_data_rounds_search = thousandeyes_sdk.endpoint_test_results.models.HttpEndpointTestsDataRoundsSearch.from_json(request_body_json) + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_single_test_filtered_http_server_scheduled_test_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + http_endpoint_tests_data_rounds_search=http_endpoint_tests_data_rounds_search, + + _headers=self.te_headers("get_single_test_filtered_http_server_scheduled_test_results", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_single_test_filtered_http_server_scheduled_test_results_error_502(self) -> None: + """Integration test for get_single_test_filtered_http_server_scheduled_test_results error path (HTTP 502)""" + request_body_json = """ + + { + "searchSort" : [ { + "sort" : "round-id", + "order" : "desc" + }, { + "sort" : "round-id", + "order" : "desc" + } ], + "searchFilters" : { + "agentId" : [ "52455b09-ff1b-4849-8194-99026cc890e0", "52455b09-ff1b-4849-8194-99026cc890e0" ], + "testId" : [ "5", "5" ], + "userPrincipalName" : [ "joeblogs32@c.com", "joeblogs32@c.com" ] + }, + "thresholdFilter" : { + "conditionalOperator" : "and", + "filters" : [ { + "name" : "response-time", + "value" : 10, + "operator" : "gte" + }, { + "name" : "response-time", + "value" : 10, + "operator" : "gte" + } ] + } + } + + """ + http_endpoint_tests_data_rounds_search = thousandeyes_sdk.endpoint_test_results.models.HttpEndpointTestsDataRoundsSearch.from_json(request_body_json) + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.get_single_test_filtered_http_server_scheduled_test_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + http_endpoint_tests_data_rounds_search=http_endpoint_tests_data_rounds_search, + + _headers=self.te_headers("get_single_test_filtered_http_server_scheduled_test_results", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-endpoint-test-results/test/test_local_network_endpoint_test_results_api_integration.py b/thousandeyes-sdk-endpoint-test-results/test/test_local_network_endpoint_test_results_api_integration.py new file mode 100644 index 00000000..43ddded4 --- /dev/null +++ b/thousandeyes-sdk-endpoint-test-results/test/test_local_network_endpoint_test_results_api_integration.py @@ -0,0 +1,1903 @@ +# coding: utf-8 + +""" + Endpoint Test Results API + + Retrieve results for scheduled and dynamic tests on endpoint agents. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.endpoint_test_results.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.endpoint_test_results.api.local_network_endpoint_test_results_api import LocalNetworkEndpointTestResultsApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestLocalNetworkEndpointTestResultsApiIntegration(IntegrationTestBase): + """LocalNetworkEndpointTestResultsApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = LocalNetworkEndpointTestResultsApi(self.api_client) + + + def test_filter_local_networks_test_results_topologies_happy_path(self) -> None: + """Integration test for filter_local_networks_test_results_topologies success path""" + request_body_json = """ + + { + "searchFilters" : { + "agentId" : [ "3fde6422-f119-40e1-ae32-d08a1243c038", "236e6f18-9637-4a2f-b15f-7aa6a29c9fce" ], + "bssid" : [ "8c:68:c8:a5:0a:8c", "0c:51:01:e4:3e:d0" ], + "location" : [ "San Francisco Bay Area", "Germany" ], + "connection" : [ "wireless", "wireless" ], + "vpnTarget" : [ "78.153.54.204", "78.153.54.206" ], + "networkId" : [ "660b34109d12", "660b34109d15" ], + "type" : [ "vpn", "proxy" ], + "ssid" : [ "wifi-name", "other-room-wifi" ], + "platform" : [ "mac", "mac" ], + "gateway" : [ "78.153.54.204", "78.153.54.206" ], + "proxyTarget" : [ "78.153.54.204", "78.153.54.206" ] + }, + "thresholdFilter" : { + "conditionalOperator" : "and", + "filters" : [ { + "name" : "loss", + "value" : 10, + "operator" : "gte" + }, { + "name" : "loss", + "value" : 10, + "operator" : "gte" + } ] + } + } + + """ + endpoint_network_topology_result_request = thousandeyes_sdk.endpoint_test_results.models.EndpointNetworkTopologyResultRequest.from_json(request_body_json) + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + response_body_json = """ + { + "endDate" : "2022-07-18T22:00:54Z", + "_links" : { + "next" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "results" : [ { + "date" : "2022-07-17T22:00:54Z", + "agentId" : "861b7557-cd57-4bbb-b648-00bddf88ef49", + "dnsServerTest" : { + "resolutionTime" : 3 + }, + "isIcmpBlocked" : true, + "gatewayScore" : { + "score" : 100, + "quality" : "great" + }, + "tcpConnect" : { + "rtt" : 77.777, + "errorCode" : "ERR_TIMED_OUT", + "error" : "An operation timed out.", + "infoFlags" : [ "TE_INFO_ICMP_BLOCKED_BY_FIREWALL" ] + }, + "vpnScore" : { + "score" : 100, + "quality" : "great" + }, + "proxyScore" : { + "score" : 100, + "quality" : "great" + }, + "batteryMetrics" : { + "batteryHealthNormalizedPercent" : 0.92, + "batteryLevel" : "medium", + "batteryLevelNormalizedPercent" : 0.3 + }, + "type" : "vpn", + "targetPort" : 80, + "platform" : "mac", + "target" : "10.0.2.2", + "cellularProfile" : { + "rssi" : -10, + "advertisedNetworkSubtype" : "LTE/HSPA", + "carrierName" : "T-Mobile", + "rsrq" : -30, + "rsrp" : -30, + "advertisedNetworkGen" : "2g, 3g, 4g, 5g", + "rscp" : -30, + "networkGen" : "2g, 3g, 4g, 5g", + "networkSubtype" : "LTE/HSPA", + "sinr" : 20 + }, + "systemMetrics" : { + "cpuUtilization" : { + "min" : 0.22, + "median" : 0.61, + "max" : 0.75, + "mean" : 0.55, + "count" : 150, + "stdDev" : 0.01 + }, + "physicalMemoryTotalBytes" : 1024, + "startTimeMs" : 1581508857327, + "physicalMemoryUsedBytes" : { + "min" : 1.2, + "median" : 1.85, + "max" : 2.5, + "mean" : 1.77, + "count" : 155, + "stdDev" : 0.25 + }, + "endTimeMs" : 1581508867333 + }, + "systemMetricDetails" : { + "topCpuApplications" : [ { + "totalMemoryBytes" : 1023334, + "processes" : [ { + "memoryBytes" : 1023334, + "memoryPercentage" : 0.22, + "name" : "Webex background", + "cpu" : 0.5, + "pid" : 15632 + }, { + "memoryBytes" : 1023334, + "memoryPercentage" : 0.22, + "name" : "Webex background", + "cpu" : 0.5, + "pid" : 15632 + } ], + "totalCpu" : 0.5, + "name" : "Webex", + "totalMemoryPercentage" : 0.22 + }, { + "totalMemoryBytes" : 1023334, + "processes" : [ { + "memoryBytes" : 1023334, + "memoryPercentage" : 0.22, + "name" : "Webex background", + "cpu" : 0.5, + "pid" : 15632 + }, { + "memoryBytes" : 1023334, + "memoryPercentage" : 0.22, + "name" : "Webex background", + "cpu" : 0.5, + "pid" : 15632 + } ], + "totalCpu" : 0.5, + "name" : "Webex", + "totalMemoryPercentage" : 0.22 + } ], + "topMemoryApplications" : [ { + "totalMemoryBytes" : 1023334, + "processes" : [ { + "memoryBytes" : 1023334, + "memoryPercentage" : 0.22, + "name" : "Webex background", + "cpu" : 0.5, + "pid" : 15632 + }, { + "memoryBytes" : 1023334, + "memoryPercentage" : 0.22, + "name" : "Webex background", + "cpu" : 0.5, + "pid" : 15632 + } ], + "totalCpu" : 0.5, + "name" : "Webex", + "totalMemoryPercentage" : 0.22 + }, { + "totalMemoryBytes" : 1023334, + "processes" : [ { + "memoryBytes" : 1023334, + "memoryPercentage" : 0.22, + "name" : "Webex background", + "cpu" : 0.5, + "pid" : 15632 + }, { + "memoryBytes" : 1023334, + "memoryPercentage" : 0.22, + "name" : "Webex background", + "cpu" : 0.5, + "pid" : 15632 + } ], + "totalCpu" : 0.5, + "name" : "Webex", + "totalMemoryPercentage" : 0.22 + } ] + }, + "connectionScore" : { + "score" : 100, + "quality" : "great" + }, + "icmpPing" : { + "maxRtt" : 66, + "loss" : 1, + "pktsReceived" : 10, + "avgRtt" : 7, + "meanDevRtt" : 11, + "minRtt" : 1, + "error" : "An operation timed out.", + "infoFlags" : [ "TE_INFO_ICMP_BLOCKED_BY_FIREWALL" ], + "pktsSent" : 10 + }, + "networkTopologyId" : "00160:54c3a4b180c6:1490536500:c7a58c49", + "roundId" : 1384309800, + "agentScore" : { + "score" : 100, + "quality" : "great" + } + }, { + "date" : "2022-07-17T22:00:54Z", + "agentId" : "861b7557-cd57-4bbb-b648-00bddf88ef49", + "dnsServerTest" : { + "resolutionTime" : 3 + }, + "isIcmpBlocked" : true, + "gatewayScore" : { + "score" : 100, + "quality" : "great" + }, + "tcpConnect" : { + "rtt" : 77.777, + "errorCode" : "ERR_TIMED_OUT", + "error" : "An operation timed out.", + "infoFlags" : [ "TE_INFO_ICMP_BLOCKED_BY_FIREWALL" ] + }, + "vpnScore" : { + "score" : 100, + "quality" : "great" + }, + "proxyScore" : { + "score" : 100, + "quality" : "great" + }, + "batteryMetrics" : { + "batteryHealthNormalizedPercent" : 0.92, + "batteryLevel" : "medium", + "batteryLevelNormalizedPercent" : 0.3 + }, + "type" : "vpn", + "targetPort" : 80, + "platform" : "mac", + "target" : "10.0.2.2", + "cellularProfile" : { + "rssi" : -10, + "advertisedNetworkSubtype" : "LTE/HSPA", + "carrierName" : "T-Mobile", + "rsrq" : -30, + "rsrp" : -30, + "advertisedNetworkGen" : "2g, 3g, 4g, 5g", + "rscp" : -30, + "networkGen" : "2g, 3g, 4g, 5g", + "networkSubtype" : "LTE/HSPA", + "sinr" : 20 + }, + "systemMetrics" : { + "cpuUtilization" : { + "min" : 0.22, + "median" : 0.61, + "max" : 0.75, + "mean" : 0.55, + "count" : 150, + "stdDev" : 0.01 + }, + "physicalMemoryTotalBytes" : 1024, + "startTimeMs" : 1581508857327, + "physicalMemoryUsedBytes" : { + "min" : 1.2, + "median" : 1.85, + "max" : 2.5, + "mean" : 1.77, + "count" : 155, + "stdDev" : 0.25 + }, + "endTimeMs" : 1581508867333 + }, + "systemMetricDetails" : { + "topCpuApplications" : [ { + "totalMemoryBytes" : 1023334, + "processes" : [ { + "memoryBytes" : 1023334, + "memoryPercentage" : 0.22, + "name" : "Webex background", + "cpu" : 0.5, + "pid" : 15632 + }, { + "memoryBytes" : 1023334, + "memoryPercentage" : 0.22, + "name" : "Webex background", + "cpu" : 0.5, + "pid" : 15632 + } ], + "totalCpu" : 0.5, + "name" : "Webex", + "totalMemoryPercentage" : 0.22 + }, { + "totalMemoryBytes" : 1023334, + "processes" : [ { + "memoryBytes" : 1023334, + "memoryPercentage" : 0.22, + "name" : "Webex background", + "cpu" : 0.5, + "pid" : 15632 + }, { + "memoryBytes" : 1023334, + "memoryPercentage" : 0.22, + "name" : "Webex background", + "cpu" : 0.5, + "pid" : 15632 + } ], + "totalCpu" : 0.5, + "name" : "Webex", + "totalMemoryPercentage" : 0.22 + } ], + "topMemoryApplications" : [ { + "totalMemoryBytes" : 1023334, + "processes" : [ { + "memoryBytes" : 1023334, + "memoryPercentage" : 0.22, + "name" : "Webex background", + "cpu" : 0.5, + "pid" : 15632 + }, { + "memoryBytes" : 1023334, + "memoryPercentage" : 0.22, + "name" : "Webex background", + "cpu" : 0.5, + "pid" : 15632 + } ], + "totalCpu" : 0.5, + "name" : "Webex", + "totalMemoryPercentage" : 0.22 + }, { + "totalMemoryBytes" : 1023334, + "processes" : [ { + "memoryBytes" : 1023334, + "memoryPercentage" : 0.22, + "name" : "Webex background", + "cpu" : 0.5, + "pid" : 15632 + }, { + "memoryBytes" : 1023334, + "memoryPercentage" : 0.22, + "name" : "Webex background", + "cpu" : 0.5, + "pid" : 15632 + } ], + "totalCpu" : 0.5, + "name" : "Webex", + "totalMemoryPercentage" : 0.22 + } ] + }, + "connectionScore" : { + "score" : 100, + "quality" : "great" + }, + "icmpPing" : { + "maxRtt" : 66, + "loss" : 1, + "pktsReceived" : 10, + "avgRtt" : 7, + "meanDevRtt" : 11, + "minRtt" : 1, + "error" : "An operation timed out.", + "infoFlags" : [ "TE_INFO_ICMP_BLOCKED_BY_FIREWALL" ], + "pktsSent" : 10 + }, + "networkTopologyId" : "00160:54c3a4b180c6:1490536500:c7a58c49", + "roundId" : 1384309800, + "agentScore" : { + "score" : 100, + "quality" : "great" + } + } ], + "startDate" : "2022-07-17T22:00:54Z" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.filter_local_networks_test_results_topologies( + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + endpoint_network_topology_result_request=endpoint_network_topology_result_request, + + _headers=self.te_headers("filter_local_networks_test_results_topologies"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_filter_local_networks_test_results_topologies_error_400(self) -> None: + """Integration test for filter_local_networks_test_results_topologies error path (HTTP 400)""" + request_body_json = """ + + { + "searchFilters" : { + "agentId" : [ "3fde6422-f119-40e1-ae32-d08a1243c038", "236e6f18-9637-4a2f-b15f-7aa6a29c9fce" ], + "bssid" : [ "8c:68:c8:a5:0a:8c", "0c:51:01:e4:3e:d0" ], + "location" : [ "San Francisco Bay Area", "Germany" ], + "connection" : [ "wireless", "wireless" ], + "vpnTarget" : [ "78.153.54.204", "78.153.54.206" ], + "networkId" : [ "660b34109d12", "660b34109d15" ], + "type" : [ "vpn", "proxy" ], + "ssid" : [ "wifi-name", "other-room-wifi" ], + "platform" : [ "mac", "mac" ], + "gateway" : [ "78.153.54.204", "78.153.54.206" ], + "proxyTarget" : [ "78.153.54.204", "78.153.54.206" ] + }, + "thresholdFilter" : { + "conditionalOperator" : "and", + "filters" : [ { + "name" : "loss", + "value" : 10, + "operator" : "gte" + }, { + "name" : "loss", + "value" : 10, + "operator" : "gte" + } ] + } + } + + """ + endpoint_network_topology_result_request = thousandeyes_sdk.endpoint_test_results.models.EndpointNetworkTopologyResultRequest.from_json(request_body_json) + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.filter_local_networks_test_results_topologies( + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + endpoint_network_topology_result_request=endpoint_network_topology_result_request, + + _headers=self.te_headers("filter_local_networks_test_results_topologies", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_filter_local_networks_test_results_topologies_error_401(self) -> None: + """Integration test for filter_local_networks_test_results_topologies error path (HTTP 401)""" + request_body_json = """ + + { + "searchFilters" : { + "agentId" : [ "3fde6422-f119-40e1-ae32-d08a1243c038", "236e6f18-9637-4a2f-b15f-7aa6a29c9fce" ], + "bssid" : [ "8c:68:c8:a5:0a:8c", "0c:51:01:e4:3e:d0" ], + "location" : [ "San Francisco Bay Area", "Germany" ], + "connection" : [ "wireless", "wireless" ], + "vpnTarget" : [ "78.153.54.204", "78.153.54.206" ], + "networkId" : [ "660b34109d12", "660b34109d15" ], + "type" : [ "vpn", "proxy" ], + "ssid" : [ "wifi-name", "other-room-wifi" ], + "platform" : [ "mac", "mac" ], + "gateway" : [ "78.153.54.204", "78.153.54.206" ], + "proxyTarget" : [ "78.153.54.204", "78.153.54.206" ] + }, + "thresholdFilter" : { + "conditionalOperator" : "and", + "filters" : [ { + "name" : "loss", + "value" : 10, + "operator" : "gte" + }, { + "name" : "loss", + "value" : 10, + "operator" : "gte" + } ] + } + } + + """ + endpoint_network_topology_result_request = thousandeyes_sdk.endpoint_test_results.models.EndpointNetworkTopologyResultRequest.from_json(request_body_json) + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.filter_local_networks_test_results_topologies( + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + endpoint_network_topology_result_request=endpoint_network_topology_result_request, + + _headers=self.te_headers("filter_local_networks_test_results_topologies", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_filter_local_networks_test_results_topologies_error_403(self) -> None: + """Integration test for filter_local_networks_test_results_topologies error path (HTTP 403)""" + request_body_json = """ + + { + "searchFilters" : { + "agentId" : [ "3fde6422-f119-40e1-ae32-d08a1243c038", "236e6f18-9637-4a2f-b15f-7aa6a29c9fce" ], + "bssid" : [ "8c:68:c8:a5:0a:8c", "0c:51:01:e4:3e:d0" ], + "location" : [ "San Francisco Bay Area", "Germany" ], + "connection" : [ "wireless", "wireless" ], + "vpnTarget" : [ "78.153.54.204", "78.153.54.206" ], + "networkId" : [ "660b34109d12", "660b34109d15" ], + "type" : [ "vpn", "proxy" ], + "ssid" : [ "wifi-name", "other-room-wifi" ], + "platform" : [ "mac", "mac" ], + "gateway" : [ "78.153.54.204", "78.153.54.206" ], + "proxyTarget" : [ "78.153.54.204", "78.153.54.206" ] + }, + "thresholdFilter" : { + "conditionalOperator" : "and", + "filters" : [ { + "name" : "loss", + "value" : 10, + "operator" : "gte" + }, { + "name" : "loss", + "value" : 10, + "operator" : "gte" + } ] + } + } + + """ + endpoint_network_topology_result_request = thousandeyes_sdk.endpoint_test_results.models.EndpointNetworkTopologyResultRequest.from_json(request_body_json) + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.filter_local_networks_test_results_topologies( + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + endpoint_network_topology_result_request=endpoint_network_topology_result_request, + + _headers=self.te_headers("filter_local_networks_test_results_topologies", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_filter_local_networks_test_results_topologies_error_404(self) -> None: + """Integration test for filter_local_networks_test_results_topologies error path (HTTP 404)""" + request_body_json = """ + + { + "searchFilters" : { + "agentId" : [ "3fde6422-f119-40e1-ae32-d08a1243c038", "236e6f18-9637-4a2f-b15f-7aa6a29c9fce" ], + "bssid" : [ "8c:68:c8:a5:0a:8c", "0c:51:01:e4:3e:d0" ], + "location" : [ "San Francisco Bay Area", "Germany" ], + "connection" : [ "wireless", "wireless" ], + "vpnTarget" : [ "78.153.54.204", "78.153.54.206" ], + "networkId" : [ "660b34109d12", "660b34109d15" ], + "type" : [ "vpn", "proxy" ], + "ssid" : [ "wifi-name", "other-room-wifi" ], + "platform" : [ "mac", "mac" ], + "gateway" : [ "78.153.54.204", "78.153.54.206" ], + "proxyTarget" : [ "78.153.54.204", "78.153.54.206" ] + }, + "thresholdFilter" : { + "conditionalOperator" : "and", + "filters" : [ { + "name" : "loss", + "value" : 10, + "operator" : "gte" + }, { + "name" : "loss", + "value" : 10, + "operator" : "gte" + } ] + } + } + + """ + endpoint_network_topology_result_request = thousandeyes_sdk.endpoint_test_results.models.EndpointNetworkTopologyResultRequest.from_json(request_body_json) + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.filter_local_networks_test_results_topologies( + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + endpoint_network_topology_result_request=endpoint_network_topology_result_request, + + _headers=self.te_headers("filter_local_networks_test_results_topologies", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_filter_local_networks_test_results_topologies_error_429(self) -> None: + """Integration test for filter_local_networks_test_results_topologies error path (HTTP 429)""" + request_body_json = """ + + { + "searchFilters" : { + "agentId" : [ "3fde6422-f119-40e1-ae32-d08a1243c038", "236e6f18-9637-4a2f-b15f-7aa6a29c9fce" ], + "bssid" : [ "8c:68:c8:a5:0a:8c", "0c:51:01:e4:3e:d0" ], + "location" : [ "San Francisco Bay Area", "Germany" ], + "connection" : [ "wireless", "wireless" ], + "vpnTarget" : [ "78.153.54.204", "78.153.54.206" ], + "networkId" : [ "660b34109d12", "660b34109d15" ], + "type" : [ "vpn", "proxy" ], + "ssid" : [ "wifi-name", "other-room-wifi" ], + "platform" : [ "mac", "mac" ], + "gateway" : [ "78.153.54.204", "78.153.54.206" ], + "proxyTarget" : [ "78.153.54.204", "78.153.54.206" ] + }, + "thresholdFilter" : { + "conditionalOperator" : "and", + "filters" : [ { + "name" : "loss", + "value" : 10, + "operator" : "gte" + }, { + "name" : "loss", + "value" : 10, + "operator" : "gte" + } ] + } + } + + """ + endpoint_network_topology_result_request = thousandeyes_sdk.endpoint_test_results.models.EndpointNetworkTopologyResultRequest.from_json(request_body_json) + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.filter_local_networks_test_results_topologies( + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + endpoint_network_topology_result_request=endpoint_network_topology_result_request, + + _headers=self.te_headers("filter_local_networks_test_results_topologies", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_filter_local_networks_test_results_topologies_error_500(self) -> None: + """Integration test for filter_local_networks_test_results_topologies error path (HTTP 500)""" + request_body_json = """ + + { + "searchFilters" : { + "agentId" : [ "3fde6422-f119-40e1-ae32-d08a1243c038", "236e6f18-9637-4a2f-b15f-7aa6a29c9fce" ], + "bssid" : [ "8c:68:c8:a5:0a:8c", "0c:51:01:e4:3e:d0" ], + "location" : [ "San Francisco Bay Area", "Germany" ], + "connection" : [ "wireless", "wireless" ], + "vpnTarget" : [ "78.153.54.204", "78.153.54.206" ], + "networkId" : [ "660b34109d12", "660b34109d15" ], + "type" : [ "vpn", "proxy" ], + "ssid" : [ "wifi-name", "other-room-wifi" ], + "platform" : [ "mac", "mac" ], + "gateway" : [ "78.153.54.204", "78.153.54.206" ], + "proxyTarget" : [ "78.153.54.204", "78.153.54.206" ] + }, + "thresholdFilter" : { + "conditionalOperator" : "and", + "filters" : [ { + "name" : "loss", + "value" : 10, + "operator" : "gte" + }, { + "name" : "loss", + "value" : 10, + "operator" : "gte" + } ] + } + } + + """ + endpoint_network_topology_result_request = thousandeyes_sdk.endpoint_test_results.models.EndpointNetworkTopologyResultRequest.from_json(request_body_json) + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.filter_local_networks_test_results_topologies( + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + endpoint_network_topology_result_request=endpoint_network_topology_result_request, + + _headers=self.te_headers("filter_local_networks_test_results_topologies", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_filter_local_networks_test_results_topologies_error_502(self) -> None: + """Integration test for filter_local_networks_test_results_topologies error path (HTTP 502)""" + request_body_json = """ + + { + "searchFilters" : { + "agentId" : [ "3fde6422-f119-40e1-ae32-d08a1243c038", "236e6f18-9637-4a2f-b15f-7aa6a29c9fce" ], + "bssid" : [ "8c:68:c8:a5:0a:8c", "0c:51:01:e4:3e:d0" ], + "location" : [ "San Francisco Bay Area", "Germany" ], + "connection" : [ "wireless", "wireless" ], + "vpnTarget" : [ "78.153.54.204", "78.153.54.206" ], + "networkId" : [ "660b34109d12", "660b34109d15" ], + "type" : [ "vpn", "proxy" ], + "ssid" : [ "wifi-name", "other-room-wifi" ], + "platform" : [ "mac", "mac" ], + "gateway" : [ "78.153.54.204", "78.153.54.206" ], + "proxyTarget" : [ "78.153.54.204", "78.153.54.206" ] + }, + "thresholdFilter" : { + "conditionalOperator" : "and", + "filters" : [ { + "name" : "loss", + "value" : 10, + "operator" : "gte" + }, { + "name" : "loss", + "value" : 10, + "operator" : "gte" + } ] + } + } + + """ + endpoint_network_topology_result_request = thousandeyes_sdk.endpoint_test_results.models.EndpointNetworkTopologyResultRequest.from_json(request_body_json) + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.filter_local_networks_test_results_topologies( + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + endpoint_network_topology_result_request=endpoint_network_topology_result_request, + + _headers=self.te_headers("filter_local_networks_test_results_topologies", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_local_networks_test_results_happy_path(self) -> None: + """Integration test for get_local_networks_test_results success path""" + aid = '1234' + response_body_json = """ + { + "localNetworks" : [ { + "publicIpRange" : "178.216.56.0-178.216.63.255", + "networkName" : "10.5.51.0 (in 178.216.56.0/21)", + "networkId" : "006c4fa7a054", + "localPrefix" : "10.5.51.0" + }, { + "publicIpRange" : "178.216.56.0-178.216.63.255", + "networkName" : "10.5.51.0 (in 178.216.56.0/21)", + "networkId" : "006c4fa7a054", + "localPrefix" : "10.5.51.0" + } ], + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_local_networks_test_results( + + aid=aid, + + _headers=self.te_headers("get_local_networks_test_results"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_local_networks_test_results_error_401(self) -> None: + """Integration test for get_local_networks_test_results error path (HTTP 401)""" + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_local_networks_test_results( + + aid=aid, + + _headers=self.te_headers("get_local_networks_test_results", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_local_networks_test_results_error_403(self) -> None: + """Integration test for get_local_networks_test_results error path (HTTP 403)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_local_networks_test_results( + + aid=aid, + + _headers=self.te_headers("get_local_networks_test_results", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_local_networks_test_results_error_404(self) -> None: + """Integration test for get_local_networks_test_results error path (HTTP 404)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_local_networks_test_results( + + aid=aid, + + _headers=self.te_headers("get_local_networks_test_results", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_local_networks_test_results_error_429(self) -> None: + """Integration test for get_local_networks_test_results error path (HTTP 429)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_local_networks_test_results( + + aid=aid, + + _headers=self.te_headers("get_local_networks_test_results", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_local_networks_test_results_error_500(self) -> None: + """Integration test for get_local_networks_test_results error path (HTTP 500)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_local_networks_test_results( + + aid=aid, + + _headers=self.te_headers("get_local_networks_test_results", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_local_networks_test_results_error_502(self) -> None: + """Integration test for get_local_networks_test_results error path (HTTP 502)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.get_local_networks_test_results( + + aid=aid, + + _headers=self.te_headers("get_local_networks_test_results", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_local_networks_test_results_topology_happy_path(self) -> None: + """Integration test for get_local_networks_test_results_topology success path""" + network_topology_id = '00160:39c518560de9:1491651900:236e6f18' + aid = '1234' + response_body_json = """ + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "results" : [ { + "date" : "2022-07-17T22:00:54Z", + "agentId" : "861b7557-cd57-4bbb-b648-00bddf88ef49", + "dnsServerTest" : { + "resolutionTime" : 3 + }, + "vpnScore" : { + "score" : 100, + "quality" : "great" + }, + "batteryMetrics" : { + "batteryHealthNormalizedPercent" : 0.92, + "batteryLevel" : "medium", + "batteryLevelNormalizedPercent" : 0.3 + }, + "type" : "vpn", + "targetPort" : 80, + "platform" : "mac", + "cellularProfile" : { + "rssi" : -10, + "advertisedNetworkSubtype" : "LTE/HSPA", + "carrierName" : "T-Mobile", + "rsrq" : -30, + "rsrp" : -30, + "advertisedNetworkGen" : "2g, 3g, 4g, 5g", + "rscp" : -30, + "networkGen" : "2g, 3g, 4g, 5g", + "networkSubtype" : "LTE/HSPA", + "sinr" : 20 + }, + "icmpTraceroute" : { + "destination" : "13.32.22.232", + "hops" : [ { + "delay" : 5, + "prefix" : "196.40.96.0/20", + "hop" : 1, + "ipAddress" : "196.40.106.237", + "name" : "89-210-88-65.access.t-2.net", + "mpls" : [ "L=301472,E=0,S=1,T=1" ], + "asn" : 34779 + }, { + "delay" : 5, + "prefix" : "196.40.96.0/20", + "hop" : 1, + "ipAddress" : "196.40.106.237", + "name" : "89-210-88-65.access.t-2.net", + "mpls" : [ "L=301472,E=0,S=1,T=1" ], + "asn" : 34779 + } ], + "error" : "An operation timed out.", + "infoFlags" : [ "TE_INFO_ICMP_BLOCKED_BY_FIREWALL" ], + "internalErrors" : [ "TE_INFO_ICMP_BLOCKED_BY_FIREWALL" ] + }, + "networkProfile" : { + "previousInterface" : { + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "interfaceName" : "en0", + "subnetMask" : "255.255.255.0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ] + }, + "ethernetProfile" : { + "linkSpeed" : 860 + }, + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "proxyProfile" : { + "method" : "System", + "proxies" : [ { + "bypass" : "*.local;169.254/16", + "proxy" : "" + }, { + "bypass" : "*.local;169.254/16", + "proxy" : "" + } ] + }, + "subnetMask" : "255.255.255.0", + "error" : "An operation timed out.", + "wirelessProfile" : { + "rssi" : -38, + "bssid" : "4c:ba:ba:f4:fa:fa", + "snr" : 57, + "vendor" : "Cisco", + "txRate" : 130, + "channel" : 1, + "noise" : -95, + "phyMode" : "802.11n", + "ssid" : "Internet for the masses", + "quality" : 100 + }, + "interfaceName" : "en0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ], + "gateway" : "10.0.0.1" + }, + "roundId" : 1384309800, + "agentScore" : { + "score" : 100, + "quality" : "great" + }, + "isIcmpBlocked" : true, + "gatewayScore" : { + "score" : 100, + "quality" : "great" + }, + "tcpConnect" : { + "rtt" : 77.777, + "errorCode" : "ERR_TIMED_OUT", + "error" : "An operation timed out.", + "infoFlags" : [ "TE_INFO_ICMP_BLOCKED_BY_FIREWALL" ] + }, + "proxyScore" : { + "score" : 100, + "quality" : "great" + }, + "coordinates" : { + "latitude" : 46.0552778, + "location" : "Slovenia", + "longitude" : 14.5144444 + }, + "icmpTraceroutes" : [ { + "destination" : "13.32.22.232", + "hops" : [ { + "delay" : 5, + "prefix" : "196.40.96.0/20", + "hop" : 1, + "ipAddress" : "196.40.106.237", + "name" : "89-210-88-65.access.t-2.net", + "mpls" : [ "L=301472,E=0,S=1,T=1" ], + "asn" : 34779 + }, { + "delay" : 5, + "prefix" : "196.40.96.0/20", + "hop" : 1, + "ipAddress" : "196.40.106.237", + "name" : "89-210-88-65.access.t-2.net", + "mpls" : [ "L=301472,E=0,S=1,T=1" ], + "asn" : 34779 + } ], + "error" : "An operation timed out.", + "infoFlags" : [ "TE_INFO_ICMP_BLOCKED_BY_FIREWALL" ], + "internalErrors" : [ "TE_INFO_ICMP_BLOCKED_BY_FIREWALL" ] + }, { + "destination" : "13.32.22.232", + "hops" : [ { + "delay" : 5, + "prefix" : "196.40.96.0/20", + "hop" : 1, + "ipAddress" : "196.40.106.237", + "name" : "89-210-88-65.access.t-2.net", + "mpls" : [ "L=301472,E=0,S=1,T=1" ], + "asn" : 34779 + }, { + "delay" : 5, + "prefix" : "196.40.96.0/20", + "hop" : 1, + "ipAddress" : "196.40.106.237", + "name" : "89-210-88-65.access.t-2.net", + "mpls" : [ "L=301472,E=0,S=1,T=1" ], + "asn" : 34779 + } ], + "error" : "An operation timed out.", + "infoFlags" : [ "TE_INFO_ICMP_BLOCKED_BY_FIREWALL" ], + "internalErrors" : [ "TE_INFO_ICMP_BLOCKED_BY_FIREWALL" ] + } ], + "target" : "10.0.2.2", + "systemMetrics" : { + "cpuUtilization" : { + "min" : 0.22, + "median" : 0.61, + "max" : 0.75, + "mean" : 0.55, + "count" : 150, + "stdDev" : 0.01 + }, + "physicalMemoryTotalBytes" : 1024, + "startTimeMs" : 1581508857327, + "physicalMemoryUsedBytes" : { + "min" : 1.2, + "median" : 1.85, + "max" : 2.5, + "mean" : 1.77, + "count" : 155, + "stdDev" : 0.25 + }, + "endTimeMs" : 1581508867333 + }, + "systemMetricDetails" : { + "topCpuApplications" : [ { + "totalMemoryBytes" : 1023334, + "processes" : [ { + "memoryBytes" : 1023334, + "memoryPercentage" : 0.22, + "name" : "Webex background", + "cpu" : 0.5, + "pid" : 15632 + }, { + "memoryBytes" : 1023334, + "memoryPercentage" : 0.22, + "name" : "Webex background", + "cpu" : 0.5, + "pid" : 15632 + } ], + "totalCpu" : 0.5, + "name" : "Webex", + "totalMemoryPercentage" : 0.22 + }, { + "totalMemoryBytes" : 1023334, + "processes" : [ { + "memoryBytes" : 1023334, + "memoryPercentage" : 0.22, + "name" : "Webex background", + "cpu" : 0.5, + "pid" : 15632 + }, { + "memoryBytes" : 1023334, + "memoryPercentage" : 0.22, + "name" : "Webex background", + "cpu" : 0.5, + "pid" : 15632 + } ], + "totalCpu" : 0.5, + "name" : "Webex", + "totalMemoryPercentage" : 0.22 + } ], + "topMemoryApplications" : [ { + "totalMemoryBytes" : 1023334, + "processes" : [ { + "memoryBytes" : 1023334, + "memoryPercentage" : 0.22, + "name" : "Webex background", + "cpu" : 0.5, + "pid" : 15632 + }, { + "memoryBytes" : 1023334, + "memoryPercentage" : 0.22, + "name" : "Webex background", + "cpu" : 0.5, + "pid" : 15632 + } ], + "totalCpu" : 0.5, + "name" : "Webex", + "totalMemoryPercentage" : 0.22 + }, { + "totalMemoryBytes" : 1023334, + "processes" : [ { + "memoryBytes" : 1023334, + "memoryPercentage" : 0.22, + "name" : "Webex background", + "cpu" : 0.5, + "pid" : 15632 + }, { + "memoryBytes" : 1023334, + "memoryPercentage" : 0.22, + "name" : "Webex background", + "cpu" : 0.5, + "pid" : 15632 + } ], + "totalCpu" : 0.5, + "name" : "Webex", + "totalMemoryPercentage" : 0.22 + } ] + }, + "connectionScore" : { + "score" : 100, + "quality" : "great" + }, + "icmpPing" : { + "maxRtt" : 66, + "loss" : 1, + "pktsReceived" : 10, + "avgRtt" : 7, + "meanDevRtt" : 11, + "minRtt" : 1, + "error" : "An operation timed out.", + "infoFlags" : [ "TE_INFO_ICMP_BLOCKED_BY_FIREWALL" ], + "pktsSent" : 10 + }, + "networkTopologyId" : "00160:54c3a4b180c6:1490536500:c7a58c49" + }, { + "date" : "2022-07-17T22:00:54Z", + "agentId" : "861b7557-cd57-4bbb-b648-00bddf88ef49", + "dnsServerTest" : { + "resolutionTime" : 3 + }, + "vpnScore" : { + "score" : 100, + "quality" : "great" + }, + "batteryMetrics" : { + "batteryHealthNormalizedPercent" : 0.92, + "batteryLevel" : "medium", + "batteryLevelNormalizedPercent" : 0.3 + }, + "type" : "vpn", + "targetPort" : 80, + "platform" : "mac", + "cellularProfile" : { + "rssi" : -10, + "advertisedNetworkSubtype" : "LTE/HSPA", + "carrierName" : "T-Mobile", + "rsrq" : -30, + "rsrp" : -30, + "advertisedNetworkGen" : "2g, 3g, 4g, 5g", + "rscp" : -30, + "networkGen" : "2g, 3g, 4g, 5g", + "networkSubtype" : "LTE/HSPA", + "sinr" : 20 + }, + "icmpTraceroute" : { + "destination" : "13.32.22.232", + "hops" : [ { + "delay" : 5, + "prefix" : "196.40.96.0/20", + "hop" : 1, + "ipAddress" : "196.40.106.237", + "name" : "89-210-88-65.access.t-2.net", + "mpls" : [ "L=301472,E=0,S=1,T=1" ], + "asn" : 34779 + }, { + "delay" : 5, + "prefix" : "196.40.96.0/20", + "hop" : 1, + "ipAddress" : "196.40.106.237", + "name" : "89-210-88-65.access.t-2.net", + "mpls" : [ "L=301472,E=0,S=1,T=1" ], + "asn" : 34779 + } ], + "error" : "An operation timed out.", + "infoFlags" : [ "TE_INFO_ICMP_BLOCKED_BY_FIREWALL" ], + "internalErrors" : [ "TE_INFO_ICMP_BLOCKED_BY_FIREWALL" ] + }, + "networkProfile" : { + "previousInterface" : { + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "interfaceName" : "en0", + "subnetMask" : "255.255.255.0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ] + }, + "ethernetProfile" : { + "linkSpeed" : 860 + }, + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "proxyProfile" : { + "method" : "System", + "proxies" : [ { + "bypass" : "*.local;169.254/16", + "proxy" : "" + }, { + "bypass" : "*.local;169.254/16", + "proxy" : "" + } ] + }, + "subnetMask" : "255.255.255.0", + "error" : "An operation timed out.", + "wirelessProfile" : { + "rssi" : -38, + "bssid" : "4c:ba:ba:f4:fa:fa", + "snr" : 57, + "vendor" : "Cisco", + "txRate" : 130, + "channel" : 1, + "noise" : -95, + "phyMode" : "802.11n", + "ssid" : "Internet for the masses", + "quality" : 100 + }, + "interfaceName" : "en0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ], + "gateway" : "10.0.0.1" + }, + "roundId" : 1384309800, + "agentScore" : { + "score" : 100, + "quality" : "great" + }, + "isIcmpBlocked" : true, + "gatewayScore" : { + "score" : 100, + "quality" : "great" + }, + "tcpConnect" : { + "rtt" : 77.777, + "errorCode" : "ERR_TIMED_OUT", + "error" : "An operation timed out.", + "infoFlags" : [ "TE_INFO_ICMP_BLOCKED_BY_FIREWALL" ] + }, + "proxyScore" : { + "score" : 100, + "quality" : "great" + }, + "coordinates" : { + "latitude" : 46.0552778, + "location" : "Slovenia", + "longitude" : 14.5144444 + }, + "icmpTraceroutes" : [ { + "destination" : "13.32.22.232", + "hops" : [ { + "delay" : 5, + "prefix" : "196.40.96.0/20", + "hop" : 1, + "ipAddress" : "196.40.106.237", + "name" : "89-210-88-65.access.t-2.net", + "mpls" : [ "L=301472,E=0,S=1,T=1" ], + "asn" : 34779 + }, { + "delay" : 5, + "prefix" : "196.40.96.0/20", + "hop" : 1, + "ipAddress" : "196.40.106.237", + "name" : "89-210-88-65.access.t-2.net", + "mpls" : [ "L=301472,E=0,S=1,T=1" ], + "asn" : 34779 + } ], + "error" : "An operation timed out.", + "infoFlags" : [ "TE_INFO_ICMP_BLOCKED_BY_FIREWALL" ], + "internalErrors" : [ "TE_INFO_ICMP_BLOCKED_BY_FIREWALL" ] + }, { + "destination" : "13.32.22.232", + "hops" : [ { + "delay" : 5, + "prefix" : "196.40.96.0/20", + "hop" : 1, + "ipAddress" : "196.40.106.237", + "name" : "89-210-88-65.access.t-2.net", + "mpls" : [ "L=301472,E=0,S=1,T=1" ], + "asn" : 34779 + }, { + "delay" : 5, + "prefix" : "196.40.96.0/20", + "hop" : 1, + "ipAddress" : "196.40.106.237", + "name" : "89-210-88-65.access.t-2.net", + "mpls" : [ "L=301472,E=0,S=1,T=1" ], + "asn" : 34779 + } ], + "error" : "An operation timed out.", + "infoFlags" : [ "TE_INFO_ICMP_BLOCKED_BY_FIREWALL" ], + "internalErrors" : [ "TE_INFO_ICMP_BLOCKED_BY_FIREWALL" ] + } ], + "target" : "10.0.2.2", + "systemMetrics" : { + "cpuUtilization" : { + "min" : 0.22, + "median" : 0.61, + "max" : 0.75, + "mean" : 0.55, + "count" : 150, + "stdDev" : 0.01 + }, + "physicalMemoryTotalBytes" : 1024, + "startTimeMs" : 1581508857327, + "physicalMemoryUsedBytes" : { + "min" : 1.2, + "median" : 1.85, + "max" : 2.5, + "mean" : 1.77, + "count" : 155, + "stdDev" : 0.25 + }, + "endTimeMs" : 1581508867333 + }, + "systemMetricDetails" : { + "topCpuApplications" : [ { + "totalMemoryBytes" : 1023334, + "processes" : [ { + "memoryBytes" : 1023334, + "memoryPercentage" : 0.22, + "name" : "Webex background", + "cpu" : 0.5, + "pid" : 15632 + }, { + "memoryBytes" : 1023334, + "memoryPercentage" : 0.22, + "name" : "Webex background", + "cpu" : 0.5, + "pid" : 15632 + } ], + "totalCpu" : 0.5, + "name" : "Webex", + "totalMemoryPercentage" : 0.22 + }, { + "totalMemoryBytes" : 1023334, + "processes" : [ { + "memoryBytes" : 1023334, + "memoryPercentage" : 0.22, + "name" : "Webex background", + "cpu" : 0.5, + "pid" : 15632 + }, { + "memoryBytes" : 1023334, + "memoryPercentage" : 0.22, + "name" : "Webex background", + "cpu" : 0.5, + "pid" : 15632 + } ], + "totalCpu" : 0.5, + "name" : "Webex", + "totalMemoryPercentage" : 0.22 + } ], + "topMemoryApplications" : [ { + "totalMemoryBytes" : 1023334, + "processes" : [ { + "memoryBytes" : 1023334, + "memoryPercentage" : 0.22, + "name" : "Webex background", + "cpu" : 0.5, + "pid" : 15632 + }, { + "memoryBytes" : 1023334, + "memoryPercentage" : 0.22, + "name" : "Webex background", + "cpu" : 0.5, + "pid" : 15632 + } ], + "totalCpu" : 0.5, + "name" : "Webex", + "totalMemoryPercentage" : 0.22 + }, { + "totalMemoryBytes" : 1023334, + "processes" : [ { + "memoryBytes" : 1023334, + "memoryPercentage" : 0.22, + "name" : "Webex background", + "cpu" : 0.5, + "pid" : 15632 + }, { + "memoryBytes" : 1023334, + "memoryPercentage" : 0.22, + "name" : "Webex background", + "cpu" : 0.5, + "pid" : 15632 + } ], + "totalCpu" : 0.5, + "name" : "Webex", + "totalMemoryPercentage" : 0.22 + } ] + }, + "connectionScore" : { + "score" : 100, + "quality" : "great" + }, + "icmpPing" : { + "maxRtt" : 66, + "loss" : 1, + "pktsReceived" : 10, + "avgRtt" : 7, + "meanDevRtt" : 11, + "minRtt" : 1, + "error" : "An operation timed out.", + "infoFlags" : [ "TE_INFO_ICMP_BLOCKED_BY_FIREWALL" ], + "pktsSent" : 10 + }, + "networkTopologyId" : "00160:54c3a4b180c6:1490536500:c7a58c49" + } ] + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_local_networks_test_results_topology( + + network_topology_id=network_topology_id, + + aid=aid, + + _headers=self.te_headers("get_local_networks_test_results_topology"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_local_networks_test_results_topology_error_401(self) -> None: + """Integration test for get_local_networks_test_results_topology error path (HTTP 401)""" + network_topology_id = '00160:39c518560de9:1491651900:236e6f18' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_local_networks_test_results_topology( + + network_topology_id=network_topology_id, + + aid=aid, + + _headers=self.te_headers("get_local_networks_test_results_topology", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_local_networks_test_results_topology_error_403(self) -> None: + """Integration test for get_local_networks_test_results_topology error path (HTTP 403)""" + network_topology_id = '00160:39c518560de9:1491651900:236e6f18' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_local_networks_test_results_topology( + + network_topology_id=network_topology_id, + + aid=aid, + + _headers=self.te_headers("get_local_networks_test_results_topology", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_local_networks_test_results_topology_error_404(self) -> None: + """Integration test for get_local_networks_test_results_topology error path (HTTP 404)""" + network_topology_id = '00160:39c518560de9:1491651900:236e6f18' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_local_networks_test_results_topology( + + network_topology_id=network_topology_id, + + aid=aid, + + _headers=self.te_headers("get_local_networks_test_results_topology", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_local_networks_test_results_topology_error_429(self) -> None: + """Integration test for get_local_networks_test_results_topology error path (HTTP 429)""" + network_topology_id = '00160:39c518560de9:1491651900:236e6f18' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_local_networks_test_results_topology( + + network_topology_id=network_topology_id, + + aid=aid, + + _headers=self.te_headers("get_local_networks_test_results_topology", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_local_networks_test_results_topology_error_500(self) -> None: + """Integration test for get_local_networks_test_results_topology error path (HTTP 500)""" + network_topology_id = '00160:39c518560de9:1491651900:236e6f18' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_local_networks_test_results_topology( + + network_topology_id=network_topology_id, + + aid=aid, + + _headers=self.te_headers("get_local_networks_test_results_topology", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_local_networks_test_results_topology_error_502(self) -> None: + """Integration test for get_local_networks_test_results_topology error path (HTTP 502)""" + network_topology_id = '00160:39c518560de9:1491651900:236e6f18' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.get_local_networks_test_results_topology( + + network_topology_id=network_topology_id, + + aid=aid, + + _headers=self.te_headers("get_local_networks_test_results_topology", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-endpoint-test-results/test/test_network_dynamic_endpoint_test_results_api_integration.py b/thousandeyes-sdk-endpoint-test-results/test/test_network_dynamic_endpoint_test_results_api_integration.py new file mode 100644 index 00000000..f1cd1c01 --- /dev/null +++ b/thousandeyes-sdk-endpoint-test-results/test/test_network_dynamic_endpoint_test_results_api_integration.py @@ -0,0 +1,2293 @@ +# coding: utf-8 + +""" + Endpoint Test Results API + + Retrieve results for scheduled and dynamic tests on endpoint agents. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.endpoint_test_results.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.endpoint_test_results.api.network_dynamic_endpoint_test_results_api import NetworkDynamicEndpointTestResultsApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestNetworkDynamicEndpointTestResultsApiIntegration(IntegrationTestBase): + """NetworkDynamicEndpointTestResultsApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = NetworkDynamicEndpointTestResultsApi(self.api_client) + + + def test_filter_dynamic_test_network_results_happy_path(self) -> None: + """Integration test for filter_dynamic_test_network_results success path""" + request_body_json = """ + + { + "searchSort" : [ { + "sort" : "round-id", + "order" : "desc" + }, { + "sort" : "round-id", + "order" : "desc" + } ], + "searchFilters" : { + "agentId" : [ "52455b09-ff1b-4849-8194-99026cc890e0", "52455b09-ff1b-4849-8194-99026cc890e0" ], + "webexConferenceId" : [ "719057112996612360", "719057112996612360" ], + "webexLocalSipSessionId" : [ "c124ba2b012050008000aa0c26c4bf0f", "c124ba2b012050008000aa0c26c4bf0f" ], + "userPrincipalName" : [ "joeblogs32@c.com", "joeblogs32@c.com" ], + "webexCorrelationId" : [ "f7d73641-8673-4547-be62-9521f78d9888", "f7d73641-8673-4547-be62-9521f78d9888" ] + }, + "thresholdFilter" : { + "conditionalOperator" : "and", + "filters" : [ { + "name" : "loss", + "value" : 10, + "operator" : "gte" + }, { + "name" : "loss", + "value" : 10, + "operator" : "gte" + } ] + } + } + + """ + dynamic_endpoint_tests_data_round_search = thousandeyes_sdk.endpoint_test_results.models.DynamicEndpointTestsDataRoundSearch.from_json(request_body_json) + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + response_body_json = """ + { + "test" : { + "hasPing" : true, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/dynamic-tests/281474976710706/network/filter" + }, { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/dynamic-tests/281474976710706/pathvis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isPrioritized" : false, + "networkMeasurements" : true, + "tcpProbeMode" : "auto", + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "protocol" : "icmp", + "createdDate" : "2022-07-17T22:00:54Z", + "ipVersion" : "V4_ONLY", + "application" : "webex", + "hasTraceroute" : true, + "isEnabled" : true, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "aid" : "1234", + "agentSelectorConfig" : { + "agentSelectorType" : "all-agents", + "maxMachines" : 25 + }, + "hasPathTraceInSession" : true, + "testName" : "Test name" + }, + "totalHits" : 12, + "endDate" : "2022-07-18T22:00:54Z", + "_links" : { + "next" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "results" : [ { + "originalTargetProfile" : { + "protocol" : "tcp", + "remotePort" : 80, + "remoteIpAddress" : "120.98.134.7" + }, + "agentId" : "861b7557-cd57-4bbb-b648-00bddf88ef49", + "minLatency" : 167, + "vpnProfile" : { + "vpnClientNetworkRange" : [ "9.88.37.27", "9.88.37.27" ], + "vpnGatewayAddress" : "120.98.134.7", + "vpnType" : "cisco-anyconnect", + "vpnClientAddresses" : [ "184.81.113.85", "13.129.91.62" ] + }, + "maxLatency" : 168, + "batteryMetrics" : { + "batteryHealthNormalizedPercent" : 0.92, + "batteryLevel" : "medium", + "batteryLevelNormalizedPercent" : 0.3 + }, + "userProfile" : { + "userName" : "joeblogs32", + "userPrincipalName" : "joeblogs32@c.com" + }, + "platform" : "mac", + "cellularProfile" : { + "rssi" : -10, + "advertisedNetworkSubtype" : "LTE/HSPA", + "carrierName" : "T-Mobile", + "rsrq" : -30, + "rsrp" : -30, + "advertisedNetworkGen" : "2g, 3g, 4g, 5g", + "rscp" : -30, + "networkGen" : "2g, 3g, 4g, 5g", + "networkSubtype" : "LTE/HSPA", + "sinr" : 20 + }, + "score" : { + "applicationScore" : 100, + "quality" : "great" + }, + "loss" : 0, + "protocol" : "tcp", + "networkProfile" : { + "previousInterface" : { + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "interfaceName" : "en0", + "subnetMask" : "255.255.255.0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ] + }, + "ethernetProfile" : { + "linkSpeed" : 860 + }, + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "proxyProfile" : { + "method" : "System", + "proxies" : [ { + "bypass" : "*.local;169.254/16", + "proxy" : "" + }, { + "bypass" : "*.local;169.254/16", + "proxy" : "" + } ] + }, + "subnetMask" : "255.255.255.0", + "error" : "An operation timed out.", + "wirelessProfile" : { + "rssi" : -38, + "bssid" : "4c:ba:ba:f4:fa:fa", + "snr" : 57, + "vendor" : "Cisco", + "txRate" : 130, + "channel" : 1, + "noise" : -95, + "phyMode" : "802.11n", + "ssid" : "Internet for the masses", + "quality" : 100 + }, + "interfaceName" : "en0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ], + "gateway" : "10.0.0.1" + }, + "ztaMetrics" : [ { + "loss" : 50, + "jitter" : 5, + "avgLatency" : 3, + "errorMessage" : "ERR_NAME_NOT_RESOLVED", + "type" : "zta_service" + }, { + "loss" : 50, + "jitter" : 5, + "avgLatency" : 3, + "errorMessage" : "ERR_NAME_NOT_RESOLVED", + "type" : "zta_service" + } ], + "roundId" : 1384309800, + "udpProbeMode" : "unknown", + "isIcmpBlocked" : true, + "avgLatency" : 167.04, + "tcpProbeMode" : "auto", + "systemMetrics" : { + "cpuUtilization" : { + "min" : 0.22, + "median" : 0.61, + "max" : 0.75, + "mean" : 0.55, + "count" : 150, + "stdDev" : 0.01 + }, + "physicalMemoryTotalBytes" : 1024, + "startTimeMs" : 1581508857327, + "physicalMemoryUsedBytes" : { + "min" : 1.2, + "median" : 1.85, + "max" : 2.5, + "mean" : 1.77, + "count" : 155, + "stdDev" : 0.25 + }, + "endTimeMs" : 1581508867333 + }, + "jitter" : 0.076808, + "application" : "webex", + "serverIp" : "185.199.108.153", + "testId" : "584739201", + "webex" : { + "remoteSipSessionId" : "22581707460321454", + "localSipSessionId" : "c124ba2b012050008000aa0c26c4bf0f", + "conferenceId" : "225817074608419375", + "correlationId" : "4e57c97e-abdf-4ec8-a78c-95bac9719896", + "meetingApp" : "ZoomCRC" + }, + "aid" : "1234", + "errorDetails" : "Error" + }, { + "originalTargetProfile" : { + "protocol" : "tcp", + "remotePort" : 80, + "remoteIpAddress" : "120.98.134.7" + }, + "agentId" : "861b7557-cd57-4bbb-b648-00bddf88ef49", + "minLatency" : 167, + "vpnProfile" : { + "vpnClientNetworkRange" : [ "9.88.37.27", "9.88.37.27" ], + "vpnGatewayAddress" : "120.98.134.7", + "vpnType" : "cisco-anyconnect", + "vpnClientAddresses" : [ "184.81.113.85", "13.129.91.62" ] + }, + "maxLatency" : 168, + "batteryMetrics" : { + "batteryHealthNormalizedPercent" : 0.92, + "batteryLevel" : "medium", + "batteryLevelNormalizedPercent" : 0.3 + }, + "userProfile" : { + "userName" : "joeblogs32", + "userPrincipalName" : "joeblogs32@c.com" + }, + "platform" : "mac", + "cellularProfile" : { + "rssi" : -10, + "advertisedNetworkSubtype" : "LTE/HSPA", + "carrierName" : "T-Mobile", + "rsrq" : -30, + "rsrp" : -30, + "advertisedNetworkGen" : "2g, 3g, 4g, 5g", + "rscp" : -30, + "networkGen" : "2g, 3g, 4g, 5g", + "networkSubtype" : "LTE/HSPA", + "sinr" : 20 + }, + "score" : { + "applicationScore" : 100, + "quality" : "great" + }, + "loss" : 0, + "protocol" : "tcp", + "networkProfile" : { + "previousInterface" : { + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "interfaceName" : "en0", + "subnetMask" : "255.255.255.0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ] + }, + "ethernetProfile" : { + "linkSpeed" : 860 + }, + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "proxyProfile" : { + "method" : "System", + "proxies" : [ { + "bypass" : "*.local;169.254/16", + "proxy" : "" + }, { + "bypass" : "*.local;169.254/16", + "proxy" : "" + } ] + }, + "subnetMask" : "255.255.255.0", + "error" : "An operation timed out.", + "wirelessProfile" : { + "rssi" : -38, + "bssid" : "4c:ba:ba:f4:fa:fa", + "snr" : 57, + "vendor" : "Cisco", + "txRate" : 130, + "channel" : 1, + "noise" : -95, + "phyMode" : "802.11n", + "ssid" : "Internet for the masses", + "quality" : 100 + }, + "interfaceName" : "en0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ], + "gateway" : "10.0.0.1" + }, + "ztaMetrics" : [ { + "loss" : 50, + "jitter" : 5, + "avgLatency" : 3, + "errorMessage" : "ERR_NAME_NOT_RESOLVED", + "type" : "zta_service" + }, { + "loss" : 50, + "jitter" : 5, + "avgLatency" : 3, + "errorMessage" : "ERR_NAME_NOT_RESOLVED", + "type" : "zta_service" + } ], + "roundId" : 1384309800, + "udpProbeMode" : "unknown", + "isIcmpBlocked" : true, + "avgLatency" : 167.04, + "tcpProbeMode" : "auto", + "systemMetrics" : { + "cpuUtilization" : { + "min" : 0.22, + "median" : 0.61, + "max" : 0.75, + "mean" : 0.55, + "count" : 150, + "stdDev" : 0.01 + }, + "physicalMemoryTotalBytes" : 1024, + "startTimeMs" : 1581508857327, + "physicalMemoryUsedBytes" : { + "min" : 1.2, + "median" : 1.85, + "max" : 2.5, + "mean" : 1.77, + "count" : 155, + "stdDev" : 0.25 + }, + "endTimeMs" : 1581508867333 + }, + "jitter" : 0.076808, + "application" : "webex", + "serverIp" : "185.199.108.153", + "testId" : "584739201", + "webex" : { + "remoteSipSessionId" : "22581707460321454", + "localSipSessionId" : "c124ba2b012050008000aa0c26c4bf0f", + "conferenceId" : "225817074608419375", + "correlationId" : "4e57c97e-abdf-4ec8-a78c-95bac9719896", + "meetingApp" : "ZoomCRC" + }, + "aid" : "1234", + "errorDetails" : "Error" + } ], + "startDate" : "2022-07-17T22:00:54Z" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.filter_dynamic_test_network_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + dynamic_endpoint_tests_data_round_search=dynamic_endpoint_tests_data_round_search, + + _headers=self.te_headers("filter_dynamic_test_network_results"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_filter_dynamic_test_network_results_error_401(self) -> None: + """Integration test for filter_dynamic_test_network_results error path (HTTP 401)""" + request_body_json = """ + + { + "searchSort" : [ { + "sort" : "round-id", + "order" : "desc" + }, { + "sort" : "round-id", + "order" : "desc" + } ], + "searchFilters" : { + "agentId" : [ "52455b09-ff1b-4849-8194-99026cc890e0", "52455b09-ff1b-4849-8194-99026cc890e0" ], + "webexConferenceId" : [ "719057112996612360", "719057112996612360" ], + "webexLocalSipSessionId" : [ "c124ba2b012050008000aa0c26c4bf0f", "c124ba2b012050008000aa0c26c4bf0f" ], + "userPrincipalName" : [ "joeblogs32@c.com", "joeblogs32@c.com" ], + "webexCorrelationId" : [ "f7d73641-8673-4547-be62-9521f78d9888", "f7d73641-8673-4547-be62-9521f78d9888" ] + }, + "thresholdFilter" : { + "conditionalOperator" : "and", + "filters" : [ { + "name" : "loss", + "value" : 10, + "operator" : "gte" + }, { + "name" : "loss", + "value" : 10, + "operator" : "gte" + } ] + } + } + + """ + dynamic_endpoint_tests_data_round_search = thousandeyes_sdk.endpoint_test_results.models.DynamicEndpointTestsDataRoundSearch.from_json(request_body_json) + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.filter_dynamic_test_network_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + dynamic_endpoint_tests_data_round_search=dynamic_endpoint_tests_data_round_search, + + _headers=self.te_headers("filter_dynamic_test_network_results", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_filter_dynamic_test_network_results_error_403(self) -> None: + """Integration test for filter_dynamic_test_network_results error path (HTTP 403)""" + request_body_json = """ + + { + "searchSort" : [ { + "sort" : "round-id", + "order" : "desc" + }, { + "sort" : "round-id", + "order" : "desc" + } ], + "searchFilters" : { + "agentId" : [ "52455b09-ff1b-4849-8194-99026cc890e0", "52455b09-ff1b-4849-8194-99026cc890e0" ], + "webexConferenceId" : [ "719057112996612360", "719057112996612360" ], + "webexLocalSipSessionId" : [ "c124ba2b012050008000aa0c26c4bf0f", "c124ba2b012050008000aa0c26c4bf0f" ], + "userPrincipalName" : [ "joeblogs32@c.com", "joeblogs32@c.com" ], + "webexCorrelationId" : [ "f7d73641-8673-4547-be62-9521f78d9888", "f7d73641-8673-4547-be62-9521f78d9888" ] + }, + "thresholdFilter" : { + "conditionalOperator" : "and", + "filters" : [ { + "name" : "loss", + "value" : 10, + "operator" : "gte" + }, { + "name" : "loss", + "value" : 10, + "operator" : "gte" + } ] + } + } + + """ + dynamic_endpoint_tests_data_round_search = thousandeyes_sdk.endpoint_test_results.models.DynamicEndpointTestsDataRoundSearch.from_json(request_body_json) + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.filter_dynamic_test_network_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + dynamic_endpoint_tests_data_round_search=dynamic_endpoint_tests_data_round_search, + + _headers=self.te_headers("filter_dynamic_test_network_results", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_filter_dynamic_test_network_results_error_404(self) -> None: + """Integration test for filter_dynamic_test_network_results error path (HTTP 404)""" + request_body_json = """ + + { + "searchSort" : [ { + "sort" : "round-id", + "order" : "desc" + }, { + "sort" : "round-id", + "order" : "desc" + } ], + "searchFilters" : { + "agentId" : [ "52455b09-ff1b-4849-8194-99026cc890e0", "52455b09-ff1b-4849-8194-99026cc890e0" ], + "webexConferenceId" : [ "719057112996612360", "719057112996612360" ], + "webexLocalSipSessionId" : [ "c124ba2b012050008000aa0c26c4bf0f", "c124ba2b012050008000aa0c26c4bf0f" ], + "userPrincipalName" : [ "joeblogs32@c.com", "joeblogs32@c.com" ], + "webexCorrelationId" : [ "f7d73641-8673-4547-be62-9521f78d9888", "f7d73641-8673-4547-be62-9521f78d9888" ] + }, + "thresholdFilter" : { + "conditionalOperator" : "and", + "filters" : [ { + "name" : "loss", + "value" : 10, + "operator" : "gte" + }, { + "name" : "loss", + "value" : 10, + "operator" : "gte" + } ] + } + } + + """ + dynamic_endpoint_tests_data_round_search = thousandeyes_sdk.endpoint_test_results.models.DynamicEndpointTestsDataRoundSearch.from_json(request_body_json) + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.filter_dynamic_test_network_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + dynamic_endpoint_tests_data_round_search=dynamic_endpoint_tests_data_round_search, + + _headers=self.te_headers("filter_dynamic_test_network_results", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_filter_dynamic_test_network_results_error_429(self) -> None: + """Integration test for filter_dynamic_test_network_results error path (HTTP 429)""" + request_body_json = """ + + { + "searchSort" : [ { + "sort" : "round-id", + "order" : "desc" + }, { + "sort" : "round-id", + "order" : "desc" + } ], + "searchFilters" : { + "agentId" : [ "52455b09-ff1b-4849-8194-99026cc890e0", "52455b09-ff1b-4849-8194-99026cc890e0" ], + "webexConferenceId" : [ "719057112996612360", "719057112996612360" ], + "webexLocalSipSessionId" : [ "c124ba2b012050008000aa0c26c4bf0f", "c124ba2b012050008000aa0c26c4bf0f" ], + "userPrincipalName" : [ "joeblogs32@c.com", "joeblogs32@c.com" ], + "webexCorrelationId" : [ "f7d73641-8673-4547-be62-9521f78d9888", "f7d73641-8673-4547-be62-9521f78d9888" ] + }, + "thresholdFilter" : { + "conditionalOperator" : "and", + "filters" : [ { + "name" : "loss", + "value" : 10, + "operator" : "gte" + }, { + "name" : "loss", + "value" : 10, + "operator" : "gte" + } ] + } + } + + """ + dynamic_endpoint_tests_data_round_search = thousandeyes_sdk.endpoint_test_results.models.DynamicEndpointTestsDataRoundSearch.from_json(request_body_json) + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.filter_dynamic_test_network_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + dynamic_endpoint_tests_data_round_search=dynamic_endpoint_tests_data_round_search, + + _headers=self.te_headers("filter_dynamic_test_network_results", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_filter_dynamic_test_network_results_error_500(self) -> None: + """Integration test for filter_dynamic_test_network_results error path (HTTP 500)""" + request_body_json = """ + + { + "searchSort" : [ { + "sort" : "round-id", + "order" : "desc" + }, { + "sort" : "round-id", + "order" : "desc" + } ], + "searchFilters" : { + "agentId" : [ "52455b09-ff1b-4849-8194-99026cc890e0", "52455b09-ff1b-4849-8194-99026cc890e0" ], + "webexConferenceId" : [ "719057112996612360", "719057112996612360" ], + "webexLocalSipSessionId" : [ "c124ba2b012050008000aa0c26c4bf0f", "c124ba2b012050008000aa0c26c4bf0f" ], + "userPrincipalName" : [ "joeblogs32@c.com", "joeblogs32@c.com" ], + "webexCorrelationId" : [ "f7d73641-8673-4547-be62-9521f78d9888", "f7d73641-8673-4547-be62-9521f78d9888" ] + }, + "thresholdFilter" : { + "conditionalOperator" : "and", + "filters" : [ { + "name" : "loss", + "value" : 10, + "operator" : "gte" + }, { + "name" : "loss", + "value" : 10, + "operator" : "gte" + } ] + } + } + + """ + dynamic_endpoint_tests_data_round_search = thousandeyes_sdk.endpoint_test_results.models.DynamicEndpointTestsDataRoundSearch.from_json(request_body_json) + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.filter_dynamic_test_network_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + dynamic_endpoint_tests_data_round_search=dynamic_endpoint_tests_data_round_search, + + _headers=self.te_headers("filter_dynamic_test_network_results", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_filter_dynamic_test_network_results_error_502(self) -> None: + """Integration test for filter_dynamic_test_network_results error path (HTTP 502)""" + request_body_json = """ + + { + "searchSort" : [ { + "sort" : "round-id", + "order" : "desc" + }, { + "sort" : "round-id", + "order" : "desc" + } ], + "searchFilters" : { + "agentId" : [ "52455b09-ff1b-4849-8194-99026cc890e0", "52455b09-ff1b-4849-8194-99026cc890e0" ], + "webexConferenceId" : [ "719057112996612360", "719057112996612360" ], + "webexLocalSipSessionId" : [ "c124ba2b012050008000aa0c26c4bf0f", "c124ba2b012050008000aa0c26c4bf0f" ], + "userPrincipalName" : [ "joeblogs32@c.com", "joeblogs32@c.com" ], + "webexCorrelationId" : [ "f7d73641-8673-4547-be62-9521f78d9888", "f7d73641-8673-4547-be62-9521f78d9888" ] + }, + "thresholdFilter" : { + "conditionalOperator" : "and", + "filters" : [ { + "name" : "loss", + "value" : 10, + "operator" : "gte" + }, { + "name" : "loss", + "value" : 10, + "operator" : "gte" + } ] + } + } + + """ + dynamic_endpoint_tests_data_round_search = thousandeyes_sdk.endpoint_test_results.models.DynamicEndpointTestsDataRoundSearch.from_json(request_body_json) + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.filter_dynamic_test_network_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + dynamic_endpoint_tests_data_round_search=dynamic_endpoint_tests_data_round_search, + + _headers=self.te_headers("filter_dynamic_test_network_results", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_dynamic_test_path_vis_agent_round_results_happy_path(self) -> None: + """Integration test for get_dynamic_test_path_vis_agent_round_results success path""" + test_id = '202701' + agent_id = '11' + round_id = '1384309800' + aid = '1234' + response_body_json = """ + { + "test" : { + "hasPing" : true, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/dynamic-tests/281474976710706/network/filter" + }, { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/dynamic-tests/281474976710706/pathvis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isPrioritized" : false, + "networkMeasurements" : true, + "tcpProbeMode" : "auto", + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "protocol" : "icmp", + "createdDate" : "2022-07-17T22:00:54Z", + "ipVersion" : "V4_ONLY", + "application" : "webex", + "hasTraceroute" : true, + "isEnabled" : true, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "aid" : "1234", + "agentSelectorConfig" : { + "agentSelectorType" : "all-agents", + "maxMachines" : 25 + }, + "hasPathTraceInSession" : true, + "testName" : "Test name" + }, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "results" : [ { + "originalTargetProfile" : { + "protocol" : "tcp", + "remotePort" : 80, + "remoteIpAddress" : "120.98.134.7" + }, + "server" : "www.google.com:443", + "udpProbeMode" : "unknown", + "agentId" : "861b7557-cd57-4bbb-b648-00bddf88ef49", + "asnDetails" : { + "asName" : "ThousandEyes, Inc", + "asNumber" : 394101 + }, + "vpnProfile" : { + "vpnClientNetworkRange" : [ "9.88.37.27", "9.88.37.27" ], + "vpnGatewayAddress" : "120.98.134.7", + "vpnType" : "cisco-anyconnect", + "vpnClientAddresses" : [ "184.81.113.85", "13.129.91.62" ] + }, + "batteryMetrics" : { + "batteryHealthNormalizedPercent" : 0.92, + "batteryLevel" : "medium", + "batteryLevelNormalizedPercent" : 0.3 + }, + "sourcePrefix" : "196.40.96.0/20", + "userProfile" : { + "userName" : "joeblogs32", + "userPrincipalName" : "joeblogs32@c.com" + }, + "platform" : "mac", + "tcpProbeMode" : "auto", + "cellularProfile" : { + "rssi" : -10, + "advertisedNetworkSubtype" : "LTE/HSPA", + "carrierName" : "T-Mobile", + "rsrq" : -30, + "rsrp" : -30, + "advertisedNetworkGen" : "2g, 3g, 4g, 5g", + "rscp" : -30, + "networkGen" : "2g, 3g, 4g, 5g", + "networkSubtype" : "LTE/HSPA", + "sinr" : 20 + }, + "protocol" : "tcp", + "systemMetrics" : { + "cpuUtilization" : { + "min" : 0.22, + "median" : 0.61, + "max" : 0.75, + "mean" : 0.55, + "count" : 150, + "stdDev" : 0.01 + }, + "physicalMemoryTotalBytes" : 1024, + "startTimeMs" : 1581508857327, + "physicalMemoryUsedBytes" : { + "min" : 1.2, + "median" : 1.85, + "max" : 2.5, + "mean" : 1.77, + "count" : 155, + "stdDev" : 0.25 + }, + "endTimeMs" : 1581508867333 + }, + "sourceIp" : "196.40.106.237", + "application" : "webex", + "pathTraces" : [ { + "protocol" : "tcp", + "udpPathTraceMode" : "unknown", + "hops" : [ { + "rdns" : "core-router1.cpt2.host-h.net", + "prefix" : "196.40.96.0/20", + "responseTime" : 1, + "hop" : 1, + "ipAddress" : "196.40.106.237", + "location" : "Cape Town, South Africa", + "network" : "HETZNER (Pty) Ltd (AS 37153)" + }, { + "rdns" : "core-router1.cpt2.host-h.net", + "prefix" : "196.40.96.0/20", + "responseTime" : 1, + "hop" : 1, + "ipAddress" : "196.40.106.237", + "location" : "Cape Town, South Africa", + "network" : "HETZNER (Pty) Ltd (AS 37153)" + } ], + "pathId" : "4711301366345855606023718047703941305741293841502186803", + "tcpPathTraceMode" : "syn-pcap" + }, { + "protocol" : "tcp", + "udpPathTraceMode" : "unknown", + "hops" : [ { + "rdns" : "core-router1.cpt2.host-h.net", + "prefix" : "196.40.96.0/20", + "responseTime" : 1, + "hop" : 1, + "ipAddress" : "196.40.106.237", + "location" : "Cape Town, South Africa", + "network" : "HETZNER (Pty) Ltd (AS 37153)" + }, { + "rdns" : "core-router1.cpt2.host-h.net", + "prefix" : "196.40.96.0/20", + "responseTime" : 1, + "hop" : 1, + "ipAddress" : "196.40.106.237", + "location" : "Cape Town, South Africa", + "network" : "HETZNER (Pty) Ltd (AS 37153)" + } ], + "pathId" : "4711301366345855606023718047703941305741293841502186803", + "tcpPathTraceMode" : "syn-pcap" + } ], + "vpnPathTraces" : [ { + "protocol" : "tcp", + "udpPathTraceMode" : "unknown", + "hops" : [ { + "rdns" : "core-router1.cpt2.host-h.net", + "prefix" : "196.40.96.0/20", + "responseTime" : 1, + "hop" : 1, + "ipAddress" : "196.40.106.237", + "location" : "Cape Town, South Africa", + "network" : "HETZNER (Pty) Ltd (AS 37153)" + }, { + "rdns" : "core-router1.cpt2.host-h.net", + "prefix" : "196.40.96.0/20", + "responseTime" : 1, + "hop" : 1, + "ipAddress" : "196.40.106.237", + "location" : "Cape Town, South Africa", + "network" : "HETZNER (Pty) Ltd (AS 37153)" + } ], + "pathId" : "4711301366345855606023718047703941305741293841502186803", + "tcpPathTraceMode" : "syn-pcap" + }, { + "protocol" : "tcp", + "udpPathTraceMode" : "unknown", + "hops" : [ { + "rdns" : "core-router1.cpt2.host-h.net", + "prefix" : "196.40.96.0/20", + "responseTime" : 1, + "hop" : 1, + "ipAddress" : "196.40.106.237", + "location" : "Cape Town, South Africa", + "network" : "HETZNER (Pty) Ltd (AS 37153)" + }, { + "rdns" : "core-router1.cpt2.host-h.net", + "prefix" : "196.40.96.0/20", + "responseTime" : 1, + "hop" : 1, + "ipAddress" : "196.40.106.237", + "location" : "Cape Town, South Africa", + "network" : "HETZNER (Pty) Ltd (AS 37153)" + } ], + "pathId" : "4711301366345855606023718047703941305741293841502186803", + "tcpPathTraceMode" : "syn-pcap" + } ], + "serverIp" : "185.199.108.153", + "networkProfile" : { + "previousInterface" : { + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "interfaceName" : "en0", + "subnetMask" : "255.255.255.0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ] + }, + "ethernetProfile" : { + "linkSpeed" : 860 + }, + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "proxyProfile" : { + "method" : "System", + "proxies" : [ { + "bypass" : "*.local;169.254/16", + "proxy" : "" + }, { + "bypass" : "*.local;169.254/16", + "proxy" : "" + } ] + }, + "subnetMask" : "255.255.255.0", + "error" : "An operation timed out.", + "wirelessProfile" : { + "rssi" : -38, + "bssid" : "4c:ba:ba:f4:fa:fa", + "snr" : 57, + "vendor" : "Cisco", + "txRate" : 130, + "channel" : 1, + "noise" : -95, + "phyMode" : "802.11n", + "ssid" : "Internet for the masses", + "quality" : 100 + }, + "interfaceName" : "en0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ], + "gateway" : "10.0.0.1" + }, + "testId" : "584739201", + "webex" : { + "remoteSipSessionId" : "22581707460321454", + "localSipSessionId" : "c124ba2b012050008000aa0c26c4bf0f", + "conferenceId" : "225817074608419375", + "correlationId" : "4e57c97e-abdf-4ec8-a78c-95bac9719896", + "meetingApp" : "ZoomCRC" + }, + "aid" : "1234", + "roundId" : 1384309800 + }, { + "originalTargetProfile" : { + "protocol" : "tcp", + "remotePort" : 80, + "remoteIpAddress" : "120.98.134.7" + }, + "server" : "www.google.com:443", + "udpProbeMode" : "unknown", + "agentId" : "861b7557-cd57-4bbb-b648-00bddf88ef49", + "asnDetails" : { + "asName" : "ThousandEyes, Inc", + "asNumber" : 394101 + }, + "vpnProfile" : { + "vpnClientNetworkRange" : [ "9.88.37.27", "9.88.37.27" ], + "vpnGatewayAddress" : "120.98.134.7", + "vpnType" : "cisco-anyconnect", + "vpnClientAddresses" : [ "184.81.113.85", "13.129.91.62" ] + }, + "batteryMetrics" : { + "batteryHealthNormalizedPercent" : 0.92, + "batteryLevel" : "medium", + "batteryLevelNormalizedPercent" : 0.3 + }, + "sourcePrefix" : "196.40.96.0/20", + "userProfile" : { + "userName" : "joeblogs32", + "userPrincipalName" : "joeblogs32@c.com" + }, + "platform" : "mac", + "tcpProbeMode" : "auto", + "cellularProfile" : { + "rssi" : -10, + "advertisedNetworkSubtype" : "LTE/HSPA", + "carrierName" : "T-Mobile", + "rsrq" : -30, + "rsrp" : -30, + "advertisedNetworkGen" : "2g, 3g, 4g, 5g", + "rscp" : -30, + "networkGen" : "2g, 3g, 4g, 5g", + "networkSubtype" : "LTE/HSPA", + "sinr" : 20 + }, + "protocol" : "tcp", + "systemMetrics" : { + "cpuUtilization" : { + "min" : 0.22, + "median" : 0.61, + "max" : 0.75, + "mean" : 0.55, + "count" : 150, + "stdDev" : 0.01 + }, + "physicalMemoryTotalBytes" : 1024, + "startTimeMs" : 1581508857327, + "physicalMemoryUsedBytes" : { + "min" : 1.2, + "median" : 1.85, + "max" : 2.5, + "mean" : 1.77, + "count" : 155, + "stdDev" : 0.25 + }, + "endTimeMs" : 1581508867333 + }, + "sourceIp" : "196.40.106.237", + "application" : "webex", + "pathTraces" : [ { + "protocol" : "tcp", + "udpPathTraceMode" : "unknown", + "hops" : [ { + "rdns" : "core-router1.cpt2.host-h.net", + "prefix" : "196.40.96.0/20", + "responseTime" : 1, + "hop" : 1, + "ipAddress" : "196.40.106.237", + "location" : "Cape Town, South Africa", + "network" : "HETZNER (Pty) Ltd (AS 37153)" + }, { + "rdns" : "core-router1.cpt2.host-h.net", + "prefix" : "196.40.96.0/20", + "responseTime" : 1, + "hop" : 1, + "ipAddress" : "196.40.106.237", + "location" : "Cape Town, South Africa", + "network" : "HETZNER (Pty) Ltd (AS 37153)" + } ], + "pathId" : "4711301366345855606023718047703941305741293841502186803", + "tcpPathTraceMode" : "syn-pcap" + }, { + "protocol" : "tcp", + "udpPathTraceMode" : "unknown", + "hops" : [ { + "rdns" : "core-router1.cpt2.host-h.net", + "prefix" : "196.40.96.0/20", + "responseTime" : 1, + "hop" : 1, + "ipAddress" : "196.40.106.237", + "location" : "Cape Town, South Africa", + "network" : "HETZNER (Pty) Ltd (AS 37153)" + }, { + "rdns" : "core-router1.cpt2.host-h.net", + "prefix" : "196.40.96.0/20", + "responseTime" : 1, + "hop" : 1, + "ipAddress" : "196.40.106.237", + "location" : "Cape Town, South Africa", + "network" : "HETZNER (Pty) Ltd (AS 37153)" + } ], + "pathId" : "4711301366345855606023718047703941305741293841502186803", + "tcpPathTraceMode" : "syn-pcap" + } ], + "vpnPathTraces" : [ { + "protocol" : "tcp", + "udpPathTraceMode" : "unknown", + "hops" : [ { + "rdns" : "core-router1.cpt2.host-h.net", + "prefix" : "196.40.96.0/20", + "responseTime" : 1, + "hop" : 1, + "ipAddress" : "196.40.106.237", + "location" : "Cape Town, South Africa", + "network" : "HETZNER (Pty) Ltd (AS 37153)" + }, { + "rdns" : "core-router1.cpt2.host-h.net", + "prefix" : "196.40.96.0/20", + "responseTime" : 1, + "hop" : 1, + "ipAddress" : "196.40.106.237", + "location" : "Cape Town, South Africa", + "network" : "HETZNER (Pty) Ltd (AS 37153)" + } ], + "pathId" : "4711301366345855606023718047703941305741293841502186803", + "tcpPathTraceMode" : "syn-pcap" + }, { + "protocol" : "tcp", + "udpPathTraceMode" : "unknown", + "hops" : [ { + "rdns" : "core-router1.cpt2.host-h.net", + "prefix" : "196.40.96.0/20", + "responseTime" : 1, + "hop" : 1, + "ipAddress" : "196.40.106.237", + "location" : "Cape Town, South Africa", + "network" : "HETZNER (Pty) Ltd (AS 37153)" + }, { + "rdns" : "core-router1.cpt2.host-h.net", + "prefix" : "196.40.96.0/20", + "responseTime" : 1, + "hop" : 1, + "ipAddress" : "196.40.106.237", + "location" : "Cape Town, South Africa", + "network" : "HETZNER (Pty) Ltd (AS 37153)" + } ], + "pathId" : "4711301366345855606023718047703941305741293841502186803", + "tcpPathTraceMode" : "syn-pcap" + } ], + "serverIp" : "185.199.108.153", + "networkProfile" : { + "previousInterface" : { + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "interfaceName" : "en0", + "subnetMask" : "255.255.255.0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ] + }, + "ethernetProfile" : { + "linkSpeed" : 860 + }, + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "proxyProfile" : { + "method" : "System", + "proxies" : [ { + "bypass" : "*.local;169.254/16", + "proxy" : "" + }, { + "bypass" : "*.local;169.254/16", + "proxy" : "" + } ] + }, + "subnetMask" : "255.255.255.0", + "error" : "An operation timed out.", + "wirelessProfile" : { + "rssi" : -38, + "bssid" : "4c:ba:ba:f4:fa:fa", + "snr" : 57, + "vendor" : "Cisco", + "txRate" : 130, + "channel" : 1, + "noise" : -95, + "phyMode" : "802.11n", + "ssid" : "Internet for the masses", + "quality" : 100 + }, + "interfaceName" : "en0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ], + "gateway" : "10.0.0.1" + }, + "testId" : "584739201", + "webex" : { + "remoteSipSessionId" : "22581707460321454", + "localSipSessionId" : "c124ba2b012050008000aa0c26c4bf0f", + "conferenceId" : "225817074608419375", + "correlationId" : "4e57c97e-abdf-4ec8-a78c-95bac9719896", + "meetingApp" : "ZoomCRC" + }, + "aid" : "1234", + "roundId" : 1384309800 + } ] + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_dynamic_test_path_vis_agent_round_results( + + test_id=test_id, + + agent_id=agent_id, + + round_id=round_id, + + aid=aid, + + _headers=self.te_headers("get_dynamic_test_path_vis_agent_round_results"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_dynamic_test_path_vis_agent_round_results_error_400(self) -> None: + """Integration test for get_dynamic_test_path_vis_agent_round_results error path (HTTP 400)""" + test_id = '202701' + agent_id = '11' + round_id = '1384309800' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.get_dynamic_test_path_vis_agent_round_results( + + test_id=test_id, + + agent_id=agent_id, + + round_id=round_id, + + aid=aid, + + _headers=self.te_headers("get_dynamic_test_path_vis_agent_round_results", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_dynamic_test_path_vis_agent_round_results_error_401(self) -> None: + """Integration test for get_dynamic_test_path_vis_agent_round_results error path (HTTP 401)""" + test_id = '202701' + agent_id = '11' + round_id = '1384309800' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_dynamic_test_path_vis_agent_round_results( + + test_id=test_id, + + agent_id=agent_id, + + round_id=round_id, + + aid=aid, + + _headers=self.te_headers("get_dynamic_test_path_vis_agent_round_results", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_dynamic_test_path_vis_agent_round_results_error_403(self) -> None: + """Integration test for get_dynamic_test_path_vis_agent_round_results error path (HTTP 403)""" + test_id = '202701' + agent_id = '11' + round_id = '1384309800' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_dynamic_test_path_vis_agent_round_results( + + test_id=test_id, + + agent_id=agent_id, + + round_id=round_id, + + aid=aid, + + _headers=self.te_headers("get_dynamic_test_path_vis_agent_round_results", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_dynamic_test_path_vis_agent_round_results_error_404(self) -> None: + """Integration test for get_dynamic_test_path_vis_agent_round_results error path (HTTP 404)""" + test_id = '202701' + agent_id = '11' + round_id = '1384309800' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_dynamic_test_path_vis_agent_round_results( + + test_id=test_id, + + agent_id=agent_id, + + round_id=round_id, + + aid=aid, + + _headers=self.te_headers("get_dynamic_test_path_vis_agent_round_results", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_dynamic_test_path_vis_agent_round_results_error_429(self) -> None: + """Integration test for get_dynamic_test_path_vis_agent_round_results error path (HTTP 429)""" + test_id = '202701' + agent_id = '11' + round_id = '1384309800' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_dynamic_test_path_vis_agent_round_results( + + test_id=test_id, + + agent_id=agent_id, + + round_id=round_id, + + aid=aid, + + _headers=self.te_headers("get_dynamic_test_path_vis_agent_round_results", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_dynamic_test_path_vis_agent_round_results_error_500(self) -> None: + """Integration test for get_dynamic_test_path_vis_agent_round_results error path (HTTP 500)""" + test_id = '202701' + agent_id = '11' + round_id = '1384309800' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_dynamic_test_path_vis_agent_round_results( + + test_id=test_id, + + agent_id=agent_id, + + round_id=round_id, + + aid=aid, + + _headers=self.te_headers("get_dynamic_test_path_vis_agent_round_results", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_dynamic_test_path_vis_agent_round_results_error_502(self) -> None: + """Integration test for get_dynamic_test_path_vis_agent_round_results error path (HTTP 502)""" + test_id = '202701' + agent_id = '11' + round_id = '1384309800' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.get_dynamic_test_path_vis_agent_round_results( + + test_id=test_id, + + agent_id=agent_id, + + round_id=round_id, + + aid=aid, + + _headers=self.te_headers("get_dynamic_test_path_vis_agent_round_results", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_dynamic_test_path_vis_results_happy_path(self) -> None: + """Integration test for get_dynamic_test_path_vis_results success path""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + response_body_json = """ + { + "test" : { + "hasPing" : true, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/dynamic-tests/281474976710706/network/filter" + }, { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/dynamic-tests/281474976710706/pathvis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isPrioritized" : false, + "networkMeasurements" : true, + "tcpProbeMode" : "auto", + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "protocol" : "icmp", + "createdDate" : "2022-07-17T22:00:54Z", + "ipVersion" : "V4_ONLY", + "application" : "webex", + "hasTraceroute" : true, + "isEnabled" : true, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "aid" : "1234", + "agentSelectorConfig" : { + "agentSelectorType" : "all-agents", + "maxMachines" : 25 + }, + "hasPathTraceInSession" : true, + "testName" : "Test name" + }, + "endDate" : "2022-07-18T22:00:54Z", + "totalHits" : 12, + "_links" : { + "next" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "results" : [ { + "originalTargetProfile" : { + "protocol" : "tcp", + "remotePort" : 80, + "remoteIpAddress" : "120.98.134.7" + }, + "server" : "www.google.com:443", + "udpProbeMode" : "unknown", + "agentId" : "861b7557-cd57-4bbb-b648-00bddf88ef49", + "asnDetails" : { + "asName" : "ThousandEyes, Inc", + "asNumber" : 394101 + }, + "vpnProfile" : { + "vpnClientNetworkRange" : [ "9.88.37.27", "9.88.37.27" ], + "vpnGatewayAddress" : "120.98.134.7", + "vpnType" : "cisco-anyconnect", + "vpnClientAddresses" : [ "184.81.113.85", "13.129.91.62" ] + }, + "batteryMetrics" : { + "batteryHealthNormalizedPercent" : 0.92, + "batteryLevel" : "medium", + "batteryLevelNormalizedPercent" : 0.3 + }, + "sourcePrefix" : "196.40.96.0/20", + "userProfile" : { + "userName" : "joeblogs32", + "userPrincipalName" : "joeblogs32@c.com" + }, + "platform" : "mac", + "tcpProbeMode" : "auto", + "cellularProfile" : { + "rssi" : -10, + "advertisedNetworkSubtype" : "LTE/HSPA", + "carrierName" : "T-Mobile", + "rsrq" : -30, + "rsrp" : -30, + "advertisedNetworkGen" : "2g, 3g, 4g, 5g", + "rscp" : -30, + "networkGen" : "2g, 3g, 4g, 5g", + "networkSubtype" : "LTE/HSPA", + "sinr" : 20 + }, + "protocol" : "tcp", + "systemMetrics" : { + "cpuUtilization" : { + "min" : 0.22, + "median" : 0.61, + "max" : 0.75, + "mean" : 0.55, + "count" : 150, + "stdDev" : 0.01 + }, + "physicalMemoryTotalBytes" : 1024, + "startTimeMs" : 1581508857327, + "physicalMemoryUsedBytes" : { + "min" : 1.2, + "median" : 1.85, + "max" : 2.5, + "mean" : 1.77, + "count" : 155, + "stdDev" : 0.25 + }, + "endTimeMs" : 1581508867333 + }, + "sourceIp" : "196.40.106.237", + "application" : "webex", + "pathTraces" : [ { + "protocol" : "tcp", + "numberOfHops" : 15, + "responseTime" : 1500, + "ipAddress" : "196.40.106.237", + "udpPathTraceMode" : "unknown", + "pathId" : "1230899668701775614109128428722974545787322404682781961521", + "tcpPathTraceMode" : "syn-pcap" + }, { + "protocol" : "tcp", + "numberOfHops" : 15, + "responseTime" : 1500, + "ipAddress" : "196.40.106.237", + "udpPathTraceMode" : "unknown", + "pathId" : "1230899668701775614109128428722974545787322404682781961521", + "tcpPathTraceMode" : "syn-pcap" + } ], + "serverIp" : "185.199.108.153", + "networkProfile" : { + "previousInterface" : { + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "interfaceName" : "en0", + "subnetMask" : "255.255.255.0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ] + }, + "ethernetProfile" : { + "linkSpeed" : 860 + }, + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "proxyProfile" : { + "method" : "System", + "proxies" : [ { + "bypass" : "*.local;169.254/16", + "proxy" : "" + }, { + "bypass" : "*.local;169.254/16", + "proxy" : "" + } ] + }, + "subnetMask" : "255.255.255.0", + "error" : "An operation timed out.", + "wirelessProfile" : { + "rssi" : -38, + "bssid" : "4c:ba:ba:f4:fa:fa", + "snr" : 57, + "vendor" : "Cisco", + "txRate" : 130, + "channel" : 1, + "noise" : -95, + "phyMode" : "802.11n", + "ssid" : "Internet for the masses", + "quality" : 100 + }, + "interfaceName" : "en0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ], + "gateway" : "10.0.0.1" + }, + "testId" : "584739201", + "location" : "San Francisco Area", + "webex" : { + "remoteSipSessionId" : "22581707460321454", + "localSipSessionId" : "c124ba2b012050008000aa0c26c4bf0f", + "conferenceId" : "225817074608419375", + "correlationId" : "4e57c97e-abdf-4ec8-a78c-95bac9719896", + "meetingApp" : "ZoomCRC" + }, + "aid" : "1234", + "roundId" : 1384309800 + }, { + "originalTargetProfile" : { + "protocol" : "tcp", + "remotePort" : 80, + "remoteIpAddress" : "120.98.134.7" + }, + "server" : "www.google.com:443", + "udpProbeMode" : "unknown", + "agentId" : "861b7557-cd57-4bbb-b648-00bddf88ef49", + "asnDetails" : { + "asName" : "ThousandEyes, Inc", + "asNumber" : 394101 + }, + "vpnProfile" : { + "vpnClientNetworkRange" : [ "9.88.37.27", "9.88.37.27" ], + "vpnGatewayAddress" : "120.98.134.7", + "vpnType" : "cisco-anyconnect", + "vpnClientAddresses" : [ "184.81.113.85", "13.129.91.62" ] + }, + "batteryMetrics" : { + "batteryHealthNormalizedPercent" : 0.92, + "batteryLevel" : "medium", + "batteryLevelNormalizedPercent" : 0.3 + }, + "sourcePrefix" : "196.40.96.0/20", + "userProfile" : { + "userName" : "joeblogs32", + "userPrincipalName" : "joeblogs32@c.com" + }, + "platform" : "mac", + "tcpProbeMode" : "auto", + "cellularProfile" : { + "rssi" : -10, + "advertisedNetworkSubtype" : "LTE/HSPA", + "carrierName" : "T-Mobile", + "rsrq" : -30, + "rsrp" : -30, + "advertisedNetworkGen" : "2g, 3g, 4g, 5g", + "rscp" : -30, + "networkGen" : "2g, 3g, 4g, 5g", + "networkSubtype" : "LTE/HSPA", + "sinr" : 20 + }, + "protocol" : "tcp", + "systemMetrics" : { + "cpuUtilization" : { + "min" : 0.22, + "median" : 0.61, + "max" : 0.75, + "mean" : 0.55, + "count" : 150, + "stdDev" : 0.01 + }, + "physicalMemoryTotalBytes" : 1024, + "startTimeMs" : 1581508857327, + "physicalMemoryUsedBytes" : { + "min" : 1.2, + "median" : 1.85, + "max" : 2.5, + "mean" : 1.77, + "count" : 155, + "stdDev" : 0.25 + }, + "endTimeMs" : 1581508867333 + }, + "sourceIp" : "196.40.106.237", + "application" : "webex", + "pathTraces" : [ { + "protocol" : "tcp", + "numberOfHops" : 15, + "responseTime" : 1500, + "ipAddress" : "196.40.106.237", + "udpPathTraceMode" : "unknown", + "pathId" : "1230899668701775614109128428722974545787322404682781961521", + "tcpPathTraceMode" : "syn-pcap" + }, { + "protocol" : "tcp", + "numberOfHops" : 15, + "responseTime" : 1500, + "ipAddress" : "196.40.106.237", + "udpPathTraceMode" : "unknown", + "pathId" : "1230899668701775614109128428722974545787322404682781961521", + "tcpPathTraceMode" : "syn-pcap" + } ], + "serverIp" : "185.199.108.153", + "networkProfile" : { + "previousInterface" : { + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "interfaceName" : "en0", + "subnetMask" : "255.255.255.0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ] + }, + "ethernetProfile" : { + "linkSpeed" : 860 + }, + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "proxyProfile" : { + "method" : "System", + "proxies" : [ { + "bypass" : "*.local;169.254/16", + "proxy" : "" + }, { + "bypass" : "*.local;169.254/16", + "proxy" : "" + } ] + }, + "subnetMask" : "255.255.255.0", + "error" : "An operation timed out.", + "wirelessProfile" : { + "rssi" : -38, + "bssid" : "4c:ba:ba:f4:fa:fa", + "snr" : 57, + "vendor" : "Cisco", + "txRate" : 130, + "channel" : 1, + "noise" : -95, + "phyMode" : "802.11n", + "ssid" : "Internet for the masses", + "quality" : 100 + }, + "interfaceName" : "en0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ], + "gateway" : "10.0.0.1" + }, + "testId" : "584739201", + "location" : "San Francisco Area", + "webex" : { + "remoteSipSessionId" : "22581707460321454", + "localSipSessionId" : "c124ba2b012050008000aa0c26c4bf0f", + "conferenceId" : "225817074608419375", + "correlationId" : "4e57c97e-abdf-4ec8-a78c-95bac9719896", + "meetingApp" : "ZoomCRC" + }, + "aid" : "1234", + "roundId" : 1384309800 + } ], + "startDate" : "2022-07-17T22:00:54Z" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_dynamic_test_path_vis_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_dynamic_test_path_vis_results"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_dynamic_test_path_vis_results_error_401(self) -> None: + """Integration test for get_dynamic_test_path_vis_results error path (HTTP 401)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_dynamic_test_path_vis_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_dynamic_test_path_vis_results", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_dynamic_test_path_vis_results_error_403(self) -> None: + """Integration test for get_dynamic_test_path_vis_results error path (HTTP 403)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_dynamic_test_path_vis_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_dynamic_test_path_vis_results", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_dynamic_test_path_vis_results_error_404(self) -> None: + """Integration test for get_dynamic_test_path_vis_results error path (HTTP 404)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_dynamic_test_path_vis_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_dynamic_test_path_vis_results", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_dynamic_test_path_vis_results_error_429(self) -> None: + """Integration test for get_dynamic_test_path_vis_results error path (HTTP 429)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_dynamic_test_path_vis_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_dynamic_test_path_vis_results", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_dynamic_test_path_vis_results_error_500(self) -> None: + """Integration test for get_dynamic_test_path_vis_results error path (HTTP 500)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_dynamic_test_path_vis_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_dynamic_test_path_vis_results", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_dynamic_test_path_vis_results_error_502(self) -> None: + """Integration test for get_dynamic_test_path_vis_results error path (HTTP 502)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.get_dynamic_test_path_vis_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_dynamic_test_path_vis_results", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-endpoint-test-results/test/test_network_endpoint_scheduled_test_results_api_integration.py b/thousandeyes-sdk-endpoint-test-results/test/test_network_endpoint_scheduled_test_results_api_integration.py new file mode 100644 index 00000000..4854b465 --- /dev/null +++ b/thousandeyes-sdk-endpoint-test-results/test/test_network_endpoint_scheduled_test_results_api_integration.py @@ -0,0 +1,2959 @@ +# coding: utf-8 + +""" + Endpoint Test Results API + + Retrieve results for scheduled and dynamic tests on endpoint agents. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.endpoint_test_results.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.endpoint_test_results.api.network_endpoint_scheduled_test_results_api import NetworkEndpointScheduledTestResultsApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestNetworkEndpointScheduledTestResultsApiIntegration(IntegrationTestBase): + """NetworkEndpointScheduledTestResultsApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = NetworkEndpointScheduledTestResultsApi(self.api_client) + + + def test_filter_scheduled_test_network_results_happy_path(self) -> None: + """Integration test for filter_scheduled_test_network_results success path""" + request_body_json = """ + + { + "searchSort" : [ { + "sort" : "round-id", + "order" : "desc" + }, { + "sort" : "round-id", + "order" : "desc" + } ], + "searchFilters" : { + "agentId" : [ "52455b09-ff1b-4849-8194-99026cc890e0", "52455b09-ff1b-4849-8194-99026cc890e0" ], + "userPrincipalName" : [ "joeblogs32@c.com", "joeblogs32@c.com" ] + }, + "thresholdFilter" : { + "conditionalOperator" : "and", + "filters" : [ { + "name" : "loss", + "value" : 10, + "operator" : "gte" + }, { + "name" : "loss", + "value" : 10, + "operator" : "gte" + } ] + } + } + + """ + endpoint_tests_data_rounds_search = thousandeyes_sdk.endpoint_test_results.models.EndpointTestsDataRoundsSearch.from_json(request_body_json) + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + response_body_json = """ + { + "test" : { + "server" : "www.example.com", + "isSavedEvent" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/scheduled-tests/281474976710706/network/filter" + }, { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/scheduled-tests/281474976710706/pathvis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isPrioritized" : false, + "networkMeasurements" : true, + "type" : "agent-to-server", + "tcpProbeMode" : "auto", + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "protocol" : "icmp", + "createdDate" : "2022-07-17T22:00:54Z", + "ipVersion" : "V4_ONLY", + "port" : 443, + "isEnabled" : true, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "aid" : "1234", + "agentSelectorConfig" : { + "agentSelectorType" : "all-agents", + "maxMachines" : 25 + }, + "hasPathTraceInSession" : true, + "testName" : "Test name" + }, + "totalHits" : 12, + "endDate" : "2022-07-18T22:00:54Z", + "_links" : { + "next" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "results" : [ { + "originalTargetProfile" : { + "protocol" : "tcp", + "remotePort" : 80, + "remoteIpAddress" : "120.98.134.7" + }, + "agentId" : "861b7557-cd57-4bbb-b648-00bddf88ef49", + "isIcmpBlocked" : true, + "avgLatency" : 167.04, + "minLatency" : 167, + "vpnProfile" : { + "vpnClientNetworkRange" : [ "9.88.37.27", "9.88.37.27" ], + "vpnGatewayAddress" : "120.98.134.7", + "vpnType" : "cisco-anyconnect", + "vpnClientAddresses" : [ "184.81.113.85", "13.129.91.62" ] + }, + "maxLatency" : 168, + "batteryMetrics" : { + "batteryHealthNormalizedPercent" : 0.92, + "batteryLevel" : "medium", + "batteryLevelNormalizedPercent" : 0.3 + }, + "userProfile" : { + "userName" : "joeblogs32", + "userPrincipalName" : "joeblogs32@c.com" + }, + "platform" : "mac", + "cellularProfile" : { + "rssi" : -10, + "advertisedNetworkSubtype" : "LTE/HSPA", + "carrierName" : "T-Mobile", + "rsrq" : -30, + "rsrp" : -30, + "advertisedNetworkGen" : "2g, 3g, 4g, 5g", + "rscp" : -30, + "networkGen" : "2g, 3g, 4g, 5g", + "networkSubtype" : "LTE/HSPA", + "sinr" : 20 + }, + "score" : { + "applicationScore" : 100, + "quality" : "great" + }, + "loss" : 0, + "systemMetrics" : { + "cpuUtilization" : { + "min" : 0.22, + "median" : 0.61, + "max" : 0.75, + "mean" : 0.55, + "count" : 150, + "stdDev" : 0.01 + }, + "physicalMemoryTotalBytes" : 1024, + "startTimeMs" : 1581508857327, + "physicalMemoryUsedBytes" : { + "min" : 1.2, + "median" : 1.85, + "max" : 2.5, + "mean" : 1.77, + "count" : 155, + "stdDev" : 0.25 + }, + "endTimeMs" : 1581508867333 + }, + "jitter" : 0.076808, + "serverIp" : "185.199.108.153", + "networkProfile" : { + "previousInterface" : { + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "interfaceName" : "en0", + "subnetMask" : "255.255.255.0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ] + }, + "ethernetProfile" : { + "linkSpeed" : 860 + }, + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "proxyProfile" : { + "method" : "System", + "proxies" : [ { + "bypass" : "*.local;169.254/16", + "proxy" : "" + }, { + "bypass" : "*.local;169.254/16", + "proxy" : "" + } ] + }, + "subnetMask" : "255.255.255.0", + "error" : "An operation timed out.", + "wirelessProfile" : { + "rssi" : -38, + "bssid" : "4c:ba:ba:f4:fa:fa", + "snr" : 57, + "vendor" : "Cisco", + "txRate" : 130, + "channel" : 1, + "noise" : -95, + "phyMode" : "802.11n", + "ssid" : "Internet for the masses", + "quality" : 100 + }, + "interfaceName" : "en0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ], + "gateway" : "10.0.0.1" + }, + "ztaMetrics" : [ { + "loss" : 50, + "jitter" : 5, + "avgLatency" : 3, + "errorMessage" : "ERR_NAME_NOT_RESOLVED", + "type" : "zta_service" + }, { + "loss" : 50, + "jitter" : 5, + "avgLatency" : 3, + "errorMessage" : "ERR_NAME_NOT_RESOLVED", + "type" : "zta_service" + } ], + "testId" : "584739201", + "aid" : "1234", + "roundId" : 1384309800, + "errorDetails" : "Error" + }, { + "originalTargetProfile" : { + "protocol" : "tcp", + "remotePort" : 80, + "remoteIpAddress" : "120.98.134.7" + }, + "agentId" : "861b7557-cd57-4bbb-b648-00bddf88ef49", + "isIcmpBlocked" : true, + "avgLatency" : 167.04, + "minLatency" : 167, + "vpnProfile" : { + "vpnClientNetworkRange" : [ "9.88.37.27", "9.88.37.27" ], + "vpnGatewayAddress" : "120.98.134.7", + "vpnType" : "cisco-anyconnect", + "vpnClientAddresses" : [ "184.81.113.85", "13.129.91.62" ] + }, + "maxLatency" : 168, + "batteryMetrics" : { + "batteryHealthNormalizedPercent" : 0.92, + "batteryLevel" : "medium", + "batteryLevelNormalizedPercent" : 0.3 + }, + "userProfile" : { + "userName" : "joeblogs32", + "userPrincipalName" : "joeblogs32@c.com" + }, + "platform" : "mac", + "cellularProfile" : { + "rssi" : -10, + "advertisedNetworkSubtype" : "LTE/HSPA", + "carrierName" : "T-Mobile", + "rsrq" : -30, + "rsrp" : -30, + "advertisedNetworkGen" : "2g, 3g, 4g, 5g", + "rscp" : -30, + "networkGen" : "2g, 3g, 4g, 5g", + "networkSubtype" : "LTE/HSPA", + "sinr" : 20 + }, + "score" : { + "applicationScore" : 100, + "quality" : "great" + }, + "loss" : 0, + "systemMetrics" : { + "cpuUtilization" : { + "min" : 0.22, + "median" : 0.61, + "max" : 0.75, + "mean" : 0.55, + "count" : 150, + "stdDev" : 0.01 + }, + "physicalMemoryTotalBytes" : 1024, + "startTimeMs" : 1581508857327, + "physicalMemoryUsedBytes" : { + "min" : 1.2, + "median" : 1.85, + "max" : 2.5, + "mean" : 1.77, + "count" : 155, + "stdDev" : 0.25 + }, + "endTimeMs" : 1581508867333 + }, + "jitter" : 0.076808, + "serverIp" : "185.199.108.153", + "networkProfile" : { + "previousInterface" : { + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "interfaceName" : "en0", + "subnetMask" : "255.255.255.0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ] + }, + "ethernetProfile" : { + "linkSpeed" : 860 + }, + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "proxyProfile" : { + "method" : "System", + "proxies" : [ { + "bypass" : "*.local;169.254/16", + "proxy" : "" + }, { + "bypass" : "*.local;169.254/16", + "proxy" : "" + } ] + }, + "subnetMask" : "255.255.255.0", + "error" : "An operation timed out.", + "wirelessProfile" : { + "rssi" : -38, + "bssid" : "4c:ba:ba:f4:fa:fa", + "snr" : 57, + "vendor" : "Cisco", + "txRate" : 130, + "channel" : 1, + "noise" : -95, + "phyMode" : "802.11n", + "ssid" : "Internet for the masses", + "quality" : 100 + }, + "interfaceName" : "en0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ], + "gateway" : "10.0.0.1" + }, + "ztaMetrics" : [ { + "loss" : 50, + "jitter" : 5, + "avgLatency" : 3, + "errorMessage" : "ERR_NAME_NOT_RESOLVED", + "type" : "zta_service" + }, { + "loss" : 50, + "jitter" : 5, + "avgLatency" : 3, + "errorMessage" : "ERR_NAME_NOT_RESOLVED", + "type" : "zta_service" + } ], + "testId" : "584739201", + "aid" : "1234", + "roundId" : 1384309800, + "errorDetails" : "Error" + } ], + "startDate" : "2022-07-17T22:00:54Z" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.filter_scheduled_test_network_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + endpoint_tests_data_rounds_search=endpoint_tests_data_rounds_search, + + _headers=self.te_headers("filter_scheduled_test_network_results"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_filter_scheduled_test_network_results_error_401(self) -> None: + """Integration test for filter_scheduled_test_network_results error path (HTTP 401)""" + request_body_json = """ + + { + "searchSort" : [ { + "sort" : "round-id", + "order" : "desc" + }, { + "sort" : "round-id", + "order" : "desc" + } ], + "searchFilters" : { + "agentId" : [ "52455b09-ff1b-4849-8194-99026cc890e0", "52455b09-ff1b-4849-8194-99026cc890e0" ], + "userPrincipalName" : [ "joeblogs32@c.com", "joeblogs32@c.com" ] + }, + "thresholdFilter" : { + "conditionalOperator" : "and", + "filters" : [ { + "name" : "loss", + "value" : 10, + "operator" : "gte" + }, { + "name" : "loss", + "value" : 10, + "operator" : "gte" + } ] + } + } + + """ + endpoint_tests_data_rounds_search = thousandeyes_sdk.endpoint_test_results.models.EndpointTestsDataRoundsSearch.from_json(request_body_json) + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.filter_scheduled_test_network_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + endpoint_tests_data_rounds_search=endpoint_tests_data_rounds_search, + + _headers=self.te_headers("filter_scheduled_test_network_results", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_filter_scheduled_test_network_results_error_403(self) -> None: + """Integration test for filter_scheduled_test_network_results error path (HTTP 403)""" + request_body_json = """ + + { + "searchSort" : [ { + "sort" : "round-id", + "order" : "desc" + }, { + "sort" : "round-id", + "order" : "desc" + } ], + "searchFilters" : { + "agentId" : [ "52455b09-ff1b-4849-8194-99026cc890e0", "52455b09-ff1b-4849-8194-99026cc890e0" ], + "userPrincipalName" : [ "joeblogs32@c.com", "joeblogs32@c.com" ] + }, + "thresholdFilter" : { + "conditionalOperator" : "and", + "filters" : [ { + "name" : "loss", + "value" : 10, + "operator" : "gte" + }, { + "name" : "loss", + "value" : 10, + "operator" : "gte" + } ] + } + } + + """ + endpoint_tests_data_rounds_search = thousandeyes_sdk.endpoint_test_results.models.EndpointTestsDataRoundsSearch.from_json(request_body_json) + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.filter_scheduled_test_network_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + endpoint_tests_data_rounds_search=endpoint_tests_data_rounds_search, + + _headers=self.te_headers("filter_scheduled_test_network_results", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_filter_scheduled_test_network_results_error_404(self) -> None: + """Integration test for filter_scheduled_test_network_results error path (HTTP 404)""" + request_body_json = """ + + { + "searchSort" : [ { + "sort" : "round-id", + "order" : "desc" + }, { + "sort" : "round-id", + "order" : "desc" + } ], + "searchFilters" : { + "agentId" : [ "52455b09-ff1b-4849-8194-99026cc890e0", "52455b09-ff1b-4849-8194-99026cc890e0" ], + "userPrincipalName" : [ "joeblogs32@c.com", "joeblogs32@c.com" ] + }, + "thresholdFilter" : { + "conditionalOperator" : "and", + "filters" : [ { + "name" : "loss", + "value" : 10, + "operator" : "gte" + }, { + "name" : "loss", + "value" : 10, + "operator" : "gte" + } ] + } + } + + """ + endpoint_tests_data_rounds_search = thousandeyes_sdk.endpoint_test_results.models.EndpointTestsDataRoundsSearch.from_json(request_body_json) + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.filter_scheduled_test_network_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + endpoint_tests_data_rounds_search=endpoint_tests_data_rounds_search, + + _headers=self.te_headers("filter_scheduled_test_network_results", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_filter_scheduled_test_network_results_error_429(self) -> None: + """Integration test for filter_scheduled_test_network_results error path (HTTP 429)""" + request_body_json = """ + + { + "searchSort" : [ { + "sort" : "round-id", + "order" : "desc" + }, { + "sort" : "round-id", + "order" : "desc" + } ], + "searchFilters" : { + "agentId" : [ "52455b09-ff1b-4849-8194-99026cc890e0", "52455b09-ff1b-4849-8194-99026cc890e0" ], + "userPrincipalName" : [ "joeblogs32@c.com", "joeblogs32@c.com" ] + }, + "thresholdFilter" : { + "conditionalOperator" : "and", + "filters" : [ { + "name" : "loss", + "value" : 10, + "operator" : "gte" + }, { + "name" : "loss", + "value" : 10, + "operator" : "gte" + } ] + } + } + + """ + endpoint_tests_data_rounds_search = thousandeyes_sdk.endpoint_test_results.models.EndpointTestsDataRoundsSearch.from_json(request_body_json) + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.filter_scheduled_test_network_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + endpoint_tests_data_rounds_search=endpoint_tests_data_rounds_search, + + _headers=self.te_headers("filter_scheduled_test_network_results", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_filter_scheduled_test_network_results_error_500(self) -> None: + """Integration test for filter_scheduled_test_network_results error path (HTTP 500)""" + request_body_json = """ + + { + "searchSort" : [ { + "sort" : "round-id", + "order" : "desc" + }, { + "sort" : "round-id", + "order" : "desc" + } ], + "searchFilters" : { + "agentId" : [ "52455b09-ff1b-4849-8194-99026cc890e0", "52455b09-ff1b-4849-8194-99026cc890e0" ], + "userPrincipalName" : [ "joeblogs32@c.com", "joeblogs32@c.com" ] + }, + "thresholdFilter" : { + "conditionalOperator" : "and", + "filters" : [ { + "name" : "loss", + "value" : 10, + "operator" : "gte" + }, { + "name" : "loss", + "value" : 10, + "operator" : "gte" + } ] + } + } + + """ + endpoint_tests_data_rounds_search = thousandeyes_sdk.endpoint_test_results.models.EndpointTestsDataRoundsSearch.from_json(request_body_json) + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.filter_scheduled_test_network_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + endpoint_tests_data_rounds_search=endpoint_tests_data_rounds_search, + + _headers=self.te_headers("filter_scheduled_test_network_results", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_filter_scheduled_test_network_results_error_502(self) -> None: + """Integration test for filter_scheduled_test_network_results error path (HTTP 502)""" + request_body_json = """ + + { + "searchSort" : [ { + "sort" : "round-id", + "order" : "desc" + }, { + "sort" : "round-id", + "order" : "desc" + } ], + "searchFilters" : { + "agentId" : [ "52455b09-ff1b-4849-8194-99026cc890e0", "52455b09-ff1b-4849-8194-99026cc890e0" ], + "userPrincipalName" : [ "joeblogs32@c.com", "joeblogs32@c.com" ] + }, + "thresholdFilter" : { + "conditionalOperator" : "and", + "filters" : [ { + "name" : "loss", + "value" : 10, + "operator" : "gte" + }, { + "name" : "loss", + "value" : 10, + "operator" : "gte" + } ] + } + } + + """ + endpoint_tests_data_rounds_search = thousandeyes_sdk.endpoint_test_results.models.EndpointTestsDataRoundsSearch.from_json(request_body_json) + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.filter_scheduled_test_network_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + endpoint_tests_data_rounds_search=endpoint_tests_data_rounds_search, + + _headers=self.te_headers("filter_scheduled_test_network_results", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_filter_scheduled_tests_network_results_happy_path(self) -> None: + """Integration test for filter_scheduled_tests_network_results success path""" + request_body_json = """ + + { + "searchSort" : [ { + "sort" : "round-id", + "order" : "desc" + }, { + "sort" : "round-id", + "order" : "desc" + } ], + "searchFilters" : { + "agentId" : [ "52455b09-ff1b-4849-8194-99026cc890e0", "52455b09-ff1b-4849-8194-99026cc890e0" ], + "testId" : [ "5", "5" ] + }, + "thresholdFilter" : { + "conditionalOperator" : "and", + "filters" : [ { + "name" : "loss", + "value" : 10, + "operator" : "gte" + }, { + "name" : "loss", + "value" : 10, + "operator" : "gte" + } ] + } + } + + """ + multi_test_id_endpoint_tests_data_rounds_search = thousandeyes_sdk.endpoint_test_results.models.MultiTestIdEndpointTestsDataRoundsSearch.from_json(request_body_json) + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + max = 5 + cursor = 'cursor_example' + use_all_permitted_aids = False + response_body_json = """ + { + "totalHits" : 12, + "endDate" : "2022-07-18T22:00:54Z", + "_links" : { + "next" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "results" : [ { + "originalTargetProfile" : { + "protocol" : "tcp", + "remotePort" : 80, + "remoteIpAddress" : "120.98.134.7" + }, + "agentId" : "861b7557-cd57-4bbb-b648-00bddf88ef49", + "isIcmpBlocked" : true, + "avgLatency" : 167.04, + "minLatency" : 167, + "vpnProfile" : { + "vpnClientNetworkRange" : [ "9.88.37.27", "9.88.37.27" ], + "vpnGatewayAddress" : "120.98.134.7", + "vpnType" : "cisco-anyconnect", + "vpnClientAddresses" : [ "184.81.113.85", "13.129.91.62" ] + }, + "maxLatency" : 168, + "batteryMetrics" : { + "batteryHealthNormalizedPercent" : 0.92, + "batteryLevel" : "medium", + "batteryLevelNormalizedPercent" : 0.3 + }, + "userProfile" : { + "userName" : "joeblogs32", + "userPrincipalName" : "joeblogs32@c.com" + }, + "platform" : "mac", + "cellularProfile" : { + "rssi" : -10, + "advertisedNetworkSubtype" : "LTE/HSPA", + "carrierName" : "T-Mobile", + "rsrq" : -30, + "rsrp" : -30, + "advertisedNetworkGen" : "2g, 3g, 4g, 5g", + "rscp" : -30, + "networkGen" : "2g, 3g, 4g, 5g", + "networkSubtype" : "LTE/HSPA", + "sinr" : 20 + }, + "score" : { + "applicationScore" : 100, + "quality" : "great" + }, + "loss" : 0, + "systemMetrics" : { + "cpuUtilization" : { + "min" : 0.22, + "median" : 0.61, + "max" : 0.75, + "mean" : 0.55, + "count" : 150, + "stdDev" : 0.01 + }, + "physicalMemoryTotalBytes" : 1024, + "startTimeMs" : 1581508857327, + "physicalMemoryUsedBytes" : { + "min" : 1.2, + "median" : 1.85, + "max" : 2.5, + "mean" : 1.77, + "count" : 155, + "stdDev" : 0.25 + }, + "endTimeMs" : 1581508867333 + }, + "jitter" : 0.076808, + "serverIp" : "185.199.108.153", + "networkProfile" : { + "previousInterface" : { + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "interfaceName" : "en0", + "subnetMask" : "255.255.255.0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ] + }, + "ethernetProfile" : { + "linkSpeed" : 860 + }, + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "proxyProfile" : { + "method" : "System", + "proxies" : [ { + "bypass" : "*.local;169.254/16", + "proxy" : "" + }, { + "bypass" : "*.local;169.254/16", + "proxy" : "" + } ] + }, + "subnetMask" : "255.255.255.0", + "error" : "An operation timed out.", + "wirelessProfile" : { + "rssi" : -38, + "bssid" : "4c:ba:ba:f4:fa:fa", + "snr" : 57, + "vendor" : "Cisco", + "txRate" : 130, + "channel" : 1, + "noise" : -95, + "phyMode" : "802.11n", + "ssid" : "Internet for the masses", + "quality" : 100 + }, + "interfaceName" : "en0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ], + "gateway" : "10.0.0.1" + }, + "ztaMetrics" : [ { + "loss" : 50, + "jitter" : 5, + "avgLatency" : 3, + "errorMessage" : "ERR_NAME_NOT_RESOLVED", + "type" : "zta_service" + }, { + "loss" : 50, + "jitter" : 5, + "avgLatency" : 3, + "errorMessage" : "ERR_NAME_NOT_RESOLVED", + "type" : "zta_service" + } ], + "testId" : "584739201", + "aid" : "1234", + "roundId" : 1384309800, + "errorDetails" : "Error" + }, { + "originalTargetProfile" : { + "protocol" : "tcp", + "remotePort" : 80, + "remoteIpAddress" : "120.98.134.7" + }, + "agentId" : "861b7557-cd57-4bbb-b648-00bddf88ef49", + "isIcmpBlocked" : true, + "avgLatency" : 167.04, + "minLatency" : 167, + "vpnProfile" : { + "vpnClientNetworkRange" : [ "9.88.37.27", "9.88.37.27" ], + "vpnGatewayAddress" : "120.98.134.7", + "vpnType" : "cisco-anyconnect", + "vpnClientAddresses" : [ "184.81.113.85", "13.129.91.62" ] + }, + "maxLatency" : 168, + "batteryMetrics" : { + "batteryHealthNormalizedPercent" : 0.92, + "batteryLevel" : "medium", + "batteryLevelNormalizedPercent" : 0.3 + }, + "userProfile" : { + "userName" : "joeblogs32", + "userPrincipalName" : "joeblogs32@c.com" + }, + "platform" : "mac", + "cellularProfile" : { + "rssi" : -10, + "advertisedNetworkSubtype" : "LTE/HSPA", + "carrierName" : "T-Mobile", + "rsrq" : -30, + "rsrp" : -30, + "advertisedNetworkGen" : "2g, 3g, 4g, 5g", + "rscp" : -30, + "networkGen" : "2g, 3g, 4g, 5g", + "networkSubtype" : "LTE/HSPA", + "sinr" : 20 + }, + "score" : { + "applicationScore" : 100, + "quality" : "great" + }, + "loss" : 0, + "systemMetrics" : { + "cpuUtilization" : { + "min" : 0.22, + "median" : 0.61, + "max" : 0.75, + "mean" : 0.55, + "count" : 150, + "stdDev" : 0.01 + }, + "physicalMemoryTotalBytes" : 1024, + "startTimeMs" : 1581508857327, + "physicalMemoryUsedBytes" : { + "min" : 1.2, + "median" : 1.85, + "max" : 2.5, + "mean" : 1.77, + "count" : 155, + "stdDev" : 0.25 + }, + "endTimeMs" : 1581508867333 + }, + "jitter" : 0.076808, + "serverIp" : "185.199.108.153", + "networkProfile" : { + "previousInterface" : { + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "interfaceName" : "en0", + "subnetMask" : "255.255.255.0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ] + }, + "ethernetProfile" : { + "linkSpeed" : 860 + }, + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "proxyProfile" : { + "method" : "System", + "proxies" : [ { + "bypass" : "*.local;169.254/16", + "proxy" : "" + }, { + "bypass" : "*.local;169.254/16", + "proxy" : "" + } ] + }, + "subnetMask" : "255.255.255.0", + "error" : "An operation timed out.", + "wirelessProfile" : { + "rssi" : -38, + "bssid" : "4c:ba:ba:f4:fa:fa", + "snr" : 57, + "vendor" : "Cisco", + "txRate" : 130, + "channel" : 1, + "noise" : -95, + "phyMode" : "802.11n", + "ssid" : "Internet for the masses", + "quality" : 100 + }, + "interfaceName" : "en0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ], + "gateway" : "10.0.0.1" + }, + "ztaMetrics" : [ { + "loss" : 50, + "jitter" : 5, + "avgLatency" : 3, + "errorMessage" : "ERR_NAME_NOT_RESOLVED", + "type" : "zta_service" + }, { + "loss" : 50, + "jitter" : 5, + "avgLatency" : 3, + "errorMessage" : "ERR_NAME_NOT_RESOLVED", + "type" : "zta_service" + } ], + "testId" : "584739201", + "aid" : "1234", + "roundId" : 1384309800, + "errorDetails" : "Error" + } ], + "startDate" : "2022-07-17T22:00:54Z" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.filter_scheduled_tests_network_results( + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + max=max, + + cursor=cursor, + + use_all_permitted_aids=use_all_permitted_aids, + + multi_test_id_endpoint_tests_data_rounds_search=multi_test_id_endpoint_tests_data_rounds_search, + + _headers=self.te_headers("filter_scheduled_tests_network_results"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_filter_scheduled_tests_network_results_error_401(self) -> None: + """Integration test for filter_scheduled_tests_network_results error path (HTTP 401)""" + request_body_json = """ + + { + "searchSort" : [ { + "sort" : "round-id", + "order" : "desc" + }, { + "sort" : "round-id", + "order" : "desc" + } ], + "searchFilters" : { + "agentId" : [ "52455b09-ff1b-4849-8194-99026cc890e0", "52455b09-ff1b-4849-8194-99026cc890e0" ], + "testId" : [ "5", "5" ] + }, + "thresholdFilter" : { + "conditionalOperator" : "and", + "filters" : [ { + "name" : "loss", + "value" : 10, + "operator" : "gte" + }, { + "name" : "loss", + "value" : 10, + "operator" : "gte" + } ] + } + } + + """ + multi_test_id_endpoint_tests_data_rounds_search = thousandeyes_sdk.endpoint_test_results.models.MultiTestIdEndpointTestsDataRoundsSearch.from_json(request_body_json) + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + max = 5 + cursor = 'cursor_example' + use_all_permitted_aids = False + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.filter_scheduled_tests_network_results( + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + max=max, + + cursor=cursor, + + use_all_permitted_aids=use_all_permitted_aids, + + multi_test_id_endpoint_tests_data_rounds_search=multi_test_id_endpoint_tests_data_rounds_search, + + _headers=self.te_headers("filter_scheduled_tests_network_results", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_filter_scheduled_tests_network_results_error_403(self) -> None: + """Integration test for filter_scheduled_tests_network_results error path (HTTP 403)""" + request_body_json = """ + + { + "searchSort" : [ { + "sort" : "round-id", + "order" : "desc" + }, { + "sort" : "round-id", + "order" : "desc" + } ], + "searchFilters" : { + "agentId" : [ "52455b09-ff1b-4849-8194-99026cc890e0", "52455b09-ff1b-4849-8194-99026cc890e0" ], + "testId" : [ "5", "5" ] + }, + "thresholdFilter" : { + "conditionalOperator" : "and", + "filters" : [ { + "name" : "loss", + "value" : 10, + "operator" : "gte" + }, { + "name" : "loss", + "value" : 10, + "operator" : "gte" + } ] + } + } + + """ + multi_test_id_endpoint_tests_data_rounds_search = thousandeyes_sdk.endpoint_test_results.models.MultiTestIdEndpointTestsDataRoundsSearch.from_json(request_body_json) + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + max = 5 + cursor = 'cursor_example' + use_all_permitted_aids = False + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.filter_scheduled_tests_network_results( + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + max=max, + + cursor=cursor, + + use_all_permitted_aids=use_all_permitted_aids, + + multi_test_id_endpoint_tests_data_rounds_search=multi_test_id_endpoint_tests_data_rounds_search, + + _headers=self.te_headers("filter_scheduled_tests_network_results", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_filter_scheduled_tests_network_results_error_404(self) -> None: + """Integration test for filter_scheduled_tests_network_results error path (HTTP 404)""" + request_body_json = """ + + { + "searchSort" : [ { + "sort" : "round-id", + "order" : "desc" + }, { + "sort" : "round-id", + "order" : "desc" + } ], + "searchFilters" : { + "agentId" : [ "52455b09-ff1b-4849-8194-99026cc890e0", "52455b09-ff1b-4849-8194-99026cc890e0" ], + "testId" : [ "5", "5" ] + }, + "thresholdFilter" : { + "conditionalOperator" : "and", + "filters" : [ { + "name" : "loss", + "value" : 10, + "operator" : "gte" + }, { + "name" : "loss", + "value" : 10, + "operator" : "gte" + } ] + } + } + + """ + multi_test_id_endpoint_tests_data_rounds_search = thousandeyes_sdk.endpoint_test_results.models.MultiTestIdEndpointTestsDataRoundsSearch.from_json(request_body_json) + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + max = 5 + cursor = 'cursor_example' + use_all_permitted_aids = False + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.filter_scheduled_tests_network_results( + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + max=max, + + cursor=cursor, + + use_all_permitted_aids=use_all_permitted_aids, + + multi_test_id_endpoint_tests_data_rounds_search=multi_test_id_endpoint_tests_data_rounds_search, + + _headers=self.te_headers("filter_scheduled_tests_network_results", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_filter_scheduled_tests_network_results_error_429(self) -> None: + """Integration test for filter_scheduled_tests_network_results error path (HTTP 429)""" + request_body_json = """ + + { + "searchSort" : [ { + "sort" : "round-id", + "order" : "desc" + }, { + "sort" : "round-id", + "order" : "desc" + } ], + "searchFilters" : { + "agentId" : [ "52455b09-ff1b-4849-8194-99026cc890e0", "52455b09-ff1b-4849-8194-99026cc890e0" ], + "testId" : [ "5", "5" ] + }, + "thresholdFilter" : { + "conditionalOperator" : "and", + "filters" : [ { + "name" : "loss", + "value" : 10, + "operator" : "gte" + }, { + "name" : "loss", + "value" : 10, + "operator" : "gte" + } ] + } + } + + """ + multi_test_id_endpoint_tests_data_rounds_search = thousandeyes_sdk.endpoint_test_results.models.MultiTestIdEndpointTestsDataRoundsSearch.from_json(request_body_json) + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + max = 5 + cursor = 'cursor_example' + use_all_permitted_aids = False + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.filter_scheduled_tests_network_results( + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + max=max, + + cursor=cursor, + + use_all_permitted_aids=use_all_permitted_aids, + + multi_test_id_endpoint_tests_data_rounds_search=multi_test_id_endpoint_tests_data_rounds_search, + + _headers=self.te_headers("filter_scheduled_tests_network_results", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_filter_scheduled_tests_network_results_error_500(self) -> None: + """Integration test for filter_scheduled_tests_network_results error path (HTTP 500)""" + request_body_json = """ + + { + "searchSort" : [ { + "sort" : "round-id", + "order" : "desc" + }, { + "sort" : "round-id", + "order" : "desc" + } ], + "searchFilters" : { + "agentId" : [ "52455b09-ff1b-4849-8194-99026cc890e0", "52455b09-ff1b-4849-8194-99026cc890e0" ], + "testId" : [ "5", "5" ] + }, + "thresholdFilter" : { + "conditionalOperator" : "and", + "filters" : [ { + "name" : "loss", + "value" : 10, + "operator" : "gte" + }, { + "name" : "loss", + "value" : 10, + "operator" : "gte" + } ] + } + } + + """ + multi_test_id_endpoint_tests_data_rounds_search = thousandeyes_sdk.endpoint_test_results.models.MultiTestIdEndpointTestsDataRoundsSearch.from_json(request_body_json) + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + max = 5 + cursor = 'cursor_example' + use_all_permitted_aids = False + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.filter_scheduled_tests_network_results( + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + max=max, + + cursor=cursor, + + use_all_permitted_aids=use_all_permitted_aids, + + multi_test_id_endpoint_tests_data_rounds_search=multi_test_id_endpoint_tests_data_rounds_search, + + _headers=self.te_headers("filter_scheduled_tests_network_results", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_filter_scheduled_tests_network_results_error_502(self) -> None: + """Integration test for filter_scheduled_tests_network_results error path (HTTP 502)""" + request_body_json = """ + + { + "searchSort" : [ { + "sort" : "round-id", + "order" : "desc" + }, { + "sort" : "round-id", + "order" : "desc" + } ], + "searchFilters" : { + "agentId" : [ "52455b09-ff1b-4849-8194-99026cc890e0", "52455b09-ff1b-4849-8194-99026cc890e0" ], + "testId" : [ "5", "5" ] + }, + "thresholdFilter" : { + "conditionalOperator" : "and", + "filters" : [ { + "name" : "loss", + "value" : 10, + "operator" : "gte" + }, { + "name" : "loss", + "value" : 10, + "operator" : "gte" + } ] + } + } + + """ + multi_test_id_endpoint_tests_data_rounds_search = thousandeyes_sdk.endpoint_test_results.models.MultiTestIdEndpointTestsDataRoundsSearch.from_json(request_body_json) + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + max = 5 + cursor = 'cursor_example' + use_all_permitted_aids = False + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.filter_scheduled_tests_network_results( + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + max=max, + + cursor=cursor, + + use_all_permitted_aids=use_all_permitted_aids, + + multi_test_id_endpoint_tests_data_rounds_search=multi_test_id_endpoint_tests_data_rounds_search, + + _headers=self.te_headers("filter_scheduled_tests_network_results", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_scheduled_test_path_vis_agent_round_results_happy_path(self) -> None: + """Integration test for get_scheduled_test_path_vis_agent_round_results success path""" + test_id = '202701' + agent_id = '11' + round_id = '1384309800' + aid = '1234' + response_body_json = """ + { + "test" : { + "server" : "www.example.com", + "isSavedEvent" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/scheduled-tests/281474976710706/network/filter" + }, { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/scheduled-tests/281474976710706/pathvis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isPrioritized" : false, + "networkMeasurements" : true, + "type" : "agent-to-server", + "tcpProbeMode" : "auto", + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "protocol" : "icmp", + "createdDate" : "2022-07-17T22:00:54Z", + "ipVersion" : "V4_ONLY", + "port" : 443, + "isEnabled" : true, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "aid" : "1234", + "agentSelectorConfig" : { + "agentSelectorType" : "all-agents", + "maxMachines" : 25 + }, + "hasPathTraceInSession" : true, + "testName" : "Test name" + }, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "results" : [ { + "originalTargetProfile" : { + "protocol" : "tcp", + "remotePort" : 80, + "remoteIpAddress" : "120.98.134.7" + }, + "server" : "www.google.com:443", + "agentId" : "861b7557-cd57-4bbb-b648-00bddf88ef49", + "asnDetails" : { + "asName" : "ThousandEyes, Inc", + "asNumber" : 394101 + }, + "vpnProfile" : { + "vpnClientNetworkRange" : [ "9.88.37.27", "9.88.37.27" ], + "vpnGatewayAddress" : "120.98.134.7", + "vpnType" : "cisco-anyconnect", + "vpnClientAddresses" : [ "184.81.113.85", "13.129.91.62" ] + }, + "batteryMetrics" : { + "batteryHealthNormalizedPercent" : 0.92, + "batteryLevel" : "medium", + "batteryLevelNormalizedPercent" : 0.3 + }, + "sourcePrefix" : "196.40.96.0/20", + "userProfile" : { + "userName" : "joeblogs32", + "userPrincipalName" : "joeblogs32@c.com" + }, + "platform" : "mac", + "cellularProfile" : { + "rssi" : -10, + "advertisedNetworkSubtype" : "LTE/HSPA", + "carrierName" : "T-Mobile", + "rsrq" : -30, + "rsrp" : -30, + "advertisedNetworkGen" : "2g, 3g, 4g, 5g", + "rscp" : -30, + "networkGen" : "2g, 3g, 4g, 5g", + "networkSubtype" : "LTE/HSPA", + "sinr" : 20 + }, + "systemMetrics" : { + "cpuUtilization" : { + "min" : 0.22, + "median" : 0.61, + "max" : 0.75, + "mean" : 0.55, + "count" : 150, + "stdDev" : 0.01 + }, + "physicalMemoryTotalBytes" : 1024, + "startTimeMs" : 1581508857327, + "physicalMemoryUsedBytes" : { + "min" : 1.2, + "median" : 1.85, + "max" : 2.5, + "mean" : 1.77, + "count" : 155, + "stdDev" : 0.25 + }, + "endTimeMs" : 1581508867333 + }, + "sourceIp" : "196.40.106.237", + "pathTraces" : [ { + "protocol" : "tcp", + "udpPathTraceMode" : "unknown", + "hops" : [ { + "rdns" : "core-router1.cpt2.host-h.net", + "prefix" : "196.40.96.0/20", + "responseTime" : 1, + "hop" : 1, + "ipAddress" : "196.40.106.237", + "location" : "Cape Town, South Africa", + "network" : "HETZNER (Pty) Ltd (AS 37153)" + }, { + "rdns" : "core-router1.cpt2.host-h.net", + "prefix" : "196.40.96.0/20", + "responseTime" : 1, + "hop" : 1, + "ipAddress" : "196.40.106.237", + "location" : "Cape Town, South Africa", + "network" : "HETZNER (Pty) Ltd (AS 37153)" + } ], + "pathId" : "4711301366345855606023718047703941305741293841502186803", + "tcpPathTraceMode" : "syn-pcap" + }, { + "protocol" : "tcp", + "udpPathTraceMode" : "unknown", + "hops" : [ { + "rdns" : "core-router1.cpt2.host-h.net", + "prefix" : "196.40.96.0/20", + "responseTime" : 1, + "hop" : 1, + "ipAddress" : "196.40.106.237", + "location" : "Cape Town, South Africa", + "network" : "HETZNER (Pty) Ltd (AS 37153)" + }, { + "rdns" : "core-router1.cpt2.host-h.net", + "prefix" : "196.40.96.0/20", + "responseTime" : 1, + "hop" : 1, + "ipAddress" : "196.40.106.237", + "location" : "Cape Town, South Africa", + "network" : "HETZNER (Pty) Ltd (AS 37153)" + } ], + "pathId" : "4711301366345855606023718047703941305741293841502186803", + "tcpPathTraceMode" : "syn-pcap" + } ], + "vpnPathTraces" : [ { + "protocol" : "tcp", + "udpPathTraceMode" : "unknown", + "hops" : [ { + "rdns" : "core-router1.cpt2.host-h.net", + "prefix" : "196.40.96.0/20", + "responseTime" : 1, + "hop" : 1, + "ipAddress" : "196.40.106.237", + "location" : "Cape Town, South Africa", + "network" : "HETZNER (Pty) Ltd (AS 37153)" + }, { + "rdns" : "core-router1.cpt2.host-h.net", + "prefix" : "196.40.96.0/20", + "responseTime" : 1, + "hop" : 1, + "ipAddress" : "196.40.106.237", + "location" : "Cape Town, South Africa", + "network" : "HETZNER (Pty) Ltd (AS 37153)" + } ], + "pathId" : "4711301366345855606023718047703941305741293841502186803", + "tcpPathTraceMode" : "syn-pcap" + }, { + "protocol" : "tcp", + "udpPathTraceMode" : "unknown", + "hops" : [ { + "rdns" : "core-router1.cpt2.host-h.net", + "prefix" : "196.40.96.0/20", + "responseTime" : 1, + "hop" : 1, + "ipAddress" : "196.40.106.237", + "location" : "Cape Town, South Africa", + "network" : "HETZNER (Pty) Ltd (AS 37153)" + }, { + "rdns" : "core-router1.cpt2.host-h.net", + "prefix" : "196.40.96.0/20", + "responseTime" : 1, + "hop" : 1, + "ipAddress" : "196.40.106.237", + "location" : "Cape Town, South Africa", + "network" : "HETZNER (Pty) Ltd (AS 37153)" + } ], + "pathId" : "4711301366345855606023718047703941305741293841502186803", + "tcpPathTraceMode" : "syn-pcap" + } ], + "serverIp" : "185.199.108.153", + "networkProfile" : { + "previousInterface" : { + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "interfaceName" : "en0", + "subnetMask" : "255.255.255.0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ] + }, + "ethernetProfile" : { + "linkSpeed" : 860 + }, + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "proxyProfile" : { + "method" : "System", + "proxies" : [ { + "bypass" : "*.local;169.254/16", + "proxy" : "" + }, { + "bypass" : "*.local;169.254/16", + "proxy" : "" + } ] + }, + "subnetMask" : "255.255.255.0", + "error" : "An operation timed out.", + "wirelessProfile" : { + "rssi" : -38, + "bssid" : "4c:ba:ba:f4:fa:fa", + "snr" : 57, + "vendor" : "Cisco", + "txRate" : 130, + "channel" : 1, + "noise" : -95, + "phyMode" : "802.11n", + "ssid" : "Internet for the masses", + "quality" : 100 + }, + "interfaceName" : "en0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ], + "gateway" : "10.0.0.1" + }, + "testId" : "584739201", + "aid" : "1234", + "roundId" : 1384309800 + }, { + "originalTargetProfile" : { + "protocol" : "tcp", + "remotePort" : 80, + "remoteIpAddress" : "120.98.134.7" + }, + "server" : "www.google.com:443", + "agentId" : "861b7557-cd57-4bbb-b648-00bddf88ef49", + "asnDetails" : { + "asName" : "ThousandEyes, Inc", + "asNumber" : 394101 + }, + "vpnProfile" : { + "vpnClientNetworkRange" : [ "9.88.37.27", "9.88.37.27" ], + "vpnGatewayAddress" : "120.98.134.7", + "vpnType" : "cisco-anyconnect", + "vpnClientAddresses" : [ "184.81.113.85", "13.129.91.62" ] + }, + "batteryMetrics" : { + "batteryHealthNormalizedPercent" : 0.92, + "batteryLevel" : "medium", + "batteryLevelNormalizedPercent" : 0.3 + }, + "sourcePrefix" : "196.40.96.0/20", + "userProfile" : { + "userName" : "joeblogs32", + "userPrincipalName" : "joeblogs32@c.com" + }, + "platform" : "mac", + "cellularProfile" : { + "rssi" : -10, + "advertisedNetworkSubtype" : "LTE/HSPA", + "carrierName" : "T-Mobile", + "rsrq" : -30, + "rsrp" : -30, + "advertisedNetworkGen" : "2g, 3g, 4g, 5g", + "rscp" : -30, + "networkGen" : "2g, 3g, 4g, 5g", + "networkSubtype" : "LTE/HSPA", + "sinr" : 20 + }, + "systemMetrics" : { + "cpuUtilization" : { + "min" : 0.22, + "median" : 0.61, + "max" : 0.75, + "mean" : 0.55, + "count" : 150, + "stdDev" : 0.01 + }, + "physicalMemoryTotalBytes" : 1024, + "startTimeMs" : 1581508857327, + "physicalMemoryUsedBytes" : { + "min" : 1.2, + "median" : 1.85, + "max" : 2.5, + "mean" : 1.77, + "count" : 155, + "stdDev" : 0.25 + }, + "endTimeMs" : 1581508867333 + }, + "sourceIp" : "196.40.106.237", + "pathTraces" : [ { + "protocol" : "tcp", + "udpPathTraceMode" : "unknown", + "hops" : [ { + "rdns" : "core-router1.cpt2.host-h.net", + "prefix" : "196.40.96.0/20", + "responseTime" : 1, + "hop" : 1, + "ipAddress" : "196.40.106.237", + "location" : "Cape Town, South Africa", + "network" : "HETZNER (Pty) Ltd (AS 37153)" + }, { + "rdns" : "core-router1.cpt2.host-h.net", + "prefix" : "196.40.96.0/20", + "responseTime" : 1, + "hop" : 1, + "ipAddress" : "196.40.106.237", + "location" : "Cape Town, South Africa", + "network" : "HETZNER (Pty) Ltd (AS 37153)" + } ], + "pathId" : "4711301366345855606023718047703941305741293841502186803", + "tcpPathTraceMode" : "syn-pcap" + }, { + "protocol" : "tcp", + "udpPathTraceMode" : "unknown", + "hops" : [ { + "rdns" : "core-router1.cpt2.host-h.net", + "prefix" : "196.40.96.0/20", + "responseTime" : 1, + "hop" : 1, + "ipAddress" : "196.40.106.237", + "location" : "Cape Town, South Africa", + "network" : "HETZNER (Pty) Ltd (AS 37153)" + }, { + "rdns" : "core-router1.cpt2.host-h.net", + "prefix" : "196.40.96.0/20", + "responseTime" : 1, + "hop" : 1, + "ipAddress" : "196.40.106.237", + "location" : "Cape Town, South Africa", + "network" : "HETZNER (Pty) Ltd (AS 37153)" + } ], + "pathId" : "4711301366345855606023718047703941305741293841502186803", + "tcpPathTraceMode" : "syn-pcap" + } ], + "vpnPathTraces" : [ { + "protocol" : "tcp", + "udpPathTraceMode" : "unknown", + "hops" : [ { + "rdns" : "core-router1.cpt2.host-h.net", + "prefix" : "196.40.96.0/20", + "responseTime" : 1, + "hop" : 1, + "ipAddress" : "196.40.106.237", + "location" : "Cape Town, South Africa", + "network" : "HETZNER (Pty) Ltd (AS 37153)" + }, { + "rdns" : "core-router1.cpt2.host-h.net", + "prefix" : "196.40.96.0/20", + "responseTime" : 1, + "hop" : 1, + "ipAddress" : "196.40.106.237", + "location" : "Cape Town, South Africa", + "network" : "HETZNER (Pty) Ltd (AS 37153)" + } ], + "pathId" : "4711301366345855606023718047703941305741293841502186803", + "tcpPathTraceMode" : "syn-pcap" + }, { + "protocol" : "tcp", + "udpPathTraceMode" : "unknown", + "hops" : [ { + "rdns" : "core-router1.cpt2.host-h.net", + "prefix" : "196.40.96.0/20", + "responseTime" : 1, + "hop" : 1, + "ipAddress" : "196.40.106.237", + "location" : "Cape Town, South Africa", + "network" : "HETZNER (Pty) Ltd (AS 37153)" + }, { + "rdns" : "core-router1.cpt2.host-h.net", + "prefix" : "196.40.96.0/20", + "responseTime" : 1, + "hop" : 1, + "ipAddress" : "196.40.106.237", + "location" : "Cape Town, South Africa", + "network" : "HETZNER (Pty) Ltd (AS 37153)" + } ], + "pathId" : "4711301366345855606023718047703941305741293841502186803", + "tcpPathTraceMode" : "syn-pcap" + } ], + "serverIp" : "185.199.108.153", + "networkProfile" : { + "previousInterface" : { + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "interfaceName" : "en0", + "subnetMask" : "255.255.255.0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ] + }, + "ethernetProfile" : { + "linkSpeed" : 860 + }, + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "proxyProfile" : { + "method" : "System", + "proxies" : [ { + "bypass" : "*.local;169.254/16", + "proxy" : "" + }, { + "bypass" : "*.local;169.254/16", + "proxy" : "" + } ] + }, + "subnetMask" : "255.255.255.0", + "error" : "An operation timed out.", + "wirelessProfile" : { + "rssi" : -38, + "bssid" : "4c:ba:ba:f4:fa:fa", + "snr" : 57, + "vendor" : "Cisco", + "txRate" : 130, + "channel" : 1, + "noise" : -95, + "phyMode" : "802.11n", + "ssid" : "Internet for the masses", + "quality" : 100 + }, + "interfaceName" : "en0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ], + "gateway" : "10.0.0.1" + }, + "testId" : "584739201", + "aid" : "1234", + "roundId" : 1384309800 + } ] + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_scheduled_test_path_vis_agent_round_results( + + test_id=test_id, + + agent_id=agent_id, + + round_id=round_id, + + aid=aid, + + _headers=self.te_headers("get_scheduled_test_path_vis_agent_round_results"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_scheduled_test_path_vis_agent_round_results_error_401(self) -> None: + """Integration test for get_scheduled_test_path_vis_agent_round_results error path (HTTP 401)""" + test_id = '202701' + agent_id = '11' + round_id = '1384309800' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_scheduled_test_path_vis_agent_round_results( + + test_id=test_id, + + agent_id=agent_id, + + round_id=round_id, + + aid=aid, + + _headers=self.te_headers("get_scheduled_test_path_vis_agent_round_results", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_scheduled_test_path_vis_agent_round_results_error_403(self) -> None: + """Integration test for get_scheduled_test_path_vis_agent_round_results error path (HTTP 403)""" + test_id = '202701' + agent_id = '11' + round_id = '1384309800' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_scheduled_test_path_vis_agent_round_results( + + test_id=test_id, + + agent_id=agent_id, + + round_id=round_id, + + aid=aid, + + _headers=self.te_headers("get_scheduled_test_path_vis_agent_round_results", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_scheduled_test_path_vis_agent_round_results_error_404(self) -> None: + """Integration test for get_scheduled_test_path_vis_agent_round_results error path (HTTP 404)""" + test_id = '202701' + agent_id = '11' + round_id = '1384309800' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_scheduled_test_path_vis_agent_round_results( + + test_id=test_id, + + agent_id=agent_id, + + round_id=round_id, + + aid=aid, + + _headers=self.te_headers("get_scheduled_test_path_vis_agent_round_results", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_scheduled_test_path_vis_agent_round_results_error_429(self) -> None: + """Integration test for get_scheduled_test_path_vis_agent_round_results error path (HTTP 429)""" + test_id = '202701' + agent_id = '11' + round_id = '1384309800' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_scheduled_test_path_vis_agent_round_results( + + test_id=test_id, + + agent_id=agent_id, + + round_id=round_id, + + aid=aid, + + _headers=self.te_headers("get_scheduled_test_path_vis_agent_round_results", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_scheduled_test_path_vis_agent_round_results_error_500(self) -> None: + """Integration test for get_scheduled_test_path_vis_agent_round_results error path (HTTP 500)""" + test_id = '202701' + agent_id = '11' + round_id = '1384309800' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_scheduled_test_path_vis_agent_round_results( + + test_id=test_id, + + agent_id=agent_id, + + round_id=round_id, + + aid=aid, + + _headers=self.te_headers("get_scheduled_test_path_vis_agent_round_results", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_scheduled_test_path_vis_agent_round_results_error_502(self) -> None: + """Integration test for get_scheduled_test_path_vis_agent_round_results error path (HTTP 502)""" + test_id = '202701' + agent_id = '11' + round_id = '1384309800' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.get_scheduled_test_path_vis_agent_round_results( + + test_id=test_id, + + agent_id=agent_id, + + round_id=round_id, + + aid=aid, + + _headers=self.te_headers("get_scheduled_test_path_vis_agent_round_results", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_scheduled_test_path_vis_results_happy_path(self) -> None: + """Integration test for get_scheduled_test_path_vis_results success path""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + response_body_json = """ + { + "test" : { + "server" : "www.example.com", + "isSavedEvent" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/scheduled-tests/281474976710706/network/filter" + }, { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/scheduled-tests/281474976710706/pathvis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isPrioritized" : false, + "networkMeasurements" : true, + "type" : "agent-to-server", + "tcpProbeMode" : "auto", + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "protocol" : "icmp", + "createdDate" : "2022-07-17T22:00:54Z", + "ipVersion" : "V4_ONLY", + "port" : 443, + "isEnabled" : true, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "aid" : "1234", + "agentSelectorConfig" : { + "agentSelectorType" : "all-agents", + "maxMachines" : 25 + }, + "hasPathTraceInSession" : true, + "testName" : "Test name" + }, + "endDate" : "2022-07-18T22:00:54Z", + "_links" : { + "next" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "results" : [ { + "originalTargetProfile" : { + "protocol" : "tcp", + "remotePort" : 80, + "remoteIpAddress" : "120.98.134.7" + }, + "server" : "www.google.com:443", + "agentId" : "861b7557-cd57-4bbb-b648-00bddf88ef49", + "asnDetails" : { + "asName" : "ThousandEyes, Inc", + "asNumber" : 394101 + }, + "vpnProfile" : { + "vpnClientNetworkRange" : [ "9.88.37.27", "9.88.37.27" ], + "vpnGatewayAddress" : "120.98.134.7", + "vpnType" : "cisco-anyconnect", + "vpnClientAddresses" : [ "184.81.113.85", "13.129.91.62" ] + }, + "batteryMetrics" : { + "batteryHealthNormalizedPercent" : 0.92, + "batteryLevel" : "medium", + "batteryLevelNormalizedPercent" : 0.3 + }, + "sourcePrefix" : "196.40.96.0/20", + "userProfile" : { + "userName" : "joeblogs32", + "userPrincipalName" : "joeblogs32@c.com" + }, + "platform" : "mac", + "cellularProfile" : { + "rssi" : -10, + "advertisedNetworkSubtype" : "LTE/HSPA", + "carrierName" : "T-Mobile", + "rsrq" : -30, + "rsrp" : -30, + "advertisedNetworkGen" : "2g, 3g, 4g, 5g", + "rscp" : -30, + "networkGen" : "2g, 3g, 4g, 5g", + "networkSubtype" : "LTE/HSPA", + "sinr" : 20 + }, + "systemMetrics" : { + "cpuUtilization" : { + "min" : 0.22, + "median" : 0.61, + "max" : 0.75, + "mean" : 0.55, + "count" : 150, + "stdDev" : 0.01 + }, + "physicalMemoryTotalBytes" : 1024, + "startTimeMs" : 1581508857327, + "physicalMemoryUsedBytes" : { + "min" : 1.2, + "median" : 1.85, + "max" : 2.5, + "mean" : 1.77, + "count" : 155, + "stdDev" : 0.25 + }, + "endTimeMs" : 1581508867333 + }, + "sourceIp" : "196.40.106.237", + "pathTraces" : [ { + "protocol" : "tcp", + "numberOfHops" : 15, + "responseTime" : 1500, + "ipAddress" : "196.40.106.237", + "udpPathTraceMode" : "unknown", + "pathId" : "1230899668701775614109128428722974545787322404682781961521", + "tcpPathTraceMode" : "syn-pcap" + }, { + "protocol" : "tcp", + "numberOfHops" : 15, + "responseTime" : 1500, + "ipAddress" : "196.40.106.237", + "udpPathTraceMode" : "unknown", + "pathId" : "1230899668701775614109128428722974545787322404682781961521", + "tcpPathTraceMode" : "syn-pcap" + } ], + "serverIp" : "185.199.108.153", + "networkProfile" : { + "previousInterface" : { + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "interfaceName" : "en0", + "subnetMask" : "255.255.255.0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ] + }, + "ethernetProfile" : { + "linkSpeed" : 860 + }, + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "proxyProfile" : { + "method" : "System", + "proxies" : [ { + "bypass" : "*.local;169.254/16", + "proxy" : "" + }, { + "bypass" : "*.local;169.254/16", + "proxy" : "" + } ] + }, + "subnetMask" : "255.255.255.0", + "error" : "An operation timed out.", + "wirelessProfile" : { + "rssi" : -38, + "bssid" : "4c:ba:ba:f4:fa:fa", + "snr" : 57, + "vendor" : "Cisco", + "txRate" : 130, + "channel" : 1, + "noise" : -95, + "phyMode" : "802.11n", + "ssid" : "Internet for the masses", + "quality" : 100 + }, + "interfaceName" : "en0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ], + "gateway" : "10.0.0.1" + }, + "testId" : "584739201", + "location" : "San Francisco Area", + "aid" : "1234", + "roundId" : 1384309800 + }, { + "originalTargetProfile" : { + "protocol" : "tcp", + "remotePort" : 80, + "remoteIpAddress" : "120.98.134.7" + }, + "server" : "www.google.com:443", + "agentId" : "861b7557-cd57-4bbb-b648-00bddf88ef49", + "asnDetails" : { + "asName" : "ThousandEyes, Inc", + "asNumber" : 394101 + }, + "vpnProfile" : { + "vpnClientNetworkRange" : [ "9.88.37.27", "9.88.37.27" ], + "vpnGatewayAddress" : "120.98.134.7", + "vpnType" : "cisco-anyconnect", + "vpnClientAddresses" : [ "184.81.113.85", "13.129.91.62" ] + }, + "batteryMetrics" : { + "batteryHealthNormalizedPercent" : 0.92, + "batteryLevel" : "medium", + "batteryLevelNormalizedPercent" : 0.3 + }, + "sourcePrefix" : "196.40.96.0/20", + "userProfile" : { + "userName" : "joeblogs32", + "userPrincipalName" : "joeblogs32@c.com" + }, + "platform" : "mac", + "cellularProfile" : { + "rssi" : -10, + "advertisedNetworkSubtype" : "LTE/HSPA", + "carrierName" : "T-Mobile", + "rsrq" : -30, + "rsrp" : -30, + "advertisedNetworkGen" : "2g, 3g, 4g, 5g", + "rscp" : -30, + "networkGen" : "2g, 3g, 4g, 5g", + "networkSubtype" : "LTE/HSPA", + "sinr" : 20 + }, + "systemMetrics" : { + "cpuUtilization" : { + "min" : 0.22, + "median" : 0.61, + "max" : 0.75, + "mean" : 0.55, + "count" : 150, + "stdDev" : 0.01 + }, + "physicalMemoryTotalBytes" : 1024, + "startTimeMs" : 1581508857327, + "physicalMemoryUsedBytes" : { + "min" : 1.2, + "median" : 1.85, + "max" : 2.5, + "mean" : 1.77, + "count" : 155, + "stdDev" : 0.25 + }, + "endTimeMs" : 1581508867333 + }, + "sourceIp" : "196.40.106.237", + "pathTraces" : [ { + "protocol" : "tcp", + "numberOfHops" : 15, + "responseTime" : 1500, + "ipAddress" : "196.40.106.237", + "udpPathTraceMode" : "unknown", + "pathId" : "1230899668701775614109128428722974545787322404682781961521", + "tcpPathTraceMode" : "syn-pcap" + }, { + "protocol" : "tcp", + "numberOfHops" : 15, + "responseTime" : 1500, + "ipAddress" : "196.40.106.237", + "udpPathTraceMode" : "unknown", + "pathId" : "1230899668701775614109128428722974545787322404682781961521", + "tcpPathTraceMode" : "syn-pcap" + } ], + "serverIp" : "185.199.108.153", + "networkProfile" : { + "previousInterface" : { + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "interfaceName" : "en0", + "subnetMask" : "255.255.255.0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ] + }, + "ethernetProfile" : { + "linkSpeed" : 860 + }, + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "proxyProfile" : { + "method" : "System", + "proxies" : [ { + "bypass" : "*.local;169.254/16", + "proxy" : "" + }, { + "bypass" : "*.local;169.254/16", + "proxy" : "" + } ] + }, + "subnetMask" : "255.255.255.0", + "error" : "An operation timed out.", + "wirelessProfile" : { + "rssi" : -38, + "bssid" : "4c:ba:ba:f4:fa:fa", + "snr" : 57, + "vendor" : "Cisco", + "txRate" : 130, + "channel" : 1, + "noise" : -95, + "phyMode" : "802.11n", + "ssid" : "Internet for the masses", + "quality" : 100 + }, + "interfaceName" : "en0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ], + "gateway" : "10.0.0.1" + }, + "testId" : "584739201", + "location" : "San Francisco Area", + "aid" : "1234", + "roundId" : 1384309800 + } ], + "startDate" : "2022-07-17T22:00:54Z" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_scheduled_test_path_vis_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_scheduled_test_path_vis_results"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_scheduled_test_path_vis_results_error_401(self) -> None: + """Integration test for get_scheduled_test_path_vis_results error path (HTTP 401)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_scheduled_test_path_vis_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_scheduled_test_path_vis_results", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_scheduled_test_path_vis_results_error_403(self) -> None: + """Integration test for get_scheduled_test_path_vis_results error path (HTTP 403)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_scheduled_test_path_vis_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_scheduled_test_path_vis_results", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_scheduled_test_path_vis_results_error_404(self) -> None: + """Integration test for get_scheduled_test_path_vis_results error path (HTTP 404)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_scheduled_test_path_vis_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_scheduled_test_path_vis_results", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_scheduled_test_path_vis_results_error_429(self) -> None: + """Integration test for get_scheduled_test_path_vis_results error path (HTTP 429)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_scheduled_test_path_vis_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_scheduled_test_path_vis_results", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_scheduled_test_path_vis_results_error_500(self) -> None: + """Integration test for get_scheduled_test_path_vis_results error path (HTTP 500)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_scheduled_test_path_vis_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_scheduled_test_path_vis_results", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_scheduled_test_path_vis_results_error_502(self) -> None: + """Integration test for get_scheduled_test_path_vis_results error path (HTTP 502)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.get_scheduled_test_path_vis_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_scheduled_test_path_vis_results", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-endpoint-test-results/test/test_real_user_endpoint_test_results_api_integration.py b/thousandeyes-sdk-endpoint-test-results/test/test_real_user_endpoint_test_results_api_integration.py new file mode 100644 index 00000000..1b69c9a9 --- /dev/null +++ b/thousandeyes-sdk-endpoint-test-results/test/test_real_user_endpoint_test_results_api_integration.py @@ -0,0 +1,2771 @@ +# coding: utf-8 + +""" + Endpoint Test Results API + + Retrieve results for scheduled and dynamic tests on endpoint agents. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.endpoint_test_results.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.endpoint_test_results.api.real_user_endpoint_test_results_api import RealUserEndpointTestResultsApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestRealUserEndpointTestResultsApiIntegration(IntegrationTestBase): + """RealUserEndpointTestResultsApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = RealUserEndpointTestResultsApi(self.api_client) + + + def test_filter_real_user_tests_network_results_happy_path(self) -> None: + """Integration test for filter_real_user_tests_network_results success path""" + request_body_json = """ + + { + "searchFilters" : { + "agentId" : [ "3fde6422-f119-40e1-ae32-d08a1243c038", "236e6f18-9637-4a2f-b15f-7aa6a29c9fce" ], + "bssid" : [ "8c:68:c8:a5:0a:8c", "0c:51:01:e4:3e:d0" ], + "visitedSite" : [ "app.thousandeyes.com" ], + "trigger" : [ "user" ], + "ssid" : [ "wifi-name", "other-room-wifi" ], + "platform" : [ "mac", "mac" ], + "proxyTarget" : [ "78.153.54.204", "78.153.54.206" ], + "destinationIp" : [ "84.255.241.1", "193.2.1.88" ], + "domain" : [ "thousandeyes.com" ], + "location" : [ "San Francisco Bay Area", "Germany" ], + "connection" : [ "wireless", "wireless" ], + "vpnTarget" : [ "78.153.54.204", "78.153.54.206" ], + "networkId" : [ "660b34109d12", "660b34109d15" ], + "gateway" : [ "78.153.54.204", "78.153.54.206" ] + } + } + + """ + real_user_endpoint_test_results_request = thousandeyes_sdk.endpoint_test_results.models.RealUserEndpointTestResultsRequest.from_json(request_body_json) + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + response_body_json = """ + { + "endDate" : "2022-07-18T22:00:54Z", + "_links" : { + "next" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "results" : [ { + "date" : "2022-07-17T22:00:54Z", + "proxy" : { + "loss" : 0.1, + "jitter" : 46, + "latency" : 150, + "target" : "54.208.6.220" + }, + "agentId" : "861b7557-cd57-4bbb-b648-00bddf88ef49", + "systemMetrics" : { + "cpuUtilization" : { + "min" : 0.22, + "median" : 0.61, + "max" : 0.75, + "mean" : 0.55, + "count" : 150, + "stdDev" : 0.01 + }, + "physicalMemoryTotalBytes" : 1024, + "startTimeMs" : 1581508857327, + "physicalMemoryUsedBytes" : { + "min" : 1.2, + "median" : 1.85, + "max" : 2.5, + "mean" : 1.77, + "count" : 155, + "stdDev" : 0.25 + }, + "endTimeMs" : 1581508867333 + }, + "vpn" : { + "loss" : 0.1, + "jitter" : 46, + "latency" : 150, + "target" : "54.208.6.220" + }, + "destination" : { + "loss" : 0.1, + "jitter" : 46, + "latency" : 150, + "target" : "54.208.6.220" + }, + "id" : "07625:1490529480:aVDViw0i", + "roundId" : 1384309800 + }, { + "date" : "2022-07-17T22:00:54Z", + "proxy" : { + "loss" : 0.1, + "jitter" : 46, + "latency" : 150, + "target" : "54.208.6.220" + }, + "agentId" : "861b7557-cd57-4bbb-b648-00bddf88ef49", + "systemMetrics" : { + "cpuUtilization" : { + "min" : 0.22, + "median" : 0.61, + "max" : 0.75, + "mean" : 0.55, + "count" : 150, + "stdDev" : 0.01 + }, + "physicalMemoryTotalBytes" : 1024, + "startTimeMs" : 1581508857327, + "physicalMemoryUsedBytes" : { + "min" : 1.2, + "median" : 1.85, + "max" : 2.5, + "mean" : 1.77, + "count" : 155, + "stdDev" : 0.25 + }, + "endTimeMs" : 1581508867333 + }, + "vpn" : { + "loss" : 0.1, + "jitter" : 46, + "latency" : 150, + "target" : "54.208.6.220" + }, + "destination" : { + "loss" : 0.1, + "jitter" : 46, + "latency" : 150, + "target" : "54.208.6.220" + }, + "id" : "07625:1490529480:aVDViw0i", + "roundId" : 1384309800 + } ], + "startDate" : "2022-07-17T22:00:54Z" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.filter_real_user_tests_network_results( + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + real_user_endpoint_test_results_request=real_user_endpoint_test_results_request, + + _headers=self.te_headers("filter_real_user_tests_network_results"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_filter_real_user_tests_network_results_error_400(self) -> None: + """Integration test for filter_real_user_tests_network_results error path (HTTP 400)""" + request_body_json = """ + + { + "searchFilters" : { + "agentId" : [ "3fde6422-f119-40e1-ae32-d08a1243c038", "236e6f18-9637-4a2f-b15f-7aa6a29c9fce" ], + "bssid" : [ "8c:68:c8:a5:0a:8c", "0c:51:01:e4:3e:d0" ], + "visitedSite" : [ "app.thousandeyes.com" ], + "trigger" : [ "user" ], + "ssid" : [ "wifi-name", "other-room-wifi" ], + "platform" : [ "mac", "mac" ], + "proxyTarget" : [ "78.153.54.204", "78.153.54.206" ], + "destinationIp" : [ "84.255.241.1", "193.2.1.88" ], + "domain" : [ "thousandeyes.com" ], + "location" : [ "San Francisco Bay Area", "Germany" ], + "connection" : [ "wireless", "wireless" ], + "vpnTarget" : [ "78.153.54.204", "78.153.54.206" ], + "networkId" : [ "660b34109d12", "660b34109d15" ], + "gateway" : [ "78.153.54.204", "78.153.54.206" ] + } + } + + """ + real_user_endpoint_test_results_request = thousandeyes_sdk.endpoint_test_results.models.RealUserEndpointTestResultsRequest.from_json(request_body_json) + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.filter_real_user_tests_network_results( + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + real_user_endpoint_test_results_request=real_user_endpoint_test_results_request, + + _headers=self.te_headers("filter_real_user_tests_network_results", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_filter_real_user_tests_network_results_error_401(self) -> None: + """Integration test for filter_real_user_tests_network_results error path (HTTP 401)""" + request_body_json = """ + + { + "searchFilters" : { + "agentId" : [ "3fde6422-f119-40e1-ae32-d08a1243c038", "236e6f18-9637-4a2f-b15f-7aa6a29c9fce" ], + "bssid" : [ "8c:68:c8:a5:0a:8c", "0c:51:01:e4:3e:d0" ], + "visitedSite" : [ "app.thousandeyes.com" ], + "trigger" : [ "user" ], + "ssid" : [ "wifi-name", "other-room-wifi" ], + "platform" : [ "mac", "mac" ], + "proxyTarget" : [ "78.153.54.204", "78.153.54.206" ], + "destinationIp" : [ "84.255.241.1", "193.2.1.88" ], + "domain" : [ "thousandeyes.com" ], + "location" : [ "San Francisco Bay Area", "Germany" ], + "connection" : [ "wireless", "wireless" ], + "vpnTarget" : [ "78.153.54.204", "78.153.54.206" ], + "networkId" : [ "660b34109d12", "660b34109d15" ], + "gateway" : [ "78.153.54.204", "78.153.54.206" ] + } + } + + """ + real_user_endpoint_test_results_request = thousandeyes_sdk.endpoint_test_results.models.RealUserEndpointTestResultsRequest.from_json(request_body_json) + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.filter_real_user_tests_network_results( + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + real_user_endpoint_test_results_request=real_user_endpoint_test_results_request, + + _headers=self.te_headers("filter_real_user_tests_network_results", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_filter_real_user_tests_network_results_error_403(self) -> None: + """Integration test for filter_real_user_tests_network_results error path (HTTP 403)""" + request_body_json = """ + + { + "searchFilters" : { + "agentId" : [ "3fde6422-f119-40e1-ae32-d08a1243c038", "236e6f18-9637-4a2f-b15f-7aa6a29c9fce" ], + "bssid" : [ "8c:68:c8:a5:0a:8c", "0c:51:01:e4:3e:d0" ], + "visitedSite" : [ "app.thousandeyes.com" ], + "trigger" : [ "user" ], + "ssid" : [ "wifi-name", "other-room-wifi" ], + "platform" : [ "mac", "mac" ], + "proxyTarget" : [ "78.153.54.204", "78.153.54.206" ], + "destinationIp" : [ "84.255.241.1", "193.2.1.88" ], + "domain" : [ "thousandeyes.com" ], + "location" : [ "San Francisco Bay Area", "Germany" ], + "connection" : [ "wireless", "wireless" ], + "vpnTarget" : [ "78.153.54.204", "78.153.54.206" ], + "networkId" : [ "660b34109d12", "660b34109d15" ], + "gateway" : [ "78.153.54.204", "78.153.54.206" ] + } + } + + """ + real_user_endpoint_test_results_request = thousandeyes_sdk.endpoint_test_results.models.RealUserEndpointTestResultsRequest.from_json(request_body_json) + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.filter_real_user_tests_network_results( + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + real_user_endpoint_test_results_request=real_user_endpoint_test_results_request, + + _headers=self.te_headers("filter_real_user_tests_network_results", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_filter_real_user_tests_network_results_error_404(self) -> None: + """Integration test for filter_real_user_tests_network_results error path (HTTP 404)""" + request_body_json = """ + + { + "searchFilters" : { + "agentId" : [ "3fde6422-f119-40e1-ae32-d08a1243c038", "236e6f18-9637-4a2f-b15f-7aa6a29c9fce" ], + "bssid" : [ "8c:68:c8:a5:0a:8c", "0c:51:01:e4:3e:d0" ], + "visitedSite" : [ "app.thousandeyes.com" ], + "trigger" : [ "user" ], + "ssid" : [ "wifi-name", "other-room-wifi" ], + "platform" : [ "mac", "mac" ], + "proxyTarget" : [ "78.153.54.204", "78.153.54.206" ], + "destinationIp" : [ "84.255.241.1", "193.2.1.88" ], + "domain" : [ "thousandeyes.com" ], + "location" : [ "San Francisco Bay Area", "Germany" ], + "connection" : [ "wireless", "wireless" ], + "vpnTarget" : [ "78.153.54.204", "78.153.54.206" ], + "networkId" : [ "660b34109d12", "660b34109d15" ], + "gateway" : [ "78.153.54.204", "78.153.54.206" ] + } + } + + """ + real_user_endpoint_test_results_request = thousandeyes_sdk.endpoint_test_results.models.RealUserEndpointTestResultsRequest.from_json(request_body_json) + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.filter_real_user_tests_network_results( + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + real_user_endpoint_test_results_request=real_user_endpoint_test_results_request, + + _headers=self.te_headers("filter_real_user_tests_network_results", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_filter_real_user_tests_network_results_error_429(self) -> None: + """Integration test for filter_real_user_tests_network_results error path (HTTP 429)""" + request_body_json = """ + + { + "searchFilters" : { + "agentId" : [ "3fde6422-f119-40e1-ae32-d08a1243c038", "236e6f18-9637-4a2f-b15f-7aa6a29c9fce" ], + "bssid" : [ "8c:68:c8:a5:0a:8c", "0c:51:01:e4:3e:d0" ], + "visitedSite" : [ "app.thousandeyes.com" ], + "trigger" : [ "user" ], + "ssid" : [ "wifi-name", "other-room-wifi" ], + "platform" : [ "mac", "mac" ], + "proxyTarget" : [ "78.153.54.204", "78.153.54.206" ], + "destinationIp" : [ "84.255.241.1", "193.2.1.88" ], + "domain" : [ "thousandeyes.com" ], + "location" : [ "San Francisco Bay Area", "Germany" ], + "connection" : [ "wireless", "wireless" ], + "vpnTarget" : [ "78.153.54.204", "78.153.54.206" ], + "networkId" : [ "660b34109d12", "660b34109d15" ], + "gateway" : [ "78.153.54.204", "78.153.54.206" ] + } + } + + """ + real_user_endpoint_test_results_request = thousandeyes_sdk.endpoint_test_results.models.RealUserEndpointTestResultsRequest.from_json(request_body_json) + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.filter_real_user_tests_network_results( + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + real_user_endpoint_test_results_request=real_user_endpoint_test_results_request, + + _headers=self.te_headers("filter_real_user_tests_network_results", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_filter_real_user_tests_network_results_error_500(self) -> None: + """Integration test for filter_real_user_tests_network_results error path (HTTP 500)""" + request_body_json = """ + + { + "searchFilters" : { + "agentId" : [ "3fde6422-f119-40e1-ae32-d08a1243c038", "236e6f18-9637-4a2f-b15f-7aa6a29c9fce" ], + "bssid" : [ "8c:68:c8:a5:0a:8c", "0c:51:01:e4:3e:d0" ], + "visitedSite" : [ "app.thousandeyes.com" ], + "trigger" : [ "user" ], + "ssid" : [ "wifi-name", "other-room-wifi" ], + "platform" : [ "mac", "mac" ], + "proxyTarget" : [ "78.153.54.204", "78.153.54.206" ], + "destinationIp" : [ "84.255.241.1", "193.2.1.88" ], + "domain" : [ "thousandeyes.com" ], + "location" : [ "San Francisco Bay Area", "Germany" ], + "connection" : [ "wireless", "wireless" ], + "vpnTarget" : [ "78.153.54.204", "78.153.54.206" ], + "networkId" : [ "660b34109d12", "660b34109d15" ], + "gateway" : [ "78.153.54.204", "78.153.54.206" ] + } + } + + """ + real_user_endpoint_test_results_request = thousandeyes_sdk.endpoint_test_results.models.RealUserEndpointTestResultsRequest.from_json(request_body_json) + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.filter_real_user_tests_network_results( + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + real_user_endpoint_test_results_request=real_user_endpoint_test_results_request, + + _headers=self.te_headers("filter_real_user_tests_network_results", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_filter_real_user_tests_network_results_error_502(self) -> None: + """Integration test for filter_real_user_tests_network_results error path (HTTP 502)""" + request_body_json = """ + + { + "searchFilters" : { + "agentId" : [ "3fde6422-f119-40e1-ae32-d08a1243c038", "236e6f18-9637-4a2f-b15f-7aa6a29c9fce" ], + "bssid" : [ "8c:68:c8:a5:0a:8c", "0c:51:01:e4:3e:d0" ], + "visitedSite" : [ "app.thousandeyes.com" ], + "trigger" : [ "user" ], + "ssid" : [ "wifi-name", "other-room-wifi" ], + "platform" : [ "mac", "mac" ], + "proxyTarget" : [ "78.153.54.204", "78.153.54.206" ], + "destinationIp" : [ "84.255.241.1", "193.2.1.88" ], + "domain" : [ "thousandeyes.com" ], + "location" : [ "San Francisco Bay Area", "Germany" ], + "connection" : [ "wireless", "wireless" ], + "vpnTarget" : [ "78.153.54.204", "78.153.54.206" ], + "networkId" : [ "660b34109d12", "660b34109d15" ], + "gateway" : [ "78.153.54.204", "78.153.54.206" ] + } + } + + """ + real_user_endpoint_test_results_request = thousandeyes_sdk.endpoint_test_results.models.RealUserEndpointTestResultsRequest.from_json(request_body_json) + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.filter_real_user_tests_network_results( + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + real_user_endpoint_test_results_request=real_user_endpoint_test_results_request, + + _headers=self.te_headers("filter_real_user_tests_network_results", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_filter_real_user_tests_results_happy_path(self) -> None: + """Integration test for filter_real_user_tests_results success path""" + request_body_json = """ + + { + "searchFilters" : { + "agentId" : [ "3fde6422-f119-40e1-ae32-d08a1243c038", "236e6f18-9637-4a2f-b15f-7aa6a29c9fce" ], + "bssid" : [ "8c:68:c8:a5:0a:8c", "0c:51:01:e4:3e:d0" ], + "visitedSite" : [ "app.thousandeyes.com" ], + "trigger" : [ "user" ], + "ssid" : [ "wifi-name", "other-room-wifi" ], + "platform" : [ "mac", "mac" ], + "proxyTarget" : [ "78.153.54.204", "78.153.54.206" ], + "destinationIp" : [ "84.255.241.1", "193.2.1.88" ], + "domain" : [ "thousandeyes.com" ], + "location" : [ "San Francisco Bay Area", "Germany" ], + "connection" : [ "wireless", "wireless" ], + "vpnTarget" : [ "78.153.54.204", "78.153.54.206" ], + "networkId" : [ "660b34109d12", "660b34109d15" ], + "gateway" : [ "78.153.54.204", "78.153.54.206" ] + } + } + + """ + real_user_endpoint_test_results_request = thousandeyes_sdk.endpoint_test_results.models.RealUserEndpointTestResultsRequest.from_json(request_body_json) + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + response_body_json = """ + { + "endDate" : "2022-07-18T22:00:54Z", + "_links" : { + "next" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "results" : [ { + "date" : "2022-07-17T22:00:54Z", + "agentId" : "861b7557-cd57-4bbb-b648-00bddf88ef49", + "committed" : "2022-07-17T22:00:54Z", + "experienceScore" : 0.5, + "sourceAddress" : "84.255.241.1", + "organizationName" : "T-2 Access Network", + "visitedSite" : "www.thousandeyes.com", + "pageId" : "C31gBrYJ", + "protocol" : "https", + "numberOfPages" : 2, + "port" : 443, + "id" : "07625:1490529480:aVDViw0i", + "roundId" : 1384309800 + }, { + "date" : "2022-07-17T22:00:54Z", + "agentId" : "861b7557-cd57-4bbb-b648-00bddf88ef49", + "committed" : "2022-07-17T22:00:54Z", + "experienceScore" : 0.5, + "sourceAddress" : "84.255.241.1", + "organizationName" : "T-2 Access Network", + "visitedSite" : "www.thousandeyes.com", + "pageId" : "C31gBrYJ", + "protocol" : "https", + "numberOfPages" : 2, + "port" : 443, + "id" : "07625:1490529480:aVDViw0i", + "roundId" : 1384309800 + } ], + "startDate" : "2022-07-17T22:00:54Z" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.filter_real_user_tests_results( + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + real_user_endpoint_test_results_request=real_user_endpoint_test_results_request, + + _headers=self.te_headers("filter_real_user_tests_results"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_filter_real_user_tests_results_error_400(self) -> None: + """Integration test for filter_real_user_tests_results error path (HTTP 400)""" + request_body_json = """ + + { + "searchFilters" : { + "agentId" : [ "3fde6422-f119-40e1-ae32-d08a1243c038", "236e6f18-9637-4a2f-b15f-7aa6a29c9fce" ], + "bssid" : [ "8c:68:c8:a5:0a:8c", "0c:51:01:e4:3e:d0" ], + "visitedSite" : [ "app.thousandeyes.com" ], + "trigger" : [ "user" ], + "ssid" : [ "wifi-name", "other-room-wifi" ], + "platform" : [ "mac", "mac" ], + "proxyTarget" : [ "78.153.54.204", "78.153.54.206" ], + "destinationIp" : [ "84.255.241.1", "193.2.1.88" ], + "domain" : [ "thousandeyes.com" ], + "location" : [ "San Francisco Bay Area", "Germany" ], + "connection" : [ "wireless", "wireless" ], + "vpnTarget" : [ "78.153.54.204", "78.153.54.206" ], + "networkId" : [ "660b34109d12", "660b34109d15" ], + "gateway" : [ "78.153.54.204", "78.153.54.206" ] + } + } + + """ + real_user_endpoint_test_results_request = thousandeyes_sdk.endpoint_test_results.models.RealUserEndpointTestResultsRequest.from_json(request_body_json) + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.filter_real_user_tests_results( + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + real_user_endpoint_test_results_request=real_user_endpoint_test_results_request, + + _headers=self.te_headers("filter_real_user_tests_results", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_filter_real_user_tests_results_error_401(self) -> None: + """Integration test for filter_real_user_tests_results error path (HTTP 401)""" + request_body_json = """ + + { + "searchFilters" : { + "agentId" : [ "3fde6422-f119-40e1-ae32-d08a1243c038", "236e6f18-9637-4a2f-b15f-7aa6a29c9fce" ], + "bssid" : [ "8c:68:c8:a5:0a:8c", "0c:51:01:e4:3e:d0" ], + "visitedSite" : [ "app.thousandeyes.com" ], + "trigger" : [ "user" ], + "ssid" : [ "wifi-name", "other-room-wifi" ], + "platform" : [ "mac", "mac" ], + "proxyTarget" : [ "78.153.54.204", "78.153.54.206" ], + "destinationIp" : [ "84.255.241.1", "193.2.1.88" ], + "domain" : [ "thousandeyes.com" ], + "location" : [ "San Francisco Bay Area", "Germany" ], + "connection" : [ "wireless", "wireless" ], + "vpnTarget" : [ "78.153.54.204", "78.153.54.206" ], + "networkId" : [ "660b34109d12", "660b34109d15" ], + "gateway" : [ "78.153.54.204", "78.153.54.206" ] + } + } + + """ + real_user_endpoint_test_results_request = thousandeyes_sdk.endpoint_test_results.models.RealUserEndpointTestResultsRequest.from_json(request_body_json) + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.filter_real_user_tests_results( + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + real_user_endpoint_test_results_request=real_user_endpoint_test_results_request, + + _headers=self.te_headers("filter_real_user_tests_results", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_filter_real_user_tests_results_error_403(self) -> None: + """Integration test for filter_real_user_tests_results error path (HTTP 403)""" + request_body_json = """ + + { + "searchFilters" : { + "agentId" : [ "3fde6422-f119-40e1-ae32-d08a1243c038", "236e6f18-9637-4a2f-b15f-7aa6a29c9fce" ], + "bssid" : [ "8c:68:c8:a5:0a:8c", "0c:51:01:e4:3e:d0" ], + "visitedSite" : [ "app.thousandeyes.com" ], + "trigger" : [ "user" ], + "ssid" : [ "wifi-name", "other-room-wifi" ], + "platform" : [ "mac", "mac" ], + "proxyTarget" : [ "78.153.54.204", "78.153.54.206" ], + "destinationIp" : [ "84.255.241.1", "193.2.1.88" ], + "domain" : [ "thousandeyes.com" ], + "location" : [ "San Francisco Bay Area", "Germany" ], + "connection" : [ "wireless", "wireless" ], + "vpnTarget" : [ "78.153.54.204", "78.153.54.206" ], + "networkId" : [ "660b34109d12", "660b34109d15" ], + "gateway" : [ "78.153.54.204", "78.153.54.206" ] + } + } + + """ + real_user_endpoint_test_results_request = thousandeyes_sdk.endpoint_test_results.models.RealUserEndpointTestResultsRequest.from_json(request_body_json) + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.filter_real_user_tests_results( + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + real_user_endpoint_test_results_request=real_user_endpoint_test_results_request, + + _headers=self.te_headers("filter_real_user_tests_results", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_filter_real_user_tests_results_error_404(self) -> None: + """Integration test for filter_real_user_tests_results error path (HTTP 404)""" + request_body_json = """ + + { + "searchFilters" : { + "agentId" : [ "3fde6422-f119-40e1-ae32-d08a1243c038", "236e6f18-9637-4a2f-b15f-7aa6a29c9fce" ], + "bssid" : [ "8c:68:c8:a5:0a:8c", "0c:51:01:e4:3e:d0" ], + "visitedSite" : [ "app.thousandeyes.com" ], + "trigger" : [ "user" ], + "ssid" : [ "wifi-name", "other-room-wifi" ], + "platform" : [ "mac", "mac" ], + "proxyTarget" : [ "78.153.54.204", "78.153.54.206" ], + "destinationIp" : [ "84.255.241.1", "193.2.1.88" ], + "domain" : [ "thousandeyes.com" ], + "location" : [ "San Francisco Bay Area", "Germany" ], + "connection" : [ "wireless", "wireless" ], + "vpnTarget" : [ "78.153.54.204", "78.153.54.206" ], + "networkId" : [ "660b34109d12", "660b34109d15" ], + "gateway" : [ "78.153.54.204", "78.153.54.206" ] + } + } + + """ + real_user_endpoint_test_results_request = thousandeyes_sdk.endpoint_test_results.models.RealUserEndpointTestResultsRequest.from_json(request_body_json) + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.filter_real_user_tests_results( + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + real_user_endpoint_test_results_request=real_user_endpoint_test_results_request, + + _headers=self.te_headers("filter_real_user_tests_results", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_filter_real_user_tests_results_error_429(self) -> None: + """Integration test for filter_real_user_tests_results error path (HTTP 429)""" + request_body_json = """ + + { + "searchFilters" : { + "agentId" : [ "3fde6422-f119-40e1-ae32-d08a1243c038", "236e6f18-9637-4a2f-b15f-7aa6a29c9fce" ], + "bssid" : [ "8c:68:c8:a5:0a:8c", "0c:51:01:e4:3e:d0" ], + "visitedSite" : [ "app.thousandeyes.com" ], + "trigger" : [ "user" ], + "ssid" : [ "wifi-name", "other-room-wifi" ], + "platform" : [ "mac", "mac" ], + "proxyTarget" : [ "78.153.54.204", "78.153.54.206" ], + "destinationIp" : [ "84.255.241.1", "193.2.1.88" ], + "domain" : [ "thousandeyes.com" ], + "location" : [ "San Francisco Bay Area", "Germany" ], + "connection" : [ "wireless", "wireless" ], + "vpnTarget" : [ "78.153.54.204", "78.153.54.206" ], + "networkId" : [ "660b34109d12", "660b34109d15" ], + "gateway" : [ "78.153.54.204", "78.153.54.206" ] + } + } + + """ + real_user_endpoint_test_results_request = thousandeyes_sdk.endpoint_test_results.models.RealUserEndpointTestResultsRequest.from_json(request_body_json) + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.filter_real_user_tests_results( + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + real_user_endpoint_test_results_request=real_user_endpoint_test_results_request, + + _headers=self.te_headers("filter_real_user_tests_results", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_filter_real_user_tests_results_error_500(self) -> None: + """Integration test for filter_real_user_tests_results error path (HTTP 500)""" + request_body_json = """ + + { + "searchFilters" : { + "agentId" : [ "3fde6422-f119-40e1-ae32-d08a1243c038", "236e6f18-9637-4a2f-b15f-7aa6a29c9fce" ], + "bssid" : [ "8c:68:c8:a5:0a:8c", "0c:51:01:e4:3e:d0" ], + "visitedSite" : [ "app.thousandeyes.com" ], + "trigger" : [ "user" ], + "ssid" : [ "wifi-name", "other-room-wifi" ], + "platform" : [ "mac", "mac" ], + "proxyTarget" : [ "78.153.54.204", "78.153.54.206" ], + "destinationIp" : [ "84.255.241.1", "193.2.1.88" ], + "domain" : [ "thousandeyes.com" ], + "location" : [ "San Francisco Bay Area", "Germany" ], + "connection" : [ "wireless", "wireless" ], + "vpnTarget" : [ "78.153.54.204", "78.153.54.206" ], + "networkId" : [ "660b34109d12", "660b34109d15" ], + "gateway" : [ "78.153.54.204", "78.153.54.206" ] + } + } + + """ + real_user_endpoint_test_results_request = thousandeyes_sdk.endpoint_test_results.models.RealUserEndpointTestResultsRequest.from_json(request_body_json) + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.filter_real_user_tests_results( + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + real_user_endpoint_test_results_request=real_user_endpoint_test_results_request, + + _headers=self.te_headers("filter_real_user_tests_results", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_filter_real_user_tests_results_error_502(self) -> None: + """Integration test for filter_real_user_tests_results error path (HTTP 502)""" + request_body_json = """ + + { + "searchFilters" : { + "agentId" : [ "3fde6422-f119-40e1-ae32-d08a1243c038", "236e6f18-9637-4a2f-b15f-7aa6a29c9fce" ], + "bssid" : [ "8c:68:c8:a5:0a:8c", "0c:51:01:e4:3e:d0" ], + "visitedSite" : [ "app.thousandeyes.com" ], + "trigger" : [ "user" ], + "ssid" : [ "wifi-name", "other-room-wifi" ], + "platform" : [ "mac", "mac" ], + "proxyTarget" : [ "78.153.54.204", "78.153.54.206" ], + "destinationIp" : [ "84.255.241.1", "193.2.1.88" ], + "domain" : [ "thousandeyes.com" ], + "location" : [ "San Francisco Bay Area", "Germany" ], + "connection" : [ "wireless", "wireless" ], + "vpnTarget" : [ "78.153.54.204", "78.153.54.206" ], + "networkId" : [ "660b34109d12", "660b34109d15" ], + "gateway" : [ "78.153.54.204", "78.153.54.206" ] + } + } + + """ + real_user_endpoint_test_results_request = thousandeyes_sdk.endpoint_test_results.models.RealUserEndpointTestResultsRequest.from_json(request_body_json) + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.filter_real_user_tests_results( + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + real_user_endpoint_test_results_request=real_user_endpoint_test_results_request, + + _headers=self.te_headers("filter_real_user_tests_results", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_filter_real_user_tests_visited_pages_results_happy_path(self) -> None: + """Integration test for filter_real_user_tests_visited_pages_results success path""" + request_body_json = """ + + { + "agentId" : [ "3fde6422-f119-40e1-ae32-d08a1243c038", "236e6f18-9637-4a2f-b15f-7aa6a29c9fce" ], + "bssid" : [ "8c:68:c8:a5:0a:8c", "0c:51:01:e4:3e:d0" ], + "visitedSite" : [ "app.thousandeyes.com" ], + "trigger" : [ "user" ], + "ssid" : [ "wifi-name", "other-room-wifi" ], + "platform" : [ "mac", "mac" ], + "proxyTarget" : [ "78.153.54.204", "78.153.54.206" ], + "destinationIp" : [ "84.255.241.1", "193.2.1.88" ], + "domain" : [ "thousandeyes.com" ], + "location" : [ "San Francisco Bay Area", "Germany" ], + "connection" : [ "wireless", "wireless" ], + "vpnTarget" : [ "78.153.54.204", "78.153.54.206" ], + "networkId" : [ "660b34109d12", "660b34109d15" ], + "gateway" : [ "78.153.54.204", "78.153.54.206" ] + } + + """ + real_user_endpoint_test_result_request_filter = thousandeyes_sdk.endpoint_test_results.models.RealUserEndpointTestResultRequestFilter.from_json(request_body_json) + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + response_body_json = """ + { + "endDate" : "2022-07-18T22:00:54Z", + "_links" : { + "next" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "results" : [ { + "pageTimings" : { + "onContentLoad" : 1483, + "onLoad" : 4569 + }, + "agentId" : "861b7557-cd57-4bbb-b648-00bddf88ef49", + "systemMetrics" : { + "cpuUtilization" : { + "min" : 0.22, + "median" : 0.61, + "max" : 0.75, + "mean" : 0.55, + "count" : 150, + "stdDev" : 0.01 + }, + "physicalMemoryTotalBytes" : 1024, + "startTimeMs" : 1581508857327, + "physicalMemoryUsedBytes" : { + "min" : 1.2, + "median" : 1.85, + "max" : 2.5, + "mean" : 1.77, + "count" : 155, + "stdDev" : 0.25 + }, + "endTimeMs" : 1581508867333 + }, + "pageTitle" : "Network Performance Resources | ThousandEyes", + "responseTime" : 240, + "pageUrl" : "https://app.thousandeyes.com/settings/integrations", + "id" : "07625:1490529480:aVDViw0i", + "pageId" : "C31gBrYJ", + "roundId" : 1384309800, + "loadDate" : "2022-07-17T22:00:54Z", + "responseCode" : 200 + }, { + "pageTimings" : { + "onContentLoad" : 1483, + "onLoad" : 4569 + }, + "agentId" : "861b7557-cd57-4bbb-b648-00bddf88ef49", + "systemMetrics" : { + "cpuUtilization" : { + "min" : 0.22, + "median" : 0.61, + "max" : 0.75, + "mean" : 0.55, + "count" : 150, + "stdDev" : 0.01 + }, + "physicalMemoryTotalBytes" : 1024, + "startTimeMs" : 1581508857327, + "physicalMemoryUsedBytes" : { + "min" : 1.2, + "median" : 1.85, + "max" : 2.5, + "mean" : 1.77, + "count" : 155, + "stdDev" : 0.25 + }, + "endTimeMs" : 1581508867333 + }, + "pageTitle" : "Network Performance Resources | ThousandEyes", + "responseTime" : 240, + "pageUrl" : "https://app.thousandeyes.com/settings/integrations", + "id" : "07625:1490529480:aVDViw0i", + "pageId" : "C31gBrYJ", + "roundId" : 1384309800, + "loadDate" : "2022-07-17T22:00:54Z", + "responseCode" : 200 + } ], + "startDate" : "2022-07-17T22:00:54Z" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.filter_real_user_tests_visited_pages_results( + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + real_user_endpoint_test_result_request_filter=real_user_endpoint_test_result_request_filter, + + _headers=self.te_headers("filter_real_user_tests_visited_pages_results"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_filter_real_user_tests_visited_pages_results_error_400(self) -> None: + """Integration test for filter_real_user_tests_visited_pages_results error path (HTTP 400)""" + request_body_json = """ + + { + "agentId" : [ "3fde6422-f119-40e1-ae32-d08a1243c038", "236e6f18-9637-4a2f-b15f-7aa6a29c9fce" ], + "bssid" : [ "8c:68:c8:a5:0a:8c", "0c:51:01:e4:3e:d0" ], + "visitedSite" : [ "app.thousandeyes.com" ], + "trigger" : [ "user" ], + "ssid" : [ "wifi-name", "other-room-wifi" ], + "platform" : [ "mac", "mac" ], + "proxyTarget" : [ "78.153.54.204", "78.153.54.206" ], + "destinationIp" : [ "84.255.241.1", "193.2.1.88" ], + "domain" : [ "thousandeyes.com" ], + "location" : [ "San Francisco Bay Area", "Germany" ], + "connection" : [ "wireless", "wireless" ], + "vpnTarget" : [ "78.153.54.204", "78.153.54.206" ], + "networkId" : [ "660b34109d12", "660b34109d15" ], + "gateway" : [ "78.153.54.204", "78.153.54.206" ] + } + + """ + real_user_endpoint_test_result_request_filter = thousandeyes_sdk.endpoint_test_results.models.RealUserEndpointTestResultRequestFilter.from_json(request_body_json) + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.filter_real_user_tests_visited_pages_results( + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + real_user_endpoint_test_result_request_filter=real_user_endpoint_test_result_request_filter, + + _headers=self.te_headers("filter_real_user_tests_visited_pages_results", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_filter_real_user_tests_visited_pages_results_error_401(self) -> None: + """Integration test for filter_real_user_tests_visited_pages_results error path (HTTP 401)""" + request_body_json = """ + + { + "agentId" : [ "3fde6422-f119-40e1-ae32-d08a1243c038", "236e6f18-9637-4a2f-b15f-7aa6a29c9fce" ], + "bssid" : [ "8c:68:c8:a5:0a:8c", "0c:51:01:e4:3e:d0" ], + "visitedSite" : [ "app.thousandeyes.com" ], + "trigger" : [ "user" ], + "ssid" : [ "wifi-name", "other-room-wifi" ], + "platform" : [ "mac", "mac" ], + "proxyTarget" : [ "78.153.54.204", "78.153.54.206" ], + "destinationIp" : [ "84.255.241.1", "193.2.1.88" ], + "domain" : [ "thousandeyes.com" ], + "location" : [ "San Francisco Bay Area", "Germany" ], + "connection" : [ "wireless", "wireless" ], + "vpnTarget" : [ "78.153.54.204", "78.153.54.206" ], + "networkId" : [ "660b34109d12", "660b34109d15" ], + "gateway" : [ "78.153.54.204", "78.153.54.206" ] + } + + """ + real_user_endpoint_test_result_request_filter = thousandeyes_sdk.endpoint_test_results.models.RealUserEndpointTestResultRequestFilter.from_json(request_body_json) + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.filter_real_user_tests_visited_pages_results( + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + real_user_endpoint_test_result_request_filter=real_user_endpoint_test_result_request_filter, + + _headers=self.te_headers("filter_real_user_tests_visited_pages_results", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_filter_real_user_tests_visited_pages_results_error_403(self) -> None: + """Integration test for filter_real_user_tests_visited_pages_results error path (HTTP 403)""" + request_body_json = """ + + { + "agentId" : [ "3fde6422-f119-40e1-ae32-d08a1243c038", "236e6f18-9637-4a2f-b15f-7aa6a29c9fce" ], + "bssid" : [ "8c:68:c8:a5:0a:8c", "0c:51:01:e4:3e:d0" ], + "visitedSite" : [ "app.thousandeyes.com" ], + "trigger" : [ "user" ], + "ssid" : [ "wifi-name", "other-room-wifi" ], + "platform" : [ "mac", "mac" ], + "proxyTarget" : [ "78.153.54.204", "78.153.54.206" ], + "destinationIp" : [ "84.255.241.1", "193.2.1.88" ], + "domain" : [ "thousandeyes.com" ], + "location" : [ "San Francisco Bay Area", "Germany" ], + "connection" : [ "wireless", "wireless" ], + "vpnTarget" : [ "78.153.54.204", "78.153.54.206" ], + "networkId" : [ "660b34109d12", "660b34109d15" ], + "gateway" : [ "78.153.54.204", "78.153.54.206" ] + } + + """ + real_user_endpoint_test_result_request_filter = thousandeyes_sdk.endpoint_test_results.models.RealUserEndpointTestResultRequestFilter.from_json(request_body_json) + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.filter_real_user_tests_visited_pages_results( + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + real_user_endpoint_test_result_request_filter=real_user_endpoint_test_result_request_filter, + + _headers=self.te_headers("filter_real_user_tests_visited_pages_results", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_filter_real_user_tests_visited_pages_results_error_404(self) -> None: + """Integration test for filter_real_user_tests_visited_pages_results error path (HTTP 404)""" + request_body_json = """ + + { + "agentId" : [ "3fde6422-f119-40e1-ae32-d08a1243c038", "236e6f18-9637-4a2f-b15f-7aa6a29c9fce" ], + "bssid" : [ "8c:68:c8:a5:0a:8c", "0c:51:01:e4:3e:d0" ], + "visitedSite" : [ "app.thousandeyes.com" ], + "trigger" : [ "user" ], + "ssid" : [ "wifi-name", "other-room-wifi" ], + "platform" : [ "mac", "mac" ], + "proxyTarget" : [ "78.153.54.204", "78.153.54.206" ], + "destinationIp" : [ "84.255.241.1", "193.2.1.88" ], + "domain" : [ "thousandeyes.com" ], + "location" : [ "San Francisco Bay Area", "Germany" ], + "connection" : [ "wireless", "wireless" ], + "vpnTarget" : [ "78.153.54.204", "78.153.54.206" ], + "networkId" : [ "660b34109d12", "660b34109d15" ], + "gateway" : [ "78.153.54.204", "78.153.54.206" ] + } + + """ + real_user_endpoint_test_result_request_filter = thousandeyes_sdk.endpoint_test_results.models.RealUserEndpointTestResultRequestFilter.from_json(request_body_json) + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.filter_real_user_tests_visited_pages_results( + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + real_user_endpoint_test_result_request_filter=real_user_endpoint_test_result_request_filter, + + _headers=self.te_headers("filter_real_user_tests_visited_pages_results", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_filter_real_user_tests_visited_pages_results_error_429(self) -> None: + """Integration test for filter_real_user_tests_visited_pages_results error path (HTTP 429)""" + request_body_json = """ + + { + "agentId" : [ "3fde6422-f119-40e1-ae32-d08a1243c038", "236e6f18-9637-4a2f-b15f-7aa6a29c9fce" ], + "bssid" : [ "8c:68:c8:a5:0a:8c", "0c:51:01:e4:3e:d0" ], + "visitedSite" : [ "app.thousandeyes.com" ], + "trigger" : [ "user" ], + "ssid" : [ "wifi-name", "other-room-wifi" ], + "platform" : [ "mac", "mac" ], + "proxyTarget" : [ "78.153.54.204", "78.153.54.206" ], + "destinationIp" : [ "84.255.241.1", "193.2.1.88" ], + "domain" : [ "thousandeyes.com" ], + "location" : [ "San Francisco Bay Area", "Germany" ], + "connection" : [ "wireless", "wireless" ], + "vpnTarget" : [ "78.153.54.204", "78.153.54.206" ], + "networkId" : [ "660b34109d12", "660b34109d15" ], + "gateway" : [ "78.153.54.204", "78.153.54.206" ] + } + + """ + real_user_endpoint_test_result_request_filter = thousandeyes_sdk.endpoint_test_results.models.RealUserEndpointTestResultRequestFilter.from_json(request_body_json) + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.filter_real_user_tests_visited_pages_results( + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + real_user_endpoint_test_result_request_filter=real_user_endpoint_test_result_request_filter, + + _headers=self.te_headers("filter_real_user_tests_visited_pages_results", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_filter_real_user_tests_visited_pages_results_error_500(self) -> None: + """Integration test for filter_real_user_tests_visited_pages_results error path (HTTP 500)""" + request_body_json = """ + + { + "agentId" : [ "3fde6422-f119-40e1-ae32-d08a1243c038", "236e6f18-9637-4a2f-b15f-7aa6a29c9fce" ], + "bssid" : [ "8c:68:c8:a5:0a:8c", "0c:51:01:e4:3e:d0" ], + "visitedSite" : [ "app.thousandeyes.com" ], + "trigger" : [ "user" ], + "ssid" : [ "wifi-name", "other-room-wifi" ], + "platform" : [ "mac", "mac" ], + "proxyTarget" : [ "78.153.54.204", "78.153.54.206" ], + "destinationIp" : [ "84.255.241.1", "193.2.1.88" ], + "domain" : [ "thousandeyes.com" ], + "location" : [ "San Francisco Bay Area", "Germany" ], + "connection" : [ "wireless", "wireless" ], + "vpnTarget" : [ "78.153.54.204", "78.153.54.206" ], + "networkId" : [ "660b34109d12", "660b34109d15" ], + "gateway" : [ "78.153.54.204", "78.153.54.206" ] + } + + """ + real_user_endpoint_test_result_request_filter = thousandeyes_sdk.endpoint_test_results.models.RealUserEndpointTestResultRequestFilter.from_json(request_body_json) + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.filter_real_user_tests_visited_pages_results( + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + real_user_endpoint_test_result_request_filter=real_user_endpoint_test_result_request_filter, + + _headers=self.te_headers("filter_real_user_tests_visited_pages_results", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_filter_real_user_tests_visited_pages_results_error_502(self) -> None: + """Integration test for filter_real_user_tests_visited_pages_results error path (HTTP 502)""" + request_body_json = """ + + { + "agentId" : [ "3fde6422-f119-40e1-ae32-d08a1243c038", "236e6f18-9637-4a2f-b15f-7aa6a29c9fce" ], + "bssid" : [ "8c:68:c8:a5:0a:8c", "0c:51:01:e4:3e:d0" ], + "visitedSite" : [ "app.thousandeyes.com" ], + "trigger" : [ "user" ], + "ssid" : [ "wifi-name", "other-room-wifi" ], + "platform" : [ "mac", "mac" ], + "proxyTarget" : [ "78.153.54.204", "78.153.54.206" ], + "destinationIp" : [ "84.255.241.1", "193.2.1.88" ], + "domain" : [ "thousandeyes.com" ], + "location" : [ "San Francisco Bay Area", "Germany" ], + "connection" : [ "wireless", "wireless" ], + "vpnTarget" : [ "78.153.54.204", "78.153.54.206" ], + "networkId" : [ "660b34109d12", "660b34109d15" ], + "gateway" : [ "78.153.54.204", "78.153.54.206" ] + } + + """ + real_user_endpoint_test_result_request_filter = thousandeyes_sdk.endpoint_test_results.models.RealUserEndpointTestResultRequestFilter.from_json(request_body_json) + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.filter_real_user_tests_visited_pages_results( + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + real_user_endpoint_test_result_request_filter=real_user_endpoint_test_result_request_filter, + + _headers=self.te_headers("filter_real_user_tests_visited_pages_results", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_real_user_test_page_results_happy_path(self) -> None: + """Integration test for get_real_user_test_page_results success path""" + id = '07625:1490529480:h3qJQTpl' + page_id = '281474976710706' + aid = '1234' + response_body_json = """ + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "har" : { + "log" : { + "browser" : { + "name" : "Google Chrome", + "version" : "57.0.2987.98" + }, + "creator" : { + "name" : "ThousandEyes Endpoint Agent", + "version" : "0.47.0" + }, + "entries" : [ { + "pageref" : "page_1", + "request" : { + "headers" : [ { + "name" : "Upgrade-Insecure-Requests", + "value" : "1" + }, { + "name" : "User-Agent", + "value" : "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.98 Safari/537.36" + }, { + "name" : "Accept", + "value" : "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8" + }, { + "name" : "Referer", + "value" : "https://www.thousandeyes.com/" + }, { + "name" : "Accept-Encoding", + "value" : "gzip, deflate, sdch, br" + }, { + "name" : "Accept-Language", + "value" : "en-US,en;q=0.6" + }, { + "name" : "Cookie", + "value" : "(removed)" + } ], + "method" : "GET", + "queryString" : [ { + "name" : "locale", + "value" : "en-US" + } ], + "url" : "https://www.thousandeyes.com/resources" + }, + "response" : { + "bodySize" : 17776, + "content" : { + "mimeType" : "text/html;charset=ISO-8859-1", + "size" : 17776 + }, + "headers" : [ { + "name" : "Content-Type", + "value" : "text/html;charset=ISO-8859-1" + }, { + "name" : "Content-Length", + "value" : "17776" + }, { + "name" : "Connection", + "value" : "keep-alive" + }, { + "name" : "Date", + "value" : "Sun, 26 Mar 2017 11:58:54 GMT" + }, { + "name" : "Server", + "value" : "Apache" + }, { + "name" : "Cache-Control", + "value" : "max-age=600, must-revalidate" + }, { + "name" : "Content-Language", + "value" : "en-US" + }, { + "name" : "Content-Encoding", + "value" : "gzip" + }, { + "name" : "X-Frame-Options", + "value" : "sameorigin" + }, { + "name" : "Strict-Transport-Security", + "value" : "max-age=31536000" + }, { + "name" : "Vary", + "value" : "Accept-Encoding" + }, { + "name" : "X-Cache", + "value" : "Miss from cloudfront" + }, { + "name" : "Via", + "value" : "1.1 5dbe09af3a2c87121e31ffa67f174f66.cloudfront.net (CloudFront)" + }, { + "name" : "X-Amz-Cf-Id", + "value" : "YkvlkBNKgHt5aMu9vcS22Z8kHn1MUr-8adupwhDk3j9vF-TpSyIxZA==" + } ], + "headersSize" : 527, + "redirectURL" : "", + "status" : 200, + "statusText" : "OK" + }, + "serverIPAddress" : "13.32.22.80", + "startedDateTime" : "2017-03-22T11:58:54.123+02:00", + "time" : 177, + "timings" : { + "blocked" : -1, + "connect" : -1, + "dns" : -1, + "receive" : 27, + "send" : -1, + "ssl" : -1, + "wait" : 150 + } + }, { + "pageref" : "page_1", + "request" : { + "headers" : [ { + "name" : "User-Agent", + "value" : "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.98 Safari/537.36" + }, { + "name" : "Accept", + "value" : "*/*" + }, { + "name" : "Referer", + "value" : "https://www.thousandeyes.com/resources" + }, { + "name" : "Accept-Encoding", + "value" : "gzip, deflate, sdch, br" + }, { + "name" : "Accept-Language", + "value" : "en-US,en;q=0.6" + } ], + "method" : "GET", + "queryString" : [ ], + "url" : "https://use.typekit.net/cjy5myw.js" + }, + "response" : { + "bodySize" : 0, + "content" : { + "mimeType" : "text/javascript;charset=utf-8", + "size" : 7814 + }, + "headers" : [ { + "name" : "status", + "value" : "200" + }, { + "name" : "access-control-allow-origin", + "value" : "*" + }, { + "name" : "cache-control", + "value" : "public, max-age=600, stale-while-revalidate=604800" + }, { + "name" : "content-encoding", + "value" : "gzip" + }, { + "name" : "content-type", + "value" : "text/javascript;charset=utf-8" + }, { + "name" : "server", + "value" : "nginx" + }, { + "name" : "status", + "value" : "200 OK" + }, { + "name" : "timing-allow-origin", + "value" : "*" + }, { + "name" : "vary", + "value" : "Accept-Encoding" + }, { + "name" : "content-length", + "value" : "7814" + }, { + "name" : "date", + "value" : "Sun, 26 Mar 2017 11:58:43 GMT" + } ], + "headersSize" : 334, + "redirectURL" : "", + "status" : 200, + "statusText" : "OK" + }, + "serverIPAddress" : "104.103.103.234", + "startedDateTime" : "2017-03-22T11:58:54.123+02:00", + "time" : 72, + "timings" : { + "blocked" : -1, + "connect" : -1, + "dns" : -1, + "receive" : 10, + "send" : -1, + "ssl" : -1, + "wait" : 62 + } + } ], + "pages" : [ { + "id" : "page_1", + "pageTimings" : { + "onContentLoad" : 874, + "onLoad" : 3492 + }, + "responseCode" : 200, + "startedDateTime" : "2017-03-22T11:58:54.123+02:00", + "title" : "Network Performance Resources | ThousandEyes" + } ], + "version" : "1.2", + "systemMetrics" : { + "startTimeMs" : 1581508857327, + "endTimeMs" : 1581508867333, + "cpuUtilization" : { + "min" : 0.30859375, + "max" : 0.5625, + "mean" : 0.38931831001805056, + "median" : 0.353515625, + "stdDev" : 0.08389194281742307, + "count" : 10 + }, + "physicalMemoryUsedBytes" : { + "min" : 12805128192, + "max" : 12825530368, + "mean" : 1.281914582109091E10, + "median" : 12818219008, + "stdDev" : 5741124.05691331, + "count" : 11 + }, + "physicalMemoryTotalBytes" : 17069891584 + } + } + } + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_real_user_test_page_results( + + id=id, + + page_id=page_id, + + aid=aid, + + _headers=self.te_headers("get_real_user_test_page_results"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_real_user_test_page_results_error_401(self) -> None: + """Integration test for get_real_user_test_page_results error path (HTTP 401)""" + id = '07625:1490529480:h3qJQTpl' + page_id = '281474976710706' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_real_user_test_page_results( + + id=id, + + page_id=page_id, + + aid=aid, + + _headers=self.te_headers("get_real_user_test_page_results", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_real_user_test_page_results_error_403(self) -> None: + """Integration test for get_real_user_test_page_results error path (HTTP 403)""" + id = '07625:1490529480:h3qJQTpl' + page_id = '281474976710706' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_real_user_test_page_results( + + id=id, + + page_id=page_id, + + aid=aid, + + _headers=self.te_headers("get_real_user_test_page_results", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_real_user_test_page_results_error_404(self) -> None: + """Integration test for get_real_user_test_page_results error path (HTTP 404)""" + id = '07625:1490529480:h3qJQTpl' + page_id = '281474976710706' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_real_user_test_page_results( + + id=id, + + page_id=page_id, + + aid=aid, + + _headers=self.te_headers("get_real_user_test_page_results", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_real_user_test_page_results_error_429(self) -> None: + """Integration test for get_real_user_test_page_results error path (HTTP 429)""" + id = '07625:1490529480:h3qJQTpl' + page_id = '281474976710706' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_real_user_test_page_results( + + id=id, + + page_id=page_id, + + aid=aid, + + _headers=self.te_headers("get_real_user_test_page_results", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_real_user_test_page_results_error_500(self) -> None: + """Integration test for get_real_user_test_page_results error path (HTTP 500)""" + id = '07625:1490529480:h3qJQTpl' + page_id = '281474976710706' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_real_user_test_page_results( + + id=id, + + page_id=page_id, + + aid=aid, + + _headers=self.te_headers("get_real_user_test_page_results", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_real_user_test_page_results_error_502(self) -> None: + """Integration test for get_real_user_test_page_results error path (HTTP 502)""" + id = '07625:1490529480:h3qJQTpl' + page_id = '281474976710706' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.get_real_user_test_page_results( + + id=id, + + page_id=page_id, + + aid=aid, + + _headers=self.te_headers("get_real_user_test_page_results", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_real_user_test_results_happy_path(self) -> None: + """Integration test for get_real_user_test_results success path""" + id = '07625:1490529480:h3qJQTpl' + aid = '1234' + response_body_json = """ + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "results" : [ { + "date" : "2022-07-17T22:00:54Z", + "agentId" : "861b7557-cd57-4bbb-b648-00bddf88ef49", + "committed" : "2022-07-17T22:00:54Z", + "experienceScore" : 0.5, + "sourceAddress" : "84.255.241.1", + "organizationName" : "T-2 Access Network", + "visitedSite" : "www.thousandeyes.com", + "coordinates" : { + "latitude" : 46.0552778, + "location" : "Slovenia", + "longitude" : 14.5144444 + }, + "network" : { + "systemMetrics" : { + "cpuUtilization" : { + "min" : 0.22, + "median" : 0.61, + "max" : 0.75, + "mean" : 0.55, + "count" : 150, + "stdDev" : 0.01 + }, + "physicalMemoryTotalBytes" : 1024, + "startTimeMs" : 1581508857327, + "physicalMemoryUsedBytes" : { + "min" : 1.2, + "median" : 1.85, + "max" : 2.5, + "mean" : 1.77, + "count" : 155, + "stdDev" : 0.25 + }, + "endTimeMs" : 1581508867333 + }, + "isIcmpBlocked" : true, + "vpnPing" : { + "maxRtt" : 66, + "loss" : 1, + "pktsReceived" : 10, + "avgRtt" : 7, + "meanDevRtt" : 11, + "minRtt" : 1, + "error" : "An operation timed out.", + "infoFlags" : [ "TE_INFO_ICMP_BLOCKED_BY_FIREWALL" ], + "pktsSent" : 10 + }, + "ping" : { + "maxRtt" : 66, + "loss" : 1, + "pktsReceived" : 10, + "avgRtt" : 7, + "meanDevRtt" : 11, + "minRtt" : 1, + "error" : "An operation timed out.", + "infoFlags" : [ "TE_INFO_ICMP_BLOCKED_BY_FIREWALL" ], + "pktsSent" : 10 + }, + "networkProfile" : { + "previousInterface" : { + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "interfaceName" : "en0", + "subnetMask" : "255.255.255.0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ] + }, + "ethernetProfile" : { + "linkSpeed" : 860 + }, + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "proxyProfile" : { + "method" : "System", + "proxies" : [ { + "bypass" : "*.local;169.254/16", + "proxy" : "" + }, { + "bypass" : "*.local;169.254/16", + "proxy" : "" + } ] + }, + "subnetMask" : "255.255.255.0", + "error" : "An operation timed out.", + "wirelessProfile" : { + "rssi" : -38, + "bssid" : "4c:ba:ba:f4:fa:fa", + "snr" : 57, + "vendor" : "Cisco", + "txRate" : 130, + "channel" : 1, + "noise" : -95, + "phyMode" : "802.11n", + "ssid" : "Internet for the masses", + "quality" : 100 + }, + "interfaceName" : "en0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ], + "gateway" : "10.0.0.1" + }, + "traceroute" : { + "destination" : "13.32.22.232", + "hops" : [ { + "delay" : 5, + "prefix" : "196.40.96.0/20", + "hop" : 1, + "ipAddress" : "196.40.106.237", + "name" : "89-210-88-65.access.t-2.net", + "mpls" : [ "L=301472,E=0,S=1,T=1" ], + "asn" : 34779 + }, { + "delay" : 5, + "prefix" : "196.40.96.0/20", + "hop" : 1, + "ipAddress" : "196.40.106.237", + "name" : "89-210-88-65.access.t-2.net", + "mpls" : [ "L=301472,E=0,S=1,T=1" ], + "asn" : 34779 + } ], + "error" : "An operation timed out.", + "infoFlags" : [ "TE_INFO_ICMP_BLOCKED_BY_FIREWALL" ], + "internalErrors" : [ "TE_INFO_ICMP_BLOCKED_BY_FIREWALL" ] + }, + "vpnTraceroute" : { + "destination" : "13.32.22.232", + "hops" : [ { + "delay" : 5, + "prefix" : "196.40.96.0/20", + "hop" : 1, + "ipAddress" : "196.40.106.237", + "name" : "89-210-88-65.access.t-2.net", + "mpls" : [ "L=301472,E=0,S=1,T=1" ], + "asn" : 34779 + }, { + "delay" : 5, + "prefix" : "196.40.96.0/20", + "hop" : 1, + "ipAddress" : "196.40.106.237", + "name" : "89-210-88-65.access.t-2.net", + "mpls" : [ "L=301472,E=0,S=1,T=1" ], + "asn" : 34779 + } ], + "error" : "An operation timed out.", + "infoFlags" : [ "TE_INFO_ICMP_BLOCKED_BY_FIREWALL" ], + "internalErrors" : [ "TE_INFO_ICMP_BLOCKED_BY_FIREWALL" ] + }, + "connectRtt" : 77.777, + "gatewayPing" : { + "maxRtt" : 66, + "loss" : 1, + "pktsReceived" : 10, + "avgRtt" : 7, + "meanDevRtt" : 11, + "minRtt" : 1, + "error" : "An operation timed out.", + "infoFlags" : [ "TE_INFO_ICMP_BLOCKED_BY_FIREWALL" ], + "pktsSent" : 10 + }, + "errors" : [ "ping: Request timed out before getting response" ] + }, + "protocol" : "https", + "pages" : [ { + "pageTimings" : { + "onContentLoad" : 1483, + "onLoad" : 4569 + }, + "pageTitle" : "Network Performance Resources | ThousandEyes", + "pageUrl" : "https://app.thousandeyes.com/settings/integrations", + "pageId" : "C31gBrYJ", + "loadDate" : "2022-07-17T22:00:54Z", + "responseCode" : 200 + }, { + "pageTimings" : { + "onContentLoad" : 1483, + "onLoad" : 4569 + }, + "pageTitle" : "Network Performance Resources | ThousandEyes", + "pageUrl" : "https://app.thousandeyes.com/settings/integrations", + "pageId" : "C31gBrYJ", + "loadDate" : "2022-07-17T22:00:54Z", + "responseCode" : 200 + } ], + "numberOfPages" : 2, + "port" : 443, + "browser" : { + "name" : "Google Chrome", + "version" : "116.0.0.0" + }, + "id" : "07625:1490529480:aVDViw0i", + "roundId" : 1384309800 + }, { + "date" : "2022-07-17T22:00:54Z", + "agentId" : "861b7557-cd57-4bbb-b648-00bddf88ef49", + "committed" : "2022-07-17T22:00:54Z", + "experienceScore" : 0.5, + "sourceAddress" : "84.255.241.1", + "organizationName" : "T-2 Access Network", + "visitedSite" : "www.thousandeyes.com", + "coordinates" : { + "latitude" : 46.0552778, + "location" : "Slovenia", + "longitude" : 14.5144444 + }, + "network" : { + "systemMetrics" : { + "cpuUtilization" : { + "min" : 0.22, + "median" : 0.61, + "max" : 0.75, + "mean" : 0.55, + "count" : 150, + "stdDev" : 0.01 + }, + "physicalMemoryTotalBytes" : 1024, + "startTimeMs" : 1581508857327, + "physicalMemoryUsedBytes" : { + "min" : 1.2, + "median" : 1.85, + "max" : 2.5, + "mean" : 1.77, + "count" : 155, + "stdDev" : 0.25 + }, + "endTimeMs" : 1581508867333 + }, + "isIcmpBlocked" : true, + "vpnPing" : { + "maxRtt" : 66, + "loss" : 1, + "pktsReceived" : 10, + "avgRtt" : 7, + "meanDevRtt" : 11, + "minRtt" : 1, + "error" : "An operation timed out.", + "infoFlags" : [ "TE_INFO_ICMP_BLOCKED_BY_FIREWALL" ], + "pktsSent" : 10 + }, + "ping" : { + "maxRtt" : 66, + "loss" : 1, + "pktsReceived" : 10, + "avgRtt" : 7, + "meanDevRtt" : 11, + "minRtt" : 1, + "error" : "An operation timed out.", + "infoFlags" : [ "TE_INFO_ICMP_BLOCKED_BY_FIREWALL" ], + "pktsSent" : 10 + }, + "networkProfile" : { + "previousInterface" : { + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "interfaceName" : "en0", + "subnetMask" : "255.255.255.0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ] + }, + "ethernetProfile" : { + "linkSpeed" : 860 + }, + "publicIpAddress" : "84.255.241.1", + "publicIpRange" : "84.255.241.0-84.255.241.255", + "ipAddress" : "10.0.0.13", + "hardwareType" : "wireless", + "localPrefix" : "10.0.0.0", + "proxyProfile" : { + "method" : "System", + "proxies" : [ { + "bypass" : "*.local;169.254/16", + "proxy" : "" + }, { + "bypass" : "*.local;169.254/16", + "proxy" : "" + } ] + }, + "subnetMask" : "255.255.255.0", + "error" : "An operation timed out.", + "wirelessProfile" : { + "rssi" : -38, + "bssid" : "4c:ba:ba:f4:fa:fa", + "snr" : 57, + "vendor" : "Cisco", + "txRate" : 130, + "channel" : 1, + "noise" : -95, + "phyMode" : "802.11n", + "ssid" : "Internet for the masses", + "quality" : 100 + }, + "interfaceName" : "en0", + "dnsServers" : [ "8.8.8.8", "8.8.8.4" ], + "gateway" : "10.0.0.1" + }, + "traceroute" : { + "destination" : "13.32.22.232", + "hops" : [ { + "delay" : 5, + "prefix" : "196.40.96.0/20", + "hop" : 1, + "ipAddress" : "196.40.106.237", + "name" : "89-210-88-65.access.t-2.net", + "mpls" : [ "L=301472,E=0,S=1,T=1" ], + "asn" : 34779 + }, { + "delay" : 5, + "prefix" : "196.40.96.0/20", + "hop" : 1, + "ipAddress" : "196.40.106.237", + "name" : "89-210-88-65.access.t-2.net", + "mpls" : [ "L=301472,E=0,S=1,T=1" ], + "asn" : 34779 + } ], + "error" : "An operation timed out.", + "infoFlags" : [ "TE_INFO_ICMP_BLOCKED_BY_FIREWALL" ], + "internalErrors" : [ "TE_INFO_ICMP_BLOCKED_BY_FIREWALL" ] + }, + "vpnTraceroute" : { + "destination" : "13.32.22.232", + "hops" : [ { + "delay" : 5, + "prefix" : "196.40.96.0/20", + "hop" : 1, + "ipAddress" : "196.40.106.237", + "name" : "89-210-88-65.access.t-2.net", + "mpls" : [ "L=301472,E=0,S=1,T=1" ], + "asn" : 34779 + }, { + "delay" : 5, + "prefix" : "196.40.96.0/20", + "hop" : 1, + "ipAddress" : "196.40.106.237", + "name" : "89-210-88-65.access.t-2.net", + "mpls" : [ "L=301472,E=0,S=1,T=1" ], + "asn" : 34779 + } ], + "error" : "An operation timed out.", + "infoFlags" : [ "TE_INFO_ICMP_BLOCKED_BY_FIREWALL" ], + "internalErrors" : [ "TE_INFO_ICMP_BLOCKED_BY_FIREWALL" ] + }, + "connectRtt" : 77.777, + "gatewayPing" : { + "maxRtt" : 66, + "loss" : 1, + "pktsReceived" : 10, + "avgRtt" : 7, + "meanDevRtt" : 11, + "minRtt" : 1, + "error" : "An operation timed out.", + "infoFlags" : [ "TE_INFO_ICMP_BLOCKED_BY_FIREWALL" ], + "pktsSent" : 10 + }, + "errors" : [ "ping: Request timed out before getting response" ] + }, + "protocol" : "https", + "pages" : [ { + "pageTimings" : { + "onContentLoad" : 1483, + "onLoad" : 4569 + }, + "pageTitle" : "Network Performance Resources | ThousandEyes", + "pageUrl" : "https://app.thousandeyes.com/settings/integrations", + "pageId" : "C31gBrYJ", + "loadDate" : "2022-07-17T22:00:54Z", + "responseCode" : 200 + }, { + "pageTimings" : { + "onContentLoad" : 1483, + "onLoad" : 4569 + }, + "pageTitle" : "Network Performance Resources | ThousandEyes", + "pageUrl" : "https://app.thousandeyes.com/settings/integrations", + "pageId" : "C31gBrYJ", + "loadDate" : "2022-07-17T22:00:54Z", + "responseCode" : 200 + } ], + "numberOfPages" : 2, + "port" : 443, + "browser" : { + "name" : "Google Chrome", + "version" : "116.0.0.0" + }, + "id" : "07625:1490529480:aVDViw0i", + "roundId" : 1384309800 + } ] + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_real_user_test_results( + + id=id, + + aid=aid, + + _headers=self.te_headers("get_real_user_test_results"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_real_user_test_results_error_401(self) -> None: + """Integration test for get_real_user_test_results error path (HTTP 401)""" + id = '07625:1490529480:h3qJQTpl' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_real_user_test_results( + + id=id, + + aid=aid, + + _headers=self.te_headers("get_real_user_test_results", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_real_user_test_results_error_403(self) -> None: + """Integration test for get_real_user_test_results error path (HTTP 403)""" + id = '07625:1490529480:h3qJQTpl' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_real_user_test_results( + + id=id, + + aid=aid, + + _headers=self.te_headers("get_real_user_test_results", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_real_user_test_results_error_404(self) -> None: + """Integration test for get_real_user_test_results error path (HTTP 404)""" + id = '07625:1490529480:h3qJQTpl' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_real_user_test_results( + + id=id, + + aid=aid, + + _headers=self.te_headers("get_real_user_test_results", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_real_user_test_results_error_429(self) -> None: + """Integration test for get_real_user_test_results error path (HTTP 429)""" + id = '07625:1490529480:h3qJQTpl' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_real_user_test_results( + + id=id, + + aid=aid, + + _headers=self.te_headers("get_real_user_test_results", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_real_user_test_results_error_500(self) -> None: + """Integration test for get_real_user_test_results error path (HTTP 500)""" + id = '07625:1490529480:h3qJQTpl' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_real_user_test_results( + + id=id, + + aid=aid, + + _headers=self.te_headers("get_real_user_test_results", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_real_user_test_results_error_502(self) -> None: + """Integration test for get_real_user_test_results error path (HTTP 502)""" + id = '07625:1490529480:h3qJQTpl' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.get_real_user_test_results( + + id=id, + + aid=aid, + + _headers=self.te_headers("get_real_user_test_results", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-endpoint-test-results/test/test_utils.py b/thousandeyes-sdk-endpoint-test-results/test/test_utils.py index 930528d9..37913f62 100644 --- a/thousandeyes-sdk-endpoint-test-results/test/test_utils.py +++ b/thousandeyes-sdk-endpoint-test-results/test/test_utils.py @@ -2,15 +2,36 @@ import json import unittest +from typing import Any from pydantic import BaseModel +def _project_onto_constructed(expected: Any, constructed: Any) -> Any: + """Keep only example fields that appear in the constructed model output.""" + if isinstance(constructed, dict): + if not isinstance(expected, dict): + return expected + return { + key: _project_onto_constructed(expected.get(key), value) + for key, value in constructed.items() + } + if isinstance(constructed, list): + if not isinstance(expected, list): + return expected + return [ + _project_onto_constructed(expected[index], value) + for index, value in enumerate(constructed) + ] + return expected + + def assert_constructed_model_matches_example_json(model: BaseModel, loaded_json: dict): test_case = unittest.TestCase() test_case.maxDiff = None test_case.assertIsNotNone(model) constructed_json = json.loads(model.to_json()) - sorted_loaded_json = json.dumps(loaded_json, sort_keys=True) + projected_loaded_json = _project_onto_constructed(loaded_json, constructed_json) + sorted_loaded_json = json.dumps(projected_loaded_json, sort_keys=True) sorted_constructed_json = json.dumps(constructed_json, sort_keys=True) test_case.assertEqual(sorted_loaded_json, sorted_constructed_json) diff --git a/thousandeyes-sdk-endpoint-tests/test/conftest.py b/thousandeyes-sdk-endpoint-tests/test/conftest.py new file mode 100644 index 00000000..2edba7b3 --- /dev/null +++ b/thousandeyes-sdk-endpoint-tests/test/conftest.py @@ -0,0 +1,7 @@ +import sys +from pathlib import Path + +_repo_root = Path(__file__).resolve().parents[2] +_core_test_support = _repo_root / "thousandeyes-sdk-core" / "test" +if str(_core_test_support) not in sys.path: + sys.path.insert(0, str(_core_test_support)) diff --git a/thousandeyes-sdk-endpoint-tests/test/integration_test_utils.py b/thousandeyes-sdk-endpoint-tests/test/integration_test_utils.py new file mode 100644 index 00000000..5a1cf965 --- /dev/null +++ b/thousandeyes-sdk-endpoint-tests/test/integration_test_utils.py @@ -0,0 +1,37 @@ +# coding: utf-8 + +""" + Endpoint Tests API + + Manage endpoint agent dynamic and scheduled tests using the Endpoint Tests API. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from thousandeyes_sdk.core.api_client import ApiClient +from thousandeyes_sdk.core.configuration import Configuration +from sdk_test_support.mock_server import ERROR_STATUS_HEADER, OPERATION_ID_HEADER, MockApiServer + +from .mock_manifest import OPERATION_MANIFEST + + +class IntegrationTestBase(unittest.TestCase): + def setUp(self) -> None: + self.server = MockApiServer(OPERATION_MANIFEST) + self.server.start() + configuration = Configuration(host=self.server.base_url, access_token="test-token") + self.api_client = ApiClient(configuration=configuration) + + def tearDown(self) -> None: + self.server.stop() + + def te_headers(self, operation_id: str, error_status=None): + headers = {OPERATION_ID_HEADER: operation_id} + if error_status is not None: + headers[ERROR_STATUS_HEADER] = error_status + return headers diff --git a/thousandeyes-sdk-endpoint-tests/test/mock_manifest.py b/thousandeyes-sdk-endpoint-tests/test/mock_manifest.py new file mode 100644 index 00000000..5f8f0d5e --- /dev/null +++ b/thousandeyes-sdk-endpoint-tests/test/mock_manifest.py @@ -0,0 +1,2809 @@ +# coding: utf-8 + +""" + Endpoint Tests API + + Manage endpoint agent dynamic and scheduled tests using the Endpoint Tests API. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json + +from sdk_test_support.mock_server_types import ErrorResponseExpectation, OperationExpectation + +OPERATION_MANIFEST = { + + "create_agent_to_server_endpoint_dynamic_test": OperationExpectation( + operation_id="create_agent_to_server_endpoint_dynamic_test", + method="POST", + path="/endpoint/tests/dynamic-tests/agent-to-server", + path_param_examples={ + }, + success_status=201, + success_body=json.loads(""" + + { + "hasPing" : true, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/dynamic-tests/281474976710706/network/filter" + }, { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/dynamic-tests/281474976710706/pathvis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isPrioritized" : false, + "networkMeasurements" : true, + "tcpProbeMode" : "auto", + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "protocol" : "icmp", + "createdDate" : "2022-07-17T22:00:54Z", + "ipVersion" : "V4_ONLY", + "application" : "webex", + "hasTraceroute" : true, + "isEnabled" : true, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "aid" : "1234", + "agentSelectorConfig" : { + "agentSelectorType" : "all-agents", + "maxMachines" : 25 + }, + "hasPathTraceInSession" : true, + "testName" : "Test name" + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "agentSelectorType" : "all-agents", + "tagIds" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "5aeab5d5-0d34-4d44-a7ac-fb440185295c" ], + "isPrioritized" : false, + "maxMachines" : 25, + "endpointAgentLabels" : [ "567", "214" ], + "tcpProbeMode" : "auto", + "agents" : [ "0a3b9998-dc3a-4ff2-b50d-ac4a7cd986e1", "66eec0f1-72b4-4755-aa83-3aed61d17f3c" ], + "protocol" : "icmp", + "ipVersion" : "V4_ONLY", + "application" : "webex", + "interval" : 60, + "hasPathTraceInSession" : true, + "testName" : "Test name" + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "delete_agent_to_server_endpoint_dynamic_test": OperationExpectation( + operation_id="delete_agent_to_server_endpoint_dynamic_test", + method="DELETE", + path="/endpoint/tests/dynamic-tests/agent-to-server/{testId}", + path_param_examples={ + "testId": '584739201', + }, + success_status=204, + success_body=None, + success_content_type="application/json", + request_body_example=None, + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_agent_to_server_endpoint_dynamic_test": OperationExpectation( + operation_id="get_agent_to_server_endpoint_dynamic_test", + method="GET", + path="/endpoint/tests/dynamic-tests/agent-to-server/{testId}", + path_param_examples={ + "testId": '584739201', + }, + success_status=200, + success_body=json.loads(""" + + { + "hasPing" : true, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/dynamic-tests/281474976710706/network/filter" + }, { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/dynamic-tests/281474976710706/pathvis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isPrioritized" : false, + "networkMeasurements" : true, + "tcpProbeMode" : "auto", + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "protocol" : "icmp", + "createdDate" : "2022-07-17T22:00:54Z", + "ipVersion" : "V4_ONLY", + "application" : "webex", + "hasTraceroute" : true, + "isEnabled" : true, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "aid" : "1234", + "agentSelectorConfig" : { + "agentSelectorType" : "all-agents", + "maxMachines" : 25 + }, + "hasPathTraceInSession" : true, + "testName" : "Test name" + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_agent_to_server_endpoint_dynamic_tests": OperationExpectation( + operation_id="get_agent_to_server_endpoint_dynamic_tests", + method="GET", + path="/endpoint/tests/dynamic-tests/agent-to-server", + path_param_examples={ + }, + success_status=200, + success_body=json.loads(""" + + { + "tests" : [ { + "hasPing" : true, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/dynamic-tests/281474976710706/network/filter" + }, { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/dynamic-tests/281474976710706/pathvis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isPrioritized" : false, + "networkMeasurements" : true, + "tcpProbeMode" : "auto", + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "protocol" : "icmp", + "createdDate" : "2022-07-17T22:00:54Z", + "ipVersion" : "V4_ONLY", + "application" : "webex", + "hasTraceroute" : true, + "isEnabled" : true, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "aid" : "1234", + "agentSelectorConfig" : { + "agentSelectorType" : "all-agents", + "maxMachines" : 25 + }, + "hasPathTraceInSession" : true, + "testName" : "Test name" + }, { + "hasPing" : true, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/dynamic-tests/281474976710706/network/filter" + }, { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/dynamic-tests/281474976710706/pathvis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isPrioritized" : false, + "networkMeasurements" : true, + "tcpProbeMode" : "auto", + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "protocol" : "icmp", + "createdDate" : "2022-07-17T22:00:54Z", + "ipVersion" : "V4_ONLY", + "application" : "webex", + "hasTraceroute" : true, + "isEnabled" : true, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "aid" : "1234", + "agentSelectorConfig" : { + "agentSelectorType" : "all-agents", + "maxMachines" : 25 + }, + "hasPathTraceInSession" : true, + "testName" : "Test name" + } ], + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "update_agent_to_server_endpoint_dynamic_test": OperationExpectation( + operation_id="update_agent_to_server_endpoint_dynamic_test", + method="PATCH", + path="/endpoint/tests/dynamic-tests/agent-to-server/{testId}", + path_param_examples={ + "testId": '584739201', + }, + success_status=200, + success_body=json.loads(""" + + { + "hasPing" : true, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/dynamic-tests/281474976710706/network/filter" + }, { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/dynamic-tests/281474976710706/pathvis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isPrioritized" : false, + "networkMeasurements" : true, + "tcpProbeMode" : "auto", + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "protocol" : "icmp", + "createdDate" : "2022-07-17T22:00:54Z", + "ipVersion" : "V4_ONLY", + "application" : "webex", + "hasTraceroute" : true, + "isEnabled" : true, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "aid" : "1234", + "agentSelectorConfig" : { + "agentSelectorType" : "all-agents", + "maxMachines" : 25 + }, + "hasPathTraceInSession" : true, + "testName" : "Test name" + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "protocol" : "icmp", + "application" : "webex", + "isEnabled" : true, + "interval" : 60, + "tcpProbeMode" : "auto", + "testName" : "Test name" + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "create_agent_to_server_endpoint_scheduled_test": OperationExpectation( + operation_id="create_agent_to_server_endpoint_scheduled_test", + method="POST", + path="/endpoint/tests/scheduled-tests/agent-to-server", + path_param_examples={ + }, + success_status=201, + success_body=json.loads(""" + + { + "server" : "www.example.com", + "isSavedEvent" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/scheduled-tests/281474976710706/network/filter" + }, { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/scheduled-tests/281474976710706/pathvis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isPrioritized" : false, + "networkMeasurements" : true, + "type" : "agent-to-server", + "tcpProbeMode" : "auto", + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "protocol" : "icmp", + "createdDate" : "2022-07-17T22:00:54Z", + "ipVersion" : "V4_ONLY", + "port" : 443, + "isEnabled" : true, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "aid" : "1234", + "agentSelectorConfig" : { + "agentSelectorType" : "all-agents", + "maxMachines" : 25 + }, + "hasPathTraceInSession" : true, + "testName" : "Test name" + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "server" : "www.example.com", + "agentSelectorType" : "all-agents", + "tagIds" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "5aeab5d5-0d34-4d44-a7ac-fb440185295c" ], + "maxMachines" : 25, + "serverName" : "www.example.com", + "isPrioritized" : false, + "endpointAgentLabels" : [ "567", "214" ], + "agents" : [ "0a3b9998-dc3a-4ff2-b50d-ac4a7cd986e1", "66eec0f1-72b4-4755-aa83-3aed61d17f3c" ], + "protocol" : "icmp", + "ipVersion" : "V4_ONLY", + "port" : 443, + "interval" : 60, + "testName" : "Test name" + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "delete_agent_to_server_endpoint_scheduled_test": OperationExpectation( + operation_id="delete_agent_to_server_endpoint_scheduled_test", + method="DELETE", + path="/endpoint/tests/scheduled-tests/agent-to-server/{testId}", + path_param_examples={ + "testId": '584739201', + }, + success_status=204, + success_body=None, + success_content_type="application/json", + request_body_example=None, + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_agent_to_server_endpoint_scheduled_test": OperationExpectation( + operation_id="get_agent_to_server_endpoint_scheduled_test", + method="GET", + path="/endpoint/tests/scheduled-tests/agent-to-server/{testId}", + path_param_examples={ + "testId": '584739201', + }, + success_status=200, + success_body=json.loads(""" + + { + "server" : "www.example.com", + "isSavedEvent" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/scheduled-tests/281474976710706/network/filter" + }, { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/scheduled-tests/281474976710706/pathvis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isPrioritized" : false, + "networkMeasurements" : true, + "type" : "agent-to-server", + "tcpProbeMode" : "auto", + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "protocol" : "icmp", + "createdDate" : "2022-07-17T22:00:54Z", + "ipVersion" : "V4_ONLY", + "port" : 443, + "isEnabled" : true, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "aid" : "1234", + "agentSelectorConfig" : { + "agentSelectorType" : "all-agents", + "maxMachines" : 25 + }, + "hasPathTraceInSession" : true, + "testName" : "Test name" + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_agent_to_server_endpoint_scheduled_tests": OperationExpectation( + operation_id="get_agent_to_server_endpoint_scheduled_tests", + method="GET", + path="/endpoint/tests/scheduled-tests/agent-to-server", + path_param_examples={ + }, + success_status=200, + success_body=json.loads(""" + + { + "tests" : [ { + "server" : "www.example.com", + "isSavedEvent" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/scheduled-tests/281474976710706/network/filter" + }, { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/scheduled-tests/281474976710706/pathvis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isPrioritized" : false, + "networkMeasurements" : true, + "type" : "agent-to-server", + "tcpProbeMode" : "auto", + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "protocol" : "icmp", + "createdDate" : "2022-07-17T22:00:54Z", + "ipVersion" : "V4_ONLY", + "port" : 443, + "isEnabled" : true, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "aid" : "1234", + "agentSelectorConfig" : { + "agentSelectorType" : "all-agents", + "maxMachines" : 25 + }, + "hasPathTraceInSession" : true, + "testName" : "Test name" + }, { + "server" : "www.example.com", + "isSavedEvent" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/scheduled-tests/281474976710706/network/filter" + }, { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/scheduled-tests/281474976710706/pathvis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isPrioritized" : false, + "networkMeasurements" : true, + "type" : "agent-to-server", + "tcpProbeMode" : "auto", + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "protocol" : "icmp", + "createdDate" : "2022-07-17T22:00:54Z", + "ipVersion" : "V4_ONLY", + "port" : 443, + "isEnabled" : true, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "aid" : "1234", + "agentSelectorConfig" : { + "agentSelectorType" : "all-agents", + "maxMachines" : 25 + }, + "hasPathTraceInSession" : true, + "testName" : "Test name" + } ], + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "update_agent_to_server_endpoint_scheduled_test": OperationExpectation( + operation_id="update_agent_to_server_endpoint_scheduled_test", + method="PATCH", + path="/endpoint/tests/scheduled-tests/agent-to-server/{testId}", + path_param_examples={ + "testId": '584739201', + }, + success_status=200, + success_body=json.loads(""" + + { + "server" : "www.example.com", + "isSavedEvent" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/scheduled-tests/281474976710706/network/filter" + }, { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/scheduled-tests/281474976710706/pathvis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isPrioritized" : false, + "networkMeasurements" : true, + "type" : "agent-to-server", + "tcpProbeMode" : "auto", + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "protocol" : "icmp", + "createdDate" : "2022-07-17T22:00:54Z", + "ipVersion" : "V4_ONLY", + "port" : 443, + "isEnabled" : true, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "aid" : "1234", + "agentSelectorConfig" : { + "agentSelectorType" : "all-agents", + "maxMachines" : 25 + }, + "hasPathTraceInSession" : true, + "testName" : "Test name" + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "server" : "www.example.com", + "protocol" : "icmp", + "port" : 49153, + "isEnabled" : true, + "interval" : 60, + "tcpProbeMode" : "auto", + "testName" : "Test name" + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_endpoint_real_user_tests": OperationExpectation( + operation_id="get_endpoint_real_user_tests", + method="GET", + path="/endpoint/tests/real-user-tests", + path_param_examples={ + }, + success_status=200, + success_body=json.loads(""" + + { + "realUserTests" : [ { + "includedDomains" : [ "example.com", "example.com" ], + "profileId" : "73421", + "monitoringSettings" : { + "monitoringSettingsId" : "1f5c1b5d-8a0d-4d6b-a3be-56b060f7f2c9", + "monitoringSettingsType" : "agent-tags", + "tagIds" : [ "49d9e7d2-7df5-43df-9b37-aa596b929062" ], + "labelIds" : [ "567" ] + }, + "name" : "Corporate domains", + "excludedDomains" : [ "static.example.com", "static.example.com" ], + "aid" : "1234" + }, { + "includedDomains" : [ "example.com", "example.com" ], + "profileId" : "73421", + "monitoringSettings" : { + "monitoringSettingsId" : "1f5c1b5d-8a0d-4d6b-a3be-56b060f7f2c9", + "monitoringSettingsType" : "agent-tags", + "tagIds" : [ "49d9e7d2-7df5-43df-9b37-aa596b929062" ], + "labelIds" : [ "567" ] + }, + "name" : "Corporate domains", + "excludedDomains" : [ "static.example.com", "static.example.com" ], + "aid" : "1234" + } ] + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_endpoint_scheduled_tests": OperationExpectation( + operation_id="get_endpoint_scheduled_tests", + method="GET", + path="/endpoint/tests/scheduled-tests", + path_param_examples={ + }, + success_status=200, + success_body=json.loads(""" + + { + "tests" : [ { + "server" : "www.example.com", + "isSavedEvent" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/scheduled-tests/281474976710706/network/filter" + }, { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/scheduled-tests/281474976710706/pathvis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isPrioritized" : false, + "networkMeasurements" : true, + "type" : "agent-to-server", + "tcpProbeMode" : "auto", + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "protocol" : "icmp", + "createdDate" : "2022-07-17T22:00:54Z", + "ipVersion" : "V4_ONLY", + "port" : 443, + "isEnabled" : true, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "aid" : "1234", + "agentSelectorConfig" : { + "agentSelectorType" : "all-agents", + "maxMachines" : 25 + }, + "hasPathTraceInSession" : true, + "testName" : "Test name" + }, { + "server" : "www.example.com", + "isSavedEvent" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/scheduled-tests/281474976710706/network/filter" + }, { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/scheduled-tests/281474976710706/pathvis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isPrioritized" : false, + "networkMeasurements" : true, + "type" : "agent-to-server", + "tcpProbeMode" : "auto", + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "protocol" : "icmp", + "createdDate" : "2022-07-17T22:00:54Z", + "ipVersion" : "V4_ONLY", + "port" : 443, + "isEnabled" : true, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "aid" : "1234", + "agentSelectorConfig" : { + "agentSelectorType" : "all-agents", + "maxMachines" : 25 + }, + "hasPathTraceInSession" : true, + "testName" : "Test name" + } ], + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "create_http_server_endpoint_scheduled_test": OperationExpectation( + operation_id="create_http_server_endpoint_scheduled_test", + method="POST", + path="/endpoint/tests/scheduled-tests/http-server", + path_param_examples={ + }, + success_status=201, + success_body=json.loads(""" + + { + "server" : "www.example.com", + "isSavedEvent" : false, + "sslVersion" : "Auto", + "useNtlm" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/scheduled-tests/281474976710706/network/filter" + }, { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/scheduled-tests/281474976710706/pathvis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isPrioritized" : false, + "httpTimeLimit" : 5000, + "type" : "http-server", + "protocol" : "icmp", + "httpVersion" : 2, + "followRedirects" : true, + "authType" : "none", + "testName" : "Test name", + "verifyCertificate" : true, + "networkMeasurements" : true, + "tcpProbeMode" : "auto", + "url" : "https://example.com:443", + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "ipVersion" : "V4_ONLY", + "port" : 443, + "isEnabled" : true, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "aid" : "1234", + "agentSelectorConfig" : { + "agentSelectorType" : "all-agents", + "maxMachines" : 25 + }, + "hasPathTraceInSession" : true, + "httpTargetTime" : 100, + "username" : "username", + "sslVersionId" : "0" + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "verifyCertificate" : true, + "hasPing" : true, + "agentSelectorType" : "all-agents", + "tagIds" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "5aeab5d5-0d34-4d44-a7ac-fb440185295c" ], + "maxMachines" : 25, + "isPrioritized" : false, + "httpTimeLimit" : 5000, + "networkMeasurements" : true, + "endpointAgentLabels" : [ "567", "214" ], + "tcpProbeMode" : "auto", + "url" : "https://example.com:443", + "agents" : [ "0a3b9998-dc3a-4ff2-b50d-ac4a7cd986e1", "66eec0f1-72b4-4755-aa83-3aed61d17f3c" ], + "protocol" : "icmp", + "password" : "password", + "ipVersion" : "V4_ONLY", + "hasTraceroute" : true, + "targetResponseTime" : 1000, + "interval" : 60, + "authType" : "none", + "hasPathTraceInSession" : true, + "testName" : "Test name", + "username" : "username", + "sslVersionId" : "0" + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "delete_http_server_endpoint_scheduled_test": OperationExpectation( + operation_id="delete_http_server_endpoint_scheduled_test", + method="DELETE", + path="/endpoint/tests/scheduled-tests/http-server/{testId}", + path_param_examples={ + "testId": '584739201', + }, + success_status=204, + success_body=None, + success_content_type="application/json", + request_body_example=None, + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_http_server_endpoint_scheduled_test": OperationExpectation( + operation_id="get_http_server_endpoint_scheduled_test", + method="GET", + path="/endpoint/tests/scheduled-tests/http-server/{testId}", + path_param_examples={ + "testId": '584739201', + }, + success_status=200, + success_body=json.loads(""" + + { + "server" : "www.example.com", + "isSavedEvent" : false, + "sslVersion" : "Auto", + "useNtlm" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/scheduled-tests/281474976710706/network/filter" + }, { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/scheduled-tests/281474976710706/pathvis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isPrioritized" : false, + "httpTimeLimit" : 5000, + "type" : "http-server", + "protocol" : "icmp", + "httpVersion" : 2, + "followRedirects" : true, + "authType" : "none", + "testName" : "Test name", + "verifyCertificate" : true, + "networkMeasurements" : true, + "tcpProbeMode" : "auto", + "url" : "https://example.com:443", + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "ipVersion" : "V4_ONLY", + "port" : 443, + "isEnabled" : true, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "aid" : "1234", + "agentSelectorConfig" : { + "agentSelectorType" : "all-agents", + "maxMachines" : 25 + }, + "hasPathTraceInSession" : true, + "httpTargetTime" : 100, + "username" : "username", + "sslVersionId" : "0" + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_http_server_endpoint_scheduled_tests": OperationExpectation( + operation_id="get_http_server_endpoint_scheduled_tests", + method="GET", + path="/endpoint/tests/scheduled-tests/http-server", + path_param_examples={ + }, + success_status=200, + success_body=json.loads(""" + + { + "tests" : [ { + "server" : "www.example.com", + "isSavedEvent" : false, + "sslVersion" : "Auto", + "useNtlm" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/scheduled-tests/281474976710706/network/filter" + }, { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/scheduled-tests/281474976710706/pathvis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isPrioritized" : false, + "httpTimeLimit" : 5000, + "type" : "http-server", + "protocol" : "icmp", + "httpVersion" : 2, + "followRedirects" : true, + "authType" : "none", + "testName" : "Test name", + "verifyCertificate" : true, + "networkMeasurements" : true, + "tcpProbeMode" : "auto", + "url" : "https://example.com:443", + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "ipVersion" : "V4_ONLY", + "port" : 443, + "isEnabled" : true, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "aid" : "1234", + "agentSelectorConfig" : { + "agentSelectorType" : "all-agents", + "maxMachines" : 25 + }, + "hasPathTraceInSession" : true, + "httpTargetTime" : 100, + "username" : "username", + "sslVersionId" : "0" + }, { + "server" : "www.example.com", + "isSavedEvent" : false, + "sslVersion" : "Auto", + "useNtlm" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/scheduled-tests/281474976710706/network/filter" + }, { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/scheduled-tests/281474976710706/pathvis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isPrioritized" : false, + "httpTimeLimit" : 5000, + "type" : "http-server", + "protocol" : "icmp", + "httpVersion" : 2, + "followRedirects" : true, + "authType" : "none", + "testName" : "Test name", + "verifyCertificate" : true, + "networkMeasurements" : true, + "tcpProbeMode" : "auto", + "url" : "https://example.com:443", + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "ipVersion" : "V4_ONLY", + "port" : 443, + "isEnabled" : true, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "aid" : "1234", + "agentSelectorConfig" : { + "agentSelectorType" : "all-agents", + "maxMachines" : 25 + }, + "hasPathTraceInSession" : true, + "httpTargetTime" : 100, + "username" : "username", + "sslVersionId" : "0" + } ], + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "update_http_server_endpoint_scheduled_test": OperationExpectation( + operation_id="update_http_server_endpoint_scheduled_test", + method="PATCH", + path="/endpoint/tests/scheduled-tests/http-server/{testId}", + path_param_examples={ + "testId": '584739201', + }, + success_status=200, + success_body=json.loads(""" + + { + "server" : "www.example.com", + "isSavedEvent" : false, + "sslVersion" : "Auto", + "useNtlm" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/scheduled-tests/281474976710706/network/filter" + }, { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/scheduled-tests/281474976710706/pathvis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isPrioritized" : false, + "httpTimeLimit" : 5000, + "type" : "http-server", + "protocol" : "icmp", + "httpVersion" : 2, + "followRedirects" : true, + "authType" : "none", + "testName" : "Test name", + "verifyCertificate" : true, + "networkMeasurements" : true, + "tcpProbeMode" : "auto", + "url" : "https://example.com:443", + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "ipVersion" : "V4_ONLY", + "port" : 443, + "isEnabled" : true, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "aid" : "1234", + "agentSelectorConfig" : { + "agentSelectorType" : "all-agents", + "maxMachines" : 25 + }, + "hasPathTraceInSession" : true, + "httpTargetTime" : 100, + "username" : "username", + "sslVersionId" : "0" + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "protocol" : "icmp", + "isEnabled" : true, + "interval" : 60, + "tcpProbeMode" : "auto", + "url" : "https://example.com:443", + "testName" : "Test name" + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + +} diff --git a/thousandeyes-sdk-endpoint-tests/test/test_agent_to_server_endpoint_dynamic_tests_api_integration.py b/thousandeyes-sdk-endpoint-tests/test/test_agent_to_server_endpoint_dynamic_tests_api_integration.py new file mode 100644 index 00000000..bb4673f4 --- /dev/null +++ b/thousandeyes-sdk-endpoint-tests/test/test_agent_to_server_endpoint_dynamic_tests_api_integration.py @@ -0,0 +1,1548 @@ +# coding: utf-8 + +""" + Endpoint Tests API + + Manage endpoint agent dynamic and scheduled tests using the Endpoint Tests API. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.endpoint_tests.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.endpoint_tests.api.agent_to_server_endpoint_dynamic_tests_api import AgentToServerEndpointDynamicTestsApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestAgentToServerEndpointDynamicTestsApiIntegration(IntegrationTestBase): + """AgentToServerEndpointDynamicTestsApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = AgentToServerEndpointDynamicTestsApi(self.api_client) + + + def test_create_agent_to_server_endpoint_dynamic_test_happy_path(self) -> None: + """Integration test for create_agent_to_server_endpoint_dynamic_test success path""" + request_body_json = """ + + { + "agentSelectorType" : "all-agents", + "tagIds" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "5aeab5d5-0d34-4d44-a7ac-fb440185295c" ], + "isPrioritized" : false, + "maxMachines" : 25, + "endpointAgentLabels" : [ "567", "214" ], + "tcpProbeMode" : "auto", + "agents" : [ "0a3b9998-dc3a-4ff2-b50d-ac4a7cd986e1", "66eec0f1-72b4-4755-aa83-3aed61d17f3c" ], + "protocol" : "icmp", + "ipVersion" : "V4_ONLY", + "application" : "webex", + "interval" : 60, + "hasPathTraceInSession" : true, + "testName" : "Test name" + } + + """ + dynamic_test_request = thousandeyes_sdk.endpoint_tests.models.DynamicTestRequest.from_json(request_body_json) + aid = '1234' + response_body_json = """ + { + "hasPing" : true, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/dynamic-tests/281474976710706/network/filter" + }, { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/dynamic-tests/281474976710706/pathvis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isPrioritized" : false, + "networkMeasurements" : true, + "tcpProbeMode" : "auto", + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "protocol" : "icmp", + "createdDate" : "2022-07-17T22:00:54Z", + "ipVersion" : "V4_ONLY", + "application" : "webex", + "hasTraceroute" : true, + "isEnabled" : true, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "aid" : "1234", + "agentSelectorConfig" : { + "agentSelectorType" : "all-agents", + "maxMachines" : 25 + }, + "hasPathTraceInSession" : true, + "testName" : "Test name" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.create_agent_to_server_endpoint_dynamic_test( + + dynamic_test_request=dynamic_test_request, + + aid=aid, + + _headers=self.te_headers("create_agent_to_server_endpoint_dynamic_test"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_create_agent_to_server_endpoint_dynamic_test_error_400(self) -> None: + """Integration test for create_agent_to_server_endpoint_dynamic_test error path (HTTP 400)""" + request_body_json = """ + + { + "agentSelectorType" : "all-agents", + "tagIds" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "5aeab5d5-0d34-4d44-a7ac-fb440185295c" ], + "isPrioritized" : false, + "maxMachines" : 25, + "endpointAgentLabels" : [ "567", "214" ], + "tcpProbeMode" : "auto", + "agents" : [ "0a3b9998-dc3a-4ff2-b50d-ac4a7cd986e1", "66eec0f1-72b4-4755-aa83-3aed61d17f3c" ], + "protocol" : "icmp", + "ipVersion" : "V4_ONLY", + "application" : "webex", + "interval" : 60, + "hasPathTraceInSession" : true, + "testName" : "Test name" + } + + """ + dynamic_test_request = thousandeyes_sdk.endpoint_tests.models.DynamicTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.create_agent_to_server_endpoint_dynamic_test( + + dynamic_test_request=dynamic_test_request, + + aid=aid, + + _headers=self.te_headers("create_agent_to_server_endpoint_dynamic_test", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_agent_to_server_endpoint_dynamic_test_error_401(self) -> None: + """Integration test for create_agent_to_server_endpoint_dynamic_test error path (HTTP 401)""" + request_body_json = """ + + { + "agentSelectorType" : "all-agents", + "tagIds" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "5aeab5d5-0d34-4d44-a7ac-fb440185295c" ], + "isPrioritized" : false, + "maxMachines" : 25, + "endpointAgentLabels" : [ "567", "214" ], + "tcpProbeMode" : "auto", + "agents" : [ "0a3b9998-dc3a-4ff2-b50d-ac4a7cd986e1", "66eec0f1-72b4-4755-aa83-3aed61d17f3c" ], + "protocol" : "icmp", + "ipVersion" : "V4_ONLY", + "application" : "webex", + "interval" : 60, + "hasPathTraceInSession" : true, + "testName" : "Test name" + } + + """ + dynamic_test_request = thousandeyes_sdk.endpoint_tests.models.DynamicTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.create_agent_to_server_endpoint_dynamic_test( + + dynamic_test_request=dynamic_test_request, + + aid=aid, + + _headers=self.te_headers("create_agent_to_server_endpoint_dynamic_test", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_agent_to_server_endpoint_dynamic_test_error_403(self) -> None: + """Integration test for create_agent_to_server_endpoint_dynamic_test error path (HTTP 403)""" + request_body_json = """ + + { + "agentSelectorType" : "all-agents", + "tagIds" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "5aeab5d5-0d34-4d44-a7ac-fb440185295c" ], + "isPrioritized" : false, + "maxMachines" : 25, + "endpointAgentLabels" : [ "567", "214" ], + "tcpProbeMode" : "auto", + "agents" : [ "0a3b9998-dc3a-4ff2-b50d-ac4a7cd986e1", "66eec0f1-72b4-4755-aa83-3aed61d17f3c" ], + "protocol" : "icmp", + "ipVersion" : "V4_ONLY", + "application" : "webex", + "interval" : 60, + "hasPathTraceInSession" : true, + "testName" : "Test name" + } + + """ + dynamic_test_request = thousandeyes_sdk.endpoint_tests.models.DynamicTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.create_agent_to_server_endpoint_dynamic_test( + + dynamic_test_request=dynamic_test_request, + + aid=aid, + + _headers=self.te_headers("create_agent_to_server_endpoint_dynamic_test", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_agent_to_server_endpoint_dynamic_test_error_404(self) -> None: + """Integration test for create_agent_to_server_endpoint_dynamic_test error path (HTTP 404)""" + request_body_json = """ + + { + "agentSelectorType" : "all-agents", + "tagIds" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "5aeab5d5-0d34-4d44-a7ac-fb440185295c" ], + "isPrioritized" : false, + "maxMachines" : 25, + "endpointAgentLabels" : [ "567", "214" ], + "tcpProbeMode" : "auto", + "agents" : [ "0a3b9998-dc3a-4ff2-b50d-ac4a7cd986e1", "66eec0f1-72b4-4755-aa83-3aed61d17f3c" ], + "protocol" : "icmp", + "ipVersion" : "V4_ONLY", + "application" : "webex", + "interval" : 60, + "hasPathTraceInSession" : true, + "testName" : "Test name" + } + + """ + dynamic_test_request = thousandeyes_sdk.endpoint_tests.models.DynamicTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.create_agent_to_server_endpoint_dynamic_test( + + dynamic_test_request=dynamic_test_request, + + aid=aid, + + _headers=self.te_headers("create_agent_to_server_endpoint_dynamic_test", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_agent_to_server_endpoint_dynamic_test_error_429(self) -> None: + """Integration test for create_agent_to_server_endpoint_dynamic_test error path (HTTP 429)""" + request_body_json = """ + + { + "agentSelectorType" : "all-agents", + "tagIds" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "5aeab5d5-0d34-4d44-a7ac-fb440185295c" ], + "isPrioritized" : false, + "maxMachines" : 25, + "endpointAgentLabels" : [ "567", "214" ], + "tcpProbeMode" : "auto", + "agents" : [ "0a3b9998-dc3a-4ff2-b50d-ac4a7cd986e1", "66eec0f1-72b4-4755-aa83-3aed61d17f3c" ], + "protocol" : "icmp", + "ipVersion" : "V4_ONLY", + "application" : "webex", + "interval" : 60, + "hasPathTraceInSession" : true, + "testName" : "Test name" + } + + """ + dynamic_test_request = thousandeyes_sdk.endpoint_tests.models.DynamicTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.create_agent_to_server_endpoint_dynamic_test( + + dynamic_test_request=dynamic_test_request, + + aid=aid, + + _headers=self.te_headers("create_agent_to_server_endpoint_dynamic_test", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_agent_to_server_endpoint_dynamic_test_error_500(self) -> None: + """Integration test for create_agent_to_server_endpoint_dynamic_test error path (HTTP 500)""" + request_body_json = """ + + { + "agentSelectorType" : "all-agents", + "tagIds" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "5aeab5d5-0d34-4d44-a7ac-fb440185295c" ], + "isPrioritized" : false, + "maxMachines" : 25, + "endpointAgentLabels" : [ "567", "214" ], + "tcpProbeMode" : "auto", + "agents" : [ "0a3b9998-dc3a-4ff2-b50d-ac4a7cd986e1", "66eec0f1-72b4-4755-aa83-3aed61d17f3c" ], + "protocol" : "icmp", + "ipVersion" : "V4_ONLY", + "application" : "webex", + "interval" : 60, + "hasPathTraceInSession" : true, + "testName" : "Test name" + } + + """ + dynamic_test_request = thousandeyes_sdk.endpoint_tests.models.DynamicTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.create_agent_to_server_endpoint_dynamic_test( + + dynamic_test_request=dynamic_test_request, + + aid=aid, + + _headers=self.te_headers("create_agent_to_server_endpoint_dynamic_test", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_agent_to_server_endpoint_dynamic_test_error_502(self) -> None: + """Integration test for create_agent_to_server_endpoint_dynamic_test error path (HTTP 502)""" + request_body_json = """ + + { + "agentSelectorType" : "all-agents", + "tagIds" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "5aeab5d5-0d34-4d44-a7ac-fb440185295c" ], + "isPrioritized" : false, + "maxMachines" : 25, + "endpointAgentLabels" : [ "567", "214" ], + "tcpProbeMode" : "auto", + "agents" : [ "0a3b9998-dc3a-4ff2-b50d-ac4a7cd986e1", "66eec0f1-72b4-4755-aa83-3aed61d17f3c" ], + "protocol" : "icmp", + "ipVersion" : "V4_ONLY", + "application" : "webex", + "interval" : 60, + "hasPathTraceInSession" : true, + "testName" : "Test name" + } + + """ + dynamic_test_request = thousandeyes_sdk.endpoint_tests.models.DynamicTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.create_agent_to_server_endpoint_dynamic_test( + + dynamic_test_request=dynamic_test_request, + + aid=aid, + + _headers=self.te_headers("create_agent_to_server_endpoint_dynamic_test", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_delete_agent_to_server_endpoint_dynamic_test_happy_path(self) -> None: + """Integration test for delete_agent_to_server_endpoint_dynamic_test success path""" + test_id = '584739201' + aid = '1234' + response = self.api.delete_agent_to_server_endpoint_dynamic_test_with_http_info( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_agent_to_server_endpoint_dynamic_test"), + ) + self.assertEqual(204, response.status_code) + self.assertIsNone(response.data) + + + def test_delete_agent_to_server_endpoint_dynamic_test_error_400(self) -> None: + """Integration test for delete_agent_to_server_endpoint_dynamic_test error path (HTTP 400)""" + test_id = '584739201' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.delete_agent_to_server_endpoint_dynamic_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_agent_to_server_endpoint_dynamic_test", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_agent_to_server_endpoint_dynamic_test_error_401(self) -> None: + """Integration test for delete_agent_to_server_endpoint_dynamic_test error path (HTTP 401)""" + test_id = '584739201' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.delete_agent_to_server_endpoint_dynamic_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_agent_to_server_endpoint_dynamic_test", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_agent_to_server_endpoint_dynamic_test_error_403(self) -> None: + """Integration test for delete_agent_to_server_endpoint_dynamic_test error path (HTTP 403)""" + test_id = '584739201' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.delete_agent_to_server_endpoint_dynamic_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_agent_to_server_endpoint_dynamic_test", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_agent_to_server_endpoint_dynamic_test_error_404(self) -> None: + """Integration test for delete_agent_to_server_endpoint_dynamic_test error path (HTTP 404)""" + test_id = '584739201' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.delete_agent_to_server_endpoint_dynamic_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_agent_to_server_endpoint_dynamic_test", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_agent_to_server_endpoint_dynamic_test_error_429(self) -> None: + """Integration test for delete_agent_to_server_endpoint_dynamic_test error path (HTTP 429)""" + test_id = '584739201' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.delete_agent_to_server_endpoint_dynamic_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_agent_to_server_endpoint_dynamic_test", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_agent_to_server_endpoint_dynamic_test_error_500(self) -> None: + """Integration test for delete_agent_to_server_endpoint_dynamic_test error path (HTTP 500)""" + test_id = '584739201' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.delete_agent_to_server_endpoint_dynamic_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_agent_to_server_endpoint_dynamic_test", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_agent_to_server_endpoint_dynamic_test_error_502(self) -> None: + """Integration test for delete_agent_to_server_endpoint_dynamic_test error path (HTTP 502)""" + test_id = '584739201' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.delete_agent_to_server_endpoint_dynamic_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_agent_to_server_endpoint_dynamic_test", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_agent_to_server_endpoint_dynamic_test_happy_path(self) -> None: + """Integration test for get_agent_to_server_endpoint_dynamic_test success path""" + test_id = '584739201' + aid = '1234' + response_body_json = """ + { + "hasPing" : true, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/dynamic-tests/281474976710706/network/filter" + }, { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/dynamic-tests/281474976710706/pathvis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isPrioritized" : false, + "networkMeasurements" : true, + "tcpProbeMode" : "auto", + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "protocol" : "icmp", + "createdDate" : "2022-07-17T22:00:54Z", + "ipVersion" : "V4_ONLY", + "application" : "webex", + "hasTraceroute" : true, + "isEnabled" : true, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "aid" : "1234", + "agentSelectorConfig" : { + "agentSelectorType" : "all-agents", + "maxMachines" : 25 + }, + "hasPathTraceInSession" : true, + "testName" : "Test name" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_agent_to_server_endpoint_dynamic_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("get_agent_to_server_endpoint_dynamic_test"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_agent_to_server_endpoint_dynamic_test_error_401(self) -> None: + """Integration test for get_agent_to_server_endpoint_dynamic_test error path (HTTP 401)""" + test_id = '584739201' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_agent_to_server_endpoint_dynamic_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("get_agent_to_server_endpoint_dynamic_test", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_agent_to_server_endpoint_dynamic_test_error_403(self) -> None: + """Integration test for get_agent_to_server_endpoint_dynamic_test error path (HTTP 403)""" + test_id = '584739201' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_agent_to_server_endpoint_dynamic_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("get_agent_to_server_endpoint_dynamic_test", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_agent_to_server_endpoint_dynamic_test_error_404(self) -> None: + """Integration test for get_agent_to_server_endpoint_dynamic_test error path (HTTP 404)""" + test_id = '584739201' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_agent_to_server_endpoint_dynamic_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("get_agent_to_server_endpoint_dynamic_test", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_agent_to_server_endpoint_dynamic_test_error_429(self) -> None: + """Integration test for get_agent_to_server_endpoint_dynamic_test error path (HTTP 429)""" + test_id = '584739201' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_agent_to_server_endpoint_dynamic_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("get_agent_to_server_endpoint_dynamic_test", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_agent_to_server_endpoint_dynamic_test_error_500(self) -> None: + """Integration test for get_agent_to_server_endpoint_dynamic_test error path (HTTP 500)""" + test_id = '584739201' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_agent_to_server_endpoint_dynamic_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("get_agent_to_server_endpoint_dynamic_test", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_agent_to_server_endpoint_dynamic_test_error_502(self) -> None: + """Integration test for get_agent_to_server_endpoint_dynamic_test error path (HTTP 502)""" + test_id = '584739201' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.get_agent_to_server_endpoint_dynamic_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("get_agent_to_server_endpoint_dynamic_test", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_agent_to_server_endpoint_dynamic_tests_happy_path(self) -> None: + """Integration test for get_agent_to_server_endpoint_dynamic_tests success path""" + aid = '1234' + response_body_json = """ + { + "tests" : [ { + "hasPing" : true, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/dynamic-tests/281474976710706/network/filter" + }, { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/dynamic-tests/281474976710706/pathvis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isPrioritized" : false, + "networkMeasurements" : true, + "tcpProbeMode" : "auto", + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "protocol" : "icmp", + "createdDate" : "2022-07-17T22:00:54Z", + "ipVersion" : "V4_ONLY", + "application" : "webex", + "hasTraceroute" : true, + "isEnabled" : true, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "aid" : "1234", + "agentSelectorConfig" : { + "agentSelectorType" : "all-agents", + "maxMachines" : 25 + }, + "hasPathTraceInSession" : true, + "testName" : "Test name" + }, { + "hasPing" : true, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/dynamic-tests/281474976710706/network/filter" + }, { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/dynamic-tests/281474976710706/pathvis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isPrioritized" : false, + "networkMeasurements" : true, + "tcpProbeMode" : "auto", + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "protocol" : "icmp", + "createdDate" : "2022-07-17T22:00:54Z", + "ipVersion" : "V4_ONLY", + "application" : "webex", + "hasTraceroute" : true, + "isEnabled" : true, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "aid" : "1234", + "agentSelectorConfig" : { + "agentSelectorType" : "all-agents", + "maxMachines" : 25 + }, + "hasPathTraceInSession" : true, + "testName" : "Test name" + } ], + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_agent_to_server_endpoint_dynamic_tests( + + aid=aid, + + _headers=self.te_headers("get_agent_to_server_endpoint_dynamic_tests"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_agent_to_server_endpoint_dynamic_tests_error_401(self) -> None: + """Integration test for get_agent_to_server_endpoint_dynamic_tests error path (HTTP 401)""" + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_agent_to_server_endpoint_dynamic_tests( + + aid=aid, + + _headers=self.te_headers("get_agent_to_server_endpoint_dynamic_tests", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_agent_to_server_endpoint_dynamic_tests_error_403(self) -> None: + """Integration test for get_agent_to_server_endpoint_dynamic_tests error path (HTTP 403)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_agent_to_server_endpoint_dynamic_tests( + + aid=aid, + + _headers=self.te_headers("get_agent_to_server_endpoint_dynamic_tests", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_agent_to_server_endpoint_dynamic_tests_error_429(self) -> None: + """Integration test for get_agent_to_server_endpoint_dynamic_tests error path (HTTP 429)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_agent_to_server_endpoint_dynamic_tests( + + aid=aid, + + _headers=self.te_headers("get_agent_to_server_endpoint_dynamic_tests", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_agent_to_server_endpoint_dynamic_tests_error_500(self) -> None: + """Integration test for get_agent_to_server_endpoint_dynamic_tests error path (HTTP 500)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_agent_to_server_endpoint_dynamic_tests( + + aid=aid, + + _headers=self.te_headers("get_agent_to_server_endpoint_dynamic_tests", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_agent_to_server_endpoint_dynamic_tests_error_502(self) -> None: + """Integration test for get_agent_to_server_endpoint_dynamic_tests error path (HTTP 502)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.get_agent_to_server_endpoint_dynamic_tests( + + aid=aid, + + _headers=self.te_headers("get_agent_to_server_endpoint_dynamic_tests", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_update_agent_to_server_endpoint_dynamic_test_happy_path(self) -> None: + """Integration test for update_agent_to_server_endpoint_dynamic_test success path""" + request_body_json = """ + + { + "protocol" : "icmp", + "application" : "webex", + "isEnabled" : true, + "interval" : 60, + "tcpProbeMode" : "auto", + "testName" : "Test name" + } + + """ + endpoint_dynamic_test_update = thousandeyes_sdk.endpoint_tests.models.EndpointDynamicTestUpdate.from_json(request_body_json) + test_id = '584739201' + aid = '1234' + response_body_json = """ + { + "hasPing" : true, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/dynamic-tests/281474976710706/network/filter" + }, { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/dynamic-tests/281474976710706/pathvis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isPrioritized" : false, + "networkMeasurements" : true, + "tcpProbeMode" : "auto", + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "protocol" : "icmp", + "createdDate" : "2022-07-17T22:00:54Z", + "ipVersion" : "V4_ONLY", + "application" : "webex", + "hasTraceroute" : true, + "isEnabled" : true, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "aid" : "1234", + "agentSelectorConfig" : { + "agentSelectorType" : "all-agents", + "maxMachines" : 25 + }, + "hasPathTraceInSession" : true, + "testName" : "Test name" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.update_agent_to_server_endpoint_dynamic_test( + + test_id=test_id, + + endpoint_dynamic_test_update=endpoint_dynamic_test_update, + + aid=aid, + + _headers=self.te_headers("update_agent_to_server_endpoint_dynamic_test"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_update_agent_to_server_endpoint_dynamic_test_error_400(self) -> None: + """Integration test for update_agent_to_server_endpoint_dynamic_test error path (HTTP 400)""" + request_body_json = """ + + { + "protocol" : "icmp", + "application" : "webex", + "isEnabled" : true, + "interval" : 60, + "tcpProbeMode" : "auto", + "testName" : "Test name" + } + + """ + endpoint_dynamic_test_update = thousandeyes_sdk.endpoint_tests.models.EndpointDynamicTestUpdate.from_json(request_body_json) + test_id = '584739201' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.update_agent_to_server_endpoint_dynamic_test( + + test_id=test_id, + + endpoint_dynamic_test_update=endpoint_dynamic_test_update, + + aid=aid, + + _headers=self.te_headers("update_agent_to_server_endpoint_dynamic_test", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_agent_to_server_endpoint_dynamic_test_error_401(self) -> None: + """Integration test for update_agent_to_server_endpoint_dynamic_test error path (HTTP 401)""" + request_body_json = """ + + { + "protocol" : "icmp", + "application" : "webex", + "isEnabled" : true, + "interval" : 60, + "tcpProbeMode" : "auto", + "testName" : "Test name" + } + + """ + endpoint_dynamic_test_update = thousandeyes_sdk.endpoint_tests.models.EndpointDynamicTestUpdate.from_json(request_body_json) + test_id = '584739201' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.update_agent_to_server_endpoint_dynamic_test( + + test_id=test_id, + + endpoint_dynamic_test_update=endpoint_dynamic_test_update, + + aid=aid, + + _headers=self.te_headers("update_agent_to_server_endpoint_dynamic_test", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_agent_to_server_endpoint_dynamic_test_error_403(self) -> None: + """Integration test for update_agent_to_server_endpoint_dynamic_test error path (HTTP 403)""" + request_body_json = """ + + { + "protocol" : "icmp", + "application" : "webex", + "isEnabled" : true, + "interval" : 60, + "tcpProbeMode" : "auto", + "testName" : "Test name" + } + + """ + endpoint_dynamic_test_update = thousandeyes_sdk.endpoint_tests.models.EndpointDynamicTestUpdate.from_json(request_body_json) + test_id = '584739201' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.update_agent_to_server_endpoint_dynamic_test( + + test_id=test_id, + + endpoint_dynamic_test_update=endpoint_dynamic_test_update, + + aid=aid, + + _headers=self.te_headers("update_agent_to_server_endpoint_dynamic_test", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_agent_to_server_endpoint_dynamic_test_error_404(self) -> None: + """Integration test for update_agent_to_server_endpoint_dynamic_test error path (HTTP 404)""" + request_body_json = """ + + { + "protocol" : "icmp", + "application" : "webex", + "isEnabled" : true, + "interval" : 60, + "tcpProbeMode" : "auto", + "testName" : "Test name" + } + + """ + endpoint_dynamic_test_update = thousandeyes_sdk.endpoint_tests.models.EndpointDynamicTestUpdate.from_json(request_body_json) + test_id = '584739201' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.update_agent_to_server_endpoint_dynamic_test( + + test_id=test_id, + + endpoint_dynamic_test_update=endpoint_dynamic_test_update, + + aid=aid, + + _headers=self.te_headers("update_agent_to_server_endpoint_dynamic_test", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_agent_to_server_endpoint_dynamic_test_error_429(self) -> None: + """Integration test for update_agent_to_server_endpoint_dynamic_test error path (HTTP 429)""" + request_body_json = """ + + { + "protocol" : "icmp", + "application" : "webex", + "isEnabled" : true, + "interval" : 60, + "tcpProbeMode" : "auto", + "testName" : "Test name" + } + + """ + endpoint_dynamic_test_update = thousandeyes_sdk.endpoint_tests.models.EndpointDynamicTestUpdate.from_json(request_body_json) + test_id = '584739201' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.update_agent_to_server_endpoint_dynamic_test( + + test_id=test_id, + + endpoint_dynamic_test_update=endpoint_dynamic_test_update, + + aid=aid, + + _headers=self.te_headers("update_agent_to_server_endpoint_dynamic_test", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_agent_to_server_endpoint_dynamic_test_error_500(self) -> None: + """Integration test for update_agent_to_server_endpoint_dynamic_test error path (HTTP 500)""" + request_body_json = """ + + { + "protocol" : "icmp", + "application" : "webex", + "isEnabled" : true, + "interval" : 60, + "tcpProbeMode" : "auto", + "testName" : "Test name" + } + + """ + endpoint_dynamic_test_update = thousandeyes_sdk.endpoint_tests.models.EndpointDynamicTestUpdate.from_json(request_body_json) + test_id = '584739201' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.update_agent_to_server_endpoint_dynamic_test( + + test_id=test_id, + + endpoint_dynamic_test_update=endpoint_dynamic_test_update, + + aid=aid, + + _headers=self.te_headers("update_agent_to_server_endpoint_dynamic_test", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_agent_to_server_endpoint_dynamic_test_error_502(self) -> None: + """Integration test for update_agent_to_server_endpoint_dynamic_test error path (HTTP 502)""" + request_body_json = """ + + { + "protocol" : "icmp", + "application" : "webex", + "isEnabled" : true, + "interval" : 60, + "tcpProbeMode" : "auto", + "testName" : "Test name" + } + + """ + endpoint_dynamic_test_update = thousandeyes_sdk.endpoint_tests.models.EndpointDynamicTestUpdate.from_json(request_body_json) + test_id = '584739201' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.update_agent_to_server_endpoint_dynamic_test( + + test_id=test_id, + + endpoint_dynamic_test_update=endpoint_dynamic_test_update, + + aid=aid, + + _headers=self.te_headers("update_agent_to_server_endpoint_dynamic_test", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-endpoint-tests/test/test_agent_to_server_endpoint_scheduled_tests_api_integration.py b/thousandeyes-sdk-endpoint-tests/test/test_agent_to_server_endpoint_scheduled_tests_api_integration.py new file mode 100644 index 00000000..33fd5cb7 --- /dev/null +++ b/thousandeyes-sdk-endpoint-tests/test/test_agent_to_server_endpoint_scheduled_tests_api_integration.py @@ -0,0 +1,1561 @@ +# coding: utf-8 + +""" + Endpoint Tests API + + Manage endpoint agent dynamic and scheduled tests using the Endpoint Tests API. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.endpoint_tests.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.endpoint_tests.api.agent_to_server_endpoint_scheduled_tests_api import AgentToServerEndpointScheduledTestsApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestAgentToServerEndpointScheduledTestsApiIntegration(IntegrationTestBase): + """AgentToServerEndpointScheduledTestsApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = AgentToServerEndpointScheduledTestsApi(self.api_client) + + + def test_create_agent_to_server_endpoint_scheduled_test_happy_path(self) -> None: + """Integration test for create_agent_to_server_endpoint_scheduled_test success path""" + request_body_json = """ + + { + "server" : "www.example.com", + "agentSelectorType" : "all-agents", + "tagIds" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "5aeab5d5-0d34-4d44-a7ac-fb440185295c" ], + "maxMachines" : 25, + "serverName" : "www.example.com", + "isPrioritized" : false, + "endpointAgentLabels" : [ "567", "214" ], + "agents" : [ "0a3b9998-dc3a-4ff2-b50d-ac4a7cd986e1", "66eec0f1-72b4-4755-aa83-3aed61d17f3c" ], + "protocol" : "icmp", + "ipVersion" : "V4_ONLY", + "port" : 443, + "interval" : 60, + "testName" : "Test name" + } + + """ + endpoint_agent_to_server_test_request = thousandeyes_sdk.endpoint_tests.models.EndpointAgentToServerTestRequest.from_json(request_body_json) + aid = '1234' + response_body_json = """ + { + "server" : "www.example.com", + "isSavedEvent" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/scheduled-tests/281474976710706/network/filter" + }, { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/scheduled-tests/281474976710706/pathvis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isPrioritized" : false, + "networkMeasurements" : true, + "type" : "agent-to-server", + "tcpProbeMode" : "auto", + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "protocol" : "icmp", + "createdDate" : "2022-07-17T22:00:54Z", + "ipVersion" : "V4_ONLY", + "port" : 443, + "isEnabled" : true, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "aid" : "1234", + "agentSelectorConfig" : { + "agentSelectorType" : "all-agents", + "maxMachines" : 25 + }, + "hasPathTraceInSession" : true, + "testName" : "Test name" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.create_agent_to_server_endpoint_scheduled_test( + + endpoint_agent_to_server_test_request=endpoint_agent_to_server_test_request, + + aid=aid, + + _headers=self.te_headers("create_agent_to_server_endpoint_scheduled_test"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_create_agent_to_server_endpoint_scheduled_test_error_400(self) -> None: + """Integration test for create_agent_to_server_endpoint_scheduled_test error path (HTTP 400)""" + request_body_json = """ + + { + "server" : "www.example.com", + "agentSelectorType" : "all-agents", + "tagIds" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "5aeab5d5-0d34-4d44-a7ac-fb440185295c" ], + "maxMachines" : 25, + "serverName" : "www.example.com", + "isPrioritized" : false, + "endpointAgentLabels" : [ "567", "214" ], + "agents" : [ "0a3b9998-dc3a-4ff2-b50d-ac4a7cd986e1", "66eec0f1-72b4-4755-aa83-3aed61d17f3c" ], + "protocol" : "icmp", + "ipVersion" : "V4_ONLY", + "port" : 443, + "interval" : 60, + "testName" : "Test name" + } + + """ + endpoint_agent_to_server_test_request = thousandeyes_sdk.endpoint_tests.models.EndpointAgentToServerTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.create_agent_to_server_endpoint_scheduled_test( + + endpoint_agent_to_server_test_request=endpoint_agent_to_server_test_request, + + aid=aid, + + _headers=self.te_headers("create_agent_to_server_endpoint_scheduled_test", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_agent_to_server_endpoint_scheduled_test_error_401(self) -> None: + """Integration test for create_agent_to_server_endpoint_scheduled_test error path (HTTP 401)""" + request_body_json = """ + + { + "server" : "www.example.com", + "agentSelectorType" : "all-agents", + "tagIds" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "5aeab5d5-0d34-4d44-a7ac-fb440185295c" ], + "maxMachines" : 25, + "serverName" : "www.example.com", + "isPrioritized" : false, + "endpointAgentLabels" : [ "567", "214" ], + "agents" : [ "0a3b9998-dc3a-4ff2-b50d-ac4a7cd986e1", "66eec0f1-72b4-4755-aa83-3aed61d17f3c" ], + "protocol" : "icmp", + "ipVersion" : "V4_ONLY", + "port" : 443, + "interval" : 60, + "testName" : "Test name" + } + + """ + endpoint_agent_to_server_test_request = thousandeyes_sdk.endpoint_tests.models.EndpointAgentToServerTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.create_agent_to_server_endpoint_scheduled_test( + + endpoint_agent_to_server_test_request=endpoint_agent_to_server_test_request, + + aid=aid, + + _headers=self.te_headers("create_agent_to_server_endpoint_scheduled_test", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_agent_to_server_endpoint_scheduled_test_error_403(self) -> None: + """Integration test for create_agent_to_server_endpoint_scheduled_test error path (HTTP 403)""" + request_body_json = """ + + { + "server" : "www.example.com", + "agentSelectorType" : "all-agents", + "tagIds" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "5aeab5d5-0d34-4d44-a7ac-fb440185295c" ], + "maxMachines" : 25, + "serverName" : "www.example.com", + "isPrioritized" : false, + "endpointAgentLabels" : [ "567", "214" ], + "agents" : [ "0a3b9998-dc3a-4ff2-b50d-ac4a7cd986e1", "66eec0f1-72b4-4755-aa83-3aed61d17f3c" ], + "protocol" : "icmp", + "ipVersion" : "V4_ONLY", + "port" : 443, + "interval" : 60, + "testName" : "Test name" + } + + """ + endpoint_agent_to_server_test_request = thousandeyes_sdk.endpoint_tests.models.EndpointAgentToServerTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.create_agent_to_server_endpoint_scheduled_test( + + endpoint_agent_to_server_test_request=endpoint_agent_to_server_test_request, + + aid=aid, + + _headers=self.te_headers("create_agent_to_server_endpoint_scheduled_test", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_agent_to_server_endpoint_scheduled_test_error_404(self) -> None: + """Integration test for create_agent_to_server_endpoint_scheduled_test error path (HTTP 404)""" + request_body_json = """ + + { + "server" : "www.example.com", + "agentSelectorType" : "all-agents", + "tagIds" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "5aeab5d5-0d34-4d44-a7ac-fb440185295c" ], + "maxMachines" : 25, + "serverName" : "www.example.com", + "isPrioritized" : false, + "endpointAgentLabels" : [ "567", "214" ], + "agents" : [ "0a3b9998-dc3a-4ff2-b50d-ac4a7cd986e1", "66eec0f1-72b4-4755-aa83-3aed61d17f3c" ], + "protocol" : "icmp", + "ipVersion" : "V4_ONLY", + "port" : 443, + "interval" : 60, + "testName" : "Test name" + } + + """ + endpoint_agent_to_server_test_request = thousandeyes_sdk.endpoint_tests.models.EndpointAgentToServerTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.create_agent_to_server_endpoint_scheduled_test( + + endpoint_agent_to_server_test_request=endpoint_agent_to_server_test_request, + + aid=aid, + + _headers=self.te_headers("create_agent_to_server_endpoint_scheduled_test", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_agent_to_server_endpoint_scheduled_test_error_429(self) -> None: + """Integration test for create_agent_to_server_endpoint_scheduled_test error path (HTTP 429)""" + request_body_json = """ + + { + "server" : "www.example.com", + "agentSelectorType" : "all-agents", + "tagIds" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "5aeab5d5-0d34-4d44-a7ac-fb440185295c" ], + "maxMachines" : 25, + "serverName" : "www.example.com", + "isPrioritized" : false, + "endpointAgentLabels" : [ "567", "214" ], + "agents" : [ "0a3b9998-dc3a-4ff2-b50d-ac4a7cd986e1", "66eec0f1-72b4-4755-aa83-3aed61d17f3c" ], + "protocol" : "icmp", + "ipVersion" : "V4_ONLY", + "port" : 443, + "interval" : 60, + "testName" : "Test name" + } + + """ + endpoint_agent_to_server_test_request = thousandeyes_sdk.endpoint_tests.models.EndpointAgentToServerTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.create_agent_to_server_endpoint_scheduled_test( + + endpoint_agent_to_server_test_request=endpoint_agent_to_server_test_request, + + aid=aid, + + _headers=self.te_headers("create_agent_to_server_endpoint_scheduled_test", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_agent_to_server_endpoint_scheduled_test_error_500(self) -> None: + """Integration test for create_agent_to_server_endpoint_scheduled_test error path (HTTP 500)""" + request_body_json = """ + + { + "server" : "www.example.com", + "agentSelectorType" : "all-agents", + "tagIds" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "5aeab5d5-0d34-4d44-a7ac-fb440185295c" ], + "maxMachines" : 25, + "serverName" : "www.example.com", + "isPrioritized" : false, + "endpointAgentLabels" : [ "567", "214" ], + "agents" : [ "0a3b9998-dc3a-4ff2-b50d-ac4a7cd986e1", "66eec0f1-72b4-4755-aa83-3aed61d17f3c" ], + "protocol" : "icmp", + "ipVersion" : "V4_ONLY", + "port" : 443, + "interval" : 60, + "testName" : "Test name" + } + + """ + endpoint_agent_to_server_test_request = thousandeyes_sdk.endpoint_tests.models.EndpointAgentToServerTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.create_agent_to_server_endpoint_scheduled_test( + + endpoint_agent_to_server_test_request=endpoint_agent_to_server_test_request, + + aid=aid, + + _headers=self.te_headers("create_agent_to_server_endpoint_scheduled_test", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_agent_to_server_endpoint_scheduled_test_error_502(self) -> None: + """Integration test for create_agent_to_server_endpoint_scheduled_test error path (HTTP 502)""" + request_body_json = """ + + { + "server" : "www.example.com", + "agentSelectorType" : "all-agents", + "tagIds" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "5aeab5d5-0d34-4d44-a7ac-fb440185295c" ], + "maxMachines" : 25, + "serverName" : "www.example.com", + "isPrioritized" : false, + "endpointAgentLabels" : [ "567", "214" ], + "agents" : [ "0a3b9998-dc3a-4ff2-b50d-ac4a7cd986e1", "66eec0f1-72b4-4755-aa83-3aed61d17f3c" ], + "protocol" : "icmp", + "ipVersion" : "V4_ONLY", + "port" : 443, + "interval" : 60, + "testName" : "Test name" + } + + """ + endpoint_agent_to_server_test_request = thousandeyes_sdk.endpoint_tests.models.EndpointAgentToServerTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.create_agent_to_server_endpoint_scheduled_test( + + endpoint_agent_to_server_test_request=endpoint_agent_to_server_test_request, + + aid=aid, + + _headers=self.te_headers("create_agent_to_server_endpoint_scheduled_test", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_delete_agent_to_server_endpoint_scheduled_test_happy_path(self) -> None: + """Integration test for delete_agent_to_server_endpoint_scheduled_test success path""" + test_id = '584739201' + aid = '1234' + response = self.api.delete_agent_to_server_endpoint_scheduled_test_with_http_info( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_agent_to_server_endpoint_scheduled_test"), + ) + self.assertEqual(204, response.status_code) + self.assertIsNone(response.data) + + + def test_delete_agent_to_server_endpoint_scheduled_test_error_400(self) -> None: + """Integration test for delete_agent_to_server_endpoint_scheduled_test error path (HTTP 400)""" + test_id = '584739201' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.delete_agent_to_server_endpoint_scheduled_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_agent_to_server_endpoint_scheduled_test", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_agent_to_server_endpoint_scheduled_test_error_401(self) -> None: + """Integration test for delete_agent_to_server_endpoint_scheduled_test error path (HTTP 401)""" + test_id = '584739201' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.delete_agent_to_server_endpoint_scheduled_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_agent_to_server_endpoint_scheduled_test", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_agent_to_server_endpoint_scheduled_test_error_403(self) -> None: + """Integration test for delete_agent_to_server_endpoint_scheduled_test error path (HTTP 403)""" + test_id = '584739201' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.delete_agent_to_server_endpoint_scheduled_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_agent_to_server_endpoint_scheduled_test", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_agent_to_server_endpoint_scheduled_test_error_404(self) -> None: + """Integration test for delete_agent_to_server_endpoint_scheduled_test error path (HTTP 404)""" + test_id = '584739201' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.delete_agent_to_server_endpoint_scheduled_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_agent_to_server_endpoint_scheduled_test", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_agent_to_server_endpoint_scheduled_test_error_429(self) -> None: + """Integration test for delete_agent_to_server_endpoint_scheduled_test error path (HTTP 429)""" + test_id = '584739201' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.delete_agent_to_server_endpoint_scheduled_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_agent_to_server_endpoint_scheduled_test", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_agent_to_server_endpoint_scheduled_test_error_500(self) -> None: + """Integration test for delete_agent_to_server_endpoint_scheduled_test error path (HTTP 500)""" + test_id = '584739201' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.delete_agent_to_server_endpoint_scheduled_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_agent_to_server_endpoint_scheduled_test", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_agent_to_server_endpoint_scheduled_test_error_502(self) -> None: + """Integration test for delete_agent_to_server_endpoint_scheduled_test error path (HTTP 502)""" + test_id = '584739201' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.delete_agent_to_server_endpoint_scheduled_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_agent_to_server_endpoint_scheduled_test", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_agent_to_server_endpoint_scheduled_test_happy_path(self) -> None: + """Integration test for get_agent_to_server_endpoint_scheduled_test success path""" + test_id = '584739201' + aid = '1234' + response_body_json = """ + { + "server" : "www.example.com", + "isSavedEvent" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/scheduled-tests/281474976710706/network/filter" + }, { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/scheduled-tests/281474976710706/pathvis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isPrioritized" : false, + "networkMeasurements" : true, + "type" : "agent-to-server", + "tcpProbeMode" : "auto", + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "protocol" : "icmp", + "createdDate" : "2022-07-17T22:00:54Z", + "ipVersion" : "V4_ONLY", + "port" : 443, + "isEnabled" : true, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "aid" : "1234", + "agentSelectorConfig" : { + "agentSelectorType" : "all-agents", + "maxMachines" : 25 + }, + "hasPathTraceInSession" : true, + "testName" : "Test name" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_agent_to_server_endpoint_scheduled_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("get_agent_to_server_endpoint_scheduled_test"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_agent_to_server_endpoint_scheduled_test_error_401(self) -> None: + """Integration test for get_agent_to_server_endpoint_scheduled_test error path (HTTP 401)""" + test_id = '584739201' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_agent_to_server_endpoint_scheduled_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("get_agent_to_server_endpoint_scheduled_test", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_agent_to_server_endpoint_scheduled_test_error_403(self) -> None: + """Integration test for get_agent_to_server_endpoint_scheduled_test error path (HTTP 403)""" + test_id = '584739201' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_agent_to_server_endpoint_scheduled_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("get_agent_to_server_endpoint_scheduled_test", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_agent_to_server_endpoint_scheduled_test_error_404(self) -> None: + """Integration test for get_agent_to_server_endpoint_scheduled_test error path (HTTP 404)""" + test_id = '584739201' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_agent_to_server_endpoint_scheduled_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("get_agent_to_server_endpoint_scheduled_test", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_agent_to_server_endpoint_scheduled_test_error_429(self) -> None: + """Integration test for get_agent_to_server_endpoint_scheduled_test error path (HTTP 429)""" + test_id = '584739201' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_agent_to_server_endpoint_scheduled_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("get_agent_to_server_endpoint_scheduled_test", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_agent_to_server_endpoint_scheduled_test_error_500(self) -> None: + """Integration test for get_agent_to_server_endpoint_scheduled_test error path (HTTP 500)""" + test_id = '584739201' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_agent_to_server_endpoint_scheduled_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("get_agent_to_server_endpoint_scheduled_test", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_agent_to_server_endpoint_scheduled_test_error_502(self) -> None: + """Integration test for get_agent_to_server_endpoint_scheduled_test error path (HTTP 502)""" + test_id = '584739201' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.get_agent_to_server_endpoint_scheduled_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("get_agent_to_server_endpoint_scheduled_test", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_agent_to_server_endpoint_scheduled_tests_happy_path(self) -> None: + """Integration test for get_agent_to_server_endpoint_scheduled_tests success path""" + aid = '1234' + response_body_json = """ + { + "tests" : [ { + "server" : "www.example.com", + "isSavedEvent" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/scheduled-tests/281474976710706/network/filter" + }, { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/scheduled-tests/281474976710706/pathvis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isPrioritized" : false, + "networkMeasurements" : true, + "type" : "agent-to-server", + "tcpProbeMode" : "auto", + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "protocol" : "icmp", + "createdDate" : "2022-07-17T22:00:54Z", + "ipVersion" : "V4_ONLY", + "port" : 443, + "isEnabled" : true, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "aid" : "1234", + "agentSelectorConfig" : { + "agentSelectorType" : "all-agents", + "maxMachines" : 25 + }, + "hasPathTraceInSession" : true, + "testName" : "Test name" + }, { + "server" : "www.example.com", + "isSavedEvent" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/scheduled-tests/281474976710706/network/filter" + }, { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/scheduled-tests/281474976710706/pathvis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isPrioritized" : false, + "networkMeasurements" : true, + "type" : "agent-to-server", + "tcpProbeMode" : "auto", + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "protocol" : "icmp", + "createdDate" : "2022-07-17T22:00:54Z", + "ipVersion" : "V4_ONLY", + "port" : 443, + "isEnabled" : true, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "aid" : "1234", + "agentSelectorConfig" : { + "agentSelectorType" : "all-agents", + "maxMachines" : 25 + }, + "hasPathTraceInSession" : true, + "testName" : "Test name" + } ], + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_agent_to_server_endpoint_scheduled_tests( + + aid=aid, + + _headers=self.te_headers("get_agent_to_server_endpoint_scheduled_tests"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_agent_to_server_endpoint_scheduled_tests_error_401(self) -> None: + """Integration test for get_agent_to_server_endpoint_scheduled_tests error path (HTTP 401)""" + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_agent_to_server_endpoint_scheduled_tests( + + aid=aid, + + _headers=self.te_headers("get_agent_to_server_endpoint_scheduled_tests", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_agent_to_server_endpoint_scheduled_tests_error_403(self) -> None: + """Integration test for get_agent_to_server_endpoint_scheduled_tests error path (HTTP 403)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_agent_to_server_endpoint_scheduled_tests( + + aid=aid, + + _headers=self.te_headers("get_agent_to_server_endpoint_scheduled_tests", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_agent_to_server_endpoint_scheduled_tests_error_429(self) -> None: + """Integration test for get_agent_to_server_endpoint_scheduled_tests error path (HTTP 429)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_agent_to_server_endpoint_scheduled_tests( + + aid=aid, + + _headers=self.te_headers("get_agent_to_server_endpoint_scheduled_tests", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_agent_to_server_endpoint_scheduled_tests_error_500(self) -> None: + """Integration test for get_agent_to_server_endpoint_scheduled_tests error path (HTTP 500)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_agent_to_server_endpoint_scheduled_tests( + + aid=aid, + + _headers=self.te_headers("get_agent_to_server_endpoint_scheduled_tests", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_agent_to_server_endpoint_scheduled_tests_error_502(self) -> None: + """Integration test for get_agent_to_server_endpoint_scheduled_tests error path (HTTP 502)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.get_agent_to_server_endpoint_scheduled_tests( + + aid=aid, + + _headers=self.te_headers("get_agent_to_server_endpoint_scheduled_tests", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_update_agent_to_server_endpoint_scheduled_test_happy_path(self) -> None: + """Integration test for update_agent_to_server_endpoint_scheduled_test success path""" + request_body_json = """ + + { + "server" : "www.example.com", + "protocol" : "icmp", + "port" : 49153, + "isEnabled" : true, + "interval" : 60, + "tcpProbeMode" : "auto", + "testName" : "Test name" + } + + """ + endpoint_network_test_update = thousandeyes_sdk.endpoint_tests.models.EndpointNetworkTestUpdate.from_json(request_body_json) + test_id = '584739201' + aid = '1234' + response_body_json = """ + { + "server" : "www.example.com", + "isSavedEvent" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/scheduled-tests/281474976710706/network/filter" + }, { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/scheduled-tests/281474976710706/pathvis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isPrioritized" : false, + "networkMeasurements" : true, + "type" : "agent-to-server", + "tcpProbeMode" : "auto", + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "protocol" : "icmp", + "createdDate" : "2022-07-17T22:00:54Z", + "ipVersion" : "V4_ONLY", + "port" : 443, + "isEnabled" : true, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "aid" : "1234", + "agentSelectorConfig" : { + "agentSelectorType" : "all-agents", + "maxMachines" : 25 + }, + "hasPathTraceInSession" : true, + "testName" : "Test name" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.update_agent_to_server_endpoint_scheduled_test( + + test_id=test_id, + + endpoint_network_test_update=endpoint_network_test_update, + + aid=aid, + + _headers=self.te_headers("update_agent_to_server_endpoint_scheduled_test"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_update_agent_to_server_endpoint_scheduled_test_error_400(self) -> None: + """Integration test for update_agent_to_server_endpoint_scheduled_test error path (HTTP 400)""" + request_body_json = """ + + { + "server" : "www.example.com", + "protocol" : "icmp", + "port" : 49153, + "isEnabled" : true, + "interval" : 60, + "tcpProbeMode" : "auto", + "testName" : "Test name" + } + + """ + endpoint_network_test_update = thousandeyes_sdk.endpoint_tests.models.EndpointNetworkTestUpdate.from_json(request_body_json) + test_id = '584739201' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.update_agent_to_server_endpoint_scheduled_test( + + test_id=test_id, + + endpoint_network_test_update=endpoint_network_test_update, + + aid=aid, + + _headers=self.te_headers("update_agent_to_server_endpoint_scheduled_test", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_agent_to_server_endpoint_scheduled_test_error_401(self) -> None: + """Integration test for update_agent_to_server_endpoint_scheduled_test error path (HTTP 401)""" + request_body_json = """ + + { + "server" : "www.example.com", + "protocol" : "icmp", + "port" : 49153, + "isEnabled" : true, + "interval" : 60, + "tcpProbeMode" : "auto", + "testName" : "Test name" + } + + """ + endpoint_network_test_update = thousandeyes_sdk.endpoint_tests.models.EndpointNetworkTestUpdate.from_json(request_body_json) + test_id = '584739201' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.update_agent_to_server_endpoint_scheduled_test( + + test_id=test_id, + + endpoint_network_test_update=endpoint_network_test_update, + + aid=aid, + + _headers=self.te_headers("update_agent_to_server_endpoint_scheduled_test", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_agent_to_server_endpoint_scheduled_test_error_403(self) -> None: + """Integration test for update_agent_to_server_endpoint_scheduled_test error path (HTTP 403)""" + request_body_json = """ + + { + "server" : "www.example.com", + "protocol" : "icmp", + "port" : 49153, + "isEnabled" : true, + "interval" : 60, + "tcpProbeMode" : "auto", + "testName" : "Test name" + } + + """ + endpoint_network_test_update = thousandeyes_sdk.endpoint_tests.models.EndpointNetworkTestUpdate.from_json(request_body_json) + test_id = '584739201' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.update_agent_to_server_endpoint_scheduled_test( + + test_id=test_id, + + endpoint_network_test_update=endpoint_network_test_update, + + aid=aid, + + _headers=self.te_headers("update_agent_to_server_endpoint_scheduled_test", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_agent_to_server_endpoint_scheduled_test_error_404(self) -> None: + """Integration test for update_agent_to_server_endpoint_scheduled_test error path (HTTP 404)""" + request_body_json = """ + + { + "server" : "www.example.com", + "protocol" : "icmp", + "port" : 49153, + "isEnabled" : true, + "interval" : 60, + "tcpProbeMode" : "auto", + "testName" : "Test name" + } + + """ + endpoint_network_test_update = thousandeyes_sdk.endpoint_tests.models.EndpointNetworkTestUpdate.from_json(request_body_json) + test_id = '584739201' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.update_agent_to_server_endpoint_scheduled_test( + + test_id=test_id, + + endpoint_network_test_update=endpoint_network_test_update, + + aid=aid, + + _headers=self.te_headers("update_agent_to_server_endpoint_scheduled_test", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_agent_to_server_endpoint_scheduled_test_error_429(self) -> None: + """Integration test for update_agent_to_server_endpoint_scheduled_test error path (HTTP 429)""" + request_body_json = """ + + { + "server" : "www.example.com", + "protocol" : "icmp", + "port" : 49153, + "isEnabled" : true, + "interval" : 60, + "tcpProbeMode" : "auto", + "testName" : "Test name" + } + + """ + endpoint_network_test_update = thousandeyes_sdk.endpoint_tests.models.EndpointNetworkTestUpdate.from_json(request_body_json) + test_id = '584739201' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.update_agent_to_server_endpoint_scheduled_test( + + test_id=test_id, + + endpoint_network_test_update=endpoint_network_test_update, + + aid=aid, + + _headers=self.te_headers("update_agent_to_server_endpoint_scheduled_test", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_agent_to_server_endpoint_scheduled_test_error_500(self) -> None: + """Integration test for update_agent_to_server_endpoint_scheduled_test error path (HTTP 500)""" + request_body_json = """ + + { + "server" : "www.example.com", + "protocol" : "icmp", + "port" : 49153, + "isEnabled" : true, + "interval" : 60, + "tcpProbeMode" : "auto", + "testName" : "Test name" + } + + """ + endpoint_network_test_update = thousandeyes_sdk.endpoint_tests.models.EndpointNetworkTestUpdate.from_json(request_body_json) + test_id = '584739201' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.update_agent_to_server_endpoint_scheduled_test( + + test_id=test_id, + + endpoint_network_test_update=endpoint_network_test_update, + + aid=aid, + + _headers=self.te_headers("update_agent_to_server_endpoint_scheduled_test", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_agent_to_server_endpoint_scheduled_test_error_502(self) -> None: + """Integration test for update_agent_to_server_endpoint_scheduled_test error path (HTTP 502)""" + request_body_json = """ + + { + "server" : "www.example.com", + "protocol" : "icmp", + "port" : 49153, + "isEnabled" : true, + "interval" : 60, + "tcpProbeMode" : "auto", + "testName" : "Test name" + } + + """ + endpoint_network_test_update = thousandeyes_sdk.endpoint_tests.models.EndpointNetworkTestUpdate.from_json(request_body_json) + test_id = '584739201' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.update_agent_to_server_endpoint_scheduled_test( + + test_id=test_id, + + endpoint_network_test_update=endpoint_network_test_update, + + aid=aid, + + _headers=self.te_headers("update_agent_to_server_endpoint_scheduled_test", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-endpoint-tests/test/test_endpoint_real_user_tests_api_integration.py b/thousandeyes-sdk-endpoint-tests/test/test_endpoint_real_user_tests_api_integration.py new file mode 100644 index 00000000..f64c4578 --- /dev/null +++ b/thousandeyes-sdk-endpoint-tests/test/test_endpoint_real_user_tests_api_integration.py @@ -0,0 +1,176 @@ +# coding: utf-8 + +""" + Endpoint Tests API + + Manage endpoint agent dynamic and scheduled tests using the Endpoint Tests API. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.endpoint_tests.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.endpoint_tests.api.endpoint_real_user_tests_api import EndpointRealUserTestsApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestEndpointRealUserTestsApiIntegration(IntegrationTestBase): + """EndpointRealUserTestsApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = EndpointRealUserTestsApi(self.api_client) + + + def test_get_endpoint_real_user_tests_happy_path(self) -> None: + """Integration test for get_endpoint_real_user_tests success path""" + aid = '1234' + response_body_json = """ + { + "realUserTests" : [ { + "includedDomains" : [ "example.com", "example.com" ], + "profileId" : "73421", + "monitoringSettings" : { + "monitoringSettingsId" : "1f5c1b5d-8a0d-4d6b-a3be-56b060f7f2c9", + "monitoringSettingsType" : "agent-tags", + "tagIds" : [ "49d9e7d2-7df5-43df-9b37-aa596b929062" ], + "labelIds" : [ "567" ] + }, + "name" : "Corporate domains", + "excludedDomains" : [ "static.example.com", "static.example.com" ], + "aid" : "1234" + }, { + "includedDomains" : [ "example.com", "example.com" ], + "profileId" : "73421", + "monitoringSettings" : { + "monitoringSettingsId" : "1f5c1b5d-8a0d-4d6b-a3be-56b060f7f2c9", + "monitoringSettingsType" : "agent-tags", + "tagIds" : [ "49d9e7d2-7df5-43df-9b37-aa596b929062" ], + "labelIds" : [ "567" ] + }, + "name" : "Corporate domains", + "excludedDomains" : [ "static.example.com", "static.example.com" ], + "aid" : "1234" + } ] + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_endpoint_real_user_tests( + + aid=aid, + + _headers=self.te_headers("get_endpoint_real_user_tests"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_endpoint_real_user_tests_error_401(self) -> None: + """Integration test for get_endpoint_real_user_tests error path (HTTP 401)""" + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_endpoint_real_user_tests( + + aid=aid, + + _headers=self.te_headers("get_endpoint_real_user_tests", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_endpoint_real_user_tests_error_403(self) -> None: + """Integration test for get_endpoint_real_user_tests error path (HTTP 403)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_endpoint_real_user_tests( + + aid=aid, + + _headers=self.te_headers("get_endpoint_real_user_tests", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_endpoint_real_user_tests_error_429(self) -> None: + """Integration test for get_endpoint_real_user_tests error path (HTTP 429)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_endpoint_real_user_tests( + + aid=aid, + + _headers=self.te_headers("get_endpoint_real_user_tests", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_endpoint_real_user_tests_error_500(self) -> None: + """Integration test for get_endpoint_real_user_tests error path (HTTP 500)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_endpoint_real_user_tests( + + aid=aid, + + _headers=self.te_headers("get_endpoint_real_user_tests", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-endpoint-tests/test/test_endpoint_scheduled_tests_api_integration.py b/thousandeyes-sdk-endpoint-tests/test/test_endpoint_scheduled_tests_api_integration.py new file mode 100644 index 00000000..ac442bfa --- /dev/null +++ b/thousandeyes-sdk-endpoint-tests/test/test_endpoint_scheduled_tests_api_integration.py @@ -0,0 +1,285 @@ +# coding: utf-8 + +""" + Endpoint Tests API + + Manage endpoint agent dynamic and scheduled tests using the Endpoint Tests API. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.endpoint_tests.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.endpoint_tests.api.endpoint_scheduled_tests_api import EndpointScheduledTestsApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestEndpointScheduledTestsApiIntegration(IntegrationTestBase): + """EndpointScheduledTestsApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = EndpointScheduledTestsApi(self.api_client) + + + def test_get_endpoint_scheduled_tests_happy_path(self) -> None: + """Integration test for get_endpoint_scheduled_tests success path""" + aid = '1234' + response_body_json = """ + { + "tests" : [ { + "server" : "www.example.com", + "isSavedEvent" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/scheduled-tests/281474976710706/network/filter" + }, { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/scheduled-tests/281474976710706/pathvis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isPrioritized" : false, + "networkMeasurements" : true, + "type" : "agent-to-server", + "tcpProbeMode" : "auto", + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "protocol" : "icmp", + "createdDate" : "2022-07-17T22:00:54Z", + "ipVersion" : "V4_ONLY", + "port" : 443, + "isEnabled" : true, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "aid" : "1234", + "agentSelectorConfig" : { + "agentSelectorType" : "all-agents", + "maxMachines" : 25 + }, + "hasPathTraceInSession" : true, + "testName" : "Test name" + }, { + "server" : "www.example.com", + "isSavedEvent" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/scheduled-tests/281474976710706/network/filter" + }, { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/scheduled-tests/281474976710706/pathvis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isPrioritized" : false, + "networkMeasurements" : true, + "type" : "agent-to-server", + "tcpProbeMode" : "auto", + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "protocol" : "icmp", + "createdDate" : "2022-07-17T22:00:54Z", + "ipVersion" : "V4_ONLY", + "port" : 443, + "isEnabled" : true, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "aid" : "1234", + "agentSelectorConfig" : { + "agentSelectorType" : "all-agents", + "maxMachines" : 25 + }, + "hasPathTraceInSession" : true, + "testName" : "Test name" + } ], + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_endpoint_scheduled_tests( + + aid=aid, + + _headers=self.te_headers("get_endpoint_scheduled_tests"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_endpoint_scheduled_tests_error_401(self) -> None: + """Integration test for get_endpoint_scheduled_tests error path (HTTP 401)""" + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_endpoint_scheduled_tests( + + aid=aid, + + _headers=self.te_headers("get_endpoint_scheduled_tests", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_endpoint_scheduled_tests_error_403(self) -> None: + """Integration test for get_endpoint_scheduled_tests error path (HTTP 403)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_endpoint_scheduled_tests( + + aid=aid, + + _headers=self.te_headers("get_endpoint_scheduled_tests", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_endpoint_scheduled_tests_error_429(self) -> None: + """Integration test for get_endpoint_scheduled_tests error path (HTTP 429)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_endpoint_scheduled_tests( + + aid=aid, + + _headers=self.te_headers("get_endpoint_scheduled_tests", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_endpoint_scheduled_tests_error_500(self) -> None: + """Integration test for get_endpoint_scheduled_tests error path (HTTP 500)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_endpoint_scheduled_tests( + + aid=aid, + + _headers=self.te_headers("get_endpoint_scheduled_tests", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_endpoint_scheduled_tests_error_502(self) -> None: + """Integration test for get_endpoint_scheduled_tests error path (HTTP 502)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.get_endpoint_scheduled_tests( + + aid=aid, + + _headers=self.te_headers("get_endpoint_scheduled_tests", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-endpoint-tests/test/test_http_server_endpoint_scheduled_tests_api_integration.py b/thousandeyes-sdk-endpoint-tests/test/test_http_server_endpoint_scheduled_tests_api_integration.py new file mode 100644 index 00000000..27b916f1 --- /dev/null +++ b/thousandeyes-sdk-endpoint-tests/test/test_http_server_endpoint_scheduled_tests_api_integration.py @@ -0,0 +1,1688 @@ +# coding: utf-8 + +""" + Endpoint Tests API + + Manage endpoint agent dynamic and scheduled tests using the Endpoint Tests API. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.endpoint_tests.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.endpoint_tests.api.http_server_endpoint_scheduled_tests_api import HTTPServerEndpointScheduledTestsApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestHTTPServerEndpointScheduledTestsApiIntegration(IntegrationTestBase): + """HTTPServerEndpointScheduledTestsApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = HTTPServerEndpointScheduledTestsApi(self.api_client) + + + def test_create_http_server_endpoint_scheduled_test_happy_path(self) -> None: + """Integration test for create_http_server_endpoint_scheduled_test success path""" + request_body_json = """ + + { + "verifyCertificate" : true, + "hasPing" : true, + "agentSelectorType" : "all-agents", + "tagIds" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "5aeab5d5-0d34-4d44-a7ac-fb440185295c" ], + "maxMachines" : 25, + "isPrioritized" : false, + "httpTimeLimit" : 5000, + "networkMeasurements" : true, + "endpointAgentLabels" : [ "567", "214" ], + "tcpProbeMode" : "auto", + "url" : "https://example.com:443", + "agents" : [ "0a3b9998-dc3a-4ff2-b50d-ac4a7cd986e1", "66eec0f1-72b4-4755-aa83-3aed61d17f3c" ], + "protocol" : "icmp", + "password" : "password", + "ipVersion" : "V4_ONLY", + "hasTraceroute" : true, + "targetResponseTime" : 1000, + "interval" : 60, + "authType" : "none", + "hasPathTraceInSession" : true, + "testName" : "Test name", + "username" : "username", + "sslVersionId" : "0" + } + + """ + endpoint_http_server_test_request = thousandeyes_sdk.endpoint_tests.models.EndpointHttpServerTestRequest.from_json(request_body_json) + aid = '1234' + response_body_json = """ + { + "server" : "www.example.com", + "isSavedEvent" : false, + "sslVersion" : "Auto", + "useNtlm" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/scheduled-tests/281474976710706/network/filter" + }, { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/scheduled-tests/281474976710706/pathvis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isPrioritized" : false, + "httpTimeLimit" : 5000, + "type" : "http-server", + "protocol" : "icmp", + "httpVersion" : 2, + "followRedirects" : true, + "authType" : "none", + "testName" : "Test name", + "verifyCertificate" : true, + "networkMeasurements" : true, + "tcpProbeMode" : "auto", + "url" : "https://example.com:443", + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "ipVersion" : "V4_ONLY", + "port" : 443, + "isEnabled" : true, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "aid" : "1234", + "agentSelectorConfig" : { + "agentSelectorType" : "all-agents", + "maxMachines" : 25 + }, + "hasPathTraceInSession" : true, + "httpTargetTime" : 100, + "username" : "username", + "sslVersionId" : "0" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.create_http_server_endpoint_scheduled_test( + + endpoint_http_server_test_request=endpoint_http_server_test_request, + + aid=aid, + + _headers=self.te_headers("create_http_server_endpoint_scheduled_test"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_create_http_server_endpoint_scheduled_test_error_400(self) -> None: + """Integration test for create_http_server_endpoint_scheduled_test error path (HTTP 400)""" + request_body_json = """ + + { + "verifyCertificate" : true, + "hasPing" : true, + "agentSelectorType" : "all-agents", + "tagIds" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "5aeab5d5-0d34-4d44-a7ac-fb440185295c" ], + "maxMachines" : 25, + "isPrioritized" : false, + "httpTimeLimit" : 5000, + "networkMeasurements" : true, + "endpointAgentLabels" : [ "567", "214" ], + "tcpProbeMode" : "auto", + "url" : "https://example.com:443", + "agents" : [ "0a3b9998-dc3a-4ff2-b50d-ac4a7cd986e1", "66eec0f1-72b4-4755-aa83-3aed61d17f3c" ], + "protocol" : "icmp", + "password" : "password", + "ipVersion" : "V4_ONLY", + "hasTraceroute" : true, + "targetResponseTime" : 1000, + "interval" : 60, + "authType" : "none", + "hasPathTraceInSession" : true, + "testName" : "Test name", + "username" : "username", + "sslVersionId" : "0" + } + + """ + endpoint_http_server_test_request = thousandeyes_sdk.endpoint_tests.models.EndpointHttpServerTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.create_http_server_endpoint_scheduled_test( + + endpoint_http_server_test_request=endpoint_http_server_test_request, + + aid=aid, + + _headers=self.te_headers("create_http_server_endpoint_scheduled_test", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_http_server_endpoint_scheduled_test_error_401(self) -> None: + """Integration test for create_http_server_endpoint_scheduled_test error path (HTTP 401)""" + request_body_json = """ + + { + "verifyCertificate" : true, + "hasPing" : true, + "agentSelectorType" : "all-agents", + "tagIds" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "5aeab5d5-0d34-4d44-a7ac-fb440185295c" ], + "maxMachines" : 25, + "isPrioritized" : false, + "httpTimeLimit" : 5000, + "networkMeasurements" : true, + "endpointAgentLabels" : [ "567", "214" ], + "tcpProbeMode" : "auto", + "url" : "https://example.com:443", + "agents" : [ "0a3b9998-dc3a-4ff2-b50d-ac4a7cd986e1", "66eec0f1-72b4-4755-aa83-3aed61d17f3c" ], + "protocol" : "icmp", + "password" : "password", + "ipVersion" : "V4_ONLY", + "hasTraceroute" : true, + "targetResponseTime" : 1000, + "interval" : 60, + "authType" : "none", + "hasPathTraceInSession" : true, + "testName" : "Test name", + "username" : "username", + "sslVersionId" : "0" + } + + """ + endpoint_http_server_test_request = thousandeyes_sdk.endpoint_tests.models.EndpointHttpServerTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.create_http_server_endpoint_scheduled_test( + + endpoint_http_server_test_request=endpoint_http_server_test_request, + + aid=aid, + + _headers=self.te_headers("create_http_server_endpoint_scheduled_test", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_http_server_endpoint_scheduled_test_error_403(self) -> None: + """Integration test for create_http_server_endpoint_scheduled_test error path (HTTP 403)""" + request_body_json = """ + + { + "verifyCertificate" : true, + "hasPing" : true, + "agentSelectorType" : "all-agents", + "tagIds" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "5aeab5d5-0d34-4d44-a7ac-fb440185295c" ], + "maxMachines" : 25, + "isPrioritized" : false, + "httpTimeLimit" : 5000, + "networkMeasurements" : true, + "endpointAgentLabels" : [ "567", "214" ], + "tcpProbeMode" : "auto", + "url" : "https://example.com:443", + "agents" : [ "0a3b9998-dc3a-4ff2-b50d-ac4a7cd986e1", "66eec0f1-72b4-4755-aa83-3aed61d17f3c" ], + "protocol" : "icmp", + "password" : "password", + "ipVersion" : "V4_ONLY", + "hasTraceroute" : true, + "targetResponseTime" : 1000, + "interval" : 60, + "authType" : "none", + "hasPathTraceInSession" : true, + "testName" : "Test name", + "username" : "username", + "sslVersionId" : "0" + } + + """ + endpoint_http_server_test_request = thousandeyes_sdk.endpoint_tests.models.EndpointHttpServerTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.create_http_server_endpoint_scheduled_test( + + endpoint_http_server_test_request=endpoint_http_server_test_request, + + aid=aid, + + _headers=self.te_headers("create_http_server_endpoint_scheduled_test", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_http_server_endpoint_scheduled_test_error_404(self) -> None: + """Integration test for create_http_server_endpoint_scheduled_test error path (HTTP 404)""" + request_body_json = """ + + { + "verifyCertificate" : true, + "hasPing" : true, + "agentSelectorType" : "all-agents", + "tagIds" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "5aeab5d5-0d34-4d44-a7ac-fb440185295c" ], + "maxMachines" : 25, + "isPrioritized" : false, + "httpTimeLimit" : 5000, + "networkMeasurements" : true, + "endpointAgentLabels" : [ "567", "214" ], + "tcpProbeMode" : "auto", + "url" : "https://example.com:443", + "agents" : [ "0a3b9998-dc3a-4ff2-b50d-ac4a7cd986e1", "66eec0f1-72b4-4755-aa83-3aed61d17f3c" ], + "protocol" : "icmp", + "password" : "password", + "ipVersion" : "V4_ONLY", + "hasTraceroute" : true, + "targetResponseTime" : 1000, + "interval" : 60, + "authType" : "none", + "hasPathTraceInSession" : true, + "testName" : "Test name", + "username" : "username", + "sslVersionId" : "0" + } + + """ + endpoint_http_server_test_request = thousandeyes_sdk.endpoint_tests.models.EndpointHttpServerTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.create_http_server_endpoint_scheduled_test( + + endpoint_http_server_test_request=endpoint_http_server_test_request, + + aid=aid, + + _headers=self.te_headers("create_http_server_endpoint_scheduled_test", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_http_server_endpoint_scheduled_test_error_429(self) -> None: + """Integration test for create_http_server_endpoint_scheduled_test error path (HTTP 429)""" + request_body_json = """ + + { + "verifyCertificate" : true, + "hasPing" : true, + "agentSelectorType" : "all-agents", + "tagIds" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "5aeab5d5-0d34-4d44-a7ac-fb440185295c" ], + "maxMachines" : 25, + "isPrioritized" : false, + "httpTimeLimit" : 5000, + "networkMeasurements" : true, + "endpointAgentLabels" : [ "567", "214" ], + "tcpProbeMode" : "auto", + "url" : "https://example.com:443", + "agents" : [ "0a3b9998-dc3a-4ff2-b50d-ac4a7cd986e1", "66eec0f1-72b4-4755-aa83-3aed61d17f3c" ], + "protocol" : "icmp", + "password" : "password", + "ipVersion" : "V4_ONLY", + "hasTraceroute" : true, + "targetResponseTime" : 1000, + "interval" : 60, + "authType" : "none", + "hasPathTraceInSession" : true, + "testName" : "Test name", + "username" : "username", + "sslVersionId" : "0" + } + + """ + endpoint_http_server_test_request = thousandeyes_sdk.endpoint_tests.models.EndpointHttpServerTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.create_http_server_endpoint_scheduled_test( + + endpoint_http_server_test_request=endpoint_http_server_test_request, + + aid=aid, + + _headers=self.te_headers("create_http_server_endpoint_scheduled_test", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_http_server_endpoint_scheduled_test_error_500(self) -> None: + """Integration test for create_http_server_endpoint_scheduled_test error path (HTTP 500)""" + request_body_json = """ + + { + "verifyCertificate" : true, + "hasPing" : true, + "agentSelectorType" : "all-agents", + "tagIds" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "5aeab5d5-0d34-4d44-a7ac-fb440185295c" ], + "maxMachines" : 25, + "isPrioritized" : false, + "httpTimeLimit" : 5000, + "networkMeasurements" : true, + "endpointAgentLabels" : [ "567", "214" ], + "tcpProbeMode" : "auto", + "url" : "https://example.com:443", + "agents" : [ "0a3b9998-dc3a-4ff2-b50d-ac4a7cd986e1", "66eec0f1-72b4-4755-aa83-3aed61d17f3c" ], + "protocol" : "icmp", + "password" : "password", + "ipVersion" : "V4_ONLY", + "hasTraceroute" : true, + "targetResponseTime" : 1000, + "interval" : 60, + "authType" : "none", + "hasPathTraceInSession" : true, + "testName" : "Test name", + "username" : "username", + "sslVersionId" : "0" + } + + """ + endpoint_http_server_test_request = thousandeyes_sdk.endpoint_tests.models.EndpointHttpServerTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.create_http_server_endpoint_scheduled_test( + + endpoint_http_server_test_request=endpoint_http_server_test_request, + + aid=aid, + + _headers=self.te_headers("create_http_server_endpoint_scheduled_test", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_http_server_endpoint_scheduled_test_error_502(self) -> None: + """Integration test for create_http_server_endpoint_scheduled_test error path (HTTP 502)""" + request_body_json = """ + + { + "verifyCertificate" : true, + "hasPing" : true, + "agentSelectorType" : "all-agents", + "tagIds" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "5aeab5d5-0d34-4d44-a7ac-fb440185295c" ], + "maxMachines" : 25, + "isPrioritized" : false, + "httpTimeLimit" : 5000, + "networkMeasurements" : true, + "endpointAgentLabels" : [ "567", "214" ], + "tcpProbeMode" : "auto", + "url" : "https://example.com:443", + "agents" : [ "0a3b9998-dc3a-4ff2-b50d-ac4a7cd986e1", "66eec0f1-72b4-4755-aa83-3aed61d17f3c" ], + "protocol" : "icmp", + "password" : "password", + "ipVersion" : "V4_ONLY", + "hasTraceroute" : true, + "targetResponseTime" : 1000, + "interval" : 60, + "authType" : "none", + "hasPathTraceInSession" : true, + "testName" : "Test name", + "username" : "username", + "sslVersionId" : "0" + } + + """ + endpoint_http_server_test_request = thousandeyes_sdk.endpoint_tests.models.EndpointHttpServerTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.create_http_server_endpoint_scheduled_test( + + endpoint_http_server_test_request=endpoint_http_server_test_request, + + aid=aid, + + _headers=self.te_headers("create_http_server_endpoint_scheduled_test", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_delete_http_server_endpoint_scheduled_test_happy_path(self) -> None: + """Integration test for delete_http_server_endpoint_scheduled_test success path""" + test_id = '584739201' + aid = '1234' + response = self.api.delete_http_server_endpoint_scheduled_test_with_http_info( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_http_server_endpoint_scheduled_test"), + ) + self.assertEqual(204, response.status_code) + self.assertIsNone(response.data) + + + def test_delete_http_server_endpoint_scheduled_test_error_400(self) -> None: + """Integration test for delete_http_server_endpoint_scheduled_test error path (HTTP 400)""" + test_id = '584739201' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.delete_http_server_endpoint_scheduled_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_http_server_endpoint_scheduled_test", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_http_server_endpoint_scheduled_test_error_401(self) -> None: + """Integration test for delete_http_server_endpoint_scheduled_test error path (HTTP 401)""" + test_id = '584739201' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.delete_http_server_endpoint_scheduled_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_http_server_endpoint_scheduled_test", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_http_server_endpoint_scheduled_test_error_403(self) -> None: + """Integration test for delete_http_server_endpoint_scheduled_test error path (HTTP 403)""" + test_id = '584739201' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.delete_http_server_endpoint_scheduled_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_http_server_endpoint_scheduled_test", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_http_server_endpoint_scheduled_test_error_404(self) -> None: + """Integration test for delete_http_server_endpoint_scheduled_test error path (HTTP 404)""" + test_id = '584739201' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.delete_http_server_endpoint_scheduled_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_http_server_endpoint_scheduled_test", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_http_server_endpoint_scheduled_test_error_429(self) -> None: + """Integration test for delete_http_server_endpoint_scheduled_test error path (HTTP 429)""" + test_id = '584739201' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.delete_http_server_endpoint_scheduled_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_http_server_endpoint_scheduled_test", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_http_server_endpoint_scheduled_test_error_500(self) -> None: + """Integration test for delete_http_server_endpoint_scheduled_test error path (HTTP 500)""" + test_id = '584739201' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.delete_http_server_endpoint_scheduled_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_http_server_endpoint_scheduled_test", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_http_server_endpoint_scheduled_test_error_502(self) -> None: + """Integration test for delete_http_server_endpoint_scheduled_test error path (HTTP 502)""" + test_id = '584739201' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.delete_http_server_endpoint_scheduled_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_http_server_endpoint_scheduled_test", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_http_server_endpoint_scheduled_test_happy_path(self) -> None: + """Integration test for get_http_server_endpoint_scheduled_test success path""" + test_id = '584739201' + aid = '1234' + response_body_json = """ + { + "server" : "www.example.com", + "isSavedEvent" : false, + "sslVersion" : "Auto", + "useNtlm" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/scheduled-tests/281474976710706/network/filter" + }, { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/scheduled-tests/281474976710706/pathvis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isPrioritized" : false, + "httpTimeLimit" : 5000, + "type" : "http-server", + "protocol" : "icmp", + "httpVersion" : 2, + "followRedirects" : true, + "authType" : "none", + "testName" : "Test name", + "verifyCertificate" : true, + "networkMeasurements" : true, + "tcpProbeMode" : "auto", + "url" : "https://example.com:443", + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "ipVersion" : "V4_ONLY", + "port" : 443, + "isEnabled" : true, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "aid" : "1234", + "agentSelectorConfig" : { + "agentSelectorType" : "all-agents", + "maxMachines" : 25 + }, + "hasPathTraceInSession" : true, + "httpTargetTime" : 100, + "username" : "username", + "sslVersionId" : "0" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_http_server_endpoint_scheduled_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("get_http_server_endpoint_scheduled_test"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_http_server_endpoint_scheduled_test_error_401(self) -> None: + """Integration test for get_http_server_endpoint_scheduled_test error path (HTTP 401)""" + test_id = '584739201' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_http_server_endpoint_scheduled_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("get_http_server_endpoint_scheduled_test", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_http_server_endpoint_scheduled_test_error_403(self) -> None: + """Integration test for get_http_server_endpoint_scheduled_test error path (HTTP 403)""" + test_id = '584739201' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_http_server_endpoint_scheduled_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("get_http_server_endpoint_scheduled_test", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_http_server_endpoint_scheduled_test_error_404(self) -> None: + """Integration test for get_http_server_endpoint_scheduled_test error path (HTTP 404)""" + test_id = '584739201' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_http_server_endpoint_scheduled_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("get_http_server_endpoint_scheduled_test", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_http_server_endpoint_scheduled_test_error_429(self) -> None: + """Integration test for get_http_server_endpoint_scheduled_test error path (HTTP 429)""" + test_id = '584739201' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_http_server_endpoint_scheduled_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("get_http_server_endpoint_scheduled_test", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_http_server_endpoint_scheduled_test_error_500(self) -> None: + """Integration test for get_http_server_endpoint_scheduled_test error path (HTTP 500)""" + test_id = '584739201' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_http_server_endpoint_scheduled_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("get_http_server_endpoint_scheduled_test", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_http_server_endpoint_scheduled_test_error_502(self) -> None: + """Integration test for get_http_server_endpoint_scheduled_test error path (HTTP 502)""" + test_id = '584739201' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.get_http_server_endpoint_scheduled_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("get_http_server_endpoint_scheduled_test", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_http_server_endpoint_scheduled_tests_happy_path(self) -> None: + """Integration test for get_http_server_endpoint_scheduled_tests success path""" + aid = '1234' + response_body_json = """ + { + "tests" : [ { + "server" : "www.example.com", + "isSavedEvent" : false, + "sslVersion" : "Auto", + "useNtlm" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/scheduled-tests/281474976710706/network/filter" + }, { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/scheduled-tests/281474976710706/pathvis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isPrioritized" : false, + "httpTimeLimit" : 5000, + "type" : "http-server", + "protocol" : "icmp", + "httpVersion" : 2, + "followRedirects" : true, + "authType" : "none", + "testName" : "Test name", + "verifyCertificate" : true, + "networkMeasurements" : true, + "tcpProbeMode" : "auto", + "url" : "https://example.com:443", + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "ipVersion" : "V4_ONLY", + "port" : 443, + "isEnabled" : true, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "aid" : "1234", + "agentSelectorConfig" : { + "agentSelectorType" : "all-agents", + "maxMachines" : 25 + }, + "hasPathTraceInSession" : true, + "httpTargetTime" : 100, + "username" : "username", + "sslVersionId" : "0" + }, { + "server" : "www.example.com", + "isSavedEvent" : false, + "sslVersion" : "Auto", + "useNtlm" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/scheduled-tests/281474976710706/network/filter" + }, { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/scheduled-tests/281474976710706/pathvis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isPrioritized" : false, + "httpTimeLimit" : 5000, + "type" : "http-server", + "protocol" : "icmp", + "httpVersion" : 2, + "followRedirects" : true, + "authType" : "none", + "testName" : "Test name", + "verifyCertificate" : true, + "networkMeasurements" : true, + "tcpProbeMode" : "auto", + "url" : "https://example.com:443", + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "ipVersion" : "V4_ONLY", + "port" : 443, + "isEnabled" : true, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "aid" : "1234", + "agentSelectorConfig" : { + "agentSelectorType" : "all-agents", + "maxMachines" : 25 + }, + "hasPathTraceInSession" : true, + "httpTargetTime" : 100, + "username" : "username", + "sslVersionId" : "0" + } ], + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_http_server_endpoint_scheduled_tests( + + aid=aid, + + _headers=self.te_headers("get_http_server_endpoint_scheduled_tests"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_http_server_endpoint_scheduled_tests_error_401(self) -> None: + """Integration test for get_http_server_endpoint_scheduled_tests error path (HTTP 401)""" + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_http_server_endpoint_scheduled_tests( + + aid=aid, + + _headers=self.te_headers("get_http_server_endpoint_scheduled_tests", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_http_server_endpoint_scheduled_tests_error_403(self) -> None: + """Integration test for get_http_server_endpoint_scheduled_tests error path (HTTP 403)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_http_server_endpoint_scheduled_tests( + + aid=aid, + + _headers=self.te_headers("get_http_server_endpoint_scheduled_tests", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_http_server_endpoint_scheduled_tests_error_429(self) -> None: + """Integration test for get_http_server_endpoint_scheduled_tests error path (HTTP 429)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_http_server_endpoint_scheduled_tests( + + aid=aid, + + _headers=self.te_headers("get_http_server_endpoint_scheduled_tests", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_http_server_endpoint_scheduled_tests_error_500(self) -> None: + """Integration test for get_http_server_endpoint_scheduled_tests error path (HTTP 500)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_http_server_endpoint_scheduled_tests( + + aid=aid, + + _headers=self.te_headers("get_http_server_endpoint_scheduled_tests", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_http_server_endpoint_scheduled_tests_error_502(self) -> None: + """Integration test for get_http_server_endpoint_scheduled_tests error path (HTTP 502)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.get_http_server_endpoint_scheduled_tests( + + aid=aid, + + _headers=self.te_headers("get_http_server_endpoint_scheduled_tests", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_update_http_server_endpoint_scheduled_test_happy_path(self) -> None: + """Integration test for update_http_server_endpoint_scheduled_test success path""" + request_body_json = """ + + { + "protocol" : "icmp", + "isEnabled" : true, + "interval" : 60, + "tcpProbeMode" : "auto", + "url" : "https://example.com:443", + "testName" : "Test name" + } + + """ + endpoint_http_test_update = thousandeyes_sdk.endpoint_tests.models.EndpointHttpTestUpdate.from_json(request_body_json) + test_id = '584739201' + aid = '1234' + response_body_json = """ + { + "server" : "www.example.com", + "isSavedEvent" : false, + "sslVersion" : "Auto", + "useNtlm" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/scheduled-tests/281474976710706/network/filter" + }, { + "href" : "https://api.thousandeyes.com/v7/endpoint/test-results/scheduled-tests/281474976710706/pathvis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isPrioritized" : false, + "httpTimeLimit" : 5000, + "type" : "http-server", + "protocol" : "icmp", + "httpVersion" : 2, + "followRedirects" : true, + "authType" : "none", + "testName" : "Test name", + "verifyCertificate" : true, + "networkMeasurements" : true, + "tcpProbeMode" : "auto", + "url" : "https://example.com:443", + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "ipVersion" : "V4_ONLY", + "port" : 443, + "isEnabled" : true, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "aid" : "1234", + "agentSelectorConfig" : { + "agentSelectorType" : "all-agents", + "maxMachines" : 25 + }, + "hasPathTraceInSession" : true, + "httpTargetTime" : 100, + "username" : "username", + "sslVersionId" : "0" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.update_http_server_endpoint_scheduled_test( + + test_id=test_id, + + endpoint_http_test_update=endpoint_http_test_update, + + aid=aid, + + _headers=self.te_headers("update_http_server_endpoint_scheduled_test"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_update_http_server_endpoint_scheduled_test_error_400(self) -> None: + """Integration test for update_http_server_endpoint_scheduled_test error path (HTTP 400)""" + request_body_json = """ + + { + "protocol" : "icmp", + "isEnabled" : true, + "interval" : 60, + "tcpProbeMode" : "auto", + "url" : "https://example.com:443", + "testName" : "Test name" + } + + """ + endpoint_http_test_update = thousandeyes_sdk.endpoint_tests.models.EndpointHttpTestUpdate.from_json(request_body_json) + test_id = '584739201' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.update_http_server_endpoint_scheduled_test( + + test_id=test_id, + + endpoint_http_test_update=endpoint_http_test_update, + + aid=aid, + + _headers=self.te_headers("update_http_server_endpoint_scheduled_test", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_http_server_endpoint_scheduled_test_error_401(self) -> None: + """Integration test for update_http_server_endpoint_scheduled_test error path (HTTP 401)""" + request_body_json = """ + + { + "protocol" : "icmp", + "isEnabled" : true, + "interval" : 60, + "tcpProbeMode" : "auto", + "url" : "https://example.com:443", + "testName" : "Test name" + } + + """ + endpoint_http_test_update = thousandeyes_sdk.endpoint_tests.models.EndpointHttpTestUpdate.from_json(request_body_json) + test_id = '584739201' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.update_http_server_endpoint_scheduled_test( + + test_id=test_id, + + endpoint_http_test_update=endpoint_http_test_update, + + aid=aid, + + _headers=self.te_headers("update_http_server_endpoint_scheduled_test", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_http_server_endpoint_scheduled_test_error_403(self) -> None: + """Integration test for update_http_server_endpoint_scheduled_test error path (HTTP 403)""" + request_body_json = """ + + { + "protocol" : "icmp", + "isEnabled" : true, + "interval" : 60, + "tcpProbeMode" : "auto", + "url" : "https://example.com:443", + "testName" : "Test name" + } + + """ + endpoint_http_test_update = thousandeyes_sdk.endpoint_tests.models.EndpointHttpTestUpdate.from_json(request_body_json) + test_id = '584739201' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.update_http_server_endpoint_scheduled_test( + + test_id=test_id, + + endpoint_http_test_update=endpoint_http_test_update, + + aid=aid, + + _headers=self.te_headers("update_http_server_endpoint_scheduled_test", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_http_server_endpoint_scheduled_test_error_404(self) -> None: + """Integration test for update_http_server_endpoint_scheduled_test error path (HTTP 404)""" + request_body_json = """ + + { + "protocol" : "icmp", + "isEnabled" : true, + "interval" : 60, + "tcpProbeMode" : "auto", + "url" : "https://example.com:443", + "testName" : "Test name" + } + + """ + endpoint_http_test_update = thousandeyes_sdk.endpoint_tests.models.EndpointHttpTestUpdate.from_json(request_body_json) + test_id = '584739201' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.update_http_server_endpoint_scheduled_test( + + test_id=test_id, + + endpoint_http_test_update=endpoint_http_test_update, + + aid=aid, + + _headers=self.te_headers("update_http_server_endpoint_scheduled_test", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_http_server_endpoint_scheduled_test_error_429(self) -> None: + """Integration test for update_http_server_endpoint_scheduled_test error path (HTTP 429)""" + request_body_json = """ + + { + "protocol" : "icmp", + "isEnabled" : true, + "interval" : 60, + "tcpProbeMode" : "auto", + "url" : "https://example.com:443", + "testName" : "Test name" + } + + """ + endpoint_http_test_update = thousandeyes_sdk.endpoint_tests.models.EndpointHttpTestUpdate.from_json(request_body_json) + test_id = '584739201' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.update_http_server_endpoint_scheduled_test( + + test_id=test_id, + + endpoint_http_test_update=endpoint_http_test_update, + + aid=aid, + + _headers=self.te_headers("update_http_server_endpoint_scheduled_test", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_http_server_endpoint_scheduled_test_error_500(self) -> None: + """Integration test for update_http_server_endpoint_scheduled_test error path (HTTP 500)""" + request_body_json = """ + + { + "protocol" : "icmp", + "isEnabled" : true, + "interval" : 60, + "tcpProbeMode" : "auto", + "url" : "https://example.com:443", + "testName" : "Test name" + } + + """ + endpoint_http_test_update = thousandeyes_sdk.endpoint_tests.models.EndpointHttpTestUpdate.from_json(request_body_json) + test_id = '584739201' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.update_http_server_endpoint_scheduled_test( + + test_id=test_id, + + endpoint_http_test_update=endpoint_http_test_update, + + aid=aid, + + _headers=self.te_headers("update_http_server_endpoint_scheduled_test", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_http_server_endpoint_scheduled_test_error_502(self) -> None: + """Integration test for update_http_server_endpoint_scheduled_test error path (HTTP 502)""" + request_body_json = """ + + { + "protocol" : "icmp", + "isEnabled" : true, + "interval" : 60, + "tcpProbeMode" : "auto", + "url" : "https://example.com:443", + "testName" : "Test name" + } + + """ + endpoint_http_test_update = thousandeyes_sdk.endpoint_tests.models.EndpointHttpTestUpdate.from_json(request_body_json) + test_id = '584739201' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.update_http_server_endpoint_scheduled_test( + + test_id=test_id, + + endpoint_http_test_update=endpoint_http_test_update, + + aid=aid, + + _headers=self.te_headers("update_http_server_endpoint_scheduled_test", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-endpoint-tests/test/test_utils.py b/thousandeyes-sdk-endpoint-tests/test/test_utils.py index 930528d9..37913f62 100644 --- a/thousandeyes-sdk-endpoint-tests/test/test_utils.py +++ b/thousandeyes-sdk-endpoint-tests/test/test_utils.py @@ -2,15 +2,36 @@ import json import unittest +from typing import Any from pydantic import BaseModel +def _project_onto_constructed(expected: Any, constructed: Any) -> Any: + """Keep only example fields that appear in the constructed model output.""" + if isinstance(constructed, dict): + if not isinstance(expected, dict): + return expected + return { + key: _project_onto_constructed(expected.get(key), value) + for key, value in constructed.items() + } + if isinstance(constructed, list): + if not isinstance(expected, list): + return expected + return [ + _project_onto_constructed(expected[index], value) + for index, value in enumerate(constructed) + ] + return expected + + def assert_constructed_model_matches_example_json(model: BaseModel, loaded_json: dict): test_case = unittest.TestCase() test_case.maxDiff = None test_case.assertIsNotNone(model) constructed_json = json.loads(model.to_json()) - sorted_loaded_json = json.dumps(loaded_json, sort_keys=True) + projected_loaded_json = _project_onto_constructed(loaded_json, constructed_json) + sorted_loaded_json = json.dumps(projected_loaded_json, sort_keys=True) sorted_constructed_json = json.dumps(constructed_json, sort_keys=True) test_case.assertEqual(sorted_loaded_json, sorted_constructed_json) diff --git a/thousandeyes-sdk-event-detection/src/thousandeyes_sdk/event_detection/api/events_api.py b/thousandeyes-sdk-event-detection/src/thousandeyes_sdk/event_detection/api/events_api.py index afd97f04..3b98006a 100644 --- a/thousandeyes-sdk-event-detection/src/thousandeyes_sdk/event_detection/api/events_api.py +++ b/thousandeyes-sdk-event-detection/src/thousandeyes_sdk/event_detection/api/events_api.py @@ -19,7 +19,7 @@ from importlib.metadata import version import thousandeyes_sdk.event_detection.models from datetime import datetime -from pydantic import Field, StrictInt, StrictStr, field_validator +from pydantic import Field, StrictBool, StrictInt, StrictStr, field_validator from typing import Optional from typing_extensions import Annotated from thousandeyes_sdk.event_detection.models.event_detail import EventDetail @@ -350,6 +350,7 @@ class EventsApi: end_date: Annotated[Optional[datetime], Field(description="Defaults to current time the request is made. Use with the `startDate` parameter. Include the complete time (hours, minutes, and seconds) in UTC time zone, following the ISO 8601 date-time format. See the example for reference. Please note that this parameter can't be used with `window`.")] = None, max: Annotated[Optional[StrictInt], Field(description="(Optional) Maximum number of objects to return.")] = None, cursor: Annotated[Optional[StrictStr], Field(description="(Optional) Opaque cursor used for pagination. Clients should use `next` value from `_links` instead of this parameter.")] = None, + ongoing: Annotated[Optional[StrictBool], Field(description="When set to `true`, only ongoing (active) events whose start date is within the specified time window are included in the response. When set to `false`, ongoing events are excluded from the response. If not set, both ongoing and concluded events appear in the response.")] = None, _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -379,6 +380,8 @@ class EventsApi: :type max: int :param cursor: (Optional) Opaque cursor used for pagination. Clients should use `next` value from `_links` instead of this parameter. :type cursor: str + :param ongoing: When set to `true`, only ongoing (active) events whose start date is within the specified time window are included in the response. When set to `false`, ongoing events are excluded from the response. If not set, both ongoing and concluded events appear in the response. + :type ongoing: bool :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of @@ -403,7 +406,7 @@ class EventsApi: return PaginationIterable( self.get_events, lambda data: data.events if data and data.events else [], - aid = aid, window = window, start_date = start_date, end_date = end_date, max = max, cursor = cursor, + aid = aid, window = window, start_date = start_date, end_date = end_date, max = max, cursor = cursor, ongoing = ongoing, _request_timeout=_request_timeout, _request_auth=_request_auth, _content_type=_content_type, @@ -421,6 +424,7 @@ class EventsApi: end_date: Annotated[Optional[datetime], Field(description="Defaults to current time the request is made. Use with the `startDate` parameter. Include the complete time (hours, minutes, and seconds) in UTC time zone, following the ISO 8601 date-time format. See the example for reference. Please note that this parameter can't be used with `window`.")] = None, max: Annotated[Optional[StrictInt], Field(description="(Optional) Maximum number of objects to return.")] = None, cursor: Annotated[Optional[StrictStr], Field(description="(Optional) Opaque cursor used for pagination. Clients should use `next` value from `_links` instead of this parameter.")] = None, + ongoing: Annotated[Optional[StrictBool], Field(description="When set to `true`, only ongoing (active) events whose start date is within the specified time window are included in the response. When set to `false`, ongoing events are excluded from the response. If not set, both ongoing and concluded events appear in the response.")] = None, _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -450,6 +454,8 @@ class EventsApi: :type max: int :param cursor: (Optional) Opaque cursor used for pagination. Clients should use `next` value from `_links` instead of this parameter. :type cursor: str + :param ongoing: When set to `true`, only ongoing (active) events whose start date is within the specified time window are included in the response. When set to `false`, ongoing events are excluded from the response. If not set, both ongoing and concluded events appear in the response. + :type ongoing: bool :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of @@ -479,6 +485,7 @@ class EventsApi: end_date=end_date, max=max, cursor=cursor, + ongoing=ongoing, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, @@ -516,6 +523,7 @@ class EventsApi: end_date: Annotated[Optional[datetime], Field(description="Defaults to current time the request is made. Use with the `startDate` parameter. Include the complete time (hours, minutes, and seconds) in UTC time zone, following the ISO 8601 date-time format. See the example for reference. Please note that this parameter can't be used with `window`.")] = None, max: Annotated[Optional[StrictInt], Field(description="(Optional) Maximum number of objects to return.")] = None, cursor: Annotated[Optional[StrictStr], Field(description="(Optional) Opaque cursor used for pagination. Clients should use `next` value from `_links` instead of this parameter.")] = None, + ongoing: Annotated[Optional[StrictBool], Field(description="When set to `true`, only ongoing (active) events whose start date is within the specified time window are included in the response. When set to `false`, ongoing events are excluded from the response. If not set, both ongoing and concluded events appear in the response.")] = None, _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -545,6 +553,8 @@ class EventsApi: :type max: int :param cursor: (Optional) Opaque cursor used for pagination. Clients should use `next` value from `_links` instead of this parameter. :type cursor: str + :param ongoing: When set to `true`, only ongoing (active) events whose start date is within the specified time window are included in the response. When set to `false`, ongoing events are excluded from the response. If not set, both ongoing and concluded events appear in the response. + :type ongoing: bool :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of @@ -574,6 +584,7 @@ class EventsApi: end_date=end_date, max=max, cursor=cursor, + ongoing=ongoing, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, @@ -611,6 +622,7 @@ class EventsApi: end_date: Annotated[Optional[datetime], Field(description="Defaults to current time the request is made. Use with the `startDate` parameter. Include the complete time (hours, minutes, and seconds) in UTC time zone, following the ISO 8601 date-time format. See the example for reference. Please note that this parameter can't be used with `window`.")] = None, max: Annotated[Optional[StrictInt], Field(description="(Optional) Maximum number of objects to return.")] = None, cursor: Annotated[Optional[StrictStr], Field(description="(Optional) Opaque cursor used for pagination. Clients should use `next` value from `_links` instead of this parameter.")] = None, + ongoing: Annotated[Optional[StrictBool], Field(description="When set to `true`, only ongoing (active) events whose start date is within the specified time window are included in the response. When set to `false`, ongoing events are excluded from the response. If not set, both ongoing and concluded events appear in the response.")] = None, _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -640,6 +652,8 @@ class EventsApi: :type max: int :param cursor: (Optional) Opaque cursor used for pagination. Clients should use `next` value from `_links` instead of this parameter. :type cursor: str + :param ongoing: When set to `true`, only ongoing (active) events whose start date is within the specified time window are included in the response. When set to `false`, ongoing events are excluded from the response. If not set, both ongoing and concluded events appear in the response. + :type ongoing: bool :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of @@ -669,6 +683,7 @@ class EventsApi: end_date=end_date, max=max, cursor=cursor, + ongoing=ongoing, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, @@ -700,6 +715,7 @@ class EventsApi: end_date, max, cursor, + ongoing, _request_auth, _content_type, _headers, @@ -762,6 +778,10 @@ class EventsApi: _query_params.append(('cursor', cursor)) + if ongoing is not None: + + _query_params.append(('ongoing', ongoing)) + # process the header parameters # process the form parameters # process the body parameter diff --git a/thousandeyes-sdk-event-detection/test/conftest.py b/thousandeyes-sdk-event-detection/test/conftest.py new file mode 100644 index 00000000..2edba7b3 --- /dev/null +++ b/thousandeyes-sdk-event-detection/test/conftest.py @@ -0,0 +1,7 @@ +import sys +from pathlib import Path + +_repo_root = Path(__file__).resolve().parents[2] +_core_test_support = _repo_root / "thousandeyes-sdk-core" / "test" +if str(_core_test_support) not in sys.path: + sys.path.insert(0, str(_core_test_support)) diff --git a/thousandeyes-sdk-event-detection/test/integration_test_utils.py b/thousandeyes-sdk-event-detection/test/integration_test_utils.py new file mode 100644 index 00000000..bb20b37c --- /dev/null +++ b/thousandeyes-sdk-event-detection/test/integration_test_utils.py @@ -0,0 +1,37 @@ +# coding: utf-8 + +""" + Event Detection API + + Event detection occurs when ThousandEyes identifies that error signals related to a component (proxy, network node, AS, server etc) have deviated from the baselines established by events. * To determine this, ThousandEyes takes the test results from all accounts groups within an organization, and analyzes that data. * Noisy test results (those that have too many errors in a short window) are removed until they stabilize, and the rest of the results are tagged with the components associated with that test result (for example, proxy, network, or server). * Next, any increase in failures from the test results and each component helps in determining the problem domain and which component may be at fault. * When this failure rate increases beyond a pre-defined threshold (set by the algorithm), an event is triggered and an email notification is sent to the user (if they've enabled email alerts). With the Events API, you can perform the following tasks on the ThousandEyes platform: * **Retrieve Events**: Obtain a list of events and detailed information for each event. For more information about events, see [Event Detection](https://docs.thousandeyes.com/product-documentation/event-detection). + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from thousandeyes_sdk.core.api_client import ApiClient +from thousandeyes_sdk.core.configuration import Configuration +from sdk_test_support.mock_server import ERROR_STATUS_HEADER, OPERATION_ID_HEADER, MockApiServer + +from .mock_manifest import OPERATION_MANIFEST + + +class IntegrationTestBase(unittest.TestCase): + def setUp(self) -> None: + self.server = MockApiServer(OPERATION_MANIFEST) + self.server.start() + configuration = Configuration(host=self.server.base_url, access_token="test-token") + self.api_client = ApiClient(configuration=configuration) + + def tearDown(self) -> None: + self.server.stop() + + def te_headers(self, operation_id: str, error_status=None): + headers = {OPERATION_ID_HEADER: operation_id} + if error_status is not None: + headers[ERROR_STATUS_HEADER] = error_status + return headers diff --git a/thousandeyes-sdk-event-detection/test/mock_manifest.py b/thousandeyes-sdk-event-detection/test/mock_manifest.py new file mode 100644 index 00000000..f5715b1d --- /dev/null +++ b/thousandeyes-sdk-event-detection/test/mock_manifest.py @@ -0,0 +1,460 @@ +# coding: utf-8 + +""" + Event Detection API + + Event detection occurs when ThousandEyes identifies that error signals related to a component (proxy, network node, AS, server etc) have deviated from the baselines established by events. * To determine this, ThousandEyes takes the test results from all accounts groups within an organization, and analyzes that data. * Noisy test results (those that have too many errors in a short window) are removed until they stabilize, and the rest of the results are tagged with the components associated with that test result (for example, proxy, network, or server). * Next, any increase in failures from the test results and each component helps in determining the problem domain and which component may be at fault. * When this failure rate increases beyond a pre-defined threshold (set by the algorithm), an event is triggered and an email notification is sent to the user (if they've enabled email alerts). With the Events API, you can perform the following tasks on the ThousandEyes platform: * **Retrieve Events**: Obtain a list of events and detailed information for each event. For more information about events, see [Event Detection](https://docs.thousandeyes.com/product-documentation/event-detection). + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json + +from sdk_test_support.mock_server_types import ErrorResponseExpectation, OperationExpectation + +OPERATION_MANIFEST = { + + "get_event": OperationExpectation( + operation_id="get_event", + method="GET", + path="/events/{id}", + path_param_examples={ + "id": 'e9c3bf02-a48c-4aa8-9e5f-898800d6f569', + }, + success_status=200, + success_body=json.loads(""" + + { + "severity" : "medium", + "summary" : "Significant number of issues detected with 66.29.146.15", + "agentType" : "cloud-enterprise-agent", + "affectedTests" : { + "total" : 5, + "tests" : [ { + "affectedTargetIds" : [ "123", "1234" ], + "affectedAgentIds" : [ "2954", "2953" ], + "_links" : { + "test" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "Google test", + "testType" : "agent-to-server", + "testId" : "226770" + }, { + "affectedTargetIds" : [ "123", "1234" ], + "affectedAgentIds" : [ "2954", "2953" ], + "_links" : { + "test" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "Google test", + "testType" : "agent-to-server", + "testId" : "226770" + } ], + "inAccountGroup" : 2 + }, + "endDate" : "2020-04-23T13:43:16Z", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "typeName" : "Network Issue", + "cause" : [ "Network Loss and/or High RTT" ], + "affectedTargets" : { + "total" : 5, + "inAccountGroup" : 2, + "targets" : [ { + "affectedAgentIds" : [ "2954", "2953" ], + "ip" : "216.239.32.10", + "name" : "google.com", + "affectedTestIds" : [ "123", "1234" ], + "serverId" : "123" + }, { + "affectedAgentIds" : [ "2954", "2953" ], + "ip" : "216.239.32.10", + "name" : "google.com", + "affectedTestIds" : [ "123", "1234" ], + "serverId" : "123" + } ] + }, + "type" : "target", + "grouping" : { + "target" : "google.com" + }, + "affectedAgents" : { + "total" : 5, + "inAccountGroup" : 2, + "agents" : [ { + "affectedTargetIds" : [ "123", "1234" ], + "agentId" : "2954", + "_links" : { + "agent" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "countryCode" : "BR", + "name" : "São Paulo, Brazil - agent", + "location" : "São Paulo, Brazil", + "affectedTestIds" : [ "2954", "2953" ], + "type" : "enterprise" + }, { + "affectedTargetIds" : [ "123", "1234" ], + "agentId" : "2954", + "_links" : { + "agent" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "countryCode" : "BR", + "name" : "São Paulo, Brazil - agent", + "location" : "São Paulo, Brazil", + "affectedTestIds" : [ "2954", "2953" ], + "type" : "enterprise" + } ] + }, + "id" : "e9c3bf02-a48c-4aa8-9e5f-898800d6f569", + "state" : "resolved", + "aid" : "1234", + "startDate" : "2020-04-23T13:43:16Z" + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_events": OperationExpectation( + operation_id="get_events", + method="GET", + path="/events", + path_param_examples={ + }, + success_status=200, + success_body=json.loads(""" + + { + "endDate" : "2022-07-18T22:00:54Z", + "_links" : { + "next" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "aid" : "1234", + "startDate" : "2022-07-17T22:00:54Z", + "events" : [ { + "severity" : "medium", + "agentType" : "cloud-enterprise-agent", + "affectedTests" : { + "total" : 5, + "inAccountGroup" : 2 + }, + "endDate" : "2020-04-23T13:43:16Z", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "typeName" : "Network Issue", + "title" : "Affecting destinations in google.com", + "type" : "target", + "affectedTargets" : { + "total" : 5, + "inAccountGroup" : 2 + }, + "affectedAgents" : { + "total" : 5, + "inAccountGroup" : 2 + }, + "id" : "e9c3bf02-a48c-4aa8-9e5f-898800d6f569", + "state" : "resolved", + "startDate" : "2020-04-23T13:43:16Z" + }, { + "severity" : "medium", + "agentType" : "cloud-enterprise-agent", + "affectedTests" : { + "total" : 5, + "inAccountGroup" : 2 + }, + "endDate" : "2020-04-23T13:43:16Z", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "typeName" : "Network Issue", + "title" : "Affecting destinations in google.com", + "type" : "target", + "affectedTargets" : { + "total" : 5, + "inAccountGroup" : 2 + }, + "affectedAgents" : { + "total" : 5, + "inAccountGroup" : 2 + }, + "id" : "e9c3bf02-a48c-4aa8-9e5f-898800d6f569", + "state" : "resolved", + "startDate" : "2020-04-23T13:43:16Z" + } ] + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + +} diff --git a/thousandeyes-sdk-event-detection/test/test_events_api_integration.py b/thousandeyes-sdk-event-detection/test/test_events_api_integration.py new file mode 100644 index 00000000..4b0ca5d1 --- /dev/null +++ b/thousandeyes-sdk-event-detection/test/test_events_api_integration.py @@ -0,0 +1,789 @@ +# coding: utf-8 + +""" + Event Detection API + + Event detection occurs when ThousandEyes identifies that error signals related to a component (proxy, network node, AS, server etc) have deviated from the baselines established by events. * To determine this, ThousandEyes takes the test results from all accounts groups within an organization, and analyzes that data. * Noisy test results (those that have too many errors in a short window) are removed until they stabilize, and the rest of the results are tagged with the components associated with that test result (for example, proxy, network, or server). * Next, any increase in failures from the test results and each component helps in determining the problem domain and which component may be at fault. * When this failure rate increases beyond a pre-defined threshold (set by the algorithm), an event is triggered and an email notification is sent to the user (if they've enabled email alerts). With the Events API, you can perform the following tasks on the ThousandEyes platform: * **Retrieve Events**: Obtain a list of events and detailed information for each event. For more information about events, see [Event Detection](https://docs.thousandeyes.com/product-documentation/event-detection). + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.event_detection.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.event_detection.api.events_api import EventsApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestEventsApiIntegration(IntegrationTestBase): + """EventsApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = EventsApi(self.api_client) + + + def test_get_event_happy_path(self) -> None: + """Integration test for get_event success path""" + id = 'e9c3bf02-a48c-4aa8-9e5f-898800d6f569' + aid = '1234' + response_body_json = """ + { + "severity" : "medium", + "summary" : "Significant number of issues detected with 66.29.146.15", + "agentType" : "cloud-enterprise-agent", + "affectedTests" : { + "total" : 5, + "tests" : [ { + "affectedTargetIds" : [ "123", "1234" ], + "affectedAgentIds" : [ "2954", "2953" ], + "_links" : { + "test" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "Google test", + "testType" : "agent-to-server", + "testId" : "226770" + }, { + "affectedTargetIds" : [ "123", "1234" ], + "affectedAgentIds" : [ "2954", "2953" ], + "_links" : { + "test" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "name" : "Google test", + "testType" : "agent-to-server", + "testId" : "226770" + } ], + "inAccountGroup" : 2 + }, + "endDate" : "2020-04-23T13:43:16Z", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "typeName" : "Network Issue", + "cause" : [ "Network Loss and/or High RTT" ], + "affectedTargets" : { + "total" : 5, + "inAccountGroup" : 2, + "targets" : [ { + "affectedAgentIds" : [ "2954", "2953" ], + "ip" : "216.239.32.10", + "name" : "google.com", + "affectedTestIds" : [ "123", "1234" ], + "serverId" : "123" + }, { + "affectedAgentIds" : [ "2954", "2953" ], + "ip" : "216.239.32.10", + "name" : "google.com", + "affectedTestIds" : [ "123", "1234" ], + "serverId" : "123" + } ] + }, + "type" : "target", + "grouping" : { + "target" : "google.com" + }, + "affectedAgents" : { + "total" : 5, + "inAccountGroup" : 2, + "agents" : [ { + "affectedTargetIds" : [ "123", "1234" ], + "agentId" : "2954", + "_links" : { + "agent" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "countryCode" : "BR", + "name" : "São Paulo, Brazil - agent", + "location" : "São Paulo, Brazil", + "affectedTestIds" : [ "2954", "2953" ], + "type" : "enterprise" + }, { + "affectedTargetIds" : [ "123", "1234" ], + "agentId" : "2954", + "_links" : { + "agent" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "countryCode" : "BR", + "name" : "São Paulo, Brazil - agent", + "location" : "São Paulo, Brazil", + "affectedTestIds" : [ "2954", "2953" ], + "type" : "enterprise" + } ] + }, + "id" : "e9c3bf02-a48c-4aa8-9e5f-898800d6f569", + "state" : "resolved", + "aid" : "1234", + "startDate" : "2020-04-23T13:43:16Z" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_event( + + id=id, + + aid=aid, + + _headers=self.te_headers("get_event"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_event_error_401(self) -> None: + """Integration test for get_event error path (HTTP 401)""" + id = 'e9c3bf02-a48c-4aa8-9e5f-898800d6f569' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_event( + + id=id, + + aid=aid, + + _headers=self.te_headers("get_event", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_event_error_403(self) -> None: + """Integration test for get_event error path (HTTP 403)""" + id = 'e9c3bf02-a48c-4aa8-9e5f-898800d6f569' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_event( + + id=id, + + aid=aid, + + _headers=self.te_headers("get_event", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_event_error_404(self) -> None: + """Integration test for get_event error path (HTTP 404)""" + id = 'e9c3bf02-a48c-4aa8-9e5f-898800d6f569' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_event( + + id=id, + + aid=aid, + + _headers=self.te_headers("get_event", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_event_error_429(self) -> None: + """Integration test for get_event error path (HTTP 429)""" + id = 'e9c3bf02-a48c-4aa8-9e5f-898800d6f569' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_event( + + id=id, + + aid=aid, + + _headers=self.te_headers("get_event", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_event_error_500(self) -> None: + """Integration test for get_event error path (HTTP 500)""" + id = 'e9c3bf02-a48c-4aa8-9e5f-898800d6f569' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_event( + + id=id, + + aid=aid, + + _headers=self.te_headers("get_event", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_event_error_502(self) -> None: + """Integration test for get_event error path (HTTP 502)""" + id = 'e9c3bf02-a48c-4aa8-9e5f-898800d6f569' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.get_event( + + id=id, + + aid=aid, + + _headers=self.te_headers("get_event", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_events_happy_path(self) -> None: + """Integration test for get_events success path""" + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + max = 5 + cursor = 'cursor_example' + ongoing = True + response_body_json = """ + { + "endDate" : "2022-07-18T22:00:54Z", + "_links" : { + "next" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "aid" : "1234", + "startDate" : "2022-07-17T22:00:54Z", + "events" : [ { + "severity" : "medium", + "agentType" : "cloud-enterprise-agent", + "affectedTests" : { + "total" : 5, + "inAccountGroup" : 2 + }, + "endDate" : "2020-04-23T13:43:16Z", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "typeName" : "Network Issue", + "title" : "Affecting destinations in google.com", + "type" : "target", + "affectedTargets" : { + "total" : 5, + "inAccountGroup" : 2 + }, + "affectedAgents" : { + "total" : 5, + "inAccountGroup" : 2 + }, + "id" : "e9c3bf02-a48c-4aa8-9e5f-898800d6f569", + "state" : "resolved", + "startDate" : "2020-04-23T13:43:16Z" + }, { + "severity" : "medium", + "agentType" : "cloud-enterprise-agent", + "affectedTests" : { + "total" : 5, + "inAccountGroup" : 2 + }, + "endDate" : "2020-04-23T13:43:16Z", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "typeName" : "Network Issue", + "title" : "Affecting destinations in google.com", + "type" : "target", + "affectedTargets" : { + "total" : 5, + "inAccountGroup" : 2 + }, + "affectedAgents" : { + "total" : 5, + "inAccountGroup" : 2 + }, + "id" : "e9c3bf02-a48c-4aa8-9e5f-898800d6f569", + "state" : "resolved", + "startDate" : "2020-04-23T13:43:16Z" + } ] + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_events( + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + max=max, + + cursor=cursor, + + ongoing=ongoing, + + _headers=self.te_headers("get_events"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_events_error_400(self) -> None: + """Integration test for get_events error path (HTTP 400)""" + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + max = 5 + cursor = 'cursor_example' + ongoing = True + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.get_events( + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + max=max, + + cursor=cursor, + + ongoing=ongoing, + + _headers=self.te_headers("get_events", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_events_error_401(self) -> None: + """Integration test for get_events error path (HTTP 401)""" + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + max = 5 + cursor = 'cursor_example' + ongoing = True + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_events( + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + max=max, + + cursor=cursor, + + ongoing=ongoing, + + _headers=self.te_headers("get_events", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_events_error_403(self) -> None: + """Integration test for get_events error path (HTTP 403)""" + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + max = 5 + cursor = 'cursor_example' + ongoing = True + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_events( + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + max=max, + + cursor=cursor, + + ongoing=ongoing, + + _headers=self.te_headers("get_events", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_events_error_404(self) -> None: + """Integration test for get_events error path (HTTP 404)""" + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + max = 5 + cursor = 'cursor_example' + ongoing = True + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_events( + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + max=max, + + cursor=cursor, + + ongoing=ongoing, + + _headers=self.te_headers("get_events", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_events_error_429(self) -> None: + """Integration test for get_events error path (HTTP 429)""" + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + max = 5 + cursor = 'cursor_example' + ongoing = True + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_events( + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + max=max, + + cursor=cursor, + + ongoing=ongoing, + + _headers=self.te_headers("get_events", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_events_error_500(self) -> None: + """Integration test for get_events error path (HTTP 500)""" + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + max = 5 + cursor = 'cursor_example' + ongoing = True + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_events( + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + max=max, + + cursor=cursor, + + ongoing=ongoing, + + _headers=self.te_headers("get_events", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_events_error_502(self) -> None: + """Integration test for get_events error path (HTTP 502)""" + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + max = 5 + cursor = 'cursor_example' + ongoing = True + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.get_events( + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + max=max, + + cursor=cursor, + + ongoing=ongoing, + + _headers=self.te_headers("get_events", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-event-detection/test/test_utils.py b/thousandeyes-sdk-event-detection/test/test_utils.py index 930528d9..37913f62 100644 --- a/thousandeyes-sdk-event-detection/test/test_utils.py +++ b/thousandeyes-sdk-event-detection/test/test_utils.py @@ -2,15 +2,36 @@ import json import unittest +from typing import Any from pydantic import BaseModel +def _project_onto_constructed(expected: Any, constructed: Any) -> Any: + """Keep only example fields that appear in the constructed model output.""" + if isinstance(constructed, dict): + if not isinstance(expected, dict): + return expected + return { + key: _project_onto_constructed(expected.get(key), value) + for key, value in constructed.items() + } + if isinstance(constructed, list): + if not isinstance(expected, list): + return expected + return [ + _project_onto_constructed(expected[index], value) + for index, value in enumerate(constructed) + ] + return expected + + def assert_constructed_model_matches_example_json(model: BaseModel, loaded_json: dict): test_case = unittest.TestCase() test_case.maxDiff = None test_case.assertIsNotNone(model) constructed_json = json.loads(model.to_json()) - sorted_loaded_json = json.dumps(loaded_json, sort_keys=True) + projected_loaded_json = _project_onto_constructed(loaded_json, constructed_json) + sorted_loaded_json = json.dumps(projected_loaded_json, sort_keys=True) sorted_constructed_json = json.dumps(constructed_json, sort_keys=True) test_case.assertEqual(sorted_loaded_json, sorted_constructed_json) diff --git a/thousandeyes-sdk-instant-tests/test/conftest.py b/thousandeyes-sdk-instant-tests/test/conftest.py new file mode 100644 index 00000000..2edba7b3 --- /dev/null +++ b/thousandeyes-sdk-instant-tests/test/conftest.py @@ -0,0 +1,7 @@ +import sys +from pathlib import Path + +_repo_root = Path(__file__).resolve().parents[2] +_core_test_support = _repo_root / "thousandeyes-sdk-core" / "test" +if str(_core_test_support) not in sys.path: + sys.path.insert(0, str(_core_test_support)) diff --git a/thousandeyes-sdk-instant-tests/test/integration_test_utils.py b/thousandeyes-sdk-instant-tests/test/integration_test_utils.py new file mode 100644 index 00000000..b4de1e4f --- /dev/null +++ b/thousandeyes-sdk-instant-tests/test/integration_test_utils.py @@ -0,0 +1,37 @@ +# coding: utf-8 + +""" + Instant Tests API + + The Instant Tests API operations lets you create and run new instant tests. You will need to be an Account Admin. The response does not include the immediate test results. Use the Test Results endpoints to get test results after creating and executing an instant test. You can find the URLs for these endpoints in the _links section of the test definition that is returned when you create the instant test. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from thousandeyes_sdk.core.api_client import ApiClient +from thousandeyes_sdk.core.configuration import Configuration +from sdk_test_support.mock_server import ERROR_STATUS_HEADER, OPERATION_ID_HEADER, MockApiServer + +from .mock_manifest import OPERATION_MANIFEST + + +class IntegrationTestBase(unittest.TestCase): + def setUp(self) -> None: + self.server = MockApiServer(OPERATION_MANIFEST) + self.server.start() + configuration = Configuration(host=self.server.base_url, access_token="test-token") + self.api_client = ApiClient(configuration=configuration) + + def tearDown(self) -> None: + self.server.stop() + + def te_headers(self, operation_id: str, error_status=None): + headers = {OPERATION_ID_HEADER: operation_id} + if error_status is not None: + headers[ERROR_STATUS_HEADER] = error_status + return headers diff --git a/thousandeyes-sdk-instant-tests/test/mock_manifest.py b/thousandeyes-sdk-instant-tests/test/mock_manifest.py new file mode 100644 index 00000000..be288d75 --- /dev/null +++ b/thousandeyes-sdk-instant-tests/test/mock_manifest.py @@ -0,0 +1,3980 @@ +# coding: utf-8 + +""" + Instant Tests API + + The Instant Tests API operations lets you create and run new instant tests. You will need to be an Account Admin. The response does not include the immediate test results. Use the Test Results endpoints to get test results after creating and executing an instant test. You can find the URLs for these endpoints in the _links section of the test definition that is returned when you create the instant test. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json + +from sdk_test_support.mock_server_types import ErrorResponseExpectation, OperationExpectation + +OPERATION_MANIFEST = { + + "create_api_instant_test": OperationExpectation( + operation_id="create_api_instant_test", + method="POST", + path="/tests/api/instant", + path_param_examples={ + }, + success_status=201, + success_body=json.loads(""" + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "credentials" : [ "3247", "1051" ], + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "requests" : [ { + "headers" : [ { + "value" : "keep-alive", + "key" : "x-custom-header" + }, { + "value" : "keep-alive", + "key" : "x-custom-header" + } ], + "variables" : [ { + "name" : "myTestName", + "value" : "tests[0].name" + }, { + "name" : "myTestName", + "value" : "tests[0].name" + } ], + "clientId" : "client-id", + "tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token", + "method" : "get", + "verifyCertificate" : false, + "body" : "body", + "url" : "https://api.thousandeyes.com/v7/status", + "password" : "basic_pw123", + "bearerToken" : "abcd-1234-...", + "scope" : "read, write, deploy", + "name" : "Step 1", + "waitTimeMs" : 0, + "clientAuthentication" : "basic-auth-header", + "clientSecret" : "client-secret", + "assertions" : [ { + "name" : "status-code", + "value" : "200", + "operator" : "is" + }, { + "name" : "status-code", + "value" : "200", + "operator" : "is" + } ], + "authType" : "none", + "collectApiResponse" : true, + "username" : "ThousandEyesUserName" + }, { + "headers" : [ { + "value" : "keep-alive", + "key" : "x-custom-header" + }, { + "value" : "keep-alive", + "key" : "x-custom-header" + } ], + "variables" : [ { + "name" : "myTestName", + "value" : "tests[0].name" + }, { + "name" : "myTestName", + "value" : "tests[0].name" + } ], + "clientId" : "client-id", + "tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token", + "method" : "get", + "verifyCertificate" : false, + "body" : "body", + "url" : "https://api.thousandeyes.com/v7/status", + "password" : "basic_pw123", + "bearerToken" : "abcd-1234-...", + "scope" : "read, write, deploy", + "name" : "Step 1", + "waitTimeMs" : 0, + "clientAuthentication" : "basic-auth-header", + "clientSecret" : "client-secret", + "assertions" : [ { + "name" : "status-code", + "value" : "200", + "operator" : "is" + }, { + "name" : "status-code", + "value" : "200", + "operator" : "is" + } ], + "authType" : "none", + "collectApiResponse" : true, + "username" : "ThousandEyesUserName" + } ], + "type" : "api", + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "protocol" : "tcp", + "collectProxyNetworkData" : false, + "followRedirects" : true, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "clientCertDomainsAllowList" : "www.thousandeyes.com", + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "overrideAgentProxy" : false, + "predefinedVariables" : [ { + "name" : "myUsername", + "value" : "ThousandEyesAccountUserName" + }, { + "name" : "myUsername", + "value" : "ThousandEyesAccountUserName" + } ], + "liveShare" : false, + "distributedTracing" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "timeLimit" : 19, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "testId" : "281474976710706", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "overrideProxyId" : "281474976710706", + "sslVersionId" : "0", + "targetTime" : 1 + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "credentials" : [ "3247", "1051" ], + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "requests" : [ { + "headers" : [ { + "value" : "keep-alive", + "key" : "x-custom-header" + }, { + "value" : "keep-alive", + "key" : "x-custom-header" + } ], + "variables" : [ { + "name" : "myTestName", + "value" : "tests[0].name" + }, { + "name" : "myTestName", + "value" : "tests[0].name" + } ], + "clientId" : "client-id", + "tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token", + "method" : "get", + "verifyCertificate" : false, + "body" : "body", + "url" : "https://api.thousandeyes.com/v7/status", + "password" : "basic_pw123", + "bearerToken" : "abcd-1234-...", + "scope" : "read, write, deploy", + "name" : "Step 1", + "waitTimeMs" : 0, + "clientAuthentication" : "basic-auth-header", + "clientSecret" : "client-secret", + "assertions" : [ { + "name" : "status-code", + "value" : "200", + "operator" : "is" + }, { + "name" : "status-code", + "value" : "200", + "operator" : "is" + } ], + "authType" : "none", + "collectApiResponse" : true, + "username" : "ThousandEyesUserName" + }, { + "headers" : [ { + "value" : "keep-alive", + "key" : "x-custom-header" + }, { + "value" : "keep-alive", + "key" : "x-custom-header" + } ], + "variables" : [ { + "name" : "myTestName", + "value" : "tests[0].name" + }, { + "name" : "myTestName", + "value" : "tests[0].name" + } ], + "clientId" : "client-id", + "tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token", + "method" : "get", + "verifyCertificate" : false, + "body" : "body", + "url" : "https://api.thousandeyes.com/v7/status", + "password" : "basic_pw123", + "bearerToken" : "abcd-1234-...", + "scope" : "read, write, deploy", + "name" : "Step 1", + "waitTimeMs" : 0, + "clientAuthentication" : "basic-auth-header", + "clientSecret" : "client-secret", + "assertions" : [ { + "name" : "status-code", + "value" : "200", + "operator" : "is" + }, { + "name" : "status-code", + "value" : "200", + "operator" : "is" + } ], + "authType" : "none", + "collectApiResponse" : true, + "username" : "ThousandEyesUserName" + } ], + "type" : "api", + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "protocol" : "tcp", + "collectProxyNetworkData" : false, + "followRedirects" : true, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "clientCertDomainsAllowList" : "www.thousandeyes.com", + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "overrideAgentProxy" : false, + "predefinedVariables" : [ { + "name" : "myUsername", + "value" : "ThousandEyesAccountUserName" + }, { + "name" : "myUsername", + "value" : "ThousandEyesAccountUserName" + } ], + "liveShare" : false, + "distributedTracing" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "timeLimit" : 19, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "sslVersionId" : "0", + "targetTime" : 1 + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "create_agent_to_agent_instant_test": OperationExpectation( + operation_id="create_agent_to_agent_instant_test", + method="POST", + path="/tests/agent-to-agent/instant", + path_param_examples={ + }, + success_status=201, + success_body=json.loads(""" + + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "description" : "ThousandEyes Test", + "type" : "agent-to-agent", + "mss" : 100, + "dscpId" : "0", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "dscp" : "Best Effort (DSCP 0)", + "pathTraceMode" : "classic", + "throughputRate" : 10, + "modifiedBy" : "user@user.com", + "testName" : "ThousandEyes Test", + "direction" : "to-target", + "throughputMeasurements" : false, + "numPathTraces" : 3, + "liveShare" : false, + "savedEvent" : true, + "throughputDuration" : 10000, + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "port" : 49153, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "targetAgentId" : "2954", + "testId" : "281474976710706", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ] + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "description" : "ThousandEyes Test", + "type" : "agent-to-agent", + "mss" : 100, + "dscpId" : "0", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "dscp" : "Best Effort (DSCP 0)", + "pathTraceMode" : "classic", + "throughputRate" : 10, + "modifiedBy" : "user@user.com", + "testName" : "ThousandEyes Test", + "direction" : "to-target", + "throughputMeasurements" : false, + "numPathTraces" : 3, + "liveShare" : false, + "savedEvent" : true, + "throughputDuration" : 10000, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "port" : 49153, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "targetAgentId" : "2954", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ] + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "create_agent_to_server_instant_test": OperationExpectation( + operation_id="create_agent_to_server_instant_test", + method="POST", + path="/tests/agent-to-server/instant", + path_param_examples={ + }, + success_status=201, + success_body=json.loads(""" + + { + "server" : "www.thousandeyes.com:80", + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "type" : "agent-to-server", + "dscpId" : "0", + "fixedPacketRate" : 25, + "protocol" : "tcp", + "dscp" : "Best Effort (DSCP 0)", + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : false, + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "testId" : "281474976710706", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "pingPayloadSize" : 112, + "continuousMode" : false + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "server" : "www.thousandeyes.com:80", + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "type" : "agent-to-server", + "dscpId" : "0", + "fixedPacketRate" : 25, + "protocol" : "tcp", + "dscp" : "Best Effort (DSCP 0)", + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : false, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "testId" : "281474976710706", + "pingPayloadSize" : 112, + "sharedWithAccounts" : [ "1234", "12345" ], + "continuousMode" : false + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "create_dns_sec_instant_test": OperationExpectation( + operation_id="create_dns_sec_instant_test", + method="POST", + path="/tests/dnssec/instant", + path_param_examples={ + }, + success_status=201, + success_body=json.loads(""" + + { + "dnsQueryClass" : "in", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "dnssec", + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "testName" : "ThousandEyes Test" + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "dnsQueryClass" : "in", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "dnssec", + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "testName" : "ThousandEyes Test" + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "create_dns_server_instant_test": OperationExpectation( + operation_id="create_dns_server_instant_test", + method="POST", + path="/tests/dns-server/instant", + path_param_examples={ + }, + success_status=201, + success_body=json.loads(""" + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "dnsTransportProtocol" : "udp", + "probeMode" : "auto", + "type" : "dns-server", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "dnsServers" : [ { + "serverName" : "dns-example.net", + "serverId" : "1447" + }, { + "serverName" : "dns-example.net", + "serverId" : "1447" + } ], + "recursiveQueries" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "dnsQueryClass" : "in", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "testId" : "281474976710706", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ] + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "dnsTransportProtocol" : "udp", + "probeMode" : "auto", + "type" : "dns-server", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "dnsServers" : [ "dns-example.net", "8.8.8.8" ], + "recursiveQueries" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "dnsQueryClass" : "in", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ] + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "create_dns_trace_instant_test": OperationExpectation( + operation_id="create_dns_trace_instant_test", + method="POST", + path="/tests/dns-trace/instant", + path_param_examples={ + }, + success_status=201, + success_body=json.loads(""" + + { + "dnsQueryClass" : "in", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "dnsTransportProtocol" : "udp", + "type" : "dns-trace", + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "testName" : "ThousandEyes Test" + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "dnsQueryClass" : "in", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "dnsTransportProtocol" : "udp", + "type" : "dns-trace", + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "testName" : "ThousandEyes Test" + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "create_ftp_server_instant_test": OperationExpectation( + operation_id="create_ftp_server_instant_test", + method="POST", + path="/tests/ftp-server/instant", + path_param_examples={ + }, + success_status=201, + success_body=json.loads(""" + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "downloadLimit" : 1048576, + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "useExplicitFtps" : false, + "probeMode" : "auto", + "type" : "ftp-server", + "password" : "password", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "ftpTargetTime" : 1400, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "requestType" : "download", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "ftpTimeLimit" : 10, + "modifiedDate" : "2022-07-17T22:00:54Z", + "testId" : "281474976710706", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "useActiveFtp" : false, + "username" : "username" + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "downloadLimit" : 1048576, + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "useExplicitFtps" : false, + "probeMode" : "auto", + "type" : "ftp-server", + "password" : "password", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "ftpTargetTime" : 1400, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "requestType" : "download", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "ftpTimeLimit" : 10, + "modifiedDate" : "2022-07-17T22:00:54Z", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "useActiveFtp" : false, + "username" : "username" + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "create_page_load_instant_test": OperationExpectation( + operation_id="create_page_load_instant_test", + method="POST", + path="/tests/page-load/instant", + path_param_examples={ + }, + success_status=201, + success_body=json.loads(""" + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "page-load", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "chromePolicies" : "{\\"ProxyMode\\":\\"direct\\"}", + "contentRegex" : "(regex)+", + "pageLoadingStrategy" : "normal", + "testName" : "ThousandEyes Test", + "allowMicAndCamera" : false, + "browserLanguage" : "en-US", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "emulatedDeviceId" : "2", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "overrideProxyId" : "281474976710706", + "sslVersion" : "Auto", + "useNtlm" : false, + "downloadLimit" : 2048, + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "blockDomains" : "domain.com/", + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowGeolocation" : false, + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "pageLoadTargetTime" : 10, + "numPathTraces" : 3, + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "pageLoadTimeLimit" : 10, + "identifyAgentTrafficWithUserAgent" : false, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "disableScreenshot" : false, + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "chromeOptions" : "--disable-gpu", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username" + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "page-load", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "chromePolicies" : "{\\"ProxyMode\\":\\"direct\\"}", + "contentRegex" : "(regex)+", + "pageLoadingStrategy" : "normal", + "testName" : "ThousandEyes Test", + "allowMicAndCamera" : false, + "browserLanguage" : "en-US", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "emulatedDeviceId" : "2", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "sslVersion" : "Auto", + "useNtlm" : false, + "downloadLimit" : 2048, + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "blockDomains" : "domain.com/", + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowGeolocation" : false, + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "pageLoadTargetTime" : 10, + "numPathTraces" : 3, + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "pageLoadTimeLimit" : 10, + "identifyAgentTrafficWithUserAgent" : false, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "disableScreenshot" : false, + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "chromeOptions" : "--disable-gpu", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username" + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "create_http_server_instant_test": OperationExpectation( + operation_id="create_http_server_instant_test", + method="POST", + path="/tests/http-server/instant", + path_param_examples={ + }, + success_status=201, + success_body=json.loads(""" + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "http-server", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "contentRegex" : "(regex)+", + "testName" : "ThousandEyes Test", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "overrideProxyId" : "281474976710706", + "sslVersion" : "Auto", + "useNtlm" : false, + "ipv6Policy" : "use-agent-policy", + "downloadLimit" : 2048, + "requestMethod" : "get", + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "headers" : [ "header1: value1", "header2: value2" ], + "numPathTraces" : 3, + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "postBody" : "{ \\"example\\" : \\"value\\"}", + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username" + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "http-server", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "contentRegex" : "(regex)+", + "testName" : "ThousandEyes Test", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "sslVersion" : "Auto", + "useNtlm" : false, + "ipv6Policy" : "use-agent-policy", + "downloadLimit" : 2048, + "requestMethod" : "get", + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "headers" : [ "header1: value1", "header2: value2" ], + "numPathTraces" : 3, + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "postBody" : "{ \\"example\\" : \\"value\\"}", + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username" + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "create_sip_server_instant_test": OperationExpectation( + operation_id="create_sip_server_instant_test", + method="POST", + path="/tests/sip-server/instant", + path_param_examples={ + }, + success_status=201, + success_body=json.loads(""" + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "registerEnabled" : false, + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "type" : "sip-server", + "authUser" : "username", + "fixedPacketRate" : 50, + "password" : "password", + "protocol" : "tcp", + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "testName" : "ThousandEyes Test", + "sipTargetTime" : 1000, + "numPathTraces" : 3, + "optionsRegex" : "[\\"a-z\\"]", + "liveShare" : false, + "savedEvent" : true, + "sipRegistrar" : "voice.thousandeyes.com", + "networkMeasurements" : true, + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "port" : 49153, + "modifiedDate" : "2022-07-17T22:00:54Z", + "sipTimeLimit" : 5, + "testId" : "281474976710706", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "user" : "username" + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "registerEnabled" : false, + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "type" : "sip-server", + "fixedPacketRate" : 50, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "targetSipCredentials" : { + "password" : "password", + "protocol" : "tcp", + "port" : 49153, + "sipRegistrar" : "voice.thousandeyes.com", + "authUser" : "username", + "user" : "username" + }, + "testName" : "ThousandEyes Test", + "sipTargetTime" : 1000, + "numPathTraces" : 3, + "optionsRegex" : "[\\"a-z\\"]", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "sipTimeLimit" : 5, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ] + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "create_voice_instant_test": OperationExpectation( + operation_id="create_voice_instant_test", + method="POST", + path="/tests/voice/instant", + path_param_examples={ + }, + success_status=201, + success_body=json.loads(""" + + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "description" : "ThousandEyes Test", + "type" : "voice", + "jitterBuffer" : 40, + "dscpId" : "0", + "duration" : 5, + "dscp" : "Best Effort (DSCP 0)", + "modifiedBy" : "user@user.com", + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "liveShare" : false, + "savedEvent" : true, + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "codec" : "G.711 @ 64 Kbps", + "codecId" : "0", + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "port" : 1024, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "targetAgentId" : "281474976710706", + "testId" : "281474976710706", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ] + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "description" : "ThousandEyes Test", + "type" : "voice", + "jitterBuffer" : 40, + "dscpId" : "0", + "duration" : 5, + "dscp" : "Best Effort (DSCP 0)", + "modifiedBy" : "user@user.com", + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "liveShare" : false, + "savedEvent" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "codec" : "G.711 @ 64 Kbps", + "codecId" : "0", + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "port" : 1024, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "targetAgentId" : "281474976710706", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ] + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "create_web_transaction_instant_test": OperationExpectation( + operation_id="create_web_transaction_instant_test", + method="POST", + path="/tests/web-transactions/instant", + path_param_examples={ + }, + success_status=201, + success_body=json.loads(""" + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "web-transactions", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "chromePolicies" : "{\\"ProxyMode\\":\\"direct\\"}", + "contentRegex" : "(regex)+", + "pageLoadingStrategy" : "normal", + "testName" : "ThousandEyes Test", + "allowMicAndCamera" : false, + "browserLanguage" : "en-US", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "emulatedDeviceId" : "2", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "overrideProxyId" : "281474976710706", + "sslVersion" : "Auto", + "useNtlm" : false, + "credentials" : [ "3247", "1051" ], + "downloadLimit" : 2048, + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "blockDomains" : "domain.com/", + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowGeolocation" : false, + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "numPathTraces" : 3, + "transactionScript" : "if (true) { return true; }", + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "identifyAgentTrafficWithUserAgent" : false, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "timeLimit" : 30, + "createdDate" : "2022-07-17T22:00:54Z", + "disableScreenshot" : false, + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "chromeOptions" : "--disable-gpu", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username", + "targetTime" : 1 + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "web-transactions", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "chromePolicies" : "{\\"ProxyMode\\":\\"direct\\"}", + "contentRegex" : "(regex)+", + "pageLoadingStrategy" : "normal", + "testName" : "ThousandEyes Test", + "allowMicAndCamera" : false, + "browserLanguage" : "en-US", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "emulatedDeviceId" : "2", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "sslVersion" : "Auto", + "useNtlm" : false, + "credentials" : [ "3247", "1051" ], + "downloadLimit" : 2048, + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "blockDomains" : "domain.com/", + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowGeolocation" : false, + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "numPathTraces" : 3, + "transactionScript" : "if (true) { return true; }", + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "identifyAgentTrafficWithUserAgent" : false, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "timeLimit" : 30, + "createdDate" : "2022-07-17T22:00:54Z", + "disableScreenshot" : false, + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "chromeOptions" : "--disable-gpu", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username", + "targetTime" : 1 + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + +} diff --git a/thousandeyes-sdk-instant-tests/test/test_agent_to_agent_instant_tests_api_integration.py b/thousandeyes-sdk-instant-tests/test/test_agent_to_agent_instant_tests_api_integration.py new file mode 100644 index 00000000..117ba1ff --- /dev/null +++ b/thousandeyes-sdk-instant-tests/test/test_agent_to_agent_instant_tests_api_integration.py @@ -0,0 +1,824 @@ +# coding: utf-8 + +""" + Instant Tests API + + The Instant Tests API operations lets you create and run new instant tests. You will need to be an Account Admin. The response does not include the immediate test results. Use the Test Results endpoints to get test results after creating and executing an instant test. You can find the URLs for these endpoints in the _links section of the test definition that is returned when you create the instant test. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.instant_tests.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.instant_tests.api.agent_to_agent_instant_tests_api import AgentToAgentInstantTestsApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestAgentToAgentInstantTestsApiIntegration(IntegrationTestBase): + """AgentToAgentInstantTestsApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = AgentToAgentInstantTestsApi(self.api_client) + + + def test_create_agent_to_agent_instant_test_happy_path(self) -> None: + """Integration test for create_agent_to_agent_instant_test success path""" + request_body_json = """ + + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "description" : "ThousandEyes Test", + "type" : "agent-to-agent", + "mss" : 100, + "dscpId" : "0", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "dscp" : "Best Effort (DSCP 0)", + "pathTraceMode" : "classic", + "throughputRate" : 10, + "modifiedBy" : "user@user.com", + "testName" : "ThousandEyes Test", + "direction" : "to-target", + "throughputMeasurements" : false, + "numPathTraces" : 3, + "liveShare" : false, + "savedEvent" : true, + "throughputDuration" : 10000, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "port" : 49153, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "targetAgentId" : "2954", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ] + } + + """ + agent_to_agent_instant_test_request = thousandeyes_sdk.instant_tests.models.AgentToAgentInstantTestRequest.from_json(request_body_json) + aid = '1234' + response_body_json = """ + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "description" : "ThousandEyes Test", + "type" : "agent-to-agent", + "mss" : 100, + "dscpId" : "0", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "dscp" : "Best Effort (DSCP 0)", + "pathTraceMode" : "classic", + "throughputRate" : 10, + "modifiedBy" : "user@user.com", + "testName" : "ThousandEyes Test", + "direction" : "to-target", + "throughputMeasurements" : false, + "numPathTraces" : 3, + "liveShare" : false, + "savedEvent" : true, + "throughputDuration" : 10000, + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "port" : 49153, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "targetAgentId" : "2954", + "testId" : "281474976710706", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ] + } + """ + expected_response = json.loads(response_body_json) + response = self.api.create_agent_to_agent_instant_test( + + agent_to_agent_instant_test_request=agent_to_agent_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_agent_to_agent_instant_test"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_create_agent_to_agent_instant_test_error_400(self) -> None: + """Integration test for create_agent_to_agent_instant_test error path (HTTP 400)""" + request_body_json = """ + + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "description" : "ThousandEyes Test", + "type" : "agent-to-agent", + "mss" : 100, + "dscpId" : "0", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "dscp" : "Best Effort (DSCP 0)", + "pathTraceMode" : "classic", + "throughputRate" : 10, + "modifiedBy" : "user@user.com", + "testName" : "ThousandEyes Test", + "direction" : "to-target", + "throughputMeasurements" : false, + "numPathTraces" : 3, + "liveShare" : false, + "savedEvent" : true, + "throughputDuration" : 10000, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "port" : 49153, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "targetAgentId" : "2954", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ] + } + + """ + agent_to_agent_instant_test_request = thousandeyes_sdk.instant_tests.models.AgentToAgentInstantTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.create_agent_to_agent_instant_test( + + agent_to_agent_instant_test_request=agent_to_agent_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_agent_to_agent_instant_test", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_agent_to_agent_instant_test_error_401(self) -> None: + """Integration test for create_agent_to_agent_instant_test error path (HTTP 401)""" + request_body_json = """ + + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "description" : "ThousandEyes Test", + "type" : "agent-to-agent", + "mss" : 100, + "dscpId" : "0", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "dscp" : "Best Effort (DSCP 0)", + "pathTraceMode" : "classic", + "throughputRate" : 10, + "modifiedBy" : "user@user.com", + "testName" : "ThousandEyes Test", + "direction" : "to-target", + "throughputMeasurements" : false, + "numPathTraces" : 3, + "liveShare" : false, + "savedEvent" : true, + "throughputDuration" : 10000, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "port" : 49153, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "targetAgentId" : "2954", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ] + } + + """ + agent_to_agent_instant_test_request = thousandeyes_sdk.instant_tests.models.AgentToAgentInstantTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.create_agent_to_agent_instant_test( + + agent_to_agent_instant_test_request=agent_to_agent_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_agent_to_agent_instant_test", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_agent_to_agent_instant_test_error_403(self) -> None: + """Integration test for create_agent_to_agent_instant_test error path (HTTP 403)""" + request_body_json = """ + + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "description" : "ThousandEyes Test", + "type" : "agent-to-agent", + "mss" : 100, + "dscpId" : "0", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "dscp" : "Best Effort (DSCP 0)", + "pathTraceMode" : "classic", + "throughputRate" : 10, + "modifiedBy" : "user@user.com", + "testName" : "ThousandEyes Test", + "direction" : "to-target", + "throughputMeasurements" : false, + "numPathTraces" : 3, + "liveShare" : false, + "savedEvent" : true, + "throughputDuration" : 10000, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "port" : 49153, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "targetAgentId" : "2954", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ] + } + + """ + agent_to_agent_instant_test_request = thousandeyes_sdk.instant_tests.models.AgentToAgentInstantTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.create_agent_to_agent_instant_test( + + agent_to_agent_instant_test_request=agent_to_agent_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_agent_to_agent_instant_test", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_agent_to_agent_instant_test_error_404(self) -> None: + """Integration test for create_agent_to_agent_instant_test error path (HTTP 404)""" + request_body_json = """ + + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "description" : "ThousandEyes Test", + "type" : "agent-to-agent", + "mss" : 100, + "dscpId" : "0", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "dscp" : "Best Effort (DSCP 0)", + "pathTraceMode" : "classic", + "throughputRate" : 10, + "modifiedBy" : "user@user.com", + "testName" : "ThousandEyes Test", + "direction" : "to-target", + "throughputMeasurements" : false, + "numPathTraces" : 3, + "liveShare" : false, + "savedEvent" : true, + "throughputDuration" : 10000, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "port" : 49153, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "targetAgentId" : "2954", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ] + } + + """ + agent_to_agent_instant_test_request = thousandeyes_sdk.instant_tests.models.AgentToAgentInstantTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.create_agent_to_agent_instant_test( + + agent_to_agent_instant_test_request=agent_to_agent_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_agent_to_agent_instant_test", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_agent_to_agent_instant_test_error_429(self) -> None: + """Integration test for create_agent_to_agent_instant_test error path (HTTP 429)""" + request_body_json = """ + + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "description" : "ThousandEyes Test", + "type" : "agent-to-agent", + "mss" : 100, + "dscpId" : "0", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "dscp" : "Best Effort (DSCP 0)", + "pathTraceMode" : "classic", + "throughputRate" : 10, + "modifiedBy" : "user@user.com", + "testName" : "ThousandEyes Test", + "direction" : "to-target", + "throughputMeasurements" : false, + "numPathTraces" : 3, + "liveShare" : false, + "savedEvent" : true, + "throughputDuration" : 10000, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "port" : 49153, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "targetAgentId" : "2954", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ] + } + + """ + agent_to_agent_instant_test_request = thousandeyes_sdk.instant_tests.models.AgentToAgentInstantTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.create_agent_to_agent_instant_test( + + agent_to_agent_instant_test_request=agent_to_agent_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_agent_to_agent_instant_test", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_agent_to_agent_instant_test_error_500(self) -> None: + """Integration test for create_agent_to_agent_instant_test error path (HTTP 500)""" + request_body_json = """ + + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "description" : "ThousandEyes Test", + "type" : "agent-to-agent", + "mss" : 100, + "dscpId" : "0", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "dscp" : "Best Effort (DSCP 0)", + "pathTraceMode" : "classic", + "throughputRate" : 10, + "modifiedBy" : "user@user.com", + "testName" : "ThousandEyes Test", + "direction" : "to-target", + "throughputMeasurements" : false, + "numPathTraces" : 3, + "liveShare" : false, + "savedEvent" : true, + "throughputDuration" : 10000, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "port" : 49153, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "targetAgentId" : "2954", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ] + } + + """ + agent_to_agent_instant_test_request = thousandeyes_sdk.instant_tests.models.AgentToAgentInstantTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.create_agent_to_agent_instant_test( + + agent_to_agent_instant_test_request=agent_to_agent_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_agent_to_agent_instant_test", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_agent_to_agent_instant_test_error_502(self) -> None: + """Integration test for create_agent_to_agent_instant_test error path (HTTP 502)""" + request_body_json = """ + + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "description" : "ThousandEyes Test", + "type" : "agent-to-agent", + "mss" : 100, + "dscpId" : "0", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "dscp" : "Best Effort (DSCP 0)", + "pathTraceMode" : "classic", + "throughputRate" : 10, + "modifiedBy" : "user@user.com", + "testName" : "ThousandEyes Test", + "direction" : "to-target", + "throughputMeasurements" : false, + "numPathTraces" : 3, + "liveShare" : false, + "savedEvent" : true, + "throughputDuration" : 10000, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "port" : 49153, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "targetAgentId" : "2954", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ] + } + + """ + agent_to_agent_instant_test_request = thousandeyes_sdk.instant_tests.models.AgentToAgentInstantTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.create_agent_to_agent_instant_test( + + agent_to_agent_instant_test_request=agent_to_agent_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_agent_to_agent_instant_test", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-instant-tests/test/test_agent_to_server_instant_tests_api_integration.py b/thousandeyes-sdk-instant-tests/test/test_agent_to_server_instant_tests_api_integration.py new file mode 100644 index 00000000..1601027b --- /dev/null +++ b/thousandeyes-sdk-instant-tests/test/test_agent_to_server_instant_tests_api_integration.py @@ -0,0 +1,833 @@ +# coding: utf-8 + +""" + Instant Tests API + + The Instant Tests API operations lets you create and run new instant tests. You will need to be an Account Admin. The response does not include the immediate test results. Use the Test Results endpoints to get test results after creating and executing an instant test. You can find the URLs for these endpoints in the _links section of the test definition that is returned when you create the instant test. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.instant_tests.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.instant_tests.api.agent_to_server_instant_tests_api import AgentToServerInstantTestsApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestAgentToServerInstantTestsApiIntegration(IntegrationTestBase): + """AgentToServerInstantTestsApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = AgentToServerInstantTestsApi(self.api_client) + + + def test_create_agent_to_server_instant_test_happy_path(self) -> None: + """Integration test for create_agent_to_server_instant_test success path""" + request_body_json = """ + + { + "server" : "www.thousandeyes.com:80", + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "type" : "agent-to-server", + "dscpId" : "0", + "fixedPacketRate" : 25, + "protocol" : "tcp", + "dscp" : "Best Effort (DSCP 0)", + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : false, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "testId" : "281474976710706", + "pingPayloadSize" : 112, + "sharedWithAccounts" : [ "1234", "12345" ], + "continuousMode" : false + } + + """ + agent_to_server_instant_test_request = thousandeyes_sdk.instant_tests.models.AgentToServerInstantTestRequest.from_json(request_body_json) + aid = '1234' + response_body_json = """ + { + "server" : "www.thousandeyes.com:80", + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "type" : "agent-to-server", + "dscpId" : "0", + "fixedPacketRate" : 25, + "protocol" : "tcp", + "dscp" : "Best Effort (DSCP 0)", + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : false, + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "testId" : "281474976710706", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "pingPayloadSize" : 112, + "continuousMode" : false + } + """ + expected_response = json.loads(response_body_json) + response = self.api.create_agent_to_server_instant_test( + + agent_to_server_instant_test_request=agent_to_server_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_agent_to_server_instant_test"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_create_agent_to_server_instant_test_error_400(self) -> None: + """Integration test for create_agent_to_server_instant_test error path (HTTP 400)""" + request_body_json = """ + + { + "server" : "www.thousandeyes.com:80", + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "type" : "agent-to-server", + "dscpId" : "0", + "fixedPacketRate" : 25, + "protocol" : "tcp", + "dscp" : "Best Effort (DSCP 0)", + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : false, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "testId" : "281474976710706", + "pingPayloadSize" : 112, + "sharedWithAccounts" : [ "1234", "12345" ], + "continuousMode" : false + } + + """ + agent_to_server_instant_test_request = thousandeyes_sdk.instant_tests.models.AgentToServerInstantTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.create_agent_to_server_instant_test( + + agent_to_server_instant_test_request=agent_to_server_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_agent_to_server_instant_test", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_agent_to_server_instant_test_error_401(self) -> None: + """Integration test for create_agent_to_server_instant_test error path (HTTP 401)""" + request_body_json = """ + + { + "server" : "www.thousandeyes.com:80", + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "type" : "agent-to-server", + "dscpId" : "0", + "fixedPacketRate" : 25, + "protocol" : "tcp", + "dscp" : "Best Effort (DSCP 0)", + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : false, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "testId" : "281474976710706", + "pingPayloadSize" : 112, + "sharedWithAccounts" : [ "1234", "12345" ], + "continuousMode" : false + } + + """ + agent_to_server_instant_test_request = thousandeyes_sdk.instant_tests.models.AgentToServerInstantTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.create_agent_to_server_instant_test( + + agent_to_server_instant_test_request=agent_to_server_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_agent_to_server_instant_test", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_agent_to_server_instant_test_error_403(self) -> None: + """Integration test for create_agent_to_server_instant_test error path (HTTP 403)""" + request_body_json = """ + + { + "server" : "www.thousandeyes.com:80", + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "type" : "agent-to-server", + "dscpId" : "0", + "fixedPacketRate" : 25, + "protocol" : "tcp", + "dscp" : "Best Effort (DSCP 0)", + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : false, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "testId" : "281474976710706", + "pingPayloadSize" : 112, + "sharedWithAccounts" : [ "1234", "12345" ], + "continuousMode" : false + } + + """ + agent_to_server_instant_test_request = thousandeyes_sdk.instant_tests.models.AgentToServerInstantTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.create_agent_to_server_instant_test( + + agent_to_server_instant_test_request=agent_to_server_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_agent_to_server_instant_test", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_agent_to_server_instant_test_error_404(self) -> None: + """Integration test for create_agent_to_server_instant_test error path (HTTP 404)""" + request_body_json = """ + + { + "server" : "www.thousandeyes.com:80", + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "type" : "agent-to-server", + "dscpId" : "0", + "fixedPacketRate" : 25, + "protocol" : "tcp", + "dscp" : "Best Effort (DSCP 0)", + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : false, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "testId" : "281474976710706", + "pingPayloadSize" : 112, + "sharedWithAccounts" : [ "1234", "12345" ], + "continuousMode" : false + } + + """ + agent_to_server_instant_test_request = thousandeyes_sdk.instant_tests.models.AgentToServerInstantTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.create_agent_to_server_instant_test( + + agent_to_server_instant_test_request=agent_to_server_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_agent_to_server_instant_test", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_agent_to_server_instant_test_error_429(self) -> None: + """Integration test for create_agent_to_server_instant_test error path (HTTP 429)""" + request_body_json = """ + + { + "server" : "www.thousandeyes.com:80", + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "type" : "agent-to-server", + "dscpId" : "0", + "fixedPacketRate" : 25, + "protocol" : "tcp", + "dscp" : "Best Effort (DSCP 0)", + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : false, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "testId" : "281474976710706", + "pingPayloadSize" : 112, + "sharedWithAccounts" : [ "1234", "12345" ], + "continuousMode" : false + } + + """ + agent_to_server_instant_test_request = thousandeyes_sdk.instant_tests.models.AgentToServerInstantTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.create_agent_to_server_instant_test( + + agent_to_server_instant_test_request=agent_to_server_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_agent_to_server_instant_test", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_agent_to_server_instant_test_error_500(self) -> None: + """Integration test for create_agent_to_server_instant_test error path (HTTP 500)""" + request_body_json = """ + + { + "server" : "www.thousandeyes.com:80", + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "type" : "agent-to-server", + "dscpId" : "0", + "fixedPacketRate" : 25, + "protocol" : "tcp", + "dscp" : "Best Effort (DSCP 0)", + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : false, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "testId" : "281474976710706", + "pingPayloadSize" : 112, + "sharedWithAccounts" : [ "1234", "12345" ], + "continuousMode" : false + } + + """ + agent_to_server_instant_test_request = thousandeyes_sdk.instant_tests.models.AgentToServerInstantTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.create_agent_to_server_instant_test( + + agent_to_server_instant_test_request=agent_to_server_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_agent_to_server_instant_test", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_agent_to_server_instant_test_error_502(self) -> None: + """Integration test for create_agent_to_server_instant_test error path (HTTP 502)""" + request_body_json = """ + + { + "server" : "www.thousandeyes.com:80", + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "type" : "agent-to-server", + "dscpId" : "0", + "fixedPacketRate" : 25, + "protocol" : "tcp", + "dscp" : "Best Effort (DSCP 0)", + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : false, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "testId" : "281474976710706", + "pingPayloadSize" : 112, + "sharedWithAccounts" : [ "1234", "12345" ], + "continuousMode" : false + } + + """ + agent_to_server_instant_test_request = thousandeyes_sdk.instant_tests.models.AgentToServerInstantTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.create_agent_to_server_instant_test( + + agent_to_server_instant_test_request=agent_to_server_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_agent_to_server_instant_test", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-instant-tests/test/test_api_instant_tests_api_integration.py b/thousandeyes-sdk-instant-tests/test/test_api_instant_tests_api_integration.py new file mode 100644 index 00000000..40cd1176 --- /dev/null +++ b/thousandeyes-sdk-instant-tests/test/test_api_instant_tests_api_integration.py @@ -0,0 +1,1724 @@ +# coding: utf-8 + +""" + Instant Tests API + + The Instant Tests API operations lets you create and run new instant tests. You will need to be an Account Admin. The response does not include the immediate test results. Use the Test Results endpoints to get test results after creating and executing an instant test. You can find the URLs for these endpoints in the _links section of the test definition that is returned when you create the instant test. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.instant_tests.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.instant_tests.api.api_instant_tests_api import APIInstantTestsApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestAPIInstantTestsApiIntegration(IntegrationTestBase): + """APIInstantTestsApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = APIInstantTestsApi(self.api_client) + + + def test_create_api_instant_test_happy_path(self) -> None: + """Integration test for create_api_instant_test success path""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "credentials" : [ "3247", "1051" ], + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "requests" : [ { + "headers" : [ { + "value" : "keep-alive", + "key" : "x-custom-header" + }, { + "value" : "keep-alive", + "key" : "x-custom-header" + } ], + "variables" : [ { + "name" : "myTestName", + "value" : "tests[0].name" + }, { + "name" : "myTestName", + "value" : "tests[0].name" + } ], + "clientId" : "client-id", + "tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token", + "method" : "get", + "verifyCertificate" : false, + "body" : "body", + "url" : "https://api.thousandeyes.com/v7/status", + "password" : "basic_pw123", + "bearerToken" : "abcd-1234-...", + "scope" : "read, write, deploy", + "name" : "Step 1", + "waitTimeMs" : 0, + "clientAuthentication" : "basic-auth-header", + "clientSecret" : "client-secret", + "assertions" : [ { + "name" : "status-code", + "value" : "200", + "operator" : "is" + }, { + "name" : "status-code", + "value" : "200", + "operator" : "is" + } ], + "authType" : "none", + "collectApiResponse" : true, + "username" : "ThousandEyesUserName" + }, { + "headers" : [ { + "value" : "keep-alive", + "key" : "x-custom-header" + }, { + "value" : "keep-alive", + "key" : "x-custom-header" + } ], + "variables" : [ { + "name" : "myTestName", + "value" : "tests[0].name" + }, { + "name" : "myTestName", + "value" : "tests[0].name" + } ], + "clientId" : "client-id", + "tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token", + "method" : "get", + "verifyCertificate" : false, + "body" : "body", + "url" : "https://api.thousandeyes.com/v7/status", + "password" : "basic_pw123", + "bearerToken" : "abcd-1234-...", + "scope" : "read, write, deploy", + "name" : "Step 1", + "waitTimeMs" : 0, + "clientAuthentication" : "basic-auth-header", + "clientSecret" : "client-secret", + "assertions" : [ { + "name" : "status-code", + "value" : "200", + "operator" : "is" + }, { + "name" : "status-code", + "value" : "200", + "operator" : "is" + } ], + "authType" : "none", + "collectApiResponse" : true, + "username" : "ThousandEyesUserName" + } ], + "type" : "api", + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "protocol" : "tcp", + "collectProxyNetworkData" : false, + "followRedirects" : true, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "clientCertDomainsAllowList" : "www.thousandeyes.com", + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "overrideAgentProxy" : false, + "predefinedVariables" : [ { + "name" : "myUsername", + "value" : "ThousandEyesAccountUserName" + }, { + "name" : "myUsername", + "value" : "ThousandEyesAccountUserName" + } ], + "liveShare" : false, + "distributedTracing" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "timeLimit" : 19, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "sslVersionId" : "0", + "targetTime" : 1 + } + + """ + api_instant_test_request = thousandeyes_sdk.instant_tests.models.ApiInstantTestRequest.from_json(request_body_json) + aid = '1234' + response_body_json = """ + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "credentials" : [ "3247", "1051" ], + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "requests" : [ { + "headers" : [ { + "value" : "keep-alive", + "key" : "x-custom-header" + }, { + "value" : "keep-alive", + "key" : "x-custom-header" + } ], + "variables" : [ { + "name" : "myTestName", + "value" : "tests[0].name" + }, { + "name" : "myTestName", + "value" : "tests[0].name" + } ], + "clientId" : "client-id", + "tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token", + "method" : "get", + "verifyCertificate" : false, + "body" : "body", + "url" : "https://api.thousandeyes.com/v7/status", + "password" : "basic_pw123", + "bearerToken" : "abcd-1234-...", + "scope" : "read, write, deploy", + "name" : "Step 1", + "waitTimeMs" : 0, + "clientAuthentication" : "basic-auth-header", + "clientSecret" : "client-secret", + "assertions" : [ { + "name" : "status-code", + "value" : "200", + "operator" : "is" + }, { + "name" : "status-code", + "value" : "200", + "operator" : "is" + } ], + "authType" : "none", + "collectApiResponse" : true, + "username" : "ThousandEyesUserName" + }, { + "headers" : [ { + "value" : "keep-alive", + "key" : "x-custom-header" + }, { + "value" : "keep-alive", + "key" : "x-custom-header" + } ], + "variables" : [ { + "name" : "myTestName", + "value" : "tests[0].name" + }, { + "name" : "myTestName", + "value" : "tests[0].name" + } ], + "clientId" : "client-id", + "tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token", + "method" : "get", + "verifyCertificate" : false, + "body" : "body", + "url" : "https://api.thousandeyes.com/v7/status", + "password" : "basic_pw123", + "bearerToken" : "abcd-1234-...", + "scope" : "read, write, deploy", + "name" : "Step 1", + "waitTimeMs" : 0, + "clientAuthentication" : "basic-auth-header", + "clientSecret" : "client-secret", + "assertions" : [ { + "name" : "status-code", + "value" : "200", + "operator" : "is" + }, { + "name" : "status-code", + "value" : "200", + "operator" : "is" + } ], + "authType" : "none", + "collectApiResponse" : true, + "username" : "ThousandEyesUserName" + } ], + "type" : "api", + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "protocol" : "tcp", + "collectProxyNetworkData" : false, + "followRedirects" : true, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "clientCertDomainsAllowList" : "www.thousandeyes.com", + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "overrideAgentProxy" : false, + "predefinedVariables" : [ { + "name" : "myUsername", + "value" : "ThousandEyesAccountUserName" + }, { + "name" : "myUsername", + "value" : "ThousandEyesAccountUserName" + } ], + "liveShare" : false, + "distributedTracing" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "timeLimit" : 19, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "testId" : "281474976710706", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "overrideProxyId" : "281474976710706", + "sslVersionId" : "0", + "targetTime" : 1 + } + """ + expected_response = json.loads(response_body_json) + response = self.api.create_api_instant_test( + + api_instant_test_request=api_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_api_instant_test"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_create_api_instant_test_error_400(self) -> None: + """Integration test for create_api_instant_test error path (HTTP 400)""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "credentials" : [ "3247", "1051" ], + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "requests" : [ { + "headers" : [ { + "value" : "keep-alive", + "key" : "x-custom-header" + }, { + "value" : "keep-alive", + "key" : "x-custom-header" + } ], + "variables" : [ { + "name" : "myTestName", + "value" : "tests[0].name" + }, { + "name" : "myTestName", + "value" : "tests[0].name" + } ], + "clientId" : "client-id", + "tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token", + "method" : "get", + "verifyCertificate" : false, + "body" : "body", + "url" : "https://api.thousandeyes.com/v7/status", + "password" : "basic_pw123", + "bearerToken" : "abcd-1234-...", + "scope" : "read, write, deploy", + "name" : "Step 1", + "waitTimeMs" : 0, + "clientAuthentication" : "basic-auth-header", + "clientSecret" : "client-secret", + "assertions" : [ { + "name" : "status-code", + "value" : "200", + "operator" : "is" + }, { + "name" : "status-code", + "value" : "200", + "operator" : "is" + } ], + "authType" : "none", + "collectApiResponse" : true, + "username" : "ThousandEyesUserName" + }, { + "headers" : [ { + "value" : "keep-alive", + "key" : "x-custom-header" + }, { + "value" : "keep-alive", + "key" : "x-custom-header" + } ], + "variables" : [ { + "name" : "myTestName", + "value" : "tests[0].name" + }, { + "name" : "myTestName", + "value" : "tests[0].name" + } ], + "clientId" : "client-id", + "tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token", + "method" : "get", + "verifyCertificate" : false, + "body" : "body", + "url" : "https://api.thousandeyes.com/v7/status", + "password" : "basic_pw123", + "bearerToken" : "abcd-1234-...", + "scope" : "read, write, deploy", + "name" : "Step 1", + "waitTimeMs" : 0, + "clientAuthentication" : "basic-auth-header", + "clientSecret" : "client-secret", + "assertions" : [ { + "name" : "status-code", + "value" : "200", + "operator" : "is" + }, { + "name" : "status-code", + "value" : "200", + "operator" : "is" + } ], + "authType" : "none", + "collectApiResponse" : true, + "username" : "ThousandEyesUserName" + } ], + "type" : "api", + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "protocol" : "tcp", + "collectProxyNetworkData" : false, + "followRedirects" : true, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "clientCertDomainsAllowList" : "www.thousandeyes.com", + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "overrideAgentProxy" : false, + "predefinedVariables" : [ { + "name" : "myUsername", + "value" : "ThousandEyesAccountUserName" + }, { + "name" : "myUsername", + "value" : "ThousandEyesAccountUserName" + } ], + "liveShare" : false, + "distributedTracing" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "timeLimit" : 19, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "sslVersionId" : "0", + "targetTime" : 1 + } + + """ + api_instant_test_request = thousandeyes_sdk.instant_tests.models.ApiInstantTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.create_api_instant_test( + + api_instant_test_request=api_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_api_instant_test", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_api_instant_test_error_401(self) -> None: + """Integration test for create_api_instant_test error path (HTTP 401)""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "credentials" : [ "3247", "1051" ], + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "requests" : [ { + "headers" : [ { + "value" : "keep-alive", + "key" : "x-custom-header" + }, { + "value" : "keep-alive", + "key" : "x-custom-header" + } ], + "variables" : [ { + "name" : "myTestName", + "value" : "tests[0].name" + }, { + "name" : "myTestName", + "value" : "tests[0].name" + } ], + "clientId" : "client-id", + "tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token", + "method" : "get", + "verifyCertificate" : false, + "body" : "body", + "url" : "https://api.thousandeyes.com/v7/status", + "password" : "basic_pw123", + "bearerToken" : "abcd-1234-...", + "scope" : "read, write, deploy", + "name" : "Step 1", + "waitTimeMs" : 0, + "clientAuthentication" : "basic-auth-header", + "clientSecret" : "client-secret", + "assertions" : [ { + "name" : "status-code", + "value" : "200", + "operator" : "is" + }, { + "name" : "status-code", + "value" : "200", + "operator" : "is" + } ], + "authType" : "none", + "collectApiResponse" : true, + "username" : "ThousandEyesUserName" + }, { + "headers" : [ { + "value" : "keep-alive", + "key" : "x-custom-header" + }, { + "value" : "keep-alive", + "key" : "x-custom-header" + } ], + "variables" : [ { + "name" : "myTestName", + "value" : "tests[0].name" + }, { + "name" : "myTestName", + "value" : "tests[0].name" + } ], + "clientId" : "client-id", + "tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token", + "method" : "get", + "verifyCertificate" : false, + "body" : "body", + "url" : "https://api.thousandeyes.com/v7/status", + "password" : "basic_pw123", + "bearerToken" : "abcd-1234-...", + "scope" : "read, write, deploy", + "name" : "Step 1", + "waitTimeMs" : 0, + "clientAuthentication" : "basic-auth-header", + "clientSecret" : "client-secret", + "assertions" : [ { + "name" : "status-code", + "value" : "200", + "operator" : "is" + }, { + "name" : "status-code", + "value" : "200", + "operator" : "is" + } ], + "authType" : "none", + "collectApiResponse" : true, + "username" : "ThousandEyesUserName" + } ], + "type" : "api", + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "protocol" : "tcp", + "collectProxyNetworkData" : false, + "followRedirects" : true, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "clientCertDomainsAllowList" : "www.thousandeyes.com", + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "overrideAgentProxy" : false, + "predefinedVariables" : [ { + "name" : "myUsername", + "value" : "ThousandEyesAccountUserName" + }, { + "name" : "myUsername", + "value" : "ThousandEyesAccountUserName" + } ], + "liveShare" : false, + "distributedTracing" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "timeLimit" : 19, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "sslVersionId" : "0", + "targetTime" : 1 + } + + """ + api_instant_test_request = thousandeyes_sdk.instant_tests.models.ApiInstantTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.create_api_instant_test( + + api_instant_test_request=api_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_api_instant_test", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_api_instant_test_error_403(self) -> None: + """Integration test for create_api_instant_test error path (HTTP 403)""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "credentials" : [ "3247", "1051" ], + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "requests" : [ { + "headers" : [ { + "value" : "keep-alive", + "key" : "x-custom-header" + }, { + "value" : "keep-alive", + "key" : "x-custom-header" + } ], + "variables" : [ { + "name" : "myTestName", + "value" : "tests[0].name" + }, { + "name" : "myTestName", + "value" : "tests[0].name" + } ], + "clientId" : "client-id", + "tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token", + "method" : "get", + "verifyCertificate" : false, + "body" : "body", + "url" : "https://api.thousandeyes.com/v7/status", + "password" : "basic_pw123", + "bearerToken" : "abcd-1234-...", + "scope" : "read, write, deploy", + "name" : "Step 1", + "waitTimeMs" : 0, + "clientAuthentication" : "basic-auth-header", + "clientSecret" : "client-secret", + "assertions" : [ { + "name" : "status-code", + "value" : "200", + "operator" : "is" + }, { + "name" : "status-code", + "value" : "200", + "operator" : "is" + } ], + "authType" : "none", + "collectApiResponse" : true, + "username" : "ThousandEyesUserName" + }, { + "headers" : [ { + "value" : "keep-alive", + "key" : "x-custom-header" + }, { + "value" : "keep-alive", + "key" : "x-custom-header" + } ], + "variables" : [ { + "name" : "myTestName", + "value" : "tests[0].name" + }, { + "name" : "myTestName", + "value" : "tests[0].name" + } ], + "clientId" : "client-id", + "tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token", + "method" : "get", + "verifyCertificate" : false, + "body" : "body", + "url" : "https://api.thousandeyes.com/v7/status", + "password" : "basic_pw123", + "bearerToken" : "abcd-1234-...", + "scope" : "read, write, deploy", + "name" : "Step 1", + "waitTimeMs" : 0, + "clientAuthentication" : "basic-auth-header", + "clientSecret" : "client-secret", + "assertions" : [ { + "name" : "status-code", + "value" : "200", + "operator" : "is" + }, { + "name" : "status-code", + "value" : "200", + "operator" : "is" + } ], + "authType" : "none", + "collectApiResponse" : true, + "username" : "ThousandEyesUserName" + } ], + "type" : "api", + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "protocol" : "tcp", + "collectProxyNetworkData" : false, + "followRedirects" : true, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "clientCertDomainsAllowList" : "www.thousandeyes.com", + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "overrideAgentProxy" : false, + "predefinedVariables" : [ { + "name" : "myUsername", + "value" : "ThousandEyesAccountUserName" + }, { + "name" : "myUsername", + "value" : "ThousandEyesAccountUserName" + } ], + "liveShare" : false, + "distributedTracing" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "timeLimit" : 19, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "sslVersionId" : "0", + "targetTime" : 1 + } + + """ + api_instant_test_request = thousandeyes_sdk.instant_tests.models.ApiInstantTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.create_api_instant_test( + + api_instant_test_request=api_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_api_instant_test", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_api_instant_test_error_404(self) -> None: + """Integration test for create_api_instant_test error path (HTTP 404)""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "credentials" : [ "3247", "1051" ], + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "requests" : [ { + "headers" : [ { + "value" : "keep-alive", + "key" : "x-custom-header" + }, { + "value" : "keep-alive", + "key" : "x-custom-header" + } ], + "variables" : [ { + "name" : "myTestName", + "value" : "tests[0].name" + }, { + "name" : "myTestName", + "value" : "tests[0].name" + } ], + "clientId" : "client-id", + "tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token", + "method" : "get", + "verifyCertificate" : false, + "body" : "body", + "url" : "https://api.thousandeyes.com/v7/status", + "password" : "basic_pw123", + "bearerToken" : "abcd-1234-...", + "scope" : "read, write, deploy", + "name" : "Step 1", + "waitTimeMs" : 0, + "clientAuthentication" : "basic-auth-header", + "clientSecret" : "client-secret", + "assertions" : [ { + "name" : "status-code", + "value" : "200", + "operator" : "is" + }, { + "name" : "status-code", + "value" : "200", + "operator" : "is" + } ], + "authType" : "none", + "collectApiResponse" : true, + "username" : "ThousandEyesUserName" + }, { + "headers" : [ { + "value" : "keep-alive", + "key" : "x-custom-header" + }, { + "value" : "keep-alive", + "key" : "x-custom-header" + } ], + "variables" : [ { + "name" : "myTestName", + "value" : "tests[0].name" + }, { + "name" : "myTestName", + "value" : "tests[0].name" + } ], + "clientId" : "client-id", + "tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token", + "method" : "get", + "verifyCertificate" : false, + "body" : "body", + "url" : "https://api.thousandeyes.com/v7/status", + "password" : "basic_pw123", + "bearerToken" : "abcd-1234-...", + "scope" : "read, write, deploy", + "name" : "Step 1", + "waitTimeMs" : 0, + "clientAuthentication" : "basic-auth-header", + "clientSecret" : "client-secret", + "assertions" : [ { + "name" : "status-code", + "value" : "200", + "operator" : "is" + }, { + "name" : "status-code", + "value" : "200", + "operator" : "is" + } ], + "authType" : "none", + "collectApiResponse" : true, + "username" : "ThousandEyesUserName" + } ], + "type" : "api", + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "protocol" : "tcp", + "collectProxyNetworkData" : false, + "followRedirects" : true, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "clientCertDomainsAllowList" : "www.thousandeyes.com", + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "overrideAgentProxy" : false, + "predefinedVariables" : [ { + "name" : "myUsername", + "value" : "ThousandEyesAccountUserName" + }, { + "name" : "myUsername", + "value" : "ThousandEyesAccountUserName" + } ], + "liveShare" : false, + "distributedTracing" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "timeLimit" : 19, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "sslVersionId" : "0", + "targetTime" : 1 + } + + """ + api_instant_test_request = thousandeyes_sdk.instant_tests.models.ApiInstantTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.create_api_instant_test( + + api_instant_test_request=api_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_api_instant_test", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_api_instant_test_error_429(self) -> None: + """Integration test for create_api_instant_test error path (HTTP 429)""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "credentials" : [ "3247", "1051" ], + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "requests" : [ { + "headers" : [ { + "value" : "keep-alive", + "key" : "x-custom-header" + }, { + "value" : "keep-alive", + "key" : "x-custom-header" + } ], + "variables" : [ { + "name" : "myTestName", + "value" : "tests[0].name" + }, { + "name" : "myTestName", + "value" : "tests[0].name" + } ], + "clientId" : "client-id", + "tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token", + "method" : "get", + "verifyCertificate" : false, + "body" : "body", + "url" : "https://api.thousandeyes.com/v7/status", + "password" : "basic_pw123", + "bearerToken" : "abcd-1234-...", + "scope" : "read, write, deploy", + "name" : "Step 1", + "waitTimeMs" : 0, + "clientAuthentication" : "basic-auth-header", + "clientSecret" : "client-secret", + "assertions" : [ { + "name" : "status-code", + "value" : "200", + "operator" : "is" + }, { + "name" : "status-code", + "value" : "200", + "operator" : "is" + } ], + "authType" : "none", + "collectApiResponse" : true, + "username" : "ThousandEyesUserName" + }, { + "headers" : [ { + "value" : "keep-alive", + "key" : "x-custom-header" + }, { + "value" : "keep-alive", + "key" : "x-custom-header" + } ], + "variables" : [ { + "name" : "myTestName", + "value" : "tests[0].name" + }, { + "name" : "myTestName", + "value" : "tests[0].name" + } ], + "clientId" : "client-id", + "tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token", + "method" : "get", + "verifyCertificate" : false, + "body" : "body", + "url" : "https://api.thousandeyes.com/v7/status", + "password" : "basic_pw123", + "bearerToken" : "abcd-1234-...", + "scope" : "read, write, deploy", + "name" : "Step 1", + "waitTimeMs" : 0, + "clientAuthentication" : "basic-auth-header", + "clientSecret" : "client-secret", + "assertions" : [ { + "name" : "status-code", + "value" : "200", + "operator" : "is" + }, { + "name" : "status-code", + "value" : "200", + "operator" : "is" + } ], + "authType" : "none", + "collectApiResponse" : true, + "username" : "ThousandEyesUserName" + } ], + "type" : "api", + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "protocol" : "tcp", + "collectProxyNetworkData" : false, + "followRedirects" : true, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "clientCertDomainsAllowList" : "www.thousandeyes.com", + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "overrideAgentProxy" : false, + "predefinedVariables" : [ { + "name" : "myUsername", + "value" : "ThousandEyesAccountUserName" + }, { + "name" : "myUsername", + "value" : "ThousandEyesAccountUserName" + } ], + "liveShare" : false, + "distributedTracing" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "timeLimit" : 19, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "sslVersionId" : "0", + "targetTime" : 1 + } + + """ + api_instant_test_request = thousandeyes_sdk.instant_tests.models.ApiInstantTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.create_api_instant_test( + + api_instant_test_request=api_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_api_instant_test", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_api_instant_test_error_500(self) -> None: + """Integration test for create_api_instant_test error path (HTTP 500)""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "credentials" : [ "3247", "1051" ], + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "requests" : [ { + "headers" : [ { + "value" : "keep-alive", + "key" : "x-custom-header" + }, { + "value" : "keep-alive", + "key" : "x-custom-header" + } ], + "variables" : [ { + "name" : "myTestName", + "value" : "tests[0].name" + }, { + "name" : "myTestName", + "value" : "tests[0].name" + } ], + "clientId" : "client-id", + "tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token", + "method" : "get", + "verifyCertificate" : false, + "body" : "body", + "url" : "https://api.thousandeyes.com/v7/status", + "password" : "basic_pw123", + "bearerToken" : "abcd-1234-...", + "scope" : "read, write, deploy", + "name" : "Step 1", + "waitTimeMs" : 0, + "clientAuthentication" : "basic-auth-header", + "clientSecret" : "client-secret", + "assertions" : [ { + "name" : "status-code", + "value" : "200", + "operator" : "is" + }, { + "name" : "status-code", + "value" : "200", + "operator" : "is" + } ], + "authType" : "none", + "collectApiResponse" : true, + "username" : "ThousandEyesUserName" + }, { + "headers" : [ { + "value" : "keep-alive", + "key" : "x-custom-header" + }, { + "value" : "keep-alive", + "key" : "x-custom-header" + } ], + "variables" : [ { + "name" : "myTestName", + "value" : "tests[0].name" + }, { + "name" : "myTestName", + "value" : "tests[0].name" + } ], + "clientId" : "client-id", + "tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token", + "method" : "get", + "verifyCertificate" : false, + "body" : "body", + "url" : "https://api.thousandeyes.com/v7/status", + "password" : "basic_pw123", + "bearerToken" : "abcd-1234-...", + "scope" : "read, write, deploy", + "name" : "Step 1", + "waitTimeMs" : 0, + "clientAuthentication" : "basic-auth-header", + "clientSecret" : "client-secret", + "assertions" : [ { + "name" : "status-code", + "value" : "200", + "operator" : "is" + }, { + "name" : "status-code", + "value" : "200", + "operator" : "is" + } ], + "authType" : "none", + "collectApiResponse" : true, + "username" : "ThousandEyesUserName" + } ], + "type" : "api", + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "protocol" : "tcp", + "collectProxyNetworkData" : false, + "followRedirects" : true, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "clientCertDomainsAllowList" : "www.thousandeyes.com", + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "overrideAgentProxy" : false, + "predefinedVariables" : [ { + "name" : "myUsername", + "value" : "ThousandEyesAccountUserName" + }, { + "name" : "myUsername", + "value" : "ThousandEyesAccountUserName" + } ], + "liveShare" : false, + "distributedTracing" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "timeLimit" : 19, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "sslVersionId" : "0", + "targetTime" : 1 + } + + """ + api_instant_test_request = thousandeyes_sdk.instant_tests.models.ApiInstantTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.create_api_instant_test( + + api_instant_test_request=api_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_api_instant_test", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_api_instant_test_error_502(self) -> None: + """Integration test for create_api_instant_test error path (HTTP 502)""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "credentials" : [ "3247", "1051" ], + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "requests" : [ { + "headers" : [ { + "value" : "keep-alive", + "key" : "x-custom-header" + }, { + "value" : "keep-alive", + "key" : "x-custom-header" + } ], + "variables" : [ { + "name" : "myTestName", + "value" : "tests[0].name" + }, { + "name" : "myTestName", + "value" : "tests[0].name" + } ], + "clientId" : "client-id", + "tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token", + "method" : "get", + "verifyCertificate" : false, + "body" : "body", + "url" : "https://api.thousandeyes.com/v7/status", + "password" : "basic_pw123", + "bearerToken" : "abcd-1234-...", + "scope" : "read, write, deploy", + "name" : "Step 1", + "waitTimeMs" : 0, + "clientAuthentication" : "basic-auth-header", + "clientSecret" : "client-secret", + "assertions" : [ { + "name" : "status-code", + "value" : "200", + "operator" : "is" + }, { + "name" : "status-code", + "value" : "200", + "operator" : "is" + } ], + "authType" : "none", + "collectApiResponse" : true, + "username" : "ThousandEyesUserName" + }, { + "headers" : [ { + "value" : "keep-alive", + "key" : "x-custom-header" + }, { + "value" : "keep-alive", + "key" : "x-custom-header" + } ], + "variables" : [ { + "name" : "myTestName", + "value" : "tests[0].name" + }, { + "name" : "myTestName", + "value" : "tests[0].name" + } ], + "clientId" : "client-id", + "tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token", + "method" : "get", + "verifyCertificate" : false, + "body" : "body", + "url" : "https://api.thousandeyes.com/v7/status", + "password" : "basic_pw123", + "bearerToken" : "abcd-1234-...", + "scope" : "read, write, deploy", + "name" : "Step 1", + "waitTimeMs" : 0, + "clientAuthentication" : "basic-auth-header", + "clientSecret" : "client-secret", + "assertions" : [ { + "name" : "status-code", + "value" : "200", + "operator" : "is" + }, { + "name" : "status-code", + "value" : "200", + "operator" : "is" + } ], + "authType" : "none", + "collectApiResponse" : true, + "username" : "ThousandEyesUserName" + } ], + "type" : "api", + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "protocol" : "tcp", + "collectProxyNetworkData" : false, + "followRedirects" : true, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "clientCertDomainsAllowList" : "www.thousandeyes.com", + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "overrideAgentProxy" : false, + "predefinedVariables" : [ { + "name" : "myUsername", + "value" : "ThousandEyesAccountUserName" + }, { + "name" : "myUsername", + "value" : "ThousandEyesAccountUserName" + } ], + "liveShare" : false, + "distributedTracing" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "timeLimit" : 19, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "sslVersionId" : "0", + "targetTime" : 1 + } + + """ + api_instant_test_request = thousandeyes_sdk.instant_tests.models.ApiInstantTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.create_api_instant_test( + + api_instant_test_request=api_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_api_instant_test", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-instant-tests/test/test_dns_server_instant_tests_api_integration.py b/thousandeyes-sdk-instant-tests/test/test_dns_server_instant_tests_api_integration.py new file mode 100644 index 00000000..51c0d619 --- /dev/null +++ b/thousandeyes-sdk-instant-tests/test/test_dns_server_instant_tests_api_integration.py @@ -0,0 +1,839 @@ +# coding: utf-8 + +""" + Instant Tests API + + The Instant Tests API operations lets you create and run new instant tests. You will need to be an Account Admin. The response does not include the immediate test results. Use the Test Results endpoints to get test results after creating and executing an instant test. You can find the URLs for these endpoints in the _links section of the test definition that is returned when you create the instant test. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.instant_tests.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.instant_tests.api.dns_server_instant_tests_api import DNSServerInstantTestsApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestDNSServerInstantTestsApiIntegration(IntegrationTestBase): + """DNSServerInstantTestsApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = DNSServerInstantTestsApi(self.api_client) + + + def test_create_dns_server_instant_test_happy_path(self) -> None: + """Integration test for create_dns_server_instant_test success path""" + request_body_json = """ + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "dnsTransportProtocol" : "udp", + "probeMode" : "auto", + "type" : "dns-server", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "dnsServers" : [ "dns-example.net", "8.8.8.8" ], + "recursiveQueries" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "dnsQueryClass" : "in", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ] + } + + """ + dns_server_instant_test_request = thousandeyes_sdk.instant_tests.models.DnsServerInstantTestRequest.from_json(request_body_json) + aid = '1234' + response_body_json = """ + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "dnsTransportProtocol" : "udp", + "probeMode" : "auto", + "type" : "dns-server", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "dnsServers" : [ { + "serverName" : "dns-example.net", + "serverId" : "1447" + }, { + "serverName" : "dns-example.net", + "serverId" : "1447" + } ], + "recursiveQueries" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "dnsQueryClass" : "in", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "testId" : "281474976710706", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ] + } + """ + expected_response = json.loads(response_body_json) + response = self.api.create_dns_server_instant_test( + + dns_server_instant_test_request=dns_server_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_dns_server_instant_test"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_create_dns_server_instant_test_error_400(self) -> None: + """Integration test for create_dns_server_instant_test error path (HTTP 400)""" + request_body_json = """ + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "dnsTransportProtocol" : "udp", + "probeMode" : "auto", + "type" : "dns-server", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "dnsServers" : [ "dns-example.net", "8.8.8.8" ], + "recursiveQueries" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "dnsQueryClass" : "in", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ] + } + + """ + dns_server_instant_test_request = thousandeyes_sdk.instant_tests.models.DnsServerInstantTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.create_dns_server_instant_test( + + dns_server_instant_test_request=dns_server_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_dns_server_instant_test", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_dns_server_instant_test_error_401(self) -> None: + """Integration test for create_dns_server_instant_test error path (HTTP 401)""" + request_body_json = """ + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "dnsTransportProtocol" : "udp", + "probeMode" : "auto", + "type" : "dns-server", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "dnsServers" : [ "dns-example.net", "8.8.8.8" ], + "recursiveQueries" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "dnsQueryClass" : "in", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ] + } + + """ + dns_server_instant_test_request = thousandeyes_sdk.instant_tests.models.DnsServerInstantTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.create_dns_server_instant_test( + + dns_server_instant_test_request=dns_server_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_dns_server_instant_test", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_dns_server_instant_test_error_403(self) -> None: + """Integration test for create_dns_server_instant_test error path (HTTP 403)""" + request_body_json = """ + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "dnsTransportProtocol" : "udp", + "probeMode" : "auto", + "type" : "dns-server", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "dnsServers" : [ "dns-example.net", "8.8.8.8" ], + "recursiveQueries" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "dnsQueryClass" : "in", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ] + } + + """ + dns_server_instant_test_request = thousandeyes_sdk.instant_tests.models.DnsServerInstantTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.create_dns_server_instant_test( + + dns_server_instant_test_request=dns_server_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_dns_server_instant_test", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_dns_server_instant_test_error_404(self) -> None: + """Integration test for create_dns_server_instant_test error path (HTTP 404)""" + request_body_json = """ + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "dnsTransportProtocol" : "udp", + "probeMode" : "auto", + "type" : "dns-server", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "dnsServers" : [ "dns-example.net", "8.8.8.8" ], + "recursiveQueries" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "dnsQueryClass" : "in", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ] + } + + """ + dns_server_instant_test_request = thousandeyes_sdk.instant_tests.models.DnsServerInstantTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.create_dns_server_instant_test( + + dns_server_instant_test_request=dns_server_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_dns_server_instant_test", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_dns_server_instant_test_error_429(self) -> None: + """Integration test for create_dns_server_instant_test error path (HTTP 429)""" + request_body_json = """ + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "dnsTransportProtocol" : "udp", + "probeMode" : "auto", + "type" : "dns-server", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "dnsServers" : [ "dns-example.net", "8.8.8.8" ], + "recursiveQueries" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "dnsQueryClass" : "in", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ] + } + + """ + dns_server_instant_test_request = thousandeyes_sdk.instant_tests.models.DnsServerInstantTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.create_dns_server_instant_test( + + dns_server_instant_test_request=dns_server_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_dns_server_instant_test", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_dns_server_instant_test_error_500(self) -> None: + """Integration test for create_dns_server_instant_test error path (HTTP 500)""" + request_body_json = """ + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "dnsTransportProtocol" : "udp", + "probeMode" : "auto", + "type" : "dns-server", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "dnsServers" : [ "dns-example.net", "8.8.8.8" ], + "recursiveQueries" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "dnsQueryClass" : "in", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ] + } + + """ + dns_server_instant_test_request = thousandeyes_sdk.instant_tests.models.DnsServerInstantTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.create_dns_server_instant_test( + + dns_server_instant_test_request=dns_server_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_dns_server_instant_test", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_dns_server_instant_test_error_502(self) -> None: + """Integration test for create_dns_server_instant_test error path (HTTP 502)""" + request_body_json = """ + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "dnsTransportProtocol" : "udp", + "probeMode" : "auto", + "type" : "dns-server", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "dnsServers" : [ "dns-example.net", "8.8.8.8" ], + "recursiveQueries" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "dnsQueryClass" : "in", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ] + } + + """ + dns_server_instant_test_request = thousandeyes_sdk.instant_tests.models.DnsServerInstantTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.create_dns_server_instant_test( + + dns_server_instant_test_request=dns_server_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_dns_server_instant_test", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-instant-tests/test/test_dns_trace_instant_tests_api_integration.py b/thousandeyes-sdk-instant-tests/test/test_dns_trace_instant_tests_api_integration.py new file mode 100644 index 00000000..890a5303 --- /dev/null +++ b/thousandeyes-sdk-instant-tests/test/test_dns_trace_instant_tests_api_integration.py @@ -0,0 +1,734 @@ +# coding: utf-8 + +""" + Instant Tests API + + The Instant Tests API operations lets you create and run new instant tests. You will need to be an Account Admin. The response does not include the immediate test results. Use the Test Results endpoints to get test results after creating and executing an instant test. You can find the URLs for these endpoints in the _links section of the test definition that is returned when you create the instant test. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.instant_tests.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.instant_tests.api.dns_trace_instant_tests_api import DNSTraceInstantTestsApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestDNSTraceInstantTestsApiIntegration(IntegrationTestBase): + """DNSTraceInstantTestsApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = DNSTraceInstantTestsApi(self.api_client) + + + def test_create_dns_trace_instant_test_happy_path(self) -> None: + """Integration test for create_dns_trace_instant_test success path""" + request_body_json = """ + + { + "dnsQueryClass" : "in", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "dnsTransportProtocol" : "udp", + "type" : "dns-trace", + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "testName" : "ThousandEyes Test" + } + + """ + dns_trace_instant_test_request = thousandeyes_sdk.instant_tests.models.DnsTraceInstantTestRequest.from_json(request_body_json) + aid = '1234' + response_body_json = """ + { + "dnsQueryClass" : "in", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "dnsTransportProtocol" : "udp", + "type" : "dns-trace", + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "testName" : "ThousandEyes Test" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.create_dns_trace_instant_test( + + dns_trace_instant_test_request=dns_trace_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_dns_trace_instant_test"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_create_dns_trace_instant_test_error_400(self) -> None: + """Integration test for create_dns_trace_instant_test error path (HTTP 400)""" + request_body_json = """ + + { + "dnsQueryClass" : "in", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "dnsTransportProtocol" : "udp", + "type" : "dns-trace", + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "testName" : "ThousandEyes Test" + } + + """ + dns_trace_instant_test_request = thousandeyes_sdk.instant_tests.models.DnsTraceInstantTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.create_dns_trace_instant_test( + + dns_trace_instant_test_request=dns_trace_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_dns_trace_instant_test", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_dns_trace_instant_test_error_401(self) -> None: + """Integration test for create_dns_trace_instant_test error path (HTTP 401)""" + request_body_json = """ + + { + "dnsQueryClass" : "in", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "dnsTransportProtocol" : "udp", + "type" : "dns-trace", + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "testName" : "ThousandEyes Test" + } + + """ + dns_trace_instant_test_request = thousandeyes_sdk.instant_tests.models.DnsTraceInstantTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.create_dns_trace_instant_test( + + dns_trace_instant_test_request=dns_trace_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_dns_trace_instant_test", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_dns_trace_instant_test_error_403(self) -> None: + """Integration test for create_dns_trace_instant_test error path (HTTP 403)""" + request_body_json = """ + + { + "dnsQueryClass" : "in", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "dnsTransportProtocol" : "udp", + "type" : "dns-trace", + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "testName" : "ThousandEyes Test" + } + + """ + dns_trace_instant_test_request = thousandeyes_sdk.instant_tests.models.DnsTraceInstantTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.create_dns_trace_instant_test( + + dns_trace_instant_test_request=dns_trace_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_dns_trace_instant_test", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_dns_trace_instant_test_error_404(self) -> None: + """Integration test for create_dns_trace_instant_test error path (HTTP 404)""" + request_body_json = """ + + { + "dnsQueryClass" : "in", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "dnsTransportProtocol" : "udp", + "type" : "dns-trace", + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "testName" : "ThousandEyes Test" + } + + """ + dns_trace_instant_test_request = thousandeyes_sdk.instant_tests.models.DnsTraceInstantTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.create_dns_trace_instant_test( + + dns_trace_instant_test_request=dns_trace_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_dns_trace_instant_test", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_dns_trace_instant_test_error_429(self) -> None: + """Integration test for create_dns_trace_instant_test error path (HTTP 429)""" + request_body_json = """ + + { + "dnsQueryClass" : "in", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "dnsTransportProtocol" : "udp", + "type" : "dns-trace", + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "testName" : "ThousandEyes Test" + } + + """ + dns_trace_instant_test_request = thousandeyes_sdk.instant_tests.models.DnsTraceInstantTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.create_dns_trace_instant_test( + + dns_trace_instant_test_request=dns_trace_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_dns_trace_instant_test", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_dns_trace_instant_test_error_500(self) -> None: + """Integration test for create_dns_trace_instant_test error path (HTTP 500)""" + request_body_json = """ + + { + "dnsQueryClass" : "in", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "dnsTransportProtocol" : "udp", + "type" : "dns-trace", + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "testName" : "ThousandEyes Test" + } + + """ + dns_trace_instant_test_request = thousandeyes_sdk.instant_tests.models.DnsTraceInstantTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.create_dns_trace_instant_test( + + dns_trace_instant_test_request=dns_trace_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_dns_trace_instant_test", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_dns_trace_instant_test_error_502(self) -> None: + """Integration test for create_dns_trace_instant_test error path (HTTP 502)""" + request_body_json = """ + + { + "dnsQueryClass" : "in", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "dnsTransportProtocol" : "udp", + "type" : "dns-trace", + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "testName" : "ThousandEyes Test" + } + + """ + dns_trace_instant_test_request = thousandeyes_sdk.instant_tests.models.DnsTraceInstantTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.create_dns_trace_instant_test( + + dns_trace_instant_test_request=dns_trace_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_dns_trace_instant_test", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-instant-tests/test/test_dnssec_instant_tests_api_integration.py b/thousandeyes-sdk-instant-tests/test/test_dnssec_instant_tests_api_integration.py new file mode 100644 index 00000000..fa8372bb --- /dev/null +++ b/thousandeyes-sdk-instant-tests/test/test_dnssec_instant_tests_api_integration.py @@ -0,0 +1,725 @@ +# coding: utf-8 + +""" + Instant Tests API + + The Instant Tests API operations lets you create and run new instant tests. You will need to be an Account Admin. The response does not include the immediate test results. Use the Test Results endpoints to get test results after creating and executing an instant test. You can find the URLs for these endpoints in the _links section of the test definition that is returned when you create the instant test. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.instant_tests.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.instant_tests.api.dnssec_instant_tests_api import DNSSECInstantTestsApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestDNSSECInstantTestsApiIntegration(IntegrationTestBase): + """DNSSECInstantTestsApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = DNSSECInstantTestsApi(self.api_client) + + + def test_create_dns_sec_instant_test_happy_path(self) -> None: + """Integration test for create_dns_sec_instant_test success path""" + request_body_json = """ + + { + "dnsQueryClass" : "in", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "dnssec", + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "testName" : "ThousandEyes Test" + } + + """ + dns_sec_instant_test_request = thousandeyes_sdk.instant_tests.models.DnsSecInstantTestRequest.from_json(request_body_json) + aid = '1234' + response_body_json = """ + { + "dnsQueryClass" : "in", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "dnssec", + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "testName" : "ThousandEyes Test" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.create_dns_sec_instant_test( + + dns_sec_instant_test_request=dns_sec_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_dns_sec_instant_test"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_create_dns_sec_instant_test_error_400(self) -> None: + """Integration test for create_dns_sec_instant_test error path (HTTP 400)""" + request_body_json = """ + + { + "dnsQueryClass" : "in", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "dnssec", + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "testName" : "ThousandEyes Test" + } + + """ + dns_sec_instant_test_request = thousandeyes_sdk.instant_tests.models.DnsSecInstantTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.create_dns_sec_instant_test( + + dns_sec_instant_test_request=dns_sec_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_dns_sec_instant_test", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_dns_sec_instant_test_error_401(self) -> None: + """Integration test for create_dns_sec_instant_test error path (HTTP 401)""" + request_body_json = """ + + { + "dnsQueryClass" : "in", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "dnssec", + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "testName" : "ThousandEyes Test" + } + + """ + dns_sec_instant_test_request = thousandeyes_sdk.instant_tests.models.DnsSecInstantTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.create_dns_sec_instant_test( + + dns_sec_instant_test_request=dns_sec_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_dns_sec_instant_test", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_dns_sec_instant_test_error_403(self) -> None: + """Integration test for create_dns_sec_instant_test error path (HTTP 403)""" + request_body_json = """ + + { + "dnsQueryClass" : "in", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "dnssec", + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "testName" : "ThousandEyes Test" + } + + """ + dns_sec_instant_test_request = thousandeyes_sdk.instant_tests.models.DnsSecInstantTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.create_dns_sec_instant_test( + + dns_sec_instant_test_request=dns_sec_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_dns_sec_instant_test", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_dns_sec_instant_test_error_404(self) -> None: + """Integration test for create_dns_sec_instant_test error path (HTTP 404)""" + request_body_json = """ + + { + "dnsQueryClass" : "in", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "dnssec", + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "testName" : "ThousandEyes Test" + } + + """ + dns_sec_instant_test_request = thousandeyes_sdk.instant_tests.models.DnsSecInstantTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.create_dns_sec_instant_test( + + dns_sec_instant_test_request=dns_sec_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_dns_sec_instant_test", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_dns_sec_instant_test_error_429(self) -> None: + """Integration test for create_dns_sec_instant_test error path (HTTP 429)""" + request_body_json = """ + + { + "dnsQueryClass" : "in", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "dnssec", + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "testName" : "ThousandEyes Test" + } + + """ + dns_sec_instant_test_request = thousandeyes_sdk.instant_tests.models.DnsSecInstantTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.create_dns_sec_instant_test( + + dns_sec_instant_test_request=dns_sec_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_dns_sec_instant_test", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_dns_sec_instant_test_error_500(self) -> None: + """Integration test for create_dns_sec_instant_test error path (HTTP 500)""" + request_body_json = """ + + { + "dnsQueryClass" : "in", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "dnssec", + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "testName" : "ThousandEyes Test" + } + + """ + dns_sec_instant_test_request = thousandeyes_sdk.instant_tests.models.DnsSecInstantTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.create_dns_sec_instant_test( + + dns_sec_instant_test_request=dns_sec_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_dns_sec_instant_test", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_dns_sec_instant_test_error_502(self) -> None: + """Integration test for create_dns_sec_instant_test error path (HTTP 502)""" + request_body_json = """ + + { + "dnsQueryClass" : "in", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "dnssec", + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "testName" : "ThousandEyes Test" + } + + """ + dns_sec_instant_test_request = thousandeyes_sdk.instant_tests.models.DnsSecInstantTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.create_dns_sec_instant_test( + + dns_sec_instant_test_request=dns_sec_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_dns_sec_instant_test", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-instant-tests/test/test_ftp_server_instant_tests_api_integration.py b/thousandeyes-sdk-instant-tests/test/test_ftp_server_instant_tests_api_integration.py new file mode 100644 index 00000000..4065b5a5 --- /dev/null +++ b/thousandeyes-sdk-instant-tests/test/test_ftp_server_instant_tests_api_integration.py @@ -0,0 +1,869 @@ +# coding: utf-8 + +""" + Instant Tests API + + The Instant Tests API operations lets you create and run new instant tests. You will need to be an Account Admin. The response does not include the immediate test results. Use the Test Results endpoints to get test results after creating and executing an instant test. You can find the URLs for these endpoints in the _links section of the test definition that is returned when you create the instant test. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.instant_tests.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.instant_tests.api.ftp_server_instant_tests_api import FTPServerInstantTestsApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestFTPServerInstantTestsApiIntegration(IntegrationTestBase): + """FTPServerInstantTestsApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = FTPServerInstantTestsApi(self.api_client) + + + def test_create_ftp_server_instant_test_happy_path(self) -> None: + """Integration test for create_ftp_server_instant_test success path""" + request_body_json = """ + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "downloadLimit" : 1048576, + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "useExplicitFtps" : false, + "probeMode" : "auto", + "type" : "ftp-server", + "password" : "password", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "ftpTargetTime" : 1400, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "requestType" : "download", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "ftpTimeLimit" : 10, + "modifiedDate" : "2022-07-17T22:00:54Z", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "useActiveFtp" : false, + "username" : "username" + } + + """ + ftp_server_instant_test_request = thousandeyes_sdk.instant_tests.models.FtpServerInstantTestRequest.from_json(request_body_json) + aid = '1234' + response_body_json = """ + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "downloadLimit" : 1048576, + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "useExplicitFtps" : false, + "probeMode" : "auto", + "type" : "ftp-server", + "password" : "password", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "ftpTargetTime" : 1400, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "requestType" : "download", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "ftpTimeLimit" : 10, + "modifiedDate" : "2022-07-17T22:00:54Z", + "testId" : "281474976710706", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "useActiveFtp" : false, + "username" : "username" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.create_ftp_server_instant_test( + + ftp_server_instant_test_request=ftp_server_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_ftp_server_instant_test"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_create_ftp_server_instant_test_error_400(self) -> None: + """Integration test for create_ftp_server_instant_test error path (HTTP 400)""" + request_body_json = """ + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "downloadLimit" : 1048576, + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "useExplicitFtps" : false, + "probeMode" : "auto", + "type" : "ftp-server", + "password" : "password", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "ftpTargetTime" : 1400, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "requestType" : "download", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "ftpTimeLimit" : 10, + "modifiedDate" : "2022-07-17T22:00:54Z", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "useActiveFtp" : false, + "username" : "username" + } + + """ + ftp_server_instant_test_request = thousandeyes_sdk.instant_tests.models.FtpServerInstantTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.create_ftp_server_instant_test( + + ftp_server_instant_test_request=ftp_server_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_ftp_server_instant_test", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_ftp_server_instant_test_error_401(self) -> None: + """Integration test for create_ftp_server_instant_test error path (HTTP 401)""" + request_body_json = """ + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "downloadLimit" : 1048576, + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "useExplicitFtps" : false, + "probeMode" : "auto", + "type" : "ftp-server", + "password" : "password", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "ftpTargetTime" : 1400, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "requestType" : "download", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "ftpTimeLimit" : 10, + "modifiedDate" : "2022-07-17T22:00:54Z", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "useActiveFtp" : false, + "username" : "username" + } + + """ + ftp_server_instant_test_request = thousandeyes_sdk.instant_tests.models.FtpServerInstantTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.create_ftp_server_instant_test( + + ftp_server_instant_test_request=ftp_server_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_ftp_server_instant_test", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_ftp_server_instant_test_error_403(self) -> None: + """Integration test for create_ftp_server_instant_test error path (HTTP 403)""" + request_body_json = """ + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "downloadLimit" : 1048576, + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "useExplicitFtps" : false, + "probeMode" : "auto", + "type" : "ftp-server", + "password" : "password", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "ftpTargetTime" : 1400, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "requestType" : "download", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "ftpTimeLimit" : 10, + "modifiedDate" : "2022-07-17T22:00:54Z", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "useActiveFtp" : false, + "username" : "username" + } + + """ + ftp_server_instant_test_request = thousandeyes_sdk.instant_tests.models.FtpServerInstantTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.create_ftp_server_instant_test( + + ftp_server_instant_test_request=ftp_server_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_ftp_server_instant_test", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_ftp_server_instant_test_error_404(self) -> None: + """Integration test for create_ftp_server_instant_test error path (HTTP 404)""" + request_body_json = """ + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "downloadLimit" : 1048576, + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "useExplicitFtps" : false, + "probeMode" : "auto", + "type" : "ftp-server", + "password" : "password", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "ftpTargetTime" : 1400, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "requestType" : "download", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "ftpTimeLimit" : 10, + "modifiedDate" : "2022-07-17T22:00:54Z", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "useActiveFtp" : false, + "username" : "username" + } + + """ + ftp_server_instant_test_request = thousandeyes_sdk.instant_tests.models.FtpServerInstantTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.create_ftp_server_instant_test( + + ftp_server_instant_test_request=ftp_server_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_ftp_server_instant_test", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_ftp_server_instant_test_error_429(self) -> None: + """Integration test for create_ftp_server_instant_test error path (HTTP 429)""" + request_body_json = """ + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "downloadLimit" : 1048576, + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "useExplicitFtps" : false, + "probeMode" : "auto", + "type" : "ftp-server", + "password" : "password", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "ftpTargetTime" : 1400, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "requestType" : "download", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "ftpTimeLimit" : 10, + "modifiedDate" : "2022-07-17T22:00:54Z", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "useActiveFtp" : false, + "username" : "username" + } + + """ + ftp_server_instant_test_request = thousandeyes_sdk.instant_tests.models.FtpServerInstantTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.create_ftp_server_instant_test( + + ftp_server_instant_test_request=ftp_server_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_ftp_server_instant_test", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_ftp_server_instant_test_error_500(self) -> None: + """Integration test for create_ftp_server_instant_test error path (HTTP 500)""" + request_body_json = """ + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "downloadLimit" : 1048576, + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "useExplicitFtps" : false, + "probeMode" : "auto", + "type" : "ftp-server", + "password" : "password", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "ftpTargetTime" : 1400, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "requestType" : "download", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "ftpTimeLimit" : 10, + "modifiedDate" : "2022-07-17T22:00:54Z", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "useActiveFtp" : false, + "username" : "username" + } + + """ + ftp_server_instant_test_request = thousandeyes_sdk.instant_tests.models.FtpServerInstantTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.create_ftp_server_instant_test( + + ftp_server_instant_test_request=ftp_server_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_ftp_server_instant_test", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_ftp_server_instant_test_error_502(self) -> None: + """Integration test for create_ftp_server_instant_test error path (HTTP 502)""" + request_body_json = """ + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "downloadLimit" : 1048576, + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "useExplicitFtps" : false, + "probeMode" : "auto", + "type" : "ftp-server", + "password" : "password", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "ftpTargetTime" : 1400, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "requestType" : "download", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "ftpTimeLimit" : 10, + "modifiedDate" : "2022-07-17T22:00:54Z", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "useActiveFtp" : false, + "username" : "username" + } + + """ + ftp_server_instant_test_request = thousandeyes_sdk.instant_tests.models.FtpServerInstantTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.create_ftp_server_instant_test( + + ftp_server_instant_test_request=ftp_server_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_ftp_server_instant_test", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-instant-tests/test/test_http_page_load_instant_tests_api_integration.py b/thousandeyes-sdk-instant-tests/test/test_http_page_load_instant_tests_api_integration.py new file mode 100644 index 00000000..00a3de6c --- /dev/null +++ b/thousandeyes-sdk-instant-tests/test/test_http_page_load_instant_tests_api_integration.py @@ -0,0 +1,1400 @@ +# coding: utf-8 + +""" + Instant Tests API + + The Instant Tests API operations lets you create and run new instant tests. You will need to be an Account Admin. The response does not include the immediate test results. Use the Test Results endpoints to get test results after creating and executing an instant test. You can find the URLs for these endpoints in the _links section of the test definition that is returned when you create the instant test. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.instant_tests.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.instant_tests.api.http_page_load_instant_tests_api import HTTPPageLoadInstantTestsApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestHTTPPageLoadInstantTestsApiIntegration(IntegrationTestBase): + """HTTPPageLoadInstantTestsApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = HTTPPageLoadInstantTestsApi(self.api_client) + + + def test_create_page_load_instant_test_happy_path(self) -> None: + """Integration test for create_page_load_instant_test success path""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "page-load", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "chromePolicies" : "{\\"ProxyMode\\":\\"direct\\"}", + "contentRegex" : "(regex)+", + "pageLoadingStrategy" : "normal", + "testName" : "ThousandEyes Test", + "allowMicAndCamera" : false, + "browserLanguage" : "en-US", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "emulatedDeviceId" : "2", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "sslVersion" : "Auto", + "useNtlm" : false, + "downloadLimit" : 2048, + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "blockDomains" : "domain.com/", + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowGeolocation" : false, + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "pageLoadTargetTime" : 10, + "numPathTraces" : 3, + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "pageLoadTimeLimit" : 10, + "identifyAgentTrafficWithUserAgent" : false, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "disableScreenshot" : false, + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "chromeOptions" : "--disable-gpu", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username" + } + + """ + page_load_instant_test_request = thousandeyes_sdk.instant_tests.models.PageLoadInstantTestRequest.from_json(request_body_json) + aid = '1234' + response_body_json = """ + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "page-load", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "chromePolicies" : "{\\"ProxyMode\\":\\"direct\\"}", + "contentRegex" : "(regex)+", + "pageLoadingStrategy" : "normal", + "testName" : "ThousandEyes Test", + "allowMicAndCamera" : false, + "browserLanguage" : "en-US", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "emulatedDeviceId" : "2", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "overrideProxyId" : "281474976710706", + "sslVersion" : "Auto", + "useNtlm" : false, + "downloadLimit" : 2048, + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "blockDomains" : "domain.com/", + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowGeolocation" : false, + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "pageLoadTargetTime" : 10, + "numPathTraces" : 3, + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "pageLoadTimeLimit" : 10, + "identifyAgentTrafficWithUserAgent" : false, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "disableScreenshot" : false, + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "chromeOptions" : "--disable-gpu", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.create_page_load_instant_test( + + page_load_instant_test_request=page_load_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_page_load_instant_test"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_create_page_load_instant_test_error_400(self) -> None: + """Integration test for create_page_load_instant_test error path (HTTP 400)""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "page-load", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "chromePolicies" : "{\\"ProxyMode\\":\\"direct\\"}", + "contentRegex" : "(regex)+", + "pageLoadingStrategy" : "normal", + "testName" : "ThousandEyes Test", + "allowMicAndCamera" : false, + "browserLanguage" : "en-US", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "emulatedDeviceId" : "2", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "sslVersion" : "Auto", + "useNtlm" : false, + "downloadLimit" : 2048, + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "blockDomains" : "domain.com/", + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowGeolocation" : false, + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "pageLoadTargetTime" : 10, + "numPathTraces" : 3, + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "pageLoadTimeLimit" : 10, + "identifyAgentTrafficWithUserAgent" : false, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "disableScreenshot" : false, + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "chromeOptions" : "--disable-gpu", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username" + } + + """ + page_load_instant_test_request = thousandeyes_sdk.instant_tests.models.PageLoadInstantTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.create_page_load_instant_test( + + page_load_instant_test_request=page_load_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_page_load_instant_test", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_page_load_instant_test_error_401(self) -> None: + """Integration test for create_page_load_instant_test error path (HTTP 401)""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "page-load", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "chromePolicies" : "{\\"ProxyMode\\":\\"direct\\"}", + "contentRegex" : "(regex)+", + "pageLoadingStrategy" : "normal", + "testName" : "ThousandEyes Test", + "allowMicAndCamera" : false, + "browserLanguage" : "en-US", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "emulatedDeviceId" : "2", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "sslVersion" : "Auto", + "useNtlm" : false, + "downloadLimit" : 2048, + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "blockDomains" : "domain.com/", + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowGeolocation" : false, + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "pageLoadTargetTime" : 10, + "numPathTraces" : 3, + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "pageLoadTimeLimit" : 10, + "identifyAgentTrafficWithUserAgent" : false, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "disableScreenshot" : false, + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "chromeOptions" : "--disable-gpu", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username" + } + + """ + page_load_instant_test_request = thousandeyes_sdk.instant_tests.models.PageLoadInstantTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.create_page_load_instant_test( + + page_load_instant_test_request=page_load_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_page_load_instant_test", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_page_load_instant_test_error_403(self) -> None: + """Integration test for create_page_load_instant_test error path (HTTP 403)""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "page-load", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "chromePolicies" : "{\\"ProxyMode\\":\\"direct\\"}", + "contentRegex" : "(regex)+", + "pageLoadingStrategy" : "normal", + "testName" : "ThousandEyes Test", + "allowMicAndCamera" : false, + "browserLanguage" : "en-US", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "emulatedDeviceId" : "2", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "sslVersion" : "Auto", + "useNtlm" : false, + "downloadLimit" : 2048, + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "blockDomains" : "domain.com/", + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowGeolocation" : false, + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "pageLoadTargetTime" : 10, + "numPathTraces" : 3, + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "pageLoadTimeLimit" : 10, + "identifyAgentTrafficWithUserAgent" : false, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "disableScreenshot" : false, + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "chromeOptions" : "--disable-gpu", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username" + } + + """ + page_load_instant_test_request = thousandeyes_sdk.instant_tests.models.PageLoadInstantTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.create_page_load_instant_test( + + page_load_instant_test_request=page_load_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_page_load_instant_test", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_page_load_instant_test_error_404(self) -> None: + """Integration test for create_page_load_instant_test error path (HTTP 404)""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "page-load", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "chromePolicies" : "{\\"ProxyMode\\":\\"direct\\"}", + "contentRegex" : "(regex)+", + "pageLoadingStrategy" : "normal", + "testName" : "ThousandEyes Test", + "allowMicAndCamera" : false, + "browserLanguage" : "en-US", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "emulatedDeviceId" : "2", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "sslVersion" : "Auto", + "useNtlm" : false, + "downloadLimit" : 2048, + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "blockDomains" : "domain.com/", + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowGeolocation" : false, + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "pageLoadTargetTime" : 10, + "numPathTraces" : 3, + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "pageLoadTimeLimit" : 10, + "identifyAgentTrafficWithUserAgent" : false, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "disableScreenshot" : false, + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "chromeOptions" : "--disable-gpu", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username" + } + + """ + page_load_instant_test_request = thousandeyes_sdk.instant_tests.models.PageLoadInstantTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.create_page_load_instant_test( + + page_load_instant_test_request=page_load_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_page_load_instant_test", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_page_load_instant_test_error_429(self) -> None: + """Integration test for create_page_load_instant_test error path (HTTP 429)""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "page-load", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "chromePolicies" : "{\\"ProxyMode\\":\\"direct\\"}", + "contentRegex" : "(regex)+", + "pageLoadingStrategy" : "normal", + "testName" : "ThousandEyes Test", + "allowMicAndCamera" : false, + "browserLanguage" : "en-US", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "emulatedDeviceId" : "2", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "sslVersion" : "Auto", + "useNtlm" : false, + "downloadLimit" : 2048, + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "blockDomains" : "domain.com/", + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowGeolocation" : false, + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "pageLoadTargetTime" : 10, + "numPathTraces" : 3, + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "pageLoadTimeLimit" : 10, + "identifyAgentTrafficWithUserAgent" : false, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "disableScreenshot" : false, + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "chromeOptions" : "--disable-gpu", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username" + } + + """ + page_load_instant_test_request = thousandeyes_sdk.instant_tests.models.PageLoadInstantTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.create_page_load_instant_test( + + page_load_instant_test_request=page_load_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_page_load_instant_test", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_page_load_instant_test_error_500(self) -> None: + """Integration test for create_page_load_instant_test error path (HTTP 500)""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "page-load", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "chromePolicies" : "{\\"ProxyMode\\":\\"direct\\"}", + "contentRegex" : "(regex)+", + "pageLoadingStrategy" : "normal", + "testName" : "ThousandEyes Test", + "allowMicAndCamera" : false, + "browserLanguage" : "en-US", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "emulatedDeviceId" : "2", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "sslVersion" : "Auto", + "useNtlm" : false, + "downloadLimit" : 2048, + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "blockDomains" : "domain.com/", + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowGeolocation" : false, + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "pageLoadTargetTime" : 10, + "numPathTraces" : 3, + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "pageLoadTimeLimit" : 10, + "identifyAgentTrafficWithUserAgent" : false, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "disableScreenshot" : false, + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "chromeOptions" : "--disable-gpu", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username" + } + + """ + page_load_instant_test_request = thousandeyes_sdk.instant_tests.models.PageLoadInstantTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.create_page_load_instant_test( + + page_load_instant_test_request=page_load_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_page_load_instant_test", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_page_load_instant_test_error_502(self) -> None: + """Integration test for create_page_load_instant_test error path (HTTP 502)""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "page-load", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "chromePolicies" : "{\\"ProxyMode\\":\\"direct\\"}", + "contentRegex" : "(regex)+", + "pageLoadingStrategy" : "normal", + "testName" : "ThousandEyes Test", + "allowMicAndCamera" : false, + "browserLanguage" : "en-US", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "emulatedDeviceId" : "2", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "sslVersion" : "Auto", + "useNtlm" : false, + "downloadLimit" : 2048, + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "blockDomains" : "domain.com/", + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowGeolocation" : false, + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "pageLoadTargetTime" : 10, + "numPathTraces" : 3, + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "pageLoadTimeLimit" : 10, + "identifyAgentTrafficWithUserAgent" : false, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "disableScreenshot" : false, + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "chromeOptions" : "--disable-gpu", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username" + } + + """ + page_load_instant_test_request = thousandeyes_sdk.instant_tests.models.PageLoadInstantTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.create_page_load_instant_test( + + page_load_instant_test_request=page_load_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_page_load_instant_test", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-instant-tests/test/test_http_server_instant_tests_api_integration.py b/thousandeyes-sdk-instant-tests/test/test_http_server_instant_tests_api_integration.py new file mode 100644 index 00000000..b01cbdae --- /dev/null +++ b/thousandeyes-sdk-instant-tests/test/test_http_server_instant_tests_api_integration.py @@ -0,0 +1,1328 @@ +# coding: utf-8 + +""" + Instant Tests API + + The Instant Tests API operations lets you create and run new instant tests. You will need to be an Account Admin. The response does not include the immediate test results. Use the Test Results endpoints to get test results after creating and executing an instant test. You can find the URLs for these endpoints in the _links section of the test definition that is returned when you create the instant test. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.instant_tests.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.instant_tests.api.http_server_instant_tests_api import HTTPServerInstantTestsApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestHTTPServerInstantTestsApiIntegration(IntegrationTestBase): + """HTTPServerInstantTestsApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = HTTPServerInstantTestsApi(self.api_client) + + + def test_create_http_server_instant_test_happy_path(self) -> None: + """Integration test for create_http_server_instant_test success path""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "http-server", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "contentRegex" : "(regex)+", + "testName" : "ThousandEyes Test", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "sslVersion" : "Auto", + "useNtlm" : false, + "ipv6Policy" : "use-agent-policy", + "downloadLimit" : 2048, + "requestMethod" : "get", + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "headers" : [ "header1: value1", "header2: value2" ], + "numPathTraces" : 3, + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "postBody" : "{ \\"example\\" : \\"value\\"}", + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username" + } + + """ + http_server_instant_test_request = thousandeyes_sdk.instant_tests.models.HttpServerInstantTestRequest.from_json(request_body_json) + aid = '1234' + response_body_json = """ + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "http-server", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "contentRegex" : "(regex)+", + "testName" : "ThousandEyes Test", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "overrideProxyId" : "281474976710706", + "sslVersion" : "Auto", + "useNtlm" : false, + "ipv6Policy" : "use-agent-policy", + "downloadLimit" : 2048, + "requestMethod" : "get", + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "headers" : [ "header1: value1", "header2: value2" ], + "numPathTraces" : 3, + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "postBody" : "{ \\"example\\" : \\"value\\"}", + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.create_http_server_instant_test( + + http_server_instant_test_request=http_server_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_http_server_instant_test"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_create_http_server_instant_test_error_400(self) -> None: + """Integration test for create_http_server_instant_test error path (HTTP 400)""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "http-server", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "contentRegex" : "(regex)+", + "testName" : "ThousandEyes Test", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "sslVersion" : "Auto", + "useNtlm" : false, + "ipv6Policy" : "use-agent-policy", + "downloadLimit" : 2048, + "requestMethod" : "get", + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "headers" : [ "header1: value1", "header2: value2" ], + "numPathTraces" : 3, + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "postBody" : "{ \\"example\\" : \\"value\\"}", + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username" + } + + """ + http_server_instant_test_request = thousandeyes_sdk.instant_tests.models.HttpServerInstantTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.create_http_server_instant_test( + + http_server_instant_test_request=http_server_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_http_server_instant_test", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_http_server_instant_test_error_401(self) -> None: + """Integration test for create_http_server_instant_test error path (HTTP 401)""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "http-server", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "contentRegex" : "(regex)+", + "testName" : "ThousandEyes Test", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "sslVersion" : "Auto", + "useNtlm" : false, + "ipv6Policy" : "use-agent-policy", + "downloadLimit" : 2048, + "requestMethod" : "get", + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "headers" : [ "header1: value1", "header2: value2" ], + "numPathTraces" : 3, + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "postBody" : "{ \\"example\\" : \\"value\\"}", + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username" + } + + """ + http_server_instant_test_request = thousandeyes_sdk.instant_tests.models.HttpServerInstantTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.create_http_server_instant_test( + + http_server_instant_test_request=http_server_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_http_server_instant_test", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_http_server_instant_test_error_403(self) -> None: + """Integration test for create_http_server_instant_test error path (HTTP 403)""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "http-server", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "contentRegex" : "(regex)+", + "testName" : "ThousandEyes Test", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "sslVersion" : "Auto", + "useNtlm" : false, + "ipv6Policy" : "use-agent-policy", + "downloadLimit" : 2048, + "requestMethod" : "get", + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "headers" : [ "header1: value1", "header2: value2" ], + "numPathTraces" : 3, + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "postBody" : "{ \\"example\\" : \\"value\\"}", + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username" + } + + """ + http_server_instant_test_request = thousandeyes_sdk.instant_tests.models.HttpServerInstantTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.create_http_server_instant_test( + + http_server_instant_test_request=http_server_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_http_server_instant_test", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_http_server_instant_test_error_404(self) -> None: + """Integration test for create_http_server_instant_test error path (HTTP 404)""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "http-server", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "contentRegex" : "(regex)+", + "testName" : "ThousandEyes Test", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "sslVersion" : "Auto", + "useNtlm" : false, + "ipv6Policy" : "use-agent-policy", + "downloadLimit" : 2048, + "requestMethod" : "get", + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "headers" : [ "header1: value1", "header2: value2" ], + "numPathTraces" : 3, + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "postBody" : "{ \\"example\\" : \\"value\\"}", + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username" + } + + """ + http_server_instant_test_request = thousandeyes_sdk.instant_tests.models.HttpServerInstantTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.create_http_server_instant_test( + + http_server_instant_test_request=http_server_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_http_server_instant_test", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_http_server_instant_test_error_429(self) -> None: + """Integration test for create_http_server_instant_test error path (HTTP 429)""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "http-server", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "contentRegex" : "(regex)+", + "testName" : "ThousandEyes Test", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "sslVersion" : "Auto", + "useNtlm" : false, + "ipv6Policy" : "use-agent-policy", + "downloadLimit" : 2048, + "requestMethod" : "get", + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "headers" : [ "header1: value1", "header2: value2" ], + "numPathTraces" : 3, + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "postBody" : "{ \\"example\\" : \\"value\\"}", + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username" + } + + """ + http_server_instant_test_request = thousandeyes_sdk.instant_tests.models.HttpServerInstantTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.create_http_server_instant_test( + + http_server_instant_test_request=http_server_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_http_server_instant_test", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_http_server_instant_test_error_500(self) -> None: + """Integration test for create_http_server_instant_test error path (HTTP 500)""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "http-server", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "contentRegex" : "(regex)+", + "testName" : "ThousandEyes Test", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "sslVersion" : "Auto", + "useNtlm" : false, + "ipv6Policy" : "use-agent-policy", + "downloadLimit" : 2048, + "requestMethod" : "get", + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "headers" : [ "header1: value1", "header2: value2" ], + "numPathTraces" : 3, + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "postBody" : "{ \\"example\\" : \\"value\\"}", + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username" + } + + """ + http_server_instant_test_request = thousandeyes_sdk.instant_tests.models.HttpServerInstantTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.create_http_server_instant_test( + + http_server_instant_test_request=http_server_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_http_server_instant_test", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_http_server_instant_test_error_502(self) -> None: + """Integration test for create_http_server_instant_test error path (HTTP 502)""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "http-server", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "contentRegex" : "(regex)+", + "testName" : "ThousandEyes Test", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "sslVersion" : "Auto", + "useNtlm" : false, + "ipv6Policy" : "use-agent-policy", + "downloadLimit" : 2048, + "requestMethod" : "get", + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "headers" : [ "header1: value1", "header2: value2" ], + "numPathTraces" : 3, + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "postBody" : "{ \\"example\\" : \\"value\\"}", + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username" + } + + """ + http_server_instant_test_request = thousandeyes_sdk.instant_tests.models.HttpServerInstantTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.create_http_server_instant_test( + + http_server_instant_test_request=http_server_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_http_server_instant_test", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-instant-tests/test/test_instant_tests_api_integration.py b/thousandeyes-sdk-instant-tests/test/test_instant_tests_api_integration.py new file mode 100644 index 00000000..67b19d69 --- /dev/null +++ b/thousandeyes-sdk-instant-tests/test/test_instant_tests_api_integration.py @@ -0,0 +1,35 @@ +# coding: utf-8 + +""" + Instant Tests API + + The Instant Tests API operations lets you create and run new instant tests. You will need to be an Account Admin. The response does not include the immediate test results. Use the Test Results endpoints to get test results after creating and executing an instant test. You can find the URLs for these endpoints in the _links section of the test definition that is returned when you create the instant test. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.instant_tests.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.instant_tests.api.instant_tests_api import InstantTestsApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestInstantTestsApiIntegration(IntegrationTestBase): + """InstantTestsApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = InstantTestsApi(self.api_client) + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-instant-tests/test/test_sip_server_instant_tests_api_integration.py b/thousandeyes-sdk-instant-tests/test/test_sip_server_instant_tests_api_integration.py new file mode 100644 index 00000000..96614a41 --- /dev/null +++ b/thousandeyes-sdk-instant-tests/test/test_sip_server_instant_tests_api_integration.py @@ -0,0 +1,876 @@ +# coding: utf-8 + +""" + Instant Tests API + + The Instant Tests API operations lets you create and run new instant tests. You will need to be an Account Admin. The response does not include the immediate test results. Use the Test Results endpoints to get test results after creating and executing an instant test. You can find the URLs for these endpoints in the _links section of the test definition that is returned when you create the instant test. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.instant_tests.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.instant_tests.api.sip_server_instant_tests_api import SIPServerInstantTestsApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestSIPServerInstantTestsApiIntegration(IntegrationTestBase): + """SIPServerInstantTestsApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = SIPServerInstantTestsApi(self.api_client) + + + def test_create_sip_server_instant_test_happy_path(self) -> None: + """Integration test for create_sip_server_instant_test success path""" + request_body_json = """ + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "registerEnabled" : false, + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "type" : "sip-server", + "fixedPacketRate" : 50, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "targetSipCredentials" : { + "password" : "password", + "protocol" : "tcp", + "port" : 49153, + "sipRegistrar" : "voice.thousandeyes.com", + "authUser" : "username", + "user" : "username" + }, + "testName" : "ThousandEyes Test", + "sipTargetTime" : 1000, + "numPathTraces" : 3, + "optionsRegex" : "[\\"a-z\\"]", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "sipTimeLimit" : 5, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ] + } + + """ + sip_server_instant_test_request = thousandeyes_sdk.instant_tests.models.SipServerInstantTestRequest.from_json(request_body_json) + aid = '1234' + response_body_json = """ + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "registerEnabled" : false, + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "type" : "sip-server", + "authUser" : "username", + "fixedPacketRate" : 50, + "password" : "password", + "protocol" : "tcp", + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "testName" : "ThousandEyes Test", + "sipTargetTime" : 1000, + "numPathTraces" : 3, + "optionsRegex" : "[\\"a-z\\"]", + "liveShare" : false, + "savedEvent" : true, + "sipRegistrar" : "voice.thousandeyes.com", + "networkMeasurements" : true, + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "port" : 49153, + "modifiedDate" : "2022-07-17T22:00:54Z", + "sipTimeLimit" : 5, + "testId" : "281474976710706", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "user" : "username" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.create_sip_server_instant_test( + + sip_server_instant_test_request=sip_server_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_sip_server_instant_test"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_create_sip_server_instant_test_error_400(self) -> None: + """Integration test for create_sip_server_instant_test error path (HTTP 400)""" + request_body_json = """ + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "registerEnabled" : false, + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "type" : "sip-server", + "fixedPacketRate" : 50, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "targetSipCredentials" : { + "password" : "password", + "protocol" : "tcp", + "port" : 49153, + "sipRegistrar" : "voice.thousandeyes.com", + "authUser" : "username", + "user" : "username" + }, + "testName" : "ThousandEyes Test", + "sipTargetTime" : 1000, + "numPathTraces" : 3, + "optionsRegex" : "[\\"a-z\\"]", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "sipTimeLimit" : 5, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ] + } + + """ + sip_server_instant_test_request = thousandeyes_sdk.instant_tests.models.SipServerInstantTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.create_sip_server_instant_test( + + sip_server_instant_test_request=sip_server_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_sip_server_instant_test", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_sip_server_instant_test_error_401(self) -> None: + """Integration test for create_sip_server_instant_test error path (HTTP 401)""" + request_body_json = """ + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "registerEnabled" : false, + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "type" : "sip-server", + "fixedPacketRate" : 50, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "targetSipCredentials" : { + "password" : "password", + "protocol" : "tcp", + "port" : 49153, + "sipRegistrar" : "voice.thousandeyes.com", + "authUser" : "username", + "user" : "username" + }, + "testName" : "ThousandEyes Test", + "sipTargetTime" : 1000, + "numPathTraces" : 3, + "optionsRegex" : "[\\"a-z\\"]", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "sipTimeLimit" : 5, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ] + } + + """ + sip_server_instant_test_request = thousandeyes_sdk.instant_tests.models.SipServerInstantTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.create_sip_server_instant_test( + + sip_server_instant_test_request=sip_server_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_sip_server_instant_test", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_sip_server_instant_test_error_403(self) -> None: + """Integration test for create_sip_server_instant_test error path (HTTP 403)""" + request_body_json = """ + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "registerEnabled" : false, + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "type" : "sip-server", + "fixedPacketRate" : 50, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "targetSipCredentials" : { + "password" : "password", + "protocol" : "tcp", + "port" : 49153, + "sipRegistrar" : "voice.thousandeyes.com", + "authUser" : "username", + "user" : "username" + }, + "testName" : "ThousandEyes Test", + "sipTargetTime" : 1000, + "numPathTraces" : 3, + "optionsRegex" : "[\\"a-z\\"]", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "sipTimeLimit" : 5, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ] + } + + """ + sip_server_instant_test_request = thousandeyes_sdk.instant_tests.models.SipServerInstantTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.create_sip_server_instant_test( + + sip_server_instant_test_request=sip_server_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_sip_server_instant_test", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_sip_server_instant_test_error_404(self) -> None: + """Integration test for create_sip_server_instant_test error path (HTTP 404)""" + request_body_json = """ + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "registerEnabled" : false, + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "type" : "sip-server", + "fixedPacketRate" : 50, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "targetSipCredentials" : { + "password" : "password", + "protocol" : "tcp", + "port" : 49153, + "sipRegistrar" : "voice.thousandeyes.com", + "authUser" : "username", + "user" : "username" + }, + "testName" : "ThousandEyes Test", + "sipTargetTime" : 1000, + "numPathTraces" : 3, + "optionsRegex" : "[\\"a-z\\"]", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "sipTimeLimit" : 5, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ] + } + + """ + sip_server_instant_test_request = thousandeyes_sdk.instant_tests.models.SipServerInstantTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.create_sip_server_instant_test( + + sip_server_instant_test_request=sip_server_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_sip_server_instant_test", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_sip_server_instant_test_error_429(self) -> None: + """Integration test for create_sip_server_instant_test error path (HTTP 429)""" + request_body_json = """ + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "registerEnabled" : false, + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "type" : "sip-server", + "fixedPacketRate" : 50, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "targetSipCredentials" : { + "password" : "password", + "protocol" : "tcp", + "port" : 49153, + "sipRegistrar" : "voice.thousandeyes.com", + "authUser" : "username", + "user" : "username" + }, + "testName" : "ThousandEyes Test", + "sipTargetTime" : 1000, + "numPathTraces" : 3, + "optionsRegex" : "[\\"a-z\\"]", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "sipTimeLimit" : 5, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ] + } + + """ + sip_server_instant_test_request = thousandeyes_sdk.instant_tests.models.SipServerInstantTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.create_sip_server_instant_test( + + sip_server_instant_test_request=sip_server_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_sip_server_instant_test", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_sip_server_instant_test_error_500(self) -> None: + """Integration test for create_sip_server_instant_test error path (HTTP 500)""" + request_body_json = """ + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "registerEnabled" : false, + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "type" : "sip-server", + "fixedPacketRate" : 50, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "targetSipCredentials" : { + "password" : "password", + "protocol" : "tcp", + "port" : 49153, + "sipRegistrar" : "voice.thousandeyes.com", + "authUser" : "username", + "user" : "username" + }, + "testName" : "ThousandEyes Test", + "sipTargetTime" : 1000, + "numPathTraces" : 3, + "optionsRegex" : "[\\"a-z\\"]", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "sipTimeLimit" : 5, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ] + } + + """ + sip_server_instant_test_request = thousandeyes_sdk.instant_tests.models.SipServerInstantTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.create_sip_server_instant_test( + + sip_server_instant_test_request=sip_server_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_sip_server_instant_test", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_sip_server_instant_test_error_502(self) -> None: + """Integration test for create_sip_server_instant_test error path (HTTP 502)""" + request_body_json = """ + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "registerEnabled" : false, + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "type" : "sip-server", + "fixedPacketRate" : 50, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "targetSipCredentials" : { + "password" : "password", + "protocol" : "tcp", + "port" : 49153, + "sipRegistrar" : "voice.thousandeyes.com", + "authUser" : "username", + "user" : "username" + }, + "testName" : "ThousandEyes Test", + "sipTargetTime" : 1000, + "numPathTraces" : 3, + "optionsRegex" : "[\\"a-z\\"]", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "sipTimeLimit" : 5, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ] + } + + """ + sip_server_instant_test_request = thousandeyes_sdk.instant_tests.models.SipServerInstantTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.create_sip_server_instant_test( + + sip_server_instant_test_request=sip_server_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_sip_server_instant_test", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-instant-tests/test/test_utils.py b/thousandeyes-sdk-instant-tests/test/test_utils.py index 930528d9..37913f62 100644 --- a/thousandeyes-sdk-instant-tests/test/test_utils.py +++ b/thousandeyes-sdk-instant-tests/test/test_utils.py @@ -2,15 +2,36 @@ import json import unittest +from typing import Any from pydantic import BaseModel +def _project_onto_constructed(expected: Any, constructed: Any) -> Any: + """Keep only example fields that appear in the constructed model output.""" + if isinstance(constructed, dict): + if not isinstance(expected, dict): + return expected + return { + key: _project_onto_constructed(expected.get(key), value) + for key, value in constructed.items() + } + if isinstance(constructed, list): + if not isinstance(expected, list): + return expected + return [ + _project_onto_constructed(expected[index], value) + for index, value in enumerate(constructed) + ] + return expected + + def assert_constructed_model_matches_example_json(model: BaseModel, loaded_json: dict): test_case = unittest.TestCase() test_case.maxDiff = None test_case.assertIsNotNone(model) constructed_json = json.loads(model.to_json()) - sorted_loaded_json = json.dumps(loaded_json, sort_keys=True) + projected_loaded_json = _project_onto_constructed(loaded_json, constructed_json) + sorted_loaded_json = json.dumps(projected_loaded_json, sort_keys=True) sorted_constructed_json = json.dumps(constructed_json, sort_keys=True) test_case.assertEqual(sorted_loaded_json, sorted_constructed_json) diff --git a/thousandeyes-sdk-instant-tests/test/test_voice_instant_tests_api_integration.py b/thousandeyes-sdk-instant-tests/test/test_voice_instant_tests_api_integration.py new file mode 100644 index 00000000..b441e773 --- /dev/null +++ b/thousandeyes-sdk-instant-tests/test/test_voice_instant_tests_api_integration.py @@ -0,0 +1,788 @@ +# coding: utf-8 + +""" + Instant Tests API + + The Instant Tests API operations lets you create and run new instant tests. You will need to be an Account Admin. The response does not include the immediate test results. Use the Test Results endpoints to get test results after creating and executing an instant test. You can find the URLs for these endpoints in the _links section of the test definition that is returned when you create the instant test. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.instant_tests.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.instant_tests.api.voice_instant_tests_api import VoiceInstantTestsApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestVoiceInstantTestsApiIntegration(IntegrationTestBase): + """VoiceInstantTestsApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = VoiceInstantTestsApi(self.api_client) + + + def test_create_voice_instant_test_happy_path(self) -> None: + """Integration test for create_voice_instant_test success path""" + request_body_json = """ + + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "description" : "ThousandEyes Test", + "type" : "voice", + "jitterBuffer" : 40, + "dscpId" : "0", + "duration" : 5, + "dscp" : "Best Effort (DSCP 0)", + "modifiedBy" : "user@user.com", + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "liveShare" : false, + "savedEvent" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "codec" : "G.711 @ 64 Kbps", + "codecId" : "0", + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "port" : 1024, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "targetAgentId" : "281474976710706", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ] + } + + """ + voice_instant_test_request = thousandeyes_sdk.instant_tests.models.VoiceInstantTestRequest.from_json(request_body_json) + aid = '1234' + response_body_json = """ + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "description" : "ThousandEyes Test", + "type" : "voice", + "jitterBuffer" : 40, + "dscpId" : "0", + "duration" : 5, + "dscp" : "Best Effort (DSCP 0)", + "modifiedBy" : "user@user.com", + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "liveShare" : false, + "savedEvent" : true, + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "codec" : "G.711 @ 64 Kbps", + "codecId" : "0", + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "port" : 1024, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "targetAgentId" : "281474976710706", + "testId" : "281474976710706", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ] + } + """ + expected_response = json.loads(response_body_json) + response = self.api.create_voice_instant_test( + + voice_instant_test_request=voice_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_voice_instant_test"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_create_voice_instant_test_error_400(self) -> None: + """Integration test for create_voice_instant_test error path (HTTP 400)""" + request_body_json = """ + + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "description" : "ThousandEyes Test", + "type" : "voice", + "jitterBuffer" : 40, + "dscpId" : "0", + "duration" : 5, + "dscp" : "Best Effort (DSCP 0)", + "modifiedBy" : "user@user.com", + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "liveShare" : false, + "savedEvent" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "codec" : "G.711 @ 64 Kbps", + "codecId" : "0", + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "port" : 1024, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "targetAgentId" : "281474976710706", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ] + } + + """ + voice_instant_test_request = thousandeyes_sdk.instant_tests.models.VoiceInstantTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.create_voice_instant_test( + + voice_instant_test_request=voice_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_voice_instant_test", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_voice_instant_test_error_401(self) -> None: + """Integration test for create_voice_instant_test error path (HTTP 401)""" + request_body_json = """ + + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "description" : "ThousandEyes Test", + "type" : "voice", + "jitterBuffer" : 40, + "dscpId" : "0", + "duration" : 5, + "dscp" : "Best Effort (DSCP 0)", + "modifiedBy" : "user@user.com", + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "liveShare" : false, + "savedEvent" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "codec" : "G.711 @ 64 Kbps", + "codecId" : "0", + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "port" : 1024, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "targetAgentId" : "281474976710706", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ] + } + + """ + voice_instant_test_request = thousandeyes_sdk.instant_tests.models.VoiceInstantTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.create_voice_instant_test( + + voice_instant_test_request=voice_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_voice_instant_test", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_voice_instant_test_error_403(self) -> None: + """Integration test for create_voice_instant_test error path (HTTP 403)""" + request_body_json = """ + + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "description" : "ThousandEyes Test", + "type" : "voice", + "jitterBuffer" : 40, + "dscpId" : "0", + "duration" : 5, + "dscp" : "Best Effort (DSCP 0)", + "modifiedBy" : "user@user.com", + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "liveShare" : false, + "savedEvent" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "codec" : "G.711 @ 64 Kbps", + "codecId" : "0", + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "port" : 1024, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "targetAgentId" : "281474976710706", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ] + } + + """ + voice_instant_test_request = thousandeyes_sdk.instant_tests.models.VoiceInstantTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.create_voice_instant_test( + + voice_instant_test_request=voice_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_voice_instant_test", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_voice_instant_test_error_404(self) -> None: + """Integration test for create_voice_instant_test error path (HTTP 404)""" + request_body_json = """ + + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "description" : "ThousandEyes Test", + "type" : "voice", + "jitterBuffer" : 40, + "dscpId" : "0", + "duration" : 5, + "dscp" : "Best Effort (DSCP 0)", + "modifiedBy" : "user@user.com", + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "liveShare" : false, + "savedEvent" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "codec" : "G.711 @ 64 Kbps", + "codecId" : "0", + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "port" : 1024, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "targetAgentId" : "281474976710706", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ] + } + + """ + voice_instant_test_request = thousandeyes_sdk.instant_tests.models.VoiceInstantTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.create_voice_instant_test( + + voice_instant_test_request=voice_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_voice_instant_test", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_voice_instant_test_error_429(self) -> None: + """Integration test for create_voice_instant_test error path (HTTP 429)""" + request_body_json = """ + + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "description" : "ThousandEyes Test", + "type" : "voice", + "jitterBuffer" : 40, + "dscpId" : "0", + "duration" : 5, + "dscp" : "Best Effort (DSCP 0)", + "modifiedBy" : "user@user.com", + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "liveShare" : false, + "savedEvent" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "codec" : "G.711 @ 64 Kbps", + "codecId" : "0", + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "port" : 1024, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "targetAgentId" : "281474976710706", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ] + } + + """ + voice_instant_test_request = thousandeyes_sdk.instant_tests.models.VoiceInstantTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.create_voice_instant_test( + + voice_instant_test_request=voice_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_voice_instant_test", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_voice_instant_test_error_500(self) -> None: + """Integration test for create_voice_instant_test error path (HTTP 500)""" + request_body_json = """ + + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "description" : "ThousandEyes Test", + "type" : "voice", + "jitterBuffer" : 40, + "dscpId" : "0", + "duration" : 5, + "dscp" : "Best Effort (DSCP 0)", + "modifiedBy" : "user@user.com", + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "liveShare" : false, + "savedEvent" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "codec" : "G.711 @ 64 Kbps", + "codecId" : "0", + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "port" : 1024, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "targetAgentId" : "281474976710706", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ] + } + + """ + voice_instant_test_request = thousandeyes_sdk.instant_tests.models.VoiceInstantTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.create_voice_instant_test( + + voice_instant_test_request=voice_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_voice_instant_test", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_voice_instant_test_error_502(self) -> None: + """Integration test for create_voice_instant_test error path (HTTP 502)""" + request_body_json = """ + + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "description" : "ThousandEyes Test", + "type" : "voice", + "jitterBuffer" : 40, + "dscpId" : "0", + "duration" : 5, + "dscp" : "Best Effort (DSCP 0)", + "modifiedBy" : "user@user.com", + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "liveShare" : false, + "savedEvent" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "codec" : "G.711 @ 64 Kbps", + "codecId" : "0", + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "port" : 1024, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "targetAgentId" : "281474976710706", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ] + } + + """ + voice_instant_test_request = thousandeyes_sdk.instant_tests.models.VoiceInstantTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.create_voice_instant_test( + + voice_instant_test_request=voice_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_voice_instant_test", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-instant-tests/test/test_web_transaction_instant_tests_api_integration.py b/thousandeyes-sdk-instant-tests/test/test_web_transaction_instant_tests_api_integration.py new file mode 100644 index 00000000..7535eb44 --- /dev/null +++ b/thousandeyes-sdk-instant-tests/test/test_web_transaction_instant_tests_api_integration.py @@ -0,0 +1,1418 @@ +# coding: utf-8 + +""" + Instant Tests API + + The Instant Tests API operations lets you create and run new instant tests. You will need to be an Account Admin. The response does not include the immediate test results. Use the Test Results endpoints to get test results after creating and executing an instant test. You can find the URLs for these endpoints in the _links section of the test definition that is returned when you create the instant test. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.instant_tests.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.instant_tests.api.web_transaction_instant_tests_api import WebTransactionInstantTestsApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestWebTransactionInstantTestsApiIntegration(IntegrationTestBase): + """WebTransactionInstantTestsApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = WebTransactionInstantTestsApi(self.api_client) + + + def test_create_web_transaction_instant_test_happy_path(self) -> None: + """Integration test for create_web_transaction_instant_test success path""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "web-transactions", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "chromePolicies" : "{\\"ProxyMode\\":\\"direct\\"}", + "contentRegex" : "(regex)+", + "pageLoadingStrategy" : "normal", + "testName" : "ThousandEyes Test", + "allowMicAndCamera" : false, + "browserLanguage" : "en-US", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "emulatedDeviceId" : "2", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "sslVersion" : "Auto", + "useNtlm" : false, + "credentials" : [ "3247", "1051" ], + "downloadLimit" : 2048, + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "blockDomains" : "domain.com/", + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowGeolocation" : false, + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "numPathTraces" : 3, + "transactionScript" : "if (true) { return true; }", + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "identifyAgentTrafficWithUserAgent" : false, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "timeLimit" : 30, + "createdDate" : "2022-07-17T22:00:54Z", + "disableScreenshot" : false, + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "chromeOptions" : "--disable-gpu", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username", + "targetTime" : 1 + } + + """ + web_transaction_instant_test_request = thousandeyes_sdk.instant_tests.models.WebTransactionInstantTestRequest.from_json(request_body_json) + aid = '1234' + response_body_json = """ + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "web-transactions", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "chromePolicies" : "{\\"ProxyMode\\":\\"direct\\"}", + "contentRegex" : "(regex)+", + "pageLoadingStrategy" : "normal", + "testName" : "ThousandEyes Test", + "allowMicAndCamera" : false, + "browserLanguage" : "en-US", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "emulatedDeviceId" : "2", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "overrideProxyId" : "281474976710706", + "sslVersion" : "Auto", + "useNtlm" : false, + "credentials" : [ "3247", "1051" ], + "downloadLimit" : 2048, + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "blockDomains" : "domain.com/", + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowGeolocation" : false, + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "numPathTraces" : 3, + "transactionScript" : "if (true) { return true; }", + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "identifyAgentTrafficWithUserAgent" : false, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "timeLimit" : 30, + "createdDate" : "2022-07-17T22:00:54Z", + "disableScreenshot" : false, + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "chromeOptions" : "--disable-gpu", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username", + "targetTime" : 1 + } + """ + expected_response = json.loads(response_body_json) + response = self.api.create_web_transaction_instant_test( + + web_transaction_instant_test_request=web_transaction_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_web_transaction_instant_test"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_create_web_transaction_instant_test_error_400(self) -> None: + """Integration test for create_web_transaction_instant_test error path (HTTP 400)""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "web-transactions", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "chromePolicies" : "{\\"ProxyMode\\":\\"direct\\"}", + "contentRegex" : "(regex)+", + "pageLoadingStrategy" : "normal", + "testName" : "ThousandEyes Test", + "allowMicAndCamera" : false, + "browserLanguage" : "en-US", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "emulatedDeviceId" : "2", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "sslVersion" : "Auto", + "useNtlm" : false, + "credentials" : [ "3247", "1051" ], + "downloadLimit" : 2048, + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "blockDomains" : "domain.com/", + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowGeolocation" : false, + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "numPathTraces" : 3, + "transactionScript" : "if (true) { return true; }", + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "identifyAgentTrafficWithUserAgent" : false, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "timeLimit" : 30, + "createdDate" : "2022-07-17T22:00:54Z", + "disableScreenshot" : false, + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "chromeOptions" : "--disable-gpu", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username", + "targetTime" : 1 + } + + """ + web_transaction_instant_test_request = thousandeyes_sdk.instant_tests.models.WebTransactionInstantTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.create_web_transaction_instant_test( + + web_transaction_instant_test_request=web_transaction_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_web_transaction_instant_test", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_web_transaction_instant_test_error_401(self) -> None: + """Integration test for create_web_transaction_instant_test error path (HTTP 401)""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "web-transactions", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "chromePolicies" : "{\\"ProxyMode\\":\\"direct\\"}", + "contentRegex" : "(regex)+", + "pageLoadingStrategy" : "normal", + "testName" : "ThousandEyes Test", + "allowMicAndCamera" : false, + "browserLanguage" : "en-US", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "emulatedDeviceId" : "2", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "sslVersion" : "Auto", + "useNtlm" : false, + "credentials" : [ "3247", "1051" ], + "downloadLimit" : 2048, + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "blockDomains" : "domain.com/", + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowGeolocation" : false, + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "numPathTraces" : 3, + "transactionScript" : "if (true) { return true; }", + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "identifyAgentTrafficWithUserAgent" : false, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "timeLimit" : 30, + "createdDate" : "2022-07-17T22:00:54Z", + "disableScreenshot" : false, + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "chromeOptions" : "--disable-gpu", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username", + "targetTime" : 1 + } + + """ + web_transaction_instant_test_request = thousandeyes_sdk.instant_tests.models.WebTransactionInstantTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.create_web_transaction_instant_test( + + web_transaction_instant_test_request=web_transaction_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_web_transaction_instant_test", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_web_transaction_instant_test_error_403(self) -> None: + """Integration test for create_web_transaction_instant_test error path (HTTP 403)""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "web-transactions", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "chromePolicies" : "{\\"ProxyMode\\":\\"direct\\"}", + "contentRegex" : "(regex)+", + "pageLoadingStrategy" : "normal", + "testName" : "ThousandEyes Test", + "allowMicAndCamera" : false, + "browserLanguage" : "en-US", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "emulatedDeviceId" : "2", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "sslVersion" : "Auto", + "useNtlm" : false, + "credentials" : [ "3247", "1051" ], + "downloadLimit" : 2048, + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "blockDomains" : "domain.com/", + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowGeolocation" : false, + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "numPathTraces" : 3, + "transactionScript" : "if (true) { return true; }", + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "identifyAgentTrafficWithUserAgent" : false, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "timeLimit" : 30, + "createdDate" : "2022-07-17T22:00:54Z", + "disableScreenshot" : false, + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "chromeOptions" : "--disable-gpu", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username", + "targetTime" : 1 + } + + """ + web_transaction_instant_test_request = thousandeyes_sdk.instant_tests.models.WebTransactionInstantTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.create_web_transaction_instant_test( + + web_transaction_instant_test_request=web_transaction_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_web_transaction_instant_test", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_web_transaction_instant_test_error_404(self) -> None: + """Integration test for create_web_transaction_instant_test error path (HTTP 404)""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "web-transactions", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "chromePolicies" : "{\\"ProxyMode\\":\\"direct\\"}", + "contentRegex" : "(regex)+", + "pageLoadingStrategy" : "normal", + "testName" : "ThousandEyes Test", + "allowMicAndCamera" : false, + "browserLanguage" : "en-US", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "emulatedDeviceId" : "2", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "sslVersion" : "Auto", + "useNtlm" : false, + "credentials" : [ "3247", "1051" ], + "downloadLimit" : 2048, + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "blockDomains" : "domain.com/", + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowGeolocation" : false, + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "numPathTraces" : 3, + "transactionScript" : "if (true) { return true; }", + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "identifyAgentTrafficWithUserAgent" : false, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "timeLimit" : 30, + "createdDate" : "2022-07-17T22:00:54Z", + "disableScreenshot" : false, + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "chromeOptions" : "--disable-gpu", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username", + "targetTime" : 1 + } + + """ + web_transaction_instant_test_request = thousandeyes_sdk.instant_tests.models.WebTransactionInstantTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.create_web_transaction_instant_test( + + web_transaction_instant_test_request=web_transaction_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_web_transaction_instant_test", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_web_transaction_instant_test_error_429(self) -> None: + """Integration test for create_web_transaction_instant_test error path (HTTP 429)""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "web-transactions", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "chromePolicies" : "{\\"ProxyMode\\":\\"direct\\"}", + "contentRegex" : "(regex)+", + "pageLoadingStrategy" : "normal", + "testName" : "ThousandEyes Test", + "allowMicAndCamera" : false, + "browserLanguage" : "en-US", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "emulatedDeviceId" : "2", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "sslVersion" : "Auto", + "useNtlm" : false, + "credentials" : [ "3247", "1051" ], + "downloadLimit" : 2048, + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "blockDomains" : "domain.com/", + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowGeolocation" : false, + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "numPathTraces" : 3, + "transactionScript" : "if (true) { return true; }", + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "identifyAgentTrafficWithUserAgent" : false, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "timeLimit" : 30, + "createdDate" : "2022-07-17T22:00:54Z", + "disableScreenshot" : false, + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "chromeOptions" : "--disable-gpu", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username", + "targetTime" : 1 + } + + """ + web_transaction_instant_test_request = thousandeyes_sdk.instant_tests.models.WebTransactionInstantTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.create_web_transaction_instant_test( + + web_transaction_instant_test_request=web_transaction_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_web_transaction_instant_test", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_web_transaction_instant_test_error_500(self) -> None: + """Integration test for create_web_transaction_instant_test error path (HTTP 500)""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "web-transactions", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "chromePolicies" : "{\\"ProxyMode\\":\\"direct\\"}", + "contentRegex" : "(regex)+", + "pageLoadingStrategy" : "normal", + "testName" : "ThousandEyes Test", + "allowMicAndCamera" : false, + "browserLanguage" : "en-US", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "emulatedDeviceId" : "2", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "sslVersion" : "Auto", + "useNtlm" : false, + "credentials" : [ "3247", "1051" ], + "downloadLimit" : 2048, + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "blockDomains" : "domain.com/", + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowGeolocation" : false, + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "numPathTraces" : 3, + "transactionScript" : "if (true) { return true; }", + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "identifyAgentTrafficWithUserAgent" : false, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "timeLimit" : 30, + "createdDate" : "2022-07-17T22:00:54Z", + "disableScreenshot" : false, + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "chromeOptions" : "--disable-gpu", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username", + "targetTime" : 1 + } + + """ + web_transaction_instant_test_request = thousandeyes_sdk.instant_tests.models.WebTransactionInstantTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.create_web_transaction_instant_test( + + web_transaction_instant_test_request=web_transaction_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_web_transaction_instant_test", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_web_transaction_instant_test_error_502(self) -> None: + """Integration test for create_web_transaction_instant_test error path (HTTP 502)""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "web-transactions", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "chromePolicies" : "{\\"ProxyMode\\":\\"direct\\"}", + "contentRegex" : "(regex)+", + "pageLoadingStrategy" : "normal", + "testName" : "ThousandEyes Test", + "allowMicAndCamera" : false, + "browserLanguage" : "en-US", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "c6b78e57-81a2-4c5f-a11a-d96c3c664d55" ], + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "emulatedDeviceId" : "2", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "sslVersion" : "Auto", + "useNtlm" : false, + "credentials" : [ "3247", "1051" ], + "downloadLimit" : 2048, + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "blockDomains" : "domain.com/", + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowGeolocation" : false, + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "numPathTraces" : 3, + "transactionScript" : "if (true) { return true; }", + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "identifyAgentTrafficWithUserAgent" : false, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "timeLimit" : 30, + "createdDate" : "2022-07-17T22:00:54Z", + "disableScreenshot" : false, + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "chromeOptions" : "--disable-gpu", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username", + "targetTime" : 1 + } + + """ + web_transaction_instant_test_request = thousandeyes_sdk.instant_tests.models.WebTransactionInstantTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.create_web_transaction_instant_test( + + web_transaction_instant_test_request=web_transaction_instant_test_request, + + aid=aid, + + _headers=self.te_headers("create_web_transaction_instant_test", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-internet-insights/test/conftest.py b/thousandeyes-sdk-internet-insights/test/conftest.py new file mode 100644 index 00000000..2edba7b3 --- /dev/null +++ b/thousandeyes-sdk-internet-insights/test/conftest.py @@ -0,0 +1,7 @@ +import sys +from pathlib import Path + +_repo_root = Path(__file__).resolve().parents[2] +_core_test_support = _repo_root / "thousandeyes-sdk-core" / "test" +if str(_core_test_support) not in sys.path: + sys.path.insert(0, str(_core_test_support)) diff --git a/thousandeyes-sdk-internet-insights/test/integration_test_utils.py b/thousandeyes-sdk-internet-insights/test/integration_test_utils.py new file mode 100644 index 00000000..693c4b1e --- /dev/null +++ b/thousandeyes-sdk-internet-insights/test/integration_test_utils.py @@ -0,0 +1,37 @@ +# coding: utf-8 + +""" + Internet Insights API + + **Note:** All Internet Insights APIs are not available for ThousandEyes for Government instance. We are happy to announce the release of the Internet Insights API set. This limited release includes endpoints that: * Make our catalog provider and Internet outage data accessible to API users. * Provide access to advanced filtering, which is part of our next-generation API efforts to allow API users to fine-tune queries across all of our APIs in a consistent manner. Internet Insights provide visibility into core Internet infrastructure, including ISPs, DNS providers, IaaS, CDNs , and SaaS providers. It tracks the macro-level impact of Internet events on individual users and enterprise networks connecting at the edge of the Internet. These events include Outages, Routing hijacks and leaks, DDoS attacks, And political interference, among others. Future releases of the Internet Insights API set will further unlock access to core Internet Insights functionality, unlocking potential integrations to enrich customer process flows. For more information about Internet Insights, see the [Internet Insights](https://docs.thousandeyes.com/product-documentation/internet-insights). + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from thousandeyes_sdk.core.api_client import ApiClient +from thousandeyes_sdk.core.configuration import Configuration +from sdk_test_support.mock_server import ERROR_STATUS_HEADER, OPERATION_ID_HEADER, MockApiServer + +from .mock_manifest import OPERATION_MANIFEST + + +class IntegrationTestBase(unittest.TestCase): + def setUp(self) -> None: + self.server = MockApiServer(OPERATION_MANIFEST) + self.server.start() + configuration = Configuration(host=self.server.base_url, access_token="test-token") + self.api_client = ApiClient(configuration=configuration) + + def tearDown(self) -> None: + self.server.stop() + + def te_headers(self, operation_id: str, error_status=None): + headers = {OPERATION_ID_HEADER: operation_id} + if error_status is not None: + headers[ERROR_STATUS_HEADER] = error_status + return headers diff --git a/thousandeyes-sdk-internet-insights/test/mock_manifest.py b/thousandeyes-sdk-internet-insights/test/mock_manifest.py new file mode 100644 index 00000000..c925a517 --- /dev/null +++ b/thousandeyes-sdk-internet-insights/test/mock_manifest.py @@ -0,0 +1,899 @@ +# coding: utf-8 + +""" + Internet Insights API + + **Note:** All Internet Insights APIs are not available for ThousandEyes for Government instance. We are happy to announce the release of the Internet Insights API set. This limited release includes endpoints that: * Make our catalog provider and Internet outage data accessible to API users. * Provide access to advanced filtering, which is part of our next-generation API efforts to allow API users to fine-tune queries across all of our APIs in a consistent manner. Internet Insights provide visibility into core Internet infrastructure, including ISPs, DNS providers, IaaS, CDNs , and SaaS providers. It tracks the macro-level impact of Internet events on individual users and enterprise networks connecting at the edge of the Internet. These events include Outages, Routing hijacks and leaks, DDoS attacks, And political interference, among others. Future releases of the Internet Insights API set will further unlock access to core Internet Insights functionality, unlocking potential integrations to enrich customer process flows. For more information about Internet Insights, see the [Internet Insights](https://docs.thousandeyes.com/product-documentation/internet-insights). + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json + +from sdk_test_support.mock_server_types import ErrorResponseExpectation, OperationExpectation + +OPERATION_MANIFEST = { + + "filter_catalog_providers": OperationExpectation( + operation_id="filter_catalog_providers", + method="POST", + path="/internet-insights/catalog/providers/filter", + path_param_examples={ + }, + success_status=200, + success_body=json.loads(""" + + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "providers" : [ { + "interfacesCount" : 15, + "locationsCount" : 50, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "countriesCount" : 2, + "dataType" : "Application", + "id" : "85602a0a-54a7-4e97-946e-67492ef1fa26", + "region" : "North America", + "asnsCount" : 10, + "included" : true, + "providerName" : "Amazon Web Services", + "providerType" : "IAAS" + }, { + "interfacesCount" : 15, + "locationsCount" : 50, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "countriesCount" : 2, + "dataType" : "Application", + "id" : "85602a0a-54a7-4e97-946e-67492ef1fa26", + "region" : "North America", + "asnsCount" : 10, + "included" : true, + "providerName" : "Amazon Web Services", + "providerType" : "IAAS" + } ] + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "providerName" : "Amazon Web Services", + "providerType" : "IAAS", + "region" : "North America", + "location" : "San Jose, US", + "asn" : "Amazon.com, Inc.", + "included" : true + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_catalog_provider": OperationExpectation( + operation_id="get_catalog_provider", + method="GET", + path="/internet-insights/catalog/providers/{providerId}", + path_param_examples={ + "providerId": '85602a0a-54a7-4e97-946e-67492ef1fa26', + }, + success_status=200, + success_body=json.loads(""" + + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dataType" : "Application", + "asns" : [ { + "name" : "LVLT-1 - Level 3 Communications, Inc.", + "id" : 1 + }, { + "name" : "LVLT-1 - Level 3 Communications, Inc.", + "id" : 1 + } ], + "locations" : [ { + "interfacesCount" : 5, + "location" : "San Jose, US" + }, { + "interfacesCount" : 5, + "location" : "San Jose, US" + } ], + "id" : "85602a0a-54a7-4e97-946e-67492ef1fa26", + "region" : "North America", + "providerName" : "Amazon Web Services", + "providerType" : "IAAS" + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "filter_outages": OperationExpectation( + operation_id="filter_outages", + method="POST", + path="/internet-insights/outages/filter", + path_param_examples={ + }, + success_status=200, + success_body=json.loads(""" + + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "outages" : [ { + "affectedInterfacesCount" : 1, + "endDate" : "2022-03-01T23:31:11Z", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "affectedLocationsCount" : 1, + "endRoundId" : 1646177700, + "affectedTestsCount" : 1, + "type" : "app", + "providerType" : "SAAS", + "duration" : 214, + "startRoundId" : 1646177400, + "name" : "Google", + "id" : "xxxxxxxxxxxxxxxxxx1", + "affectedServersCount" : 2, + "asn" : 19994, + "providerName" : "Google", + "startDate" : "2022-03-01T23:31:11Z" + }, { + "affectedInterfacesCount" : 1, + "endDate" : "2022-03-01T23:31:11Z", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "affectedLocationsCount" : 1, + "endRoundId" : 1646177700, + "affectedTestsCount" : 1, + "type" : "app", + "providerType" : "SAAS", + "duration" : 214, + "startRoundId" : 1646177400, + "name" : "Google", + "id" : "xxxxxxxxxxxxxxxxxx1", + "affectedServersCount" : 2, + "asn" : 19994, + "providerName" : "Google", + "startDate" : "2022-03-01T23:31:11Z" + } ] + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "startDate" : "2022-03-01T01:30:00Z", + "endDate" : "2022-03-01T23:30:15Z", + "outageScope" : "all", + "providerName" : [ "Telia", "Amazon" ], + "interfaceNetwork" : [ "Telianet", "Cloudflare" ], + "applicationName" : [ "slack", "facebook" ] + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_app_outage": OperationExpectation( + operation_id="get_app_outage", + method="GET", + path="/internet-insights/outages/app/{outageId}", + path_param_examples={ + "outageId": 'F73E24F17E4996923196826A208BB572508A8EB13BEE14B0', + }, + success_status=200, + success_body=json.loads(""" + + { + "affectedDomains" : [ "amazon.com", "amazon.com" ], + "affectedTests" : [ { + "name" : "amazon-test2", + "id" : 5 + }, { + "name" : "amazon-test2", + "id" : 5 + } ], + "endDate" : "2023-01-27T20:53:51.256Z", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "endRoundId" : 1674852600, + "providerType" : "SAAS", + "duration" : 180, + "startRoundId" : 1674852600, + "affectedAgents" : [ { + "name" : "London, England", + "id" : 11 + }, { + "name" : "London, England", + "id" : 11 + } ], + "id" : "0CC4C4209887126DE42E92252FB43962CBB3193147F318EA", + "providerName" : "Amazon Web Services", + "applicationName" : "Amazon Web Services", + "startDate" : "2023-01-27T20:50:51.256Z", + "errors" : [ "HTTP_SERVER_TIMEOUT", "HTTP_SERVER_TIMEOUT" ], + "affectedLocations" : [ { + "location" : "Chicago, Illinois, US", + "affectedServers" : [ { + "prefix" : "123.176.185.0/23", + "domain" : "amazon.com" + }, { + "prefix" : "123.176.185.0/23", + "domain" : "amazon.com" + } ] + }, { + "location" : "Chicago, Illinois, US", + "affectedServers" : [ { + "prefix" : "123.176.185.0/23", + "domain" : "amazon.com" + }, { + "prefix" : "123.176.185.0/23", + "domain" : "amazon.com" + } ] + } ] + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_network_outage": OperationExpectation( + operation_id="get_network_outage", + method="GET", + path="/internet-insights/outages/net/{outageId}", + path_param_examples={ + "outageId": '694D8656960F34F76489BCE5E9BCD58EC53027462740D75F', + }, + success_status=200, + success_body=json.loads(""" + + { + "affectedDomains" : [ "periodic-failure.com", "periodic-failure.com" ], + "affectedTests" : [ { + "name" : "amazon-test2", + "id" : 5 + }, { + "name" : "amazon-test2", + "id" : 5 + } ], + "endDate" : "2023-01-27T20:53:51.256Z", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "networkName" : "Rackspace Hosting", + "endRoundId" : 1674852600, + "providerType" : "IAAS", + "duration" : 180, + "startRoundId" : 1674852600, + "affectedAgents" : [ { + "name" : "London, England", + "id" : 11 + }, { + "name" : "London, England", + "id" : 11 + } ], + "id" : "8EF2760862C705783A2F8BCBAAABB44F28DBC670DBA3B610", + "asn" : 19994, + "providerName" : "Rackspace", + "startDate" : "2023-01-27T20:50:51.256Z", + "affectedLocations" : [ { + "affectedInterfaces" : [ "50.51.52.53", "50.51.52.53" ], + "location" : "Chicago, Illinois, US" + }, { + "affectedInterfaces" : [ "50.51.52.53", "50.51.52.53" ], + "location" : "Chicago, Illinois, US" + } ] + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + +} diff --git a/thousandeyes-sdk-internet-insights/test/test_internet_insights_catalog_providers_api_integration.py b/thousandeyes-sdk-internet-insights/test/test_internet_insights_catalog_providers_api_integration.py new file mode 100644 index 00000000..689bbf01 --- /dev/null +++ b/thousandeyes-sdk-internet-insights/test/test_internet_insights_catalog_providers_api_integration.py @@ -0,0 +1,669 @@ +# coding: utf-8 + +""" + Internet Insights API + + **Note:** All Internet Insights APIs are not available for ThousandEyes for Government instance. We are happy to announce the release of the Internet Insights API set. This limited release includes endpoints that: * Make our catalog provider and Internet outage data accessible to API users. * Provide access to advanced filtering, which is part of our next-generation API efforts to allow API users to fine-tune queries across all of our APIs in a consistent manner. Internet Insights provide visibility into core Internet infrastructure, including ISPs, DNS providers, IaaS, CDNs , and SaaS providers. It tracks the macro-level impact of Internet events on individual users and enterprise networks connecting at the edge of the Internet. These events include Outages, Routing hijacks and leaks, DDoS attacks, And political interference, among others. Future releases of the Internet Insights API set will further unlock access to core Internet Insights functionality, unlocking potential integrations to enrich customer process flows. For more information about Internet Insights, see the [Internet Insights](https://docs.thousandeyes.com/product-documentation/internet-insights). + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.internet_insights.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.internet_insights.api.internet_insights_catalog_providers_api import InternetInsightsCatalogProvidersApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestInternetInsightsCatalogProvidersApiIntegration(IntegrationTestBase): + """InternetInsightsCatalogProvidersApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = InternetInsightsCatalogProvidersApi(self.api_client) + + + def test_filter_catalog_providers_happy_path(self) -> None: + """Integration test for filter_catalog_providers success path""" + request_body_json = """ + + { + "providerName" : "Amazon Web Services", + "providerType" : "IAAS", + "region" : "North America", + "location" : "San Jose, US", + "asn" : "Amazon.com, Inc.", + "included" : true + } + + """ + api_catalog_provider_filter = thousandeyes_sdk.internet_insights.models.ApiCatalogProviderFilter.from_json(request_body_json) + aid = '1234' + response_body_json = """ + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "providers" : [ { + "interfacesCount" : 15, + "locationsCount" : 50, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "countriesCount" : 2, + "dataType" : "Application", + "id" : "85602a0a-54a7-4e97-946e-67492ef1fa26", + "region" : "North America", + "asnsCount" : 10, + "included" : true, + "providerName" : "Amazon Web Services", + "providerType" : "IAAS" + }, { + "interfacesCount" : 15, + "locationsCount" : 50, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "countriesCount" : 2, + "dataType" : "Application", + "id" : "85602a0a-54a7-4e97-946e-67492ef1fa26", + "region" : "North America", + "asnsCount" : 10, + "included" : true, + "providerName" : "Amazon Web Services", + "providerType" : "IAAS" + } ] + } + """ + expected_response = json.loads(response_body_json) + response = self.api.filter_catalog_providers( + + api_catalog_provider_filter=api_catalog_provider_filter, + + aid=aid, + + _headers=self.te_headers("filter_catalog_providers"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_filter_catalog_providers_error_400(self) -> None: + """Integration test for filter_catalog_providers error path (HTTP 400)""" + request_body_json = """ + + { + "providerName" : "Amazon Web Services", + "providerType" : "IAAS", + "region" : "North America", + "location" : "San Jose, US", + "asn" : "Amazon.com, Inc.", + "included" : true + } + + """ + api_catalog_provider_filter = thousandeyes_sdk.internet_insights.models.ApiCatalogProviderFilter.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.filter_catalog_providers( + + api_catalog_provider_filter=api_catalog_provider_filter, + + aid=aid, + + _headers=self.te_headers("filter_catalog_providers", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_filter_catalog_providers_error_401(self) -> None: + """Integration test for filter_catalog_providers error path (HTTP 401)""" + request_body_json = """ + + { + "providerName" : "Amazon Web Services", + "providerType" : "IAAS", + "region" : "North America", + "location" : "San Jose, US", + "asn" : "Amazon.com, Inc.", + "included" : true + } + + """ + api_catalog_provider_filter = thousandeyes_sdk.internet_insights.models.ApiCatalogProviderFilter.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.filter_catalog_providers( + + api_catalog_provider_filter=api_catalog_provider_filter, + + aid=aid, + + _headers=self.te_headers("filter_catalog_providers", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_filter_catalog_providers_error_403(self) -> None: + """Integration test for filter_catalog_providers error path (HTTP 403)""" + request_body_json = """ + + { + "providerName" : "Amazon Web Services", + "providerType" : "IAAS", + "region" : "North America", + "location" : "San Jose, US", + "asn" : "Amazon.com, Inc.", + "included" : true + } + + """ + api_catalog_provider_filter = thousandeyes_sdk.internet_insights.models.ApiCatalogProviderFilter.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.filter_catalog_providers( + + api_catalog_provider_filter=api_catalog_provider_filter, + + aid=aid, + + _headers=self.te_headers("filter_catalog_providers", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_filter_catalog_providers_error_404(self) -> None: + """Integration test for filter_catalog_providers error path (HTTP 404)""" + request_body_json = """ + + { + "providerName" : "Amazon Web Services", + "providerType" : "IAAS", + "region" : "North America", + "location" : "San Jose, US", + "asn" : "Amazon.com, Inc.", + "included" : true + } + + """ + api_catalog_provider_filter = thousandeyes_sdk.internet_insights.models.ApiCatalogProviderFilter.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.filter_catalog_providers( + + api_catalog_provider_filter=api_catalog_provider_filter, + + aid=aid, + + _headers=self.te_headers("filter_catalog_providers", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_filter_catalog_providers_error_429(self) -> None: + """Integration test for filter_catalog_providers error path (HTTP 429)""" + request_body_json = """ + + { + "providerName" : "Amazon Web Services", + "providerType" : "IAAS", + "region" : "North America", + "location" : "San Jose, US", + "asn" : "Amazon.com, Inc.", + "included" : true + } + + """ + api_catalog_provider_filter = thousandeyes_sdk.internet_insights.models.ApiCatalogProviderFilter.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.filter_catalog_providers( + + api_catalog_provider_filter=api_catalog_provider_filter, + + aid=aid, + + _headers=self.te_headers("filter_catalog_providers", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_filter_catalog_providers_error_500(self) -> None: + """Integration test for filter_catalog_providers error path (HTTP 500)""" + request_body_json = """ + + { + "providerName" : "Amazon Web Services", + "providerType" : "IAAS", + "region" : "North America", + "location" : "San Jose, US", + "asn" : "Amazon.com, Inc.", + "included" : true + } + + """ + api_catalog_provider_filter = thousandeyes_sdk.internet_insights.models.ApiCatalogProviderFilter.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.filter_catalog_providers( + + api_catalog_provider_filter=api_catalog_provider_filter, + + aid=aid, + + _headers=self.te_headers("filter_catalog_providers", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_filter_catalog_providers_error_502(self) -> None: + """Integration test for filter_catalog_providers error path (HTTP 502)""" + request_body_json = """ + + { + "providerName" : "Amazon Web Services", + "providerType" : "IAAS", + "region" : "North America", + "location" : "San Jose, US", + "asn" : "Amazon.com, Inc.", + "included" : true + } + + """ + api_catalog_provider_filter = thousandeyes_sdk.internet_insights.models.ApiCatalogProviderFilter.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.filter_catalog_providers( + + api_catalog_provider_filter=api_catalog_provider_filter, + + aid=aid, + + _headers=self.te_headers("filter_catalog_providers", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_catalog_provider_happy_path(self) -> None: + """Integration test for get_catalog_provider success path""" + provider_id = '85602a0a-54a7-4e97-946e-67492ef1fa26' + aid = '1234' + response_body_json = """ + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dataType" : "Application", + "asns" : [ { + "name" : "LVLT-1 - Level 3 Communications, Inc.", + "id" : 1 + }, { + "name" : "LVLT-1 - Level 3 Communications, Inc.", + "id" : 1 + } ], + "locations" : [ { + "interfacesCount" : 5, + "location" : "San Jose, US" + }, { + "interfacesCount" : 5, + "location" : "San Jose, US" + } ], + "id" : "85602a0a-54a7-4e97-946e-67492ef1fa26", + "region" : "North America", + "providerName" : "Amazon Web Services", + "providerType" : "IAAS" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_catalog_provider( + + provider_id=provider_id, + + aid=aid, + + _headers=self.te_headers("get_catalog_provider"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_catalog_provider_error_400(self) -> None: + """Integration test for get_catalog_provider error path (HTTP 400)""" + provider_id = '85602a0a-54a7-4e97-946e-67492ef1fa26' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.get_catalog_provider( + + provider_id=provider_id, + + aid=aid, + + _headers=self.te_headers("get_catalog_provider", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_catalog_provider_error_401(self) -> None: + """Integration test for get_catalog_provider error path (HTTP 401)""" + provider_id = '85602a0a-54a7-4e97-946e-67492ef1fa26' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_catalog_provider( + + provider_id=provider_id, + + aid=aid, + + _headers=self.te_headers("get_catalog_provider", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_catalog_provider_error_403(self) -> None: + """Integration test for get_catalog_provider error path (HTTP 403)""" + provider_id = '85602a0a-54a7-4e97-946e-67492ef1fa26' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_catalog_provider( + + provider_id=provider_id, + + aid=aid, + + _headers=self.te_headers("get_catalog_provider", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_catalog_provider_error_404(self) -> None: + """Integration test for get_catalog_provider error path (HTTP 404)""" + provider_id = '85602a0a-54a7-4e97-946e-67492ef1fa26' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_catalog_provider( + + provider_id=provider_id, + + aid=aid, + + _headers=self.te_headers("get_catalog_provider", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_catalog_provider_error_429(self) -> None: + """Integration test for get_catalog_provider error path (HTTP 429)""" + provider_id = '85602a0a-54a7-4e97-946e-67492ef1fa26' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_catalog_provider( + + provider_id=provider_id, + + aid=aid, + + _headers=self.te_headers("get_catalog_provider", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_catalog_provider_error_500(self) -> None: + """Integration test for get_catalog_provider error path (HTTP 500)""" + provider_id = '85602a0a-54a7-4e97-946e-67492ef1fa26' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_catalog_provider( + + provider_id=provider_id, + + aid=aid, + + _headers=self.te_headers("get_catalog_provider", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_catalog_provider_error_502(self) -> None: + """Integration test for get_catalog_provider error path (HTTP 502)""" + provider_id = '85602a0a-54a7-4e97-946e-67492ef1fa26' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.get_catalog_provider( + + provider_id=provider_id, + + aid=aid, + + _headers=self.te_headers("get_catalog_provider", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-internet-insights/test/test_internet_insights_outages_api_integration.py b/thousandeyes-sdk-internet-insights/test/test_internet_insights_outages_api_integration.py new file mode 100644 index 00000000..cd7d3990 --- /dev/null +++ b/thousandeyes-sdk-internet-insights/test/test_internet_insights_outages_api_integration.py @@ -0,0 +1,972 @@ +# coding: utf-8 + +""" + Internet Insights API + + **Note:** All Internet Insights APIs are not available for ThousandEyes for Government instance. We are happy to announce the release of the Internet Insights API set. This limited release includes endpoints that: * Make our catalog provider and Internet outage data accessible to API users. * Provide access to advanced filtering, which is part of our next-generation API efforts to allow API users to fine-tune queries across all of our APIs in a consistent manner. Internet Insights provide visibility into core Internet infrastructure, including ISPs, DNS providers, IaaS, CDNs , and SaaS providers. It tracks the macro-level impact of Internet events on individual users and enterprise networks connecting at the edge of the Internet. These events include Outages, Routing hijacks and leaks, DDoS attacks, And political interference, among others. Future releases of the Internet Insights API set will further unlock access to core Internet Insights functionality, unlocking potential integrations to enrich customer process flows. For more information about Internet Insights, see the [Internet Insights](https://docs.thousandeyes.com/product-documentation/internet-insights). + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.internet_insights.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.internet_insights.api.internet_insights_outages_api import InternetInsightsOutagesApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestInternetInsightsOutagesApiIntegration(IntegrationTestBase): + """InternetInsightsOutagesApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = InternetInsightsOutagesApi(self.api_client) + + + def test_filter_outages_happy_path(self) -> None: + """Integration test for filter_outages success path""" + request_body_json = """ + + { + "startDate" : "2022-03-01T01:30:00Z", + "endDate" : "2022-03-01T23:30:15Z", + "outageScope" : "all", + "providerName" : [ "Telia", "Amazon" ], + "interfaceNetwork" : [ "Telianet", "Cloudflare" ], + "applicationName" : [ "slack", "facebook" ] + } + + """ + api_outage_filter = thousandeyes_sdk.internet_insights.models.ApiOutageFilter.from_json(request_body_json) + aid = '1234' + response_body_json = """ + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "outages" : [ { + "affectedInterfacesCount" : 1, + "endDate" : "2022-03-01T23:31:11Z", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "affectedLocationsCount" : 1, + "endRoundId" : 1646177700, + "affectedTestsCount" : 1, + "type" : "app", + "providerType" : "SAAS", + "duration" : 214, + "startRoundId" : 1646177400, + "name" : "Google", + "id" : "xxxxxxxxxxxxxxxxxx1", + "affectedServersCount" : 2, + "asn" : 19994, + "providerName" : "Google", + "startDate" : "2022-03-01T23:31:11Z" + }, { + "affectedInterfacesCount" : 1, + "endDate" : "2022-03-01T23:31:11Z", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "affectedLocationsCount" : 1, + "endRoundId" : 1646177700, + "affectedTestsCount" : 1, + "type" : "app", + "providerType" : "SAAS", + "duration" : 214, + "startRoundId" : 1646177400, + "name" : "Google", + "id" : "xxxxxxxxxxxxxxxxxx1", + "affectedServersCount" : 2, + "asn" : 19994, + "providerName" : "Google", + "startDate" : "2022-03-01T23:31:11Z" + } ] + } + """ + expected_response = json.loads(response_body_json) + response = self.api.filter_outages( + + api_outage_filter=api_outage_filter, + + aid=aid, + + _headers=self.te_headers("filter_outages"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_filter_outages_error_400(self) -> None: + """Integration test for filter_outages error path (HTTP 400)""" + request_body_json = """ + + { + "startDate" : "2022-03-01T01:30:00Z", + "endDate" : "2022-03-01T23:30:15Z", + "outageScope" : "all", + "providerName" : [ "Telia", "Amazon" ], + "interfaceNetwork" : [ "Telianet", "Cloudflare" ], + "applicationName" : [ "slack", "facebook" ] + } + + """ + api_outage_filter = thousandeyes_sdk.internet_insights.models.ApiOutageFilter.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.filter_outages( + + api_outage_filter=api_outage_filter, + + aid=aid, + + _headers=self.te_headers("filter_outages", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_filter_outages_error_401(self) -> None: + """Integration test for filter_outages error path (HTTP 401)""" + request_body_json = """ + + { + "startDate" : "2022-03-01T01:30:00Z", + "endDate" : "2022-03-01T23:30:15Z", + "outageScope" : "all", + "providerName" : [ "Telia", "Amazon" ], + "interfaceNetwork" : [ "Telianet", "Cloudflare" ], + "applicationName" : [ "slack", "facebook" ] + } + + """ + api_outage_filter = thousandeyes_sdk.internet_insights.models.ApiOutageFilter.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.filter_outages( + + api_outage_filter=api_outage_filter, + + aid=aid, + + _headers=self.te_headers("filter_outages", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_filter_outages_error_403(self) -> None: + """Integration test for filter_outages error path (HTTP 403)""" + request_body_json = """ + + { + "startDate" : "2022-03-01T01:30:00Z", + "endDate" : "2022-03-01T23:30:15Z", + "outageScope" : "all", + "providerName" : [ "Telia", "Amazon" ], + "interfaceNetwork" : [ "Telianet", "Cloudflare" ], + "applicationName" : [ "slack", "facebook" ] + } + + """ + api_outage_filter = thousandeyes_sdk.internet_insights.models.ApiOutageFilter.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.filter_outages( + + api_outage_filter=api_outage_filter, + + aid=aid, + + _headers=self.te_headers("filter_outages", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_filter_outages_error_404(self) -> None: + """Integration test for filter_outages error path (HTTP 404)""" + request_body_json = """ + + { + "startDate" : "2022-03-01T01:30:00Z", + "endDate" : "2022-03-01T23:30:15Z", + "outageScope" : "all", + "providerName" : [ "Telia", "Amazon" ], + "interfaceNetwork" : [ "Telianet", "Cloudflare" ], + "applicationName" : [ "slack", "facebook" ] + } + + """ + api_outage_filter = thousandeyes_sdk.internet_insights.models.ApiOutageFilter.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.filter_outages( + + api_outage_filter=api_outage_filter, + + aid=aid, + + _headers=self.te_headers("filter_outages", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_filter_outages_error_429(self) -> None: + """Integration test for filter_outages error path (HTTP 429)""" + request_body_json = """ + + { + "startDate" : "2022-03-01T01:30:00Z", + "endDate" : "2022-03-01T23:30:15Z", + "outageScope" : "all", + "providerName" : [ "Telia", "Amazon" ], + "interfaceNetwork" : [ "Telianet", "Cloudflare" ], + "applicationName" : [ "slack", "facebook" ] + } + + """ + api_outage_filter = thousandeyes_sdk.internet_insights.models.ApiOutageFilter.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.filter_outages( + + api_outage_filter=api_outage_filter, + + aid=aid, + + _headers=self.te_headers("filter_outages", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_filter_outages_error_500(self) -> None: + """Integration test for filter_outages error path (HTTP 500)""" + request_body_json = """ + + { + "startDate" : "2022-03-01T01:30:00Z", + "endDate" : "2022-03-01T23:30:15Z", + "outageScope" : "all", + "providerName" : [ "Telia", "Amazon" ], + "interfaceNetwork" : [ "Telianet", "Cloudflare" ], + "applicationName" : [ "slack", "facebook" ] + } + + """ + api_outage_filter = thousandeyes_sdk.internet_insights.models.ApiOutageFilter.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.filter_outages( + + api_outage_filter=api_outage_filter, + + aid=aid, + + _headers=self.te_headers("filter_outages", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_filter_outages_error_502(self) -> None: + """Integration test for filter_outages error path (HTTP 502)""" + request_body_json = """ + + { + "startDate" : "2022-03-01T01:30:00Z", + "endDate" : "2022-03-01T23:30:15Z", + "outageScope" : "all", + "providerName" : [ "Telia", "Amazon" ], + "interfaceNetwork" : [ "Telianet", "Cloudflare" ], + "applicationName" : [ "slack", "facebook" ] + } + + """ + api_outage_filter = thousandeyes_sdk.internet_insights.models.ApiOutageFilter.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.filter_outages( + + api_outage_filter=api_outage_filter, + + aid=aid, + + _headers=self.te_headers("filter_outages", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_app_outage_happy_path(self) -> None: + """Integration test for get_app_outage success path""" + outage_id = 'F73E24F17E4996923196826A208BB572508A8EB13BEE14B0' + aid = '1234' + response_body_json = """ + { + "affectedDomains" : [ "amazon.com", "amazon.com" ], + "affectedTests" : [ { + "name" : "amazon-test2", + "id" : 5 + }, { + "name" : "amazon-test2", + "id" : 5 + } ], + "endDate" : "2023-01-27T20:53:51.256Z", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "endRoundId" : 1674852600, + "providerType" : "SAAS", + "duration" : 180, + "startRoundId" : 1674852600, + "affectedAgents" : [ { + "name" : "London, England", + "id" : 11 + }, { + "name" : "London, England", + "id" : 11 + } ], + "id" : "0CC4C4209887126DE42E92252FB43962CBB3193147F318EA", + "providerName" : "Amazon Web Services", + "applicationName" : "Amazon Web Services", + "startDate" : "2023-01-27T20:50:51.256Z", + "errors" : [ "HTTP_SERVER_TIMEOUT", "HTTP_SERVER_TIMEOUT" ], + "affectedLocations" : [ { + "location" : "Chicago, Illinois, US", + "affectedServers" : [ { + "prefix" : "123.176.185.0/23", + "domain" : "amazon.com" + }, { + "prefix" : "123.176.185.0/23", + "domain" : "amazon.com" + } ] + }, { + "location" : "Chicago, Illinois, US", + "affectedServers" : [ { + "prefix" : "123.176.185.0/23", + "domain" : "amazon.com" + }, { + "prefix" : "123.176.185.0/23", + "domain" : "amazon.com" + } ] + } ] + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_app_outage( + + outage_id=outage_id, + + aid=aid, + + _headers=self.te_headers("get_app_outage"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_app_outage_error_400(self) -> None: + """Integration test for get_app_outage error path (HTTP 400)""" + outage_id = 'F73E24F17E4996923196826A208BB572508A8EB13BEE14B0' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.get_app_outage( + + outage_id=outage_id, + + aid=aid, + + _headers=self.te_headers("get_app_outage", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_app_outage_error_401(self) -> None: + """Integration test for get_app_outage error path (HTTP 401)""" + outage_id = 'F73E24F17E4996923196826A208BB572508A8EB13BEE14B0' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_app_outage( + + outage_id=outage_id, + + aid=aid, + + _headers=self.te_headers("get_app_outage", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_app_outage_error_403(self) -> None: + """Integration test for get_app_outage error path (HTTP 403)""" + outage_id = 'F73E24F17E4996923196826A208BB572508A8EB13BEE14B0' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_app_outage( + + outage_id=outage_id, + + aid=aid, + + _headers=self.te_headers("get_app_outage", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_app_outage_error_404(self) -> None: + """Integration test for get_app_outage error path (HTTP 404)""" + outage_id = 'F73E24F17E4996923196826A208BB572508A8EB13BEE14B0' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_app_outage( + + outage_id=outage_id, + + aid=aid, + + _headers=self.te_headers("get_app_outage", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_app_outage_error_429(self) -> None: + """Integration test for get_app_outage error path (HTTP 429)""" + outage_id = 'F73E24F17E4996923196826A208BB572508A8EB13BEE14B0' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_app_outage( + + outage_id=outage_id, + + aid=aid, + + _headers=self.te_headers("get_app_outage", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_app_outage_error_500(self) -> None: + """Integration test for get_app_outage error path (HTTP 500)""" + outage_id = 'F73E24F17E4996923196826A208BB572508A8EB13BEE14B0' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_app_outage( + + outage_id=outage_id, + + aid=aid, + + _headers=self.te_headers("get_app_outage", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_app_outage_error_502(self) -> None: + """Integration test for get_app_outage error path (HTTP 502)""" + outage_id = 'F73E24F17E4996923196826A208BB572508A8EB13BEE14B0' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.get_app_outage( + + outage_id=outage_id, + + aid=aid, + + _headers=self.te_headers("get_app_outage", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_network_outage_happy_path(self) -> None: + """Integration test for get_network_outage success path""" + outage_id = '694D8656960F34F76489BCE5E9BCD58EC53027462740D75F' + aid = '1234' + response_body_json = """ + { + "affectedDomains" : [ "periodic-failure.com", "periodic-failure.com" ], + "affectedTests" : [ { + "name" : "amazon-test2", + "id" : 5 + }, { + "name" : "amazon-test2", + "id" : 5 + } ], + "endDate" : "2023-01-27T20:53:51.256Z", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "networkName" : "Rackspace Hosting", + "endRoundId" : 1674852600, + "providerType" : "IAAS", + "duration" : 180, + "startRoundId" : 1674852600, + "affectedAgents" : [ { + "name" : "London, England", + "id" : 11 + }, { + "name" : "London, England", + "id" : 11 + } ], + "id" : "8EF2760862C705783A2F8BCBAAABB44F28DBC670DBA3B610", + "asn" : 19994, + "providerName" : "Rackspace", + "startDate" : "2023-01-27T20:50:51.256Z", + "affectedLocations" : [ { + "affectedInterfaces" : [ "50.51.52.53", "50.51.52.53" ], + "location" : "Chicago, Illinois, US" + }, { + "affectedInterfaces" : [ "50.51.52.53", "50.51.52.53" ], + "location" : "Chicago, Illinois, US" + } ] + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_network_outage( + + outage_id=outage_id, + + aid=aid, + + _headers=self.te_headers("get_network_outage"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_network_outage_error_400(self) -> None: + """Integration test for get_network_outage error path (HTTP 400)""" + outage_id = '694D8656960F34F76489BCE5E9BCD58EC53027462740D75F' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.get_network_outage( + + outage_id=outage_id, + + aid=aid, + + _headers=self.te_headers("get_network_outage", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_network_outage_error_401(self) -> None: + """Integration test for get_network_outage error path (HTTP 401)""" + outage_id = '694D8656960F34F76489BCE5E9BCD58EC53027462740D75F' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_network_outage( + + outage_id=outage_id, + + aid=aid, + + _headers=self.te_headers("get_network_outage", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_network_outage_error_403(self) -> None: + """Integration test for get_network_outage error path (HTTP 403)""" + outage_id = '694D8656960F34F76489BCE5E9BCD58EC53027462740D75F' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_network_outage( + + outage_id=outage_id, + + aid=aid, + + _headers=self.te_headers("get_network_outage", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_network_outage_error_404(self) -> None: + """Integration test for get_network_outage error path (HTTP 404)""" + outage_id = '694D8656960F34F76489BCE5E9BCD58EC53027462740D75F' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_network_outage( + + outage_id=outage_id, + + aid=aid, + + _headers=self.te_headers("get_network_outage", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_network_outage_error_429(self) -> None: + """Integration test for get_network_outage error path (HTTP 429)""" + outage_id = '694D8656960F34F76489BCE5E9BCD58EC53027462740D75F' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_network_outage( + + outage_id=outage_id, + + aid=aid, + + _headers=self.te_headers("get_network_outage", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_network_outage_error_500(self) -> None: + """Integration test for get_network_outage error path (HTTP 500)""" + outage_id = '694D8656960F34F76489BCE5E9BCD58EC53027462740D75F' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_network_outage( + + outage_id=outage_id, + + aid=aid, + + _headers=self.te_headers("get_network_outage", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_network_outage_error_502(self) -> None: + """Integration test for get_network_outage error path (HTTP 502)""" + outage_id = '694D8656960F34F76489BCE5E9BCD58EC53027462740D75F' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.get_network_outage( + + outage_id=outage_id, + + aid=aid, + + _headers=self.te_headers("get_network_outage", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-internet-insights/test/test_utils.py b/thousandeyes-sdk-internet-insights/test/test_utils.py index 930528d9..37913f62 100644 --- a/thousandeyes-sdk-internet-insights/test/test_utils.py +++ b/thousandeyes-sdk-internet-insights/test/test_utils.py @@ -2,15 +2,36 @@ import json import unittest +from typing import Any from pydantic import BaseModel +def _project_onto_constructed(expected: Any, constructed: Any) -> Any: + """Keep only example fields that appear in the constructed model output.""" + if isinstance(constructed, dict): + if not isinstance(expected, dict): + return expected + return { + key: _project_onto_constructed(expected.get(key), value) + for key, value in constructed.items() + } + if isinstance(constructed, list): + if not isinstance(expected, list): + return expected + return [ + _project_onto_constructed(expected[index], value) + for index, value in enumerate(constructed) + ] + return expected + + def assert_constructed_model_matches_example_json(model: BaseModel, loaded_json: dict): test_case = unittest.TestCase() test_case.maxDiff = None test_case.assertIsNotNone(model) constructed_json = json.loads(model.to_json()) - sorted_loaded_json = json.dumps(loaded_json, sort_keys=True) + projected_loaded_json = _project_onto_constructed(loaded_json, constructed_json) + sorted_loaded_json = json.dumps(projected_loaded_json, sort_keys=True) sorted_constructed_json = json.dumps(constructed_json, sort_keys=True) test_case.assertEqual(sorted_loaded_json, sorted_constructed_json) diff --git a/thousandeyes-sdk-snapshots/test/conftest.py b/thousandeyes-sdk-snapshots/test/conftest.py new file mode 100644 index 00000000..2edba7b3 --- /dev/null +++ b/thousandeyes-sdk-snapshots/test/conftest.py @@ -0,0 +1,7 @@ +import sys +from pathlib import Path + +_repo_root = Path(__file__).resolve().parents[2] +_core_test_support = _repo_root / "thousandeyes-sdk-core" / "test" +if str(_core_test_support) not in sys.path: + sys.path.insert(0, str(_core_test_support)) diff --git a/thousandeyes-sdk-snapshots/test/integration_test_utils.py b/thousandeyes-sdk-snapshots/test/integration_test_utils.py new file mode 100644 index 00000000..f7109bbb --- /dev/null +++ b/thousandeyes-sdk-snapshots/test/integration_test_utils.py @@ -0,0 +1,37 @@ +# coding: utf-8 + +""" + Test Snapshots API + + Creates a new test snapshot in ThousandEyes. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from thousandeyes_sdk.core.api_client import ApiClient +from thousandeyes_sdk.core.configuration import Configuration +from sdk_test_support.mock_server import ERROR_STATUS_HEADER, OPERATION_ID_HEADER, MockApiServer + +from .mock_manifest import OPERATION_MANIFEST + + +class IntegrationTestBase(unittest.TestCase): + def setUp(self) -> None: + self.server = MockApiServer(OPERATION_MANIFEST) + self.server.start() + configuration = Configuration(host=self.server.base_url, access_token="test-token") + self.api_client = ApiClient(configuration=configuration) + + def tearDown(self) -> None: + self.server.stop() + + def te_headers(self, operation_id: str, error_status=None): + headers = {OPERATION_ID_HEADER: operation_id} + if error_status is not None: + headers[ERROR_STATUS_HEADER] = error_status + return headers diff --git a/thousandeyes-sdk-snapshots/test/mock_manifest.py b/thousandeyes-sdk-snapshots/test/mock_manifest.py new file mode 100644 index 00000000..0b88c58d --- /dev/null +++ b/thousandeyes-sdk-snapshots/test/mock_manifest.py @@ -0,0 +1,213 @@ +# coding: utf-8 + +""" + Test Snapshots API + + Creates a new test snapshot in ThousandEyes. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json + +from sdk_test_support.mock_server_types import ErrorResponseExpectation, OperationExpectation + +OPERATION_MANIFEST = { + + "create_test_snapshot": OperationExpectation( + operation_id="create_test_snapshot", + method="POST", + path="/tests/{testId}/snapshot", + path_param_examples={ + "testId": '202701', + }, + success_status=201, + success_body=json.loads(""" + + { + "shareDate" : "2023-06-06T00:00:00Z", + "uid" : "281474976810911", + "test" : { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + }, + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "startRoundId" : 1538784000, + "displayName" : "Snapshot created through API", + "endRoundId" : 1538787600, + "testId" : "281474976710801", + "extraParams" : "params", + "id" : "wdiac", + "roundId" : 1538784000, + "sourceTestId" : "281474976710706" + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "endDate" : "2023-06-06T01:00:00Z", + "displayName" : "Snapshot created through API", + "isPublic" : false, + "startDate" : "2023-06-06T00:00:00Z" + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + +} diff --git a/thousandeyes-sdk-snapshots/test/test_test_snapshots_api_integration.py b/thousandeyes-sdk-snapshots/test/test_test_snapshots_api_integration.py new file mode 100644 index 00000000..a8bf42de --- /dev/null +++ b/thousandeyes-sdk-snapshots/test/test_test_snapshots_api_integration.py @@ -0,0 +1,427 @@ +# coding: utf-8 + +""" + Test Snapshots API + + Creates a new test snapshot in ThousandEyes. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.snapshots.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.snapshots.api.test_snapshots_api import TestSnapshotsApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestTestSnapshotsApiIntegration(IntegrationTestBase): + """TestSnapshotsApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = TestSnapshotsApi(self.api_client) + + + def test_create_test_snapshot_happy_path(self) -> None: + """Integration test for create_test_snapshot success path""" + request_body_json = """ + + { + "endDate" : "2023-06-06T01:00:00Z", + "displayName" : "Snapshot created through API", + "isPublic" : false, + "startDate" : "2023-06-06T00:00:00Z" + } + + """ + snapshot_request = thousandeyes_sdk.snapshots.models.SnapshotRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + response_body_json = """ + { + "shareDate" : "2023-06-06T00:00:00Z", + "uid" : "281474976810911", + "test" : { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + }, + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "startRoundId" : 1538784000, + "displayName" : "Snapshot created through API", + "endRoundId" : 1538787600, + "testId" : "281474976710801", + "extraParams" : "params", + "id" : "wdiac", + "roundId" : 1538784000, + "sourceTestId" : "281474976710706" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.create_test_snapshot( + + test_id=test_id, + + snapshot_request=snapshot_request, + + aid=aid, + + _headers=self.te_headers("create_test_snapshot"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_create_test_snapshot_error_400(self) -> None: + """Integration test for create_test_snapshot error path (HTTP 400)""" + request_body_json = """ + + { + "endDate" : "2023-06-06T01:00:00Z", + "displayName" : "Snapshot created through API", + "isPublic" : false, + "startDate" : "2023-06-06T00:00:00Z" + } + + """ + snapshot_request = thousandeyes_sdk.snapshots.models.SnapshotRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.create_test_snapshot( + + test_id=test_id, + + snapshot_request=snapshot_request, + + aid=aid, + + _headers=self.te_headers("create_test_snapshot", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_test_snapshot_error_401(self) -> None: + """Integration test for create_test_snapshot error path (HTTP 401)""" + request_body_json = """ + + { + "endDate" : "2023-06-06T01:00:00Z", + "displayName" : "Snapshot created through API", + "isPublic" : false, + "startDate" : "2023-06-06T00:00:00Z" + } + + """ + snapshot_request = thousandeyes_sdk.snapshots.models.SnapshotRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.create_test_snapshot( + + test_id=test_id, + + snapshot_request=snapshot_request, + + aid=aid, + + _headers=self.te_headers("create_test_snapshot", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_test_snapshot_error_403(self) -> None: + """Integration test for create_test_snapshot error path (HTTP 403)""" + request_body_json = """ + + { + "endDate" : "2023-06-06T01:00:00Z", + "displayName" : "Snapshot created through API", + "isPublic" : false, + "startDate" : "2023-06-06T00:00:00Z" + } + + """ + snapshot_request = thousandeyes_sdk.snapshots.models.SnapshotRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.create_test_snapshot( + + test_id=test_id, + + snapshot_request=snapshot_request, + + aid=aid, + + _headers=self.te_headers("create_test_snapshot", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_test_snapshot_error_404(self) -> None: + """Integration test for create_test_snapshot error path (HTTP 404)""" + request_body_json = """ + + { + "endDate" : "2023-06-06T01:00:00Z", + "displayName" : "Snapshot created through API", + "isPublic" : false, + "startDate" : "2023-06-06T00:00:00Z" + } + + """ + snapshot_request = thousandeyes_sdk.snapshots.models.SnapshotRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.create_test_snapshot( + + test_id=test_id, + + snapshot_request=snapshot_request, + + aid=aid, + + _headers=self.te_headers("create_test_snapshot", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_test_snapshot_error_429(self) -> None: + """Integration test for create_test_snapshot error path (HTTP 429)""" + request_body_json = """ + + { + "endDate" : "2023-06-06T01:00:00Z", + "displayName" : "Snapshot created through API", + "isPublic" : false, + "startDate" : "2023-06-06T00:00:00Z" + } + + """ + snapshot_request = thousandeyes_sdk.snapshots.models.SnapshotRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.create_test_snapshot( + + test_id=test_id, + + snapshot_request=snapshot_request, + + aid=aid, + + _headers=self.te_headers("create_test_snapshot", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_test_snapshot_error_500(self) -> None: + """Integration test for create_test_snapshot error path (HTTP 500)""" + request_body_json = """ + + { + "endDate" : "2023-06-06T01:00:00Z", + "displayName" : "Snapshot created through API", + "isPublic" : false, + "startDate" : "2023-06-06T00:00:00Z" + } + + """ + snapshot_request = thousandeyes_sdk.snapshots.models.SnapshotRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.create_test_snapshot( + + test_id=test_id, + + snapshot_request=snapshot_request, + + aid=aid, + + _headers=self.te_headers("create_test_snapshot", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_test_snapshot_error_502(self) -> None: + """Integration test for create_test_snapshot error path (HTTP 502)""" + request_body_json = """ + + { + "endDate" : "2023-06-06T01:00:00Z", + "displayName" : "Snapshot created through API", + "isPublic" : false, + "startDate" : "2023-06-06T00:00:00Z" + } + + """ + snapshot_request = thousandeyes_sdk.snapshots.models.SnapshotRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.create_test_snapshot( + + test_id=test_id, + + snapshot_request=snapshot_request, + + aid=aid, + + _headers=self.te_headers("create_test_snapshot", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-snapshots/test/test_utils.py b/thousandeyes-sdk-snapshots/test/test_utils.py index 930528d9..37913f62 100644 --- a/thousandeyes-sdk-snapshots/test/test_utils.py +++ b/thousandeyes-sdk-snapshots/test/test_utils.py @@ -2,15 +2,36 @@ import json import unittest +from typing import Any from pydantic import BaseModel +def _project_onto_constructed(expected: Any, constructed: Any) -> Any: + """Keep only example fields that appear in the constructed model output.""" + if isinstance(constructed, dict): + if not isinstance(expected, dict): + return expected + return { + key: _project_onto_constructed(expected.get(key), value) + for key, value in constructed.items() + } + if isinstance(constructed, list): + if not isinstance(expected, list): + return expected + return [ + _project_onto_constructed(expected[index], value) + for index, value in enumerate(constructed) + ] + return expected + + def assert_constructed_model_matches_example_json(model: BaseModel, loaded_json: dict): test_case = unittest.TestCase() test_case.maxDiff = None test_case.assertIsNotNone(model) constructed_json = json.loads(model.to_json()) - sorted_loaded_json = json.dumps(loaded_json, sort_keys=True) + projected_loaded_json = _project_onto_constructed(loaded_json, constructed_json) + sorted_loaded_json = json.dumps(projected_loaded_json, sort_keys=True) sorted_constructed_json = json.dumps(constructed_json, sort_keys=True) test_case.assertEqual(sorted_loaded_json, sorted_constructed_json) diff --git a/thousandeyes-sdk-streaming/test/conftest.py b/thousandeyes-sdk-streaming/test/conftest.py new file mode 100644 index 00000000..2edba7b3 --- /dev/null +++ b/thousandeyes-sdk-streaming/test/conftest.py @@ -0,0 +1,7 @@ +import sys +from pathlib import Path + +_repo_root = Path(__file__).resolve().parents[2] +_core_test_support = _repo_root / "thousandeyes-sdk-core" / "test" +if str(_core_test_support) not in sys.path: + sys.path.insert(0, str(_core_test_support)) diff --git a/thousandeyes-sdk-streaming/test/integration_test_utils.py b/thousandeyes-sdk-streaming/test/integration_test_utils.py new file mode 100644 index 00000000..20108a9f --- /dev/null +++ b/thousandeyes-sdk-streaming/test/integration_test_utils.py @@ -0,0 +1,37 @@ +# coding: utf-8 + +""" + ThousandEyes for OpenTelemetry API + + **Note:** The following ThousandEyes for OpenTelemetry API capabilities are not available for ThousandEyes for Government instance: * Traces * OTel-based integrations that rely on connectors and operations, including: * Splunk Cloud Platform HEC * Splunk Enterprise HEC * Splunk Observability APM * Dynatrace Observability APM ThousandEyes for OpenTelemetry provides machine-to-machine integration between ThousandEyes and its customers. It allows you to export ThousandEyes telemetry data in OTel format, which is widely used in the industry. With ThousandEyes for OTel, you can leverage frameworks widely used in the observability domain - such as Splunk, Grafana, and Honeycomb - to capture and analyze ThousandEyes data. Any client that supports OTel can use ThousandEyes for OpenTelemetry. ThousandEyes for OTel is made up of the following components: * Data streaming APIs that you can use to configure and enable your ThousandEyes tests with OTel-compatible streams, in particular to configure how ThousandEyes telemetry data is exported to client integrations. * A set of streaming pipelines called _collectors_ that actively fetch ThousandEyes network test data, enrich the data with some additional detail, filter, and push the data to the customer-configured endpoints, depending on what you configure via the public APIs. * Third-party OTel collectors that receive, transform, filter, and export different metrics to client applications such as AppD, or any other OTel-capable client configuration. For more information about ThousandEyes for OpenTelemetry, see the [product documentation](https://docs.thousandeyes.com/product-documentation/integration-guides/opentelemetry). + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from thousandeyes_sdk.core.api_client import ApiClient +from thousandeyes_sdk.core.configuration import Configuration +from sdk_test_support.mock_server import ERROR_STATUS_HEADER, OPERATION_ID_HEADER, MockApiServer + +from .mock_manifest import OPERATION_MANIFEST + + +class IntegrationTestBase(unittest.TestCase): + def setUp(self) -> None: + self.server = MockApiServer(OPERATION_MANIFEST) + self.server.start() + configuration = Configuration(host=self.server.base_url, access_token="test-token") + self.api_client = ApiClient(configuration=configuration) + + def tearDown(self) -> None: + self.server.stop() + + def te_headers(self, operation_id: str, error_status=None): + headers = {OPERATION_ID_HEADER: operation_id} + if error_status is not None: + headers[ERROR_STATUS_HEADER] = error_status + return headers diff --git a/thousandeyes-sdk-streaming/test/mock_manifest.py b/thousandeyes-sdk-streaming/test/mock_manifest.py new file mode 100644 index 00000000..88dd4618 --- /dev/null +++ b/thousandeyes-sdk-streaming/test/mock_manifest.py @@ -0,0 +1,759 @@ +# coding: utf-8 + +""" + ThousandEyes for OpenTelemetry API + + **Note:** The following ThousandEyes for OpenTelemetry API capabilities are not available for ThousandEyes for Government instance: * Traces * OTel-based integrations that rely on connectors and operations, including: * Splunk Cloud Platform HEC * Splunk Enterprise HEC * Splunk Observability APM * Dynatrace Observability APM ThousandEyes for OpenTelemetry provides machine-to-machine integration between ThousandEyes and its customers. It allows you to export ThousandEyes telemetry data in OTel format, which is widely used in the industry. With ThousandEyes for OTel, you can leverage frameworks widely used in the observability domain - such as Splunk, Grafana, and Honeycomb - to capture and analyze ThousandEyes data. Any client that supports OTel can use ThousandEyes for OpenTelemetry. ThousandEyes for OTel is made up of the following components: * Data streaming APIs that you can use to configure and enable your ThousandEyes tests with OTel-compatible streams, in particular to configure how ThousandEyes telemetry data is exported to client integrations. * A set of streaming pipelines called _collectors_ that actively fetch ThousandEyes network test data, enrich the data with some additional detail, filter, and push the data to the customer-configured endpoints, depending on what you configure via the public APIs. * Third-party OTel collectors that receive, transform, filter, and export different metrics to client applications such as AppD, or any other OTel-capable client configuration. For more information about ThousandEyes for OpenTelemetry, see the [product documentation](https://docs.thousandeyes.com/product-documentation/integration-guides/opentelemetry). + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json + +from sdk_test_support.mock_server_types import ErrorResponseExpectation, OperationExpectation + +OPERATION_MANIFEST = { + + "create_stream": OperationExpectation( + operation_id="create_stream", + method="POST", + path="/streams", + path_param_examples={ + }, + success_status=201, + success_body=json.loads(""" + + { + "endpointAgentLabel" : [ { + "id" : "1234" + }, { + "id" : "1234" + } ], + "endpointType" : "grpc", + "_links" : { + "self" : { + "href" : "https://api.thousandeyes.com/v7/streams/575766da-9664-4e85-94fe-facbe1154799" + } + }, + "streamEndpointUrl" : "https://api.thousandeyes.otel-collector", + "exporterConfig" : { + "authorization" : { + "oAuth2" : { + "clientId" : "1234567890", + "tokenUrl" : "https://example.com/token", + "clientSecret" : "1234567890", + "scopes" : [ "read", "write" ] + } + }, + "splunkHec" : { + "sourceType" : "ThousandEyesOTel", + "index" : "thousandeyes_otel_events_index", + "source" : "ThousandEyesOTel", + "token" : "d0a91307-be2f-4218-a9f8-71c02d98846b" + } + }, + "filters" : { + "testTypes" : { + "values" : [ "agent-to-server", "bgp", "http-server" ] + } + }, + "type" : "opentelemetry", + "enabled" : true, + "dataModelVersion" : "v2", + "endpointAgentTag" : [ { + "id" : "91863f70-e5a6-4a1c-a266-caf02db3607d" + }, { + "id" : "91863f70-e5a6-4a1c-a266-caf02db3607d" + } ], + "testMatch" : [ { + "id" : "1234", + "domain" : "cea" + }, { + "id" : "5678", + "domain" : "endpoint" + } ], + "tagMatch" : [ { + "key" : "keyA", + "value" : "valueA" + }, { + "key" : "keyB", + "value" : "valueB" + } ], + "id" : "342ieu09", + "streamStatus" : { + "lastSuccess" : 1679677853573, + "lastFailure" : 1679677853573, + "status" : "connected" + }, + "signal" : "metric", + "auditOperation" : { + "createdDate" : 1679677853573, + "createdBy" : 3962 + }, + "customHeaders" : { + "Authorization" : "*****", + "Content-Type" : "*****" + } + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "endpointAgentLabel" : [ { + "id" : "1234" + }, { + "id" : "1234" + } ], + "endpointType" : "grpc", + "streamEndpointUrl" : "https://api.thousandeyes.otel-collector", + "exporterConfig" : { + "authorization" : { + "oAuth2" : { + "clientId" : "1234567890", + "tokenUrl" : "https://example.com/token", + "clientSecret" : "1234567890", + "scopes" : [ "read", "write" ] + } + }, + "splunkHec" : { + "sourceType" : "ThousandEyesOTel", + "index" : "thousandeyes_otel_events_index", + "source" : "ThousandEyesOTel", + "token" : "d0a91307-be2f-4218-a9f8-71c02d98846b" + } + }, + "filters" : { + "testTypes" : { + "values" : [ "agent-to-server", "bgp", "http-server" ] + } + }, + "type" : "opentelemetry", + "dataModelVersion" : "v2", + "enabled" : true, + "endpointAgentTag" : [ { + "id" : "91863f70-e5a6-4a1c-a266-caf02db3607d" + }, { + "id" : "91863f70-e5a6-4a1c-a266-caf02db3607d" + } ], + "testMatch" : [ { + "id" : "1234", + "domain" : "cea" + }, { + "id" : "5678", + "domain" : "endpoint" + } ], + "tagMatch" : [ { + "key" : "keyA", + "value" : "valueA" + }, { + "key" : "keyB", + "value" : "valueB" + } ], + "signal" : "metric", + "customHeaders" : { + "Authorization" : "*****", + "Content-Type" : "*****" + } + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "path" : "https://api.thousandeyes.com/v7/streams", + "httpStatus" : "BAD_REQUEST", + "errors" : [ "JSON parse error: invalid type", "JSON parse error: invalid type" ], + "timestamp" : 1679677853573 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "412": ErrorResponseExpectation( + status=412, + body=json.loads(""" + { + "path" : "https://api.thousandeyes.com/v7/streams", + "httpStatus" : "PRECONDITION_FAILED", + "errors" : [ "User cannot create more than 5 integrations", "User cannot create more than 5 integrations" ], + "timestamp" : 1679677853573 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "path" : "https://api.thousandeyes.com/v7/request/path", + "errors" : "Internal Server Error", + "timestamp" : 1679677853573, + "status" : 500 + }"""), + content_type="application/json", + ), + + }, + ), + + "delete_stream": OperationExpectation( + operation_id="delete_stream", + method="DELETE", + path="/streams/{id}", + path_param_examples={ + "id": 'id_example', + }, + success_status=204, + success_body=None, + success_content_type="application/json", + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "path" : "https://api.thousandeyes.com/v7/request/path", + "errors" : "Internal Server Error", + "timestamp" : 1679677853573, + "status" : 500 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_stream": OperationExpectation( + operation_id="get_stream", + method="GET", + path="/streams/{id}", + path_param_examples={ + "id": 'id_example', + }, + success_status=200, + success_body=json.loads(""" + + { + "endpointAgentLabel" : [ { + "id" : "1234" + }, { + "id" : "1234" + } ], + "endpointType" : "grpc", + "_links" : { + "self" : { + "href" : "https://api.thousandeyes.com/v7/streams/575766da-9664-4e85-94fe-facbe1154799" + } + }, + "streamEndpointUrl" : "https://api.thousandeyes.otel-collector", + "exporterConfig" : { + "authorization" : { + "oAuth2" : { + "clientId" : "1234567890", + "tokenUrl" : "https://example.com/token", + "clientSecret" : "1234567890", + "scopes" : [ "read", "write" ] + } + }, + "splunkHec" : { + "sourceType" : "ThousandEyesOTel", + "index" : "thousandeyes_otel_events_index", + "source" : "ThousandEyesOTel", + "token" : "d0a91307-be2f-4218-a9f8-71c02d98846b" + } + }, + "filters" : { + "testTypes" : { + "values" : [ "agent-to-server", "bgp", "http-server" ] + } + }, + "type" : "opentelemetry", + "enabled" : true, + "dataModelVersion" : "v2", + "endpointAgentTag" : [ { + "id" : "91863f70-e5a6-4a1c-a266-caf02db3607d" + }, { + "id" : "91863f70-e5a6-4a1c-a266-caf02db3607d" + } ], + "testMatch" : [ { + "id" : "1234", + "domain" : "cea" + }, { + "id" : "5678", + "domain" : "endpoint" + } ], + "tagMatch" : [ { + "key" : "keyA", + "value" : "valueA" + }, { + "key" : "keyB", + "value" : "valueB" + } ], + "id" : "342ieu09", + "streamStatus" : { + "lastSuccess" : 1679677853573, + "lastFailure" : 1679677853573, + "status" : "connected" + }, + "signal" : "metric", + "auditOperation" : { + "createdDate" : 1679677853573, + "updatedBy" : 3962, + "createdBy" : 3962, + "updatedDate" : 1679677853573 + }, + "customHeaders" : { + "Authorization" : "*****", + "Content-Type" : "*****" + } + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "path" : "https://api.thousandeyes.com/v7/request/path", + "errors" : "Internal Server Error", + "timestamp" : 1679677853573, + "status" : 500 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_streams": OperationExpectation( + operation_id="get_streams", + method="GET", + path="/streams", + path_param_examples={ + }, + success_status=200, + success_body=json.loads(""" + + [ { + "endpointAgentLabel" : [ { + "id" : "1234" + }, { + "id" : "1234" + } ], + "endpointType" : "grpc", + "_links" : { + "self" : { + "href" : "https://api.thousandeyes.com/v7/streams/575766da-9664-4e85-94fe-facbe1154799" + } + }, + "streamEndpointUrl" : "https://api.thousandeyes.otel-collector", + "exporterConfig" : { + "authorization" : { + "oAuth2" : { + "clientId" : "1234567890", + "tokenUrl" : "https://example.com/token", + "clientSecret" : "1234567890", + "scopes" : [ "read", "write" ] + } + }, + "splunkHec" : { + "sourceType" : "ThousandEyesOTel", + "index" : "thousandeyes_otel_events_index", + "source" : "ThousandEyesOTel", + "token" : "d0a91307-be2f-4218-a9f8-71c02d98846b" + } + }, + "filters" : { + "testTypes" : { + "values" : [ "agent-to-server", "bgp", "http-server" ] + } + }, + "type" : "opentelemetry", + "enabled" : true, + "dataModelVersion" : "v2", + "endpointAgentTag" : [ { + "id" : "91863f70-e5a6-4a1c-a266-caf02db3607d" + }, { + "id" : "91863f70-e5a6-4a1c-a266-caf02db3607d" + } ], + "testMatch" : [ { + "id" : "1234", + "domain" : "cea" + }, { + "id" : "5678", + "domain" : "endpoint" + } ], + "tagMatch" : [ { + "key" : "keyA", + "value" : "valueA" + }, { + "key" : "keyB", + "value" : "valueB" + } ], + "id" : "342ieu09", + "streamStatus" : { + "lastSuccess" : 1679677853573, + "lastFailure" : 1679677853573, + "status" : "connected" + }, + "signal" : "metric", + "auditOperation" : { + "createdDate" : 1679677853573, + "updatedBy" : 3962, + "createdBy" : 3962, + "updatedDate" : 1679677853573 + }, + "customHeaders" : { + "Authorization" : "*****", + "Content-Type" : "*****" + } + }, { + "endpointAgentLabel" : [ { + "id" : "1234" + }, { + "id" : "1234" + } ], + "endpointType" : "grpc", + "_links" : { + "self" : { + "href" : "https://api.thousandeyes.com/v7/streams/575766da-9664-4e85-94fe-facbe1154799" + } + }, + "streamEndpointUrl" : "https://api.thousandeyes.otel-collector", + "exporterConfig" : { + "authorization" : { + "oAuth2" : { + "clientId" : "1234567890", + "tokenUrl" : "https://example.com/token", + "clientSecret" : "1234567890", + "scopes" : [ "read", "write" ] + } + }, + "splunkHec" : { + "sourceType" : "ThousandEyesOTel", + "index" : "thousandeyes_otel_events_index", + "source" : "ThousandEyesOTel", + "token" : "d0a91307-be2f-4218-a9f8-71c02d98846b" + } + }, + "filters" : { + "testTypes" : { + "values" : [ "agent-to-server", "bgp", "http-server" ] + } + }, + "type" : "opentelemetry", + "enabled" : true, + "dataModelVersion" : "v2", + "endpointAgentTag" : [ { + "id" : "91863f70-e5a6-4a1c-a266-caf02db3607d" + }, { + "id" : "91863f70-e5a6-4a1c-a266-caf02db3607d" + } ], + "testMatch" : [ { + "id" : "1234", + "domain" : "cea" + }, { + "id" : "5678", + "domain" : "endpoint" + } ], + "tagMatch" : [ { + "key" : "keyA", + "value" : "valueA" + }, { + "key" : "keyB", + "value" : "valueB" + } ], + "id" : "342ieu09", + "streamStatus" : { + "lastSuccess" : 1679677853573, + "lastFailure" : 1679677853573, + "status" : "connected" + }, + "signal" : "metric", + "auditOperation" : { + "createdDate" : 1679677853573, + "updatedBy" : 3962, + "createdBy" : 3962, + "updatedDate" : 1679677853573 + }, + "customHeaders" : { + "Authorization" : "*****", + "Content-Type" : "*****" + } + } ] + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "path" : "https://api.thousandeyes.com/v7/streams", + "httpStatus" : "BAD_REQUEST", + "errors" : [ "JSON parse error: invalid type", "JSON parse error: invalid type" ], + "timestamp" : 1679677853573 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "path" : "https://api.thousandeyes.com/v7/request/path", + "errors" : "Internal Server Error", + "timestamp" : 1679677853573, + "status" : 500 + }"""), + content_type="application/json", + ), + + }, + ), + + "update_stream": OperationExpectation( + operation_id="update_stream", + method="PUT", + path="/streams/{id}", + path_param_examples={ + "id": 'id_example', + }, + success_status=200, + success_body=json.loads(""" + + { + "endpointAgentLabel" : [ { + "id" : "1234" + }, { + "id" : "1234" + } ], + "endpointType" : "grpc", + "_links" : { + "self" : { + "href" : "https://api.thousandeyes.com/v7/streams/575766da-9664-4e85-94fe-facbe1154799" + } + }, + "streamEndpointUrl" : "https://api.thousandeyes.otel-collector", + "exporterConfig" : { + "authorization" : { + "oAuth2" : { + "clientId" : "1234567890", + "tokenUrl" : "https://example.com/token", + "clientSecret" : "1234567890", + "scopes" : [ "read", "write" ] + } + }, + "splunkHec" : { + "sourceType" : "ThousandEyesOTel", + "index" : "thousandeyes_otel_events_index", + "source" : "ThousandEyesOTel", + "token" : "d0a91307-be2f-4218-a9f8-71c02d98846b" + } + }, + "filters" : { + "testTypes" : { + "values" : [ "agent-to-server", "bgp", "http-server" ] + } + }, + "type" : "opentelemetry", + "enabled" : true, + "dataModelVersion" : "v2", + "endpointAgentTag" : [ { + "id" : "91863f70-e5a6-4a1c-a266-caf02db3607d" + }, { + "id" : "91863f70-e5a6-4a1c-a266-caf02db3607d" + } ], + "testMatch" : [ { + "id" : "1234", + "domain" : "cea" + }, { + "id" : "5678", + "domain" : "endpoint" + } ], + "tagMatch" : [ { + "key" : "keyA", + "value" : "valueA" + }, { + "key" : "keyB", + "value" : "valueB" + } ], + "id" : "342ieu09", + "streamStatus" : { + "lastSuccess" : 1679677853573, + "lastFailure" : 1679677853573, + "status" : "connected" + }, + "signal" : "metric", + "auditOperation" : { + "createdDate" : 1679677853573, + "updatedBy" : 3962, + "createdBy" : 3962, + "updatedDate" : 1679677853573 + }, + "customHeaders" : { + "Authorization" : "*****", + "Content-Type" : "*****" + } + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "endpointAgentLabel" : [ { + "id" : "1234" + }, { + "id" : "1234" + } ], + "endpointAgentTag" : [ { + "id" : "91863f70-e5a6-4a1c-a266-caf02db3607d" + }, { + "id" : "91863f70-e5a6-4a1c-a266-caf02db3607d" + } ], + "testMatch" : [ { + "id" : "1234", + "domain" : "cea" + }, { + "id" : "5678", + "domain" : "endpoint" + } ], + "streamEndpointUrl" : "https://api.thousandeyes.otel-collector", + "exporterConfig" : { + "authorization" : { + "oAuth2" : { + "clientId" : "1234567890", + "tokenUrl" : "https://example.com/token", + "clientSecret" : "1234567890", + "scopes" : [ "read", "write" ] + } + }, + "splunkHec" : { + "sourceType" : "ThousandEyesOTel", + "index" : "thousandeyes_otel_events_index", + "source" : "ThousandEyesOTel", + "token" : "d0a91307-be2f-4218-a9f8-71c02d98846b" + } + }, + "tagMatch" : [ { + "key" : "keyA", + "value" : "valueA" + }, { + "key" : "keyB", + "value" : "valueB" + } ], + "filters" : { + "testTypes" : { + "values" : [ "agent-to-server", "bgp", "http-server" ] + } + }, + "customHeaders" : { + "Authorization" : "*****", + "Content-Type" : "*****" + }, + "enabled" : true + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "path" : "https://api.thousandeyes.com/v7/streams", + "httpStatus" : "BAD_REQUEST", + "errors" : [ "JSON parse error: invalid type", "JSON parse error: invalid type" ], + "timestamp" : 1679677853573 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "path" : "https://api.thousandeyes.com/v7/request/path", + "errors" : "Internal Server Error", + "timestamp" : 1679677853573, + "status" : 500 + }"""), + content_type="application/json", + ), + + }, + ), + +} diff --git a/thousandeyes-sdk-streaming/test/test_streaming_api_integration.py b/thousandeyes-sdk-streaming/test/test_streaming_api_integration.py new file mode 100644 index 00000000..01fff3ef --- /dev/null +++ b/thousandeyes-sdk-streaming/test/test_streaming_api_integration.py @@ -0,0 +1,1404 @@ +# coding: utf-8 + +""" + ThousandEyes for OpenTelemetry API + + **Note:** The following ThousandEyes for OpenTelemetry API capabilities are not available for ThousandEyes for Government instance: * Traces * OTel-based integrations that rely on connectors and operations, including: * Splunk Cloud Platform HEC * Splunk Enterprise HEC * Splunk Observability APM * Dynatrace Observability APM ThousandEyes for OpenTelemetry provides machine-to-machine integration between ThousandEyes and its customers. It allows you to export ThousandEyes telemetry data in OTel format, which is widely used in the industry. With ThousandEyes for OTel, you can leverage frameworks widely used in the observability domain - such as Splunk, Grafana, and Honeycomb - to capture and analyze ThousandEyes data. Any client that supports OTel can use ThousandEyes for OpenTelemetry. ThousandEyes for OTel is made up of the following components: * Data streaming APIs that you can use to configure and enable your ThousandEyes tests with OTel-compatible streams, in particular to configure how ThousandEyes telemetry data is exported to client integrations. * A set of streaming pipelines called _collectors_ that actively fetch ThousandEyes network test data, enrich the data with some additional detail, filter, and push the data to the customer-configured endpoints, depending on what you configure via the public APIs. * Third-party OTel collectors that receive, transform, filter, and export different metrics to client applications such as AppD, or any other OTel-capable client configuration. For more information about ThousandEyes for OpenTelemetry, see the [product documentation](https://docs.thousandeyes.com/product-documentation/integration-guides/opentelemetry). + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.streaming.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.streaming.api.streaming_api import StreamingApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestStreamingApiIntegration(IntegrationTestBase): + """StreamingApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = StreamingApi(self.api_client) + + + def test_create_stream_happy_path(self) -> None: + """Integration test for create_stream success path""" + request_body_json = """ + + { + "endpointAgentLabel" : [ { + "id" : "1234" + }, { + "id" : "1234" + } ], + "endpointType" : "grpc", + "streamEndpointUrl" : "https://api.thousandeyes.otel-collector", + "exporterConfig" : { + "authorization" : { + "oAuth2" : { + "clientId" : "1234567890", + "tokenUrl" : "https://example.com/token", + "clientSecret" : "1234567890", + "scopes" : [ "read", "write" ] + } + }, + "splunkHec" : { + "sourceType" : "ThousandEyesOTel", + "index" : "thousandeyes_otel_events_index", + "source" : "ThousandEyesOTel", + "token" : "d0a91307-be2f-4218-a9f8-71c02d98846b" + } + }, + "filters" : { + "testTypes" : { + "values" : [ "agent-to-server", "bgp", "http-server" ] + } + }, + "type" : "opentelemetry", + "dataModelVersion" : "v2", + "enabled" : true, + "endpointAgentTag" : [ { + "id" : "91863f70-e5a6-4a1c-a266-caf02db3607d" + }, { + "id" : "91863f70-e5a6-4a1c-a266-caf02db3607d" + } ], + "testMatch" : [ { + "id" : "1234", + "domain" : "cea" + }, { + "id" : "5678", + "domain" : "endpoint" + } ], + "tagMatch" : [ { + "key" : "keyA", + "value" : "valueA" + }, { + "key" : "keyB", + "value" : "valueB" + } ], + "signal" : "metric", + "customHeaders" : { + "Authorization" : "*****", + "Content-Type" : "*****" + } + } + + """ + stream = thousandeyes_sdk.streaming.models.Stream.from_json(request_body_json) + aid = '1234' + response_body_json = """ + { + "endpointAgentLabel" : [ { + "id" : "1234" + }, { + "id" : "1234" + } ], + "endpointType" : "grpc", + "_links" : { + "self" : { + "href" : "https://api.thousandeyes.com/v7/streams/575766da-9664-4e85-94fe-facbe1154799" + } + }, + "streamEndpointUrl" : "https://api.thousandeyes.otel-collector", + "exporterConfig" : { + "authorization" : { + "oAuth2" : { + "clientId" : "1234567890", + "tokenUrl" : "https://example.com/token", + "clientSecret" : "1234567890", + "scopes" : [ "read", "write" ] + } + }, + "splunkHec" : { + "sourceType" : "ThousandEyesOTel", + "index" : "thousandeyes_otel_events_index", + "source" : "ThousandEyesOTel", + "token" : "d0a91307-be2f-4218-a9f8-71c02d98846b" + } + }, + "filters" : { + "testTypes" : { + "values" : [ "agent-to-server", "bgp", "http-server" ] + } + }, + "type" : "opentelemetry", + "enabled" : true, + "dataModelVersion" : "v2", + "endpointAgentTag" : [ { + "id" : "91863f70-e5a6-4a1c-a266-caf02db3607d" + }, { + "id" : "91863f70-e5a6-4a1c-a266-caf02db3607d" + } ], + "testMatch" : [ { + "id" : "1234", + "domain" : "cea" + }, { + "id" : "5678", + "domain" : "endpoint" + } ], + "tagMatch" : [ { + "key" : "keyA", + "value" : "valueA" + }, { + "key" : "keyB", + "value" : "valueB" + } ], + "id" : "342ieu09", + "streamStatus" : { + "lastSuccess" : 1679677853573, + "lastFailure" : 1679677853573, + "status" : "connected" + }, + "signal" : "metric", + "auditOperation" : { + "createdDate" : 1679677853573, + "createdBy" : 3962 + }, + "customHeaders" : { + "Authorization" : "*****", + "Content-Type" : "*****" + } + } + """ + expected_response = json.loads(response_body_json) + response = self.api.create_stream( + + aid=aid, + + stream=stream, + + _headers=self.te_headers("create_stream"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_create_stream_error_400(self) -> None: + """Integration test for create_stream error path (HTTP 400)""" + request_body_json = """ + + { + "endpointAgentLabel" : [ { + "id" : "1234" + }, { + "id" : "1234" + } ], + "endpointType" : "grpc", + "streamEndpointUrl" : "https://api.thousandeyes.otel-collector", + "exporterConfig" : { + "authorization" : { + "oAuth2" : { + "clientId" : "1234567890", + "tokenUrl" : "https://example.com/token", + "clientSecret" : "1234567890", + "scopes" : [ "read", "write" ] + } + }, + "splunkHec" : { + "sourceType" : "ThousandEyesOTel", + "index" : "thousandeyes_otel_events_index", + "source" : "ThousandEyesOTel", + "token" : "d0a91307-be2f-4218-a9f8-71c02d98846b" + } + }, + "filters" : { + "testTypes" : { + "values" : [ "agent-to-server", "bgp", "http-server" ] + } + }, + "type" : "opentelemetry", + "dataModelVersion" : "v2", + "enabled" : true, + "endpointAgentTag" : [ { + "id" : "91863f70-e5a6-4a1c-a266-caf02db3607d" + }, { + "id" : "91863f70-e5a6-4a1c-a266-caf02db3607d" + } ], + "testMatch" : [ { + "id" : "1234", + "domain" : "cea" + }, { + "id" : "5678", + "domain" : "endpoint" + } ], + "tagMatch" : [ { + "key" : "keyA", + "value" : "valueA" + }, { + "key" : "keyB", + "value" : "valueB" + } ], + "signal" : "metric", + "customHeaders" : { + "Authorization" : "*****", + "Content-Type" : "*****" + } + } + + """ + stream = thousandeyes_sdk.streaming.models.Stream.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "path" : "https://api.thousandeyes.com/v7/streams", + "httpStatus" : "BAD_REQUEST", + "errors" : [ "JSON parse error: invalid type", "JSON parse error: invalid type" ], + "timestamp" : 1679677853573 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.create_stream( + + aid=aid, + + stream=stream, + + _headers=self.te_headers("create_stream", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_stream_error_401(self) -> None: + """Integration test for create_stream error path (HTTP 401)""" + request_body_json = """ + + { + "endpointAgentLabel" : [ { + "id" : "1234" + }, { + "id" : "1234" + } ], + "endpointType" : "grpc", + "streamEndpointUrl" : "https://api.thousandeyes.otel-collector", + "exporterConfig" : { + "authorization" : { + "oAuth2" : { + "clientId" : "1234567890", + "tokenUrl" : "https://example.com/token", + "clientSecret" : "1234567890", + "scopes" : [ "read", "write" ] + } + }, + "splunkHec" : { + "sourceType" : "ThousandEyesOTel", + "index" : "thousandeyes_otel_events_index", + "source" : "ThousandEyesOTel", + "token" : "d0a91307-be2f-4218-a9f8-71c02d98846b" + } + }, + "filters" : { + "testTypes" : { + "values" : [ "agent-to-server", "bgp", "http-server" ] + } + }, + "type" : "opentelemetry", + "dataModelVersion" : "v2", + "enabled" : true, + "endpointAgentTag" : [ { + "id" : "91863f70-e5a6-4a1c-a266-caf02db3607d" + }, { + "id" : "91863f70-e5a6-4a1c-a266-caf02db3607d" + } ], + "testMatch" : [ { + "id" : "1234", + "domain" : "cea" + }, { + "id" : "5678", + "domain" : "endpoint" + } ], + "tagMatch" : [ { + "key" : "keyA", + "value" : "valueA" + }, { + "key" : "keyB", + "value" : "valueB" + } ], + "signal" : "metric", + "customHeaders" : { + "Authorization" : "*****", + "Content-Type" : "*****" + } + } + + """ + stream = thousandeyes_sdk.streaming.models.Stream.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.create_stream( + + aid=aid, + + stream=stream, + + _headers=self.te_headers("create_stream", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_stream_error_412(self) -> None: + """Integration test for create_stream error path (HTTP 412)""" + request_body_json = """ + + { + "endpointAgentLabel" : [ { + "id" : "1234" + }, { + "id" : "1234" + } ], + "endpointType" : "grpc", + "streamEndpointUrl" : "https://api.thousandeyes.otel-collector", + "exporterConfig" : { + "authorization" : { + "oAuth2" : { + "clientId" : "1234567890", + "tokenUrl" : "https://example.com/token", + "clientSecret" : "1234567890", + "scopes" : [ "read", "write" ] + } + }, + "splunkHec" : { + "sourceType" : "ThousandEyesOTel", + "index" : "thousandeyes_otel_events_index", + "source" : "ThousandEyesOTel", + "token" : "d0a91307-be2f-4218-a9f8-71c02d98846b" + } + }, + "filters" : { + "testTypes" : { + "values" : [ "agent-to-server", "bgp", "http-server" ] + } + }, + "type" : "opentelemetry", + "dataModelVersion" : "v2", + "enabled" : true, + "endpointAgentTag" : [ { + "id" : "91863f70-e5a6-4a1c-a266-caf02db3607d" + }, { + "id" : "91863f70-e5a6-4a1c-a266-caf02db3607d" + } ], + "testMatch" : [ { + "id" : "1234", + "domain" : "cea" + }, { + "id" : "5678", + "domain" : "endpoint" + } ], + "tagMatch" : [ { + "key" : "keyA", + "value" : "valueA" + }, { + "key" : "keyB", + "value" : "valueB" + } ], + "signal" : "metric", + "customHeaders" : { + "Authorization" : "*****", + "Content-Type" : "*****" + } + } + + """ + stream = thousandeyes_sdk.streaming.models.Stream.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "path" : "https://api.thousandeyes.com/v7/streams", + "httpStatus" : "PRECONDITION_FAILED", + "errors" : [ "User cannot create more than 5 integrations", "User cannot create more than 5 integrations" ], + "timestamp" : 1679677853573 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(412) + ) as context: + self.api.create_stream( + + aid=aid, + + stream=stream, + + _headers=self.te_headers("create_stream", error_status="412"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_stream_error_500(self) -> None: + """Integration test for create_stream error path (HTTP 500)""" + request_body_json = """ + + { + "endpointAgentLabel" : [ { + "id" : "1234" + }, { + "id" : "1234" + } ], + "endpointType" : "grpc", + "streamEndpointUrl" : "https://api.thousandeyes.otel-collector", + "exporterConfig" : { + "authorization" : { + "oAuth2" : { + "clientId" : "1234567890", + "tokenUrl" : "https://example.com/token", + "clientSecret" : "1234567890", + "scopes" : [ "read", "write" ] + } + }, + "splunkHec" : { + "sourceType" : "ThousandEyesOTel", + "index" : "thousandeyes_otel_events_index", + "source" : "ThousandEyesOTel", + "token" : "d0a91307-be2f-4218-a9f8-71c02d98846b" + } + }, + "filters" : { + "testTypes" : { + "values" : [ "agent-to-server", "bgp", "http-server" ] + } + }, + "type" : "opentelemetry", + "dataModelVersion" : "v2", + "enabled" : true, + "endpointAgentTag" : [ { + "id" : "91863f70-e5a6-4a1c-a266-caf02db3607d" + }, { + "id" : "91863f70-e5a6-4a1c-a266-caf02db3607d" + } ], + "testMatch" : [ { + "id" : "1234", + "domain" : "cea" + }, { + "id" : "5678", + "domain" : "endpoint" + } ], + "tagMatch" : [ { + "key" : "keyA", + "value" : "valueA" + }, { + "key" : "keyB", + "value" : "valueB" + } ], + "signal" : "metric", + "customHeaders" : { + "Authorization" : "*****", + "Content-Type" : "*****" + } + } + + """ + stream = thousandeyes_sdk.streaming.models.Stream.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "path" : "https://api.thousandeyes.com/v7/request/path", + "errors" : "Internal Server Error", + "timestamp" : 1679677853573, + "status" : 500 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.create_stream( + + aid=aid, + + stream=stream, + + _headers=self.te_headers("create_stream", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_delete_stream_happy_path(self) -> None: + """Integration test for delete_stream success path""" + id = 'id_example' + aid = '1234' + response = self.api.delete_stream_with_http_info( + + id=id, + + aid=aid, + + _headers=self.te_headers("delete_stream"), + ) + self.assertEqual(204, response.status_code) + self.assertIsNone(response.data) + + + def test_delete_stream_error_401(self) -> None: + """Integration test for delete_stream error path (HTTP 401)""" + id = 'id_example' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.delete_stream( + + id=id, + + aid=aid, + + _headers=self.te_headers("delete_stream", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_stream_error_500(self) -> None: + """Integration test for delete_stream error path (HTTP 500)""" + id = 'id_example' + aid = '1234' + error_body_json = """ + { + "path" : "https://api.thousandeyes.com/v7/request/path", + "errors" : "Internal Server Error", + "timestamp" : 1679677853573, + "status" : 500 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.delete_stream( + + id=id, + + aid=aid, + + _headers=self.te_headers("delete_stream", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_stream_happy_path(self) -> None: + """Integration test for get_stream success path""" + id = 'id_example' + aid = '1234' + response_body_json = """ + { + "endpointAgentLabel" : [ { + "id" : "1234" + }, { + "id" : "1234" + } ], + "endpointType" : "grpc", + "_links" : { + "self" : { + "href" : "https://api.thousandeyes.com/v7/streams/575766da-9664-4e85-94fe-facbe1154799" + } + }, + "streamEndpointUrl" : "https://api.thousandeyes.otel-collector", + "exporterConfig" : { + "authorization" : { + "oAuth2" : { + "clientId" : "1234567890", + "tokenUrl" : "https://example.com/token", + "clientSecret" : "1234567890", + "scopes" : [ "read", "write" ] + } + }, + "splunkHec" : { + "sourceType" : "ThousandEyesOTel", + "index" : "thousandeyes_otel_events_index", + "source" : "ThousandEyesOTel", + "token" : "d0a91307-be2f-4218-a9f8-71c02d98846b" + } + }, + "filters" : { + "testTypes" : { + "values" : [ "agent-to-server", "bgp", "http-server" ] + } + }, + "type" : "opentelemetry", + "enabled" : true, + "dataModelVersion" : "v2", + "endpointAgentTag" : [ { + "id" : "91863f70-e5a6-4a1c-a266-caf02db3607d" + }, { + "id" : "91863f70-e5a6-4a1c-a266-caf02db3607d" + } ], + "testMatch" : [ { + "id" : "1234", + "domain" : "cea" + }, { + "id" : "5678", + "domain" : "endpoint" + } ], + "tagMatch" : [ { + "key" : "keyA", + "value" : "valueA" + }, { + "key" : "keyB", + "value" : "valueB" + } ], + "id" : "342ieu09", + "streamStatus" : { + "lastSuccess" : 1679677853573, + "lastFailure" : 1679677853573, + "status" : "connected" + }, + "signal" : "metric", + "auditOperation" : { + "createdDate" : 1679677853573, + "updatedBy" : 3962, + "createdBy" : 3962, + "updatedDate" : 1679677853573 + }, + "customHeaders" : { + "Authorization" : "*****", + "Content-Type" : "*****" + } + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_stream( + + id=id, + + aid=aid, + + _headers=self.te_headers("get_stream"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_stream_error_401(self) -> None: + """Integration test for get_stream error path (HTTP 401)""" + id = 'id_example' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_stream( + + id=id, + + aid=aid, + + _headers=self.te_headers("get_stream", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_stream_error_500(self) -> None: + """Integration test for get_stream error path (HTTP 500)""" + id = 'id_example' + aid = '1234' + error_body_json = """ + { + "path" : "https://api.thousandeyes.com/v7/request/path", + "errors" : "Internal Server Error", + "timestamp" : 1679677853573, + "status" : 500 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_stream( + + id=id, + + aid=aid, + + _headers=self.te_headers("get_stream", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_streams_happy_path(self) -> None: + """Integration test for get_streams success path""" + aid = '1234' + response_body_json = """ + [ { + "endpointAgentLabel" : [ { + "id" : "1234" + }, { + "id" : "1234" + } ], + "endpointType" : "grpc", + "_links" : { + "self" : { + "href" : "https://api.thousandeyes.com/v7/streams/575766da-9664-4e85-94fe-facbe1154799" + } + }, + "streamEndpointUrl" : "https://api.thousandeyes.otel-collector", + "exporterConfig" : { + "authorization" : { + "oAuth2" : { + "clientId" : "1234567890", + "tokenUrl" : "https://example.com/token", + "clientSecret" : "1234567890", + "scopes" : [ "read", "write" ] + } + }, + "splunkHec" : { + "sourceType" : "ThousandEyesOTel", + "index" : "thousandeyes_otel_events_index", + "source" : "ThousandEyesOTel", + "token" : "d0a91307-be2f-4218-a9f8-71c02d98846b" + } + }, + "filters" : { + "testTypes" : { + "values" : [ "agent-to-server", "bgp", "http-server" ] + } + }, + "type" : "opentelemetry", + "enabled" : true, + "dataModelVersion" : "v2", + "endpointAgentTag" : [ { + "id" : "91863f70-e5a6-4a1c-a266-caf02db3607d" + }, { + "id" : "91863f70-e5a6-4a1c-a266-caf02db3607d" + } ], + "testMatch" : [ { + "id" : "1234", + "domain" : "cea" + }, { + "id" : "5678", + "domain" : "endpoint" + } ], + "tagMatch" : [ { + "key" : "keyA", + "value" : "valueA" + }, { + "key" : "keyB", + "value" : "valueB" + } ], + "id" : "342ieu09", + "streamStatus" : { + "lastSuccess" : 1679677853573, + "lastFailure" : 1679677853573, + "status" : "connected" + }, + "signal" : "metric", + "auditOperation" : { + "createdDate" : 1679677853573, + "updatedBy" : 3962, + "createdBy" : 3962, + "updatedDate" : 1679677853573 + }, + "customHeaders" : { + "Authorization" : "*****", + "Content-Type" : "*****" + } + }, { + "endpointAgentLabel" : [ { + "id" : "1234" + }, { + "id" : "1234" + } ], + "endpointType" : "grpc", + "_links" : { + "self" : { + "href" : "https://api.thousandeyes.com/v7/streams/575766da-9664-4e85-94fe-facbe1154799" + } + }, + "streamEndpointUrl" : "https://api.thousandeyes.otel-collector", + "exporterConfig" : { + "authorization" : { + "oAuth2" : { + "clientId" : "1234567890", + "tokenUrl" : "https://example.com/token", + "clientSecret" : "1234567890", + "scopes" : [ "read", "write" ] + } + }, + "splunkHec" : { + "sourceType" : "ThousandEyesOTel", + "index" : "thousandeyes_otel_events_index", + "source" : "ThousandEyesOTel", + "token" : "d0a91307-be2f-4218-a9f8-71c02d98846b" + } + }, + "filters" : { + "testTypes" : { + "values" : [ "agent-to-server", "bgp", "http-server" ] + } + }, + "type" : "opentelemetry", + "enabled" : true, + "dataModelVersion" : "v2", + "endpointAgentTag" : [ { + "id" : "91863f70-e5a6-4a1c-a266-caf02db3607d" + }, { + "id" : "91863f70-e5a6-4a1c-a266-caf02db3607d" + } ], + "testMatch" : [ { + "id" : "1234", + "domain" : "cea" + }, { + "id" : "5678", + "domain" : "endpoint" + } ], + "tagMatch" : [ { + "key" : "keyA", + "value" : "valueA" + }, { + "key" : "keyB", + "value" : "valueB" + } ], + "id" : "342ieu09", + "streamStatus" : { + "lastSuccess" : 1679677853573, + "lastFailure" : 1679677853573, + "status" : "connected" + }, + "signal" : "metric", + "auditOperation" : { + "createdDate" : 1679677853573, + "updatedBy" : 3962, + "createdBy" : 3962, + "updatedDate" : 1679677853573 + }, + "customHeaders" : { + "Authorization" : "*****", + "Content-Type" : "*****" + } + } ] + """ + expected_response = json.loads(response_body_json) + response = self.api.get_streams( + + aid=aid, + + _headers=self.te_headers("get_streams"), + ) + self.assertIsInstance(response, list) + self.assertEqual(len(response), len(expected_response)) + for index, element in enumerate(response): + assert_constructed_model_matches_example_json(element, expected_response[index]) + + + def test_get_streams_error_400(self) -> None: + """Integration test for get_streams error path (HTTP 400)""" + aid = '1234' + error_body_json = """ + { + "path" : "https://api.thousandeyes.com/v7/streams", + "httpStatus" : "BAD_REQUEST", + "errors" : [ "JSON parse error: invalid type", "JSON parse error: invalid type" ], + "timestamp" : 1679677853573 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.get_streams( + + aid=aid, + + _headers=self.te_headers("get_streams", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_streams_error_401(self) -> None: + """Integration test for get_streams error path (HTTP 401)""" + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_streams( + + aid=aid, + + _headers=self.te_headers("get_streams", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_streams_error_500(self) -> None: + """Integration test for get_streams error path (HTTP 500)""" + aid = '1234' + error_body_json = """ + { + "path" : "https://api.thousandeyes.com/v7/request/path", + "errors" : "Internal Server Error", + "timestamp" : 1679677853573, + "status" : 500 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_streams( + + aid=aid, + + _headers=self.te_headers("get_streams", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_update_stream_happy_path(self) -> None: + """Integration test for update_stream success path""" + request_body_json = """ + + { + "endpointAgentLabel" : [ { + "id" : "1234" + }, { + "id" : "1234" + } ], + "endpointAgentTag" : [ { + "id" : "91863f70-e5a6-4a1c-a266-caf02db3607d" + }, { + "id" : "91863f70-e5a6-4a1c-a266-caf02db3607d" + } ], + "testMatch" : [ { + "id" : "1234", + "domain" : "cea" + }, { + "id" : "5678", + "domain" : "endpoint" + } ], + "streamEndpointUrl" : "https://api.thousandeyes.otel-collector", + "exporterConfig" : { + "authorization" : { + "oAuth2" : { + "clientId" : "1234567890", + "tokenUrl" : "https://example.com/token", + "clientSecret" : "1234567890", + "scopes" : [ "read", "write" ] + } + }, + "splunkHec" : { + "sourceType" : "ThousandEyesOTel", + "index" : "thousandeyes_otel_events_index", + "source" : "ThousandEyesOTel", + "token" : "d0a91307-be2f-4218-a9f8-71c02d98846b" + } + }, + "tagMatch" : [ { + "key" : "keyA", + "value" : "valueA" + }, { + "key" : "keyB", + "value" : "valueB" + } ], + "filters" : { + "testTypes" : { + "values" : [ "agent-to-server", "bgp", "http-server" ] + } + }, + "customHeaders" : { + "Authorization" : "*****", + "Content-Type" : "*****" + }, + "enabled" : true + } + + """ + put_stream = thousandeyes_sdk.streaming.models.PutStream.from_json(request_body_json) + id = 'id_example' + aid = '1234' + response_body_json = """ + { + "endpointAgentLabel" : [ { + "id" : "1234" + }, { + "id" : "1234" + } ], + "endpointType" : "grpc", + "_links" : { + "self" : { + "href" : "https://api.thousandeyes.com/v7/streams/575766da-9664-4e85-94fe-facbe1154799" + } + }, + "streamEndpointUrl" : "https://api.thousandeyes.otel-collector", + "exporterConfig" : { + "authorization" : { + "oAuth2" : { + "clientId" : "1234567890", + "tokenUrl" : "https://example.com/token", + "clientSecret" : "1234567890", + "scopes" : [ "read", "write" ] + } + }, + "splunkHec" : { + "sourceType" : "ThousandEyesOTel", + "index" : "thousandeyes_otel_events_index", + "source" : "ThousandEyesOTel", + "token" : "d0a91307-be2f-4218-a9f8-71c02d98846b" + } + }, + "filters" : { + "testTypes" : { + "values" : [ "agent-to-server", "bgp", "http-server" ] + } + }, + "type" : "opentelemetry", + "enabled" : true, + "dataModelVersion" : "v2", + "endpointAgentTag" : [ { + "id" : "91863f70-e5a6-4a1c-a266-caf02db3607d" + }, { + "id" : "91863f70-e5a6-4a1c-a266-caf02db3607d" + } ], + "testMatch" : [ { + "id" : "1234", + "domain" : "cea" + }, { + "id" : "5678", + "domain" : "endpoint" + } ], + "tagMatch" : [ { + "key" : "keyA", + "value" : "valueA" + }, { + "key" : "keyB", + "value" : "valueB" + } ], + "id" : "342ieu09", + "streamStatus" : { + "lastSuccess" : 1679677853573, + "lastFailure" : 1679677853573, + "status" : "connected" + }, + "signal" : "metric", + "auditOperation" : { + "createdDate" : 1679677853573, + "updatedBy" : 3962, + "createdBy" : 3962, + "updatedDate" : 1679677853573 + }, + "customHeaders" : { + "Authorization" : "*****", + "Content-Type" : "*****" + } + } + """ + expected_response = json.loads(response_body_json) + response = self.api.update_stream( + + id=id, + + aid=aid, + + put_stream=put_stream, + + _headers=self.te_headers("update_stream"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_update_stream_error_400(self) -> None: + """Integration test for update_stream error path (HTTP 400)""" + request_body_json = """ + + { + "endpointAgentLabel" : [ { + "id" : "1234" + }, { + "id" : "1234" + } ], + "endpointAgentTag" : [ { + "id" : "91863f70-e5a6-4a1c-a266-caf02db3607d" + }, { + "id" : "91863f70-e5a6-4a1c-a266-caf02db3607d" + } ], + "testMatch" : [ { + "id" : "1234", + "domain" : "cea" + }, { + "id" : "5678", + "domain" : "endpoint" + } ], + "streamEndpointUrl" : "https://api.thousandeyes.otel-collector", + "exporterConfig" : { + "authorization" : { + "oAuth2" : { + "clientId" : "1234567890", + "tokenUrl" : "https://example.com/token", + "clientSecret" : "1234567890", + "scopes" : [ "read", "write" ] + } + }, + "splunkHec" : { + "sourceType" : "ThousandEyesOTel", + "index" : "thousandeyes_otel_events_index", + "source" : "ThousandEyesOTel", + "token" : "d0a91307-be2f-4218-a9f8-71c02d98846b" + } + }, + "tagMatch" : [ { + "key" : "keyA", + "value" : "valueA" + }, { + "key" : "keyB", + "value" : "valueB" + } ], + "filters" : { + "testTypes" : { + "values" : [ "agent-to-server", "bgp", "http-server" ] + } + }, + "customHeaders" : { + "Authorization" : "*****", + "Content-Type" : "*****" + }, + "enabled" : true + } + + """ + put_stream = thousandeyes_sdk.streaming.models.PutStream.from_json(request_body_json) + id = 'id_example' + aid = '1234' + error_body_json = """ + { + "path" : "https://api.thousandeyes.com/v7/streams", + "httpStatus" : "BAD_REQUEST", + "errors" : [ "JSON parse error: invalid type", "JSON parse error: invalid type" ], + "timestamp" : 1679677853573 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.update_stream( + + id=id, + + aid=aid, + + put_stream=put_stream, + + _headers=self.te_headers("update_stream", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_stream_error_401(self) -> None: + """Integration test for update_stream error path (HTTP 401)""" + request_body_json = """ + + { + "endpointAgentLabel" : [ { + "id" : "1234" + }, { + "id" : "1234" + } ], + "endpointAgentTag" : [ { + "id" : "91863f70-e5a6-4a1c-a266-caf02db3607d" + }, { + "id" : "91863f70-e5a6-4a1c-a266-caf02db3607d" + } ], + "testMatch" : [ { + "id" : "1234", + "domain" : "cea" + }, { + "id" : "5678", + "domain" : "endpoint" + } ], + "streamEndpointUrl" : "https://api.thousandeyes.otel-collector", + "exporterConfig" : { + "authorization" : { + "oAuth2" : { + "clientId" : "1234567890", + "tokenUrl" : "https://example.com/token", + "clientSecret" : "1234567890", + "scopes" : [ "read", "write" ] + } + }, + "splunkHec" : { + "sourceType" : "ThousandEyesOTel", + "index" : "thousandeyes_otel_events_index", + "source" : "ThousandEyesOTel", + "token" : "d0a91307-be2f-4218-a9f8-71c02d98846b" + } + }, + "tagMatch" : [ { + "key" : "keyA", + "value" : "valueA" + }, { + "key" : "keyB", + "value" : "valueB" + } ], + "filters" : { + "testTypes" : { + "values" : [ "agent-to-server", "bgp", "http-server" ] + } + }, + "customHeaders" : { + "Authorization" : "*****", + "Content-Type" : "*****" + }, + "enabled" : true + } + + """ + put_stream = thousandeyes_sdk.streaming.models.PutStream.from_json(request_body_json) + id = 'id_example' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.update_stream( + + id=id, + + aid=aid, + + put_stream=put_stream, + + _headers=self.te_headers("update_stream", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_stream_error_500(self) -> None: + """Integration test for update_stream error path (HTTP 500)""" + request_body_json = """ + + { + "endpointAgentLabel" : [ { + "id" : "1234" + }, { + "id" : "1234" + } ], + "endpointAgentTag" : [ { + "id" : "91863f70-e5a6-4a1c-a266-caf02db3607d" + }, { + "id" : "91863f70-e5a6-4a1c-a266-caf02db3607d" + } ], + "testMatch" : [ { + "id" : "1234", + "domain" : "cea" + }, { + "id" : "5678", + "domain" : "endpoint" + } ], + "streamEndpointUrl" : "https://api.thousandeyes.otel-collector", + "exporterConfig" : { + "authorization" : { + "oAuth2" : { + "clientId" : "1234567890", + "tokenUrl" : "https://example.com/token", + "clientSecret" : "1234567890", + "scopes" : [ "read", "write" ] + } + }, + "splunkHec" : { + "sourceType" : "ThousandEyesOTel", + "index" : "thousandeyes_otel_events_index", + "source" : "ThousandEyesOTel", + "token" : "d0a91307-be2f-4218-a9f8-71c02d98846b" + } + }, + "tagMatch" : [ { + "key" : "keyA", + "value" : "valueA" + }, { + "key" : "keyB", + "value" : "valueB" + } ], + "filters" : { + "testTypes" : { + "values" : [ "agent-to-server", "bgp", "http-server" ] + } + }, + "customHeaders" : { + "Authorization" : "*****", + "Content-Type" : "*****" + }, + "enabled" : true + } + + """ + put_stream = thousandeyes_sdk.streaming.models.PutStream.from_json(request_body_json) + id = 'id_example' + aid = '1234' + error_body_json = """ + { + "path" : "https://api.thousandeyes.com/v7/request/path", + "errors" : "Internal Server Error", + "timestamp" : 1679677853573, + "status" : 500 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.update_stream( + + id=id, + + aid=aid, + + put_stream=put_stream, + + _headers=self.te_headers("update_stream", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-streaming/test/test_utils.py b/thousandeyes-sdk-streaming/test/test_utils.py index 930528d9..37913f62 100644 --- a/thousandeyes-sdk-streaming/test/test_utils.py +++ b/thousandeyes-sdk-streaming/test/test_utils.py @@ -2,15 +2,36 @@ import json import unittest +from typing import Any from pydantic import BaseModel +def _project_onto_constructed(expected: Any, constructed: Any) -> Any: + """Keep only example fields that appear in the constructed model output.""" + if isinstance(constructed, dict): + if not isinstance(expected, dict): + return expected + return { + key: _project_onto_constructed(expected.get(key), value) + for key, value in constructed.items() + } + if isinstance(constructed, list): + if not isinstance(expected, list): + return expected + return [ + _project_onto_constructed(expected[index], value) + for index, value in enumerate(constructed) + ] + return expected + + def assert_constructed_model_matches_example_json(model: BaseModel, loaded_json: dict): test_case = unittest.TestCase() test_case.maxDiff = None test_case.assertIsNotNone(model) constructed_json = json.loads(model.to_json()) - sorted_loaded_json = json.dumps(loaded_json, sort_keys=True) + projected_loaded_json = _project_onto_constructed(loaded_json, constructed_json) + sorted_loaded_json = json.dumps(projected_loaded_json, sort_keys=True) sorted_constructed_json = json.dumps(constructed_json, sort_keys=True) test_case.assertEqual(sorted_loaded_json, sorted_constructed_json) diff --git a/thousandeyes-sdk-tags/test/conftest.py b/thousandeyes-sdk-tags/test/conftest.py new file mode 100644 index 00000000..2edba7b3 --- /dev/null +++ b/thousandeyes-sdk-tags/test/conftest.py @@ -0,0 +1,7 @@ +import sys +from pathlib import Path + +_repo_root = Path(__file__).resolve().parents[2] +_core_test_support = _repo_root / "thousandeyes-sdk-core" / "test" +if str(_core_test_support) not in sys.path: + sys.path.insert(0, str(_core_test_support)) diff --git a/thousandeyes-sdk-tags/test/integration_test_utils.py b/thousandeyes-sdk-tags/test/integration_test_utils.py new file mode 100644 index 00000000..38df1ff2 --- /dev/null +++ b/thousandeyes-sdk-tags/test/integration_test_utils.py @@ -0,0 +1,37 @@ +# coding: utf-8 + +""" + Tags API + + The ThousandEyes Tags API provides a tagging system with key/value pairs. It allows you to tag assets within the ThousandEyes platform (such as agents, tests, or dashboards) with meaningful metadata. For example: `branch:sfo`, `branch:nyc`, and `team:netops`. This feature provides: * Support for automation. * Powerful and flexible reports/dashboards. * Support for third-party integrations. Things to note with the ThousandEyes Tags API: * Tags are backwards-compatible with existing labels. * Tags are separated by Tests (CEA), Agents (CEA), Endpoint Agents, Scheduled Endpoint Tests, and Reports. A single tag can only apply to one type of target object, so each tag must specify the target type of object via a `type` field. * Tags are defined in a single table so that they can be represented using a single model - `Tag`. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from thousandeyes_sdk.core.api_client import ApiClient +from thousandeyes_sdk.core.configuration import Configuration +from sdk_test_support.mock_server import ERROR_STATUS_HEADER, OPERATION_ID_HEADER, MockApiServer + +from .mock_manifest import OPERATION_MANIFEST + + +class IntegrationTestBase(unittest.TestCase): + def setUp(self) -> None: + self.server = MockApiServer(OPERATION_MANIFEST) + self.server.start() + configuration = Configuration(host=self.server.base_url, access_token="test-token") + self.api_client = ApiClient(configuration=configuration) + + def tearDown(self) -> None: + self.server.stop() + + def te_headers(self, operation_id: str, error_status=None): + headers = {OPERATION_ID_HEADER: operation_id} + if error_status is not None: + headers[ERROR_STATUS_HEADER] = error_status + return headers diff --git a/thousandeyes-sdk-tags/test/mock_manifest.py b/thousandeyes-sdk-tags/test/mock_manifest.py new file mode 100644 index 00000000..6d951851 --- /dev/null +++ b/thousandeyes-sdk-tags/test/mock_manifest.py @@ -0,0 +1,1774 @@ +# coding: utf-8 + +""" + Tags API + + The ThousandEyes Tags API provides a tagging system with key/value pairs. It allows you to tag assets within the ThousandEyes platform (such as agents, tests, or dashboards) with meaningful metadata. For example: `branch:sfo`, `branch:nyc`, and `team:netops`. This feature provides: * Support for automation. * Powerful and flexible reports/dashboards. * Support for third-party integrations. Things to note with the ThousandEyes Tags API: * Tags are backwards-compatible with existing labels. * Tags are separated by Tests (CEA), Agents (CEA), Endpoint Agents, Scheduled Endpoint Tests, and Reports. A single tag can only apply to one type of target object, so each tag must specify the target type of object via a `type` field. * Tags are defined in a single table so that they can be represented using a single model - `Tag`. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json + +from sdk_test_support.mock_server_types import ErrorResponseExpectation, OperationExpectation + +OPERATION_MANIFEST = { + + "assign_tag": OperationExpectation( + operation_id="assign_tag", + method="POST", + path="/tags/{id}/assign", + path_param_examples={ + "id": 'c6b78e57-81a2-4c5f-a11a-d96c3c664d55', + }, + success_status=207, + success_body=json.loads(""" + + { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ], + "tagId" : "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ] + } + + """), + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "path" : "https://api.thousandeyes.com/v7/request/path", + "errors" : "Internal Server Error", + "timestamp" : 1679677853573, + "status" : 500 + }"""), + content_type="application/json", + ), + + }, + ), + + "assign_tags": OperationExpectation( + operation_id="assign_tags", + method="POST", + path="/tags/assign", + path_param_examples={ + }, + success_status=207, + success_body=json.loads(""" + + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "tags" : [ { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ], + "tagId" : "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + }, { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ], + "tagId" : "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + } ] + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "tags" : [ { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ], + "tagId" : "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + }, { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ], + "tagId" : "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + } ] + } + + """), + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "path" : "https://api.thousandeyes.com/v7/request/path", + "errors" : "Internal Server Error", + "timestamp" : 1679677853573, + "status" : 500 + }"""), + content_type="application/json", + ), + + }, + ), + + "unassign_tag": OperationExpectation( + operation_id="unassign_tag", + method="POST", + path="/tags/{id}/unassign", + path_param_examples={ + "id": 'c6b78e57-81a2-4c5f-a11a-d96c3c664d55', + }, + success_status=204, + success_body=None, + success_content_type="application/json", + request_body_example=json.loads(""" + + { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ] + } + + """), + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "path" : "https://api.thousandeyes.com/v7/request/path", + "errors" : "Internal Server Error", + "timestamp" : 1679677853573, + "status" : 500 + }"""), + content_type="application/json", + ), + + }, + ), + + "unassign_tags": OperationExpectation( + operation_id="unassign_tags", + method="POST", + path="/tags/unassign", + path_param_examples={ + }, + success_status=207, + success_body=json.loads(""" + + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "tags" : [ { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ], + "tagId" : "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + }, { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ], + "tagId" : "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + } ] + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "tags" : [ { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ], + "tagId" : "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + }, { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ], + "tagId" : "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + } ] + } + + """), + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "path" : "https://api.thousandeyes.com/v7/request/path", + "errors" : "Internal Server Error", + "timestamp" : 1679677853573, + "status" : 500 + }"""), + content_type="application/json", + ), + + }, + ), + + "create_tag": OperationExpectation( + operation_id="create_tag", + method="POST", + path="/tags", + path_param_examples={ + }, + success_status=201, + success_body=json.loads(""" + + { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ], + "color" : "#FF0000", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "matchType" : "and", + "builtIn" : true, + "icon" : "icon", + "description" : "To tag assets in San Francisco", + "filters" : [ { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + }, { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + } ], + "type" : "static", + "objectType" : "test", + "accessType" : "all", + "modifiedDate" : "2022-03-01T23:31:11Z", + "legacyId" : 0.8008281904610115, + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "aid" : 1234, + "value" : "sfo", + "key" : "branch", + "createDate" : "2022-03-01T23:31:11Z" + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ], + "color" : "#FF0000", + "matchType" : "and", + "builtIn" : true, + "icon" : "icon", + "description" : "To tag assets in San Francisco", + "filters" : [ { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + }, { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + } ], + "type" : "static", + "objectType" : "test", + "accessType" : "all", + "modifiedDate" : "2022-03-01T23:31:11Z", + "legacyId" : 0.8008281904610115, + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "aid" : 1234, + "value" : "sfo", + "key" : "branch", + "createDate" : "2022-03-01T23:31:11Z" + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "path" : "https://api.thousandeyes.com/v7/request/path", + "errors" : "Internal Server Error", + "timestamp" : 1679677853573, + "status" : 500 + }"""), + content_type="application/json", + ), + + }, + ), + + "create_tags": OperationExpectation( + operation_id="create_tags", + method="POST", + path="/tags/bulk", + path_param_examples={ + }, + success_status=207, + success_body=json.loads(""" + + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "errors" : [ { + "tag" : { + "key" : { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ], + "color" : "#FF0000", + "matchType" : "and", + "builtIn" : true, + "icon" : "icon", + "description" : "To tag assets in San Francisco", + "filters" : [ { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + }, { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + } ], + "type" : "static", + "objectType" : "test", + "accessType" : "all", + "modifiedDate" : "2022-03-01T23:31:11Z", + "legacyId" : 0.8008281904610115, + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "aid" : 1234, + "value" : "sfo", + "key" : "branch", + "createDate" : "2022-03-01T23:31:11Z" + } + }, + "message" : "Object successfully created", + "responseCode" : 200 + }, { + "tag" : { + "key" : { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ], + "color" : "#FF0000", + "matchType" : "and", + "builtIn" : true, + "icon" : "icon", + "description" : "To tag assets in San Francisco", + "filters" : [ { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + }, { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + } ], + "type" : "static", + "objectType" : "test", + "accessType" : "all", + "modifiedDate" : "2022-03-01T23:31:11Z", + "legacyId" : 0.8008281904610115, + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "aid" : 1234, + "value" : "sfo", + "key" : "branch", + "createDate" : "2022-03-01T23:31:11Z" + } + }, + "message" : "Object successfully created", + "responseCode" : 200 + } ], + "tags" : [ { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ], + "color" : "#FF0000", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "matchType" : "and", + "builtIn" : true, + "icon" : "icon", + "description" : "To tag assets in San Francisco", + "filters" : [ { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + }, { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + } ], + "type" : "static", + "objectType" : "test", + "accessType" : "all", + "modifiedDate" : "2022-03-01T23:31:11Z", + "legacyId" : 0.8008281904610115, + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "aid" : 1234, + "value" : "sfo", + "key" : "branch", + "createDate" : "2022-03-01T23:31:11Z" + }, { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ], + "color" : "#FF0000", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "matchType" : "and", + "builtIn" : true, + "icon" : "icon", + "description" : "To tag assets in San Francisco", + "filters" : [ { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + }, { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + } ], + "type" : "static", + "objectType" : "test", + "accessType" : "all", + "modifiedDate" : "2022-03-01T23:31:11Z", + "legacyId" : 0.8008281904610115, + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "aid" : 1234, + "value" : "sfo", + "key" : "branch", + "createDate" : "2022-03-01T23:31:11Z" + } ] + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "errors" : [ { + "tag" : { + "key" : { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ], + "color" : "#FF0000", + "matchType" : "and", + "builtIn" : true, + "icon" : "icon", + "description" : "To tag assets in San Francisco", + "filters" : [ { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + }, { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + } ], + "type" : "static", + "objectType" : "test", + "accessType" : "all", + "modifiedDate" : "2022-03-01T23:31:11Z", + "legacyId" : 0.8008281904610115, + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "aid" : 1234, + "value" : "sfo", + "key" : "branch", + "createDate" : "2022-03-01T23:31:11Z" + } + }, + "message" : "Object successfully created", + "responseCode" : 200 + }, { + "tag" : { + "key" : { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ], + "color" : "#FF0000", + "matchType" : "and", + "builtIn" : true, + "icon" : "icon", + "description" : "To tag assets in San Francisco", + "filters" : [ { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + }, { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + } ], + "type" : "static", + "objectType" : "test", + "accessType" : "all", + "modifiedDate" : "2022-03-01T23:31:11Z", + "legacyId" : 0.8008281904610115, + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "aid" : 1234, + "value" : "sfo", + "key" : "branch", + "createDate" : "2022-03-01T23:31:11Z" + } + }, + "message" : "Object successfully created", + "responseCode" : 200 + } ], + "tags" : [ { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ], + "color" : "#FF0000", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "matchType" : "and", + "builtIn" : true, + "icon" : "icon", + "description" : "To tag assets in San Francisco", + "filters" : [ { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + }, { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + } ], + "type" : "static", + "objectType" : "test", + "accessType" : "all", + "modifiedDate" : "2022-03-01T23:31:11Z", + "legacyId" : 0.8008281904610115, + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "aid" : 1234, + "value" : "sfo", + "key" : "branch", + "createDate" : "2022-03-01T23:31:11Z" + }, { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ], + "color" : "#FF0000", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "matchType" : "and", + "builtIn" : true, + "icon" : "icon", + "description" : "To tag assets in San Francisco", + "filters" : [ { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + }, { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + } ], + "type" : "static", + "objectType" : "test", + "accessType" : "all", + "modifiedDate" : "2022-03-01T23:31:11Z", + "legacyId" : 0.8008281904610115, + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "aid" : 1234, + "value" : "sfo", + "key" : "branch", + "createDate" : "2022-03-01T23:31:11Z" + } ] + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "path" : "https://api.thousandeyes.com/v7/request/path", + "errors" : "Internal Server Error", + "timestamp" : 1679677853573, + "status" : 500 + }"""), + content_type="application/json", + ), + + }, + ), + + "delete_tag": OperationExpectation( + operation_id="delete_tag", + method="DELETE", + path="/tags/{id}", + path_param_examples={ + "id": 'c6b78e57-81a2-4c5f-a11a-d96c3c664d55', + }, + success_status=204, + success_body=None, + success_content_type="application/json", + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "path" : "https://api.thousandeyes.com/v7/request/path", + "errors" : "Internal Server Error", + "timestamp" : 1679677853573, + "status" : 500 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_tag": OperationExpectation( + operation_id="get_tag", + method="GET", + path="/tags/{id}", + path_param_examples={ + "id": 'c6b78e57-81a2-4c5f-a11a-d96c3c664d55', + }, + success_status=200, + success_body=json.loads(""" + + { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ], + "color" : "#FF0000", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "matchType" : "and", + "builtIn" : true, + "icon" : "icon", + "description" : "To tag assets in San Francisco", + "filters" : [ { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + }, { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + } ], + "type" : "static", + "objectType" : "test", + "accessType" : "all", + "modifiedDate" : "2022-03-01T23:31:11Z", + "legacyId" : 0.8008281904610115, + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "aid" : 1234, + "value" : "sfo", + "key" : "branch", + "createDate" : "2022-03-01T23:31:11Z" + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "path" : "https://api.thousandeyes.com/v7/request/path", + "errors" : "Internal Server Error", + "timestamp" : 1679677853573, + "status" : 500 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_tags": OperationExpectation( + operation_id="get_tags", + method="GET", + path="/tags", + path_param_examples={ + }, + success_status=200, + success_body=json.loads(""" + + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "tags" : [ { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ], + "color" : "#FF0000", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "matchType" : "and", + "builtIn" : true, + "icon" : "icon", + "description" : "To tag assets in San Francisco", + "filters" : [ { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + }, { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + } ], + "type" : "static", + "objectType" : "test", + "accessType" : "all", + "modifiedDate" : "2022-03-01T23:31:11Z", + "legacyId" : 0.8008281904610115, + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "aid" : 1234, + "value" : "sfo", + "key" : "branch", + "createDate" : "2022-03-01T23:31:11Z" + }, { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ], + "color" : "#FF0000", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "matchType" : "and", + "builtIn" : true, + "icon" : "icon", + "description" : "To tag assets in San Francisco", + "filters" : [ { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + }, { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + } ], + "type" : "static", + "objectType" : "test", + "accessType" : "all", + "modifiedDate" : "2022-03-01T23:31:11Z", + "legacyId" : 0.8008281904610115, + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "aid" : 1234, + "value" : "sfo", + "key" : "branch", + "createDate" : "2022-03-01T23:31:11Z" + } ] + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "path" : "https://api.thousandeyes.com/v7/request/path", + "errors" : "Internal Server Error", + "timestamp" : 1679677853573, + "status" : 500 + }"""), + content_type="application/json", + ), + + }, + ), + + "update_tag": OperationExpectation( + operation_id="update_tag", + method="PUT", + path="/tags/{id}", + path_param_examples={ + "id": 'c6b78e57-81a2-4c5f-a11a-d96c3c664d55', + }, + success_status=200, + success_body=json.loads(""" + + { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ], + "color" : "#FF0000", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "matchType" : "and", + "builtIn" : true, + "icon" : "icon", + "description" : "To tag assets in San Francisco", + "filters" : [ { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + }, { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + } ], + "type" : "static", + "objectType" : "test", + "accessType" : "all", + "modifiedDate" : "2022-03-01T23:31:11Z", + "legacyId" : 0.8008281904610115, + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "aid" : 1234, + "value" : "sfo", + "key" : "branch", + "createDate" : "2022-03-01T23:31:11Z" + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ], + "color" : "#FF0000", + "matchType" : "and", + "builtIn" : true, + "icon" : "icon", + "description" : "To tag assets in San Francisco", + "filters" : [ { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + }, { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + } ], + "type" : "static", + "objectType" : "test", + "accessType" : "all", + "modifiedDate" : "2022-03-01T23:31:11Z", + "legacyId" : 0.8008281904610115, + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "aid" : 1234, + "value" : "sfo", + "key" : "branch", + "createDate" : "2022-03-01T23:31:11Z" + } + + """), + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "path" : "https://api.thousandeyes.com/v7/request/path", + "errors" : "Internal Server Error", + "timestamp" : 1679677853573, + "status" : 500 + }"""), + content_type="application/json", + ), + + }, + ), + +} diff --git a/thousandeyes-sdk-tags/test/test_tag_assignment_api_integration.py b/thousandeyes-sdk-tags/test/test_tag_assignment_api_integration.py new file mode 100644 index 00000000..692a2599 --- /dev/null +++ b/thousandeyes-sdk-tags/test/test_tag_assignment_api_integration.py @@ -0,0 +1,1717 @@ +# coding: utf-8 + +""" + Tags API + + The ThousandEyes Tags API provides a tagging system with key/value pairs. It allows you to tag assets within the ThousandEyes platform (such as agents, tests, or dashboards) with meaningful metadata. For example: `branch:sfo`, `branch:nyc`, and `team:netops`. This feature provides: * Support for automation. * Powerful and flexible reports/dashboards. * Support for third-party integrations. Things to note with the ThousandEyes Tags API: * Tags are backwards-compatible with existing labels. * Tags are separated by Tests (CEA), Agents (CEA), Endpoint Agents, Scheduled Endpoint Tests, and Reports. A single tag can only apply to one type of target object, so each tag must specify the target type of object via a `type` field. * Tags are defined in a single table so that they can be represented using a single model - `Tag`. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.tags.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.tags.api.tag_assignment_api import TagAssignmentApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestTagAssignmentApiIntegration(IntegrationTestBase): + """TagAssignmentApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = TagAssignmentApi(self.api_client) + + + def test_assign_tag_happy_path(self) -> None: + """Integration test for assign_tag success path""" + request_body_json = """ + + { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ] + } + + """ + tag_assignment = thousandeyes_sdk.tags.models.TagAssignment.from_json(request_body_json) + id = 'c6b78e57-81a2-4c5f-a11a-d96c3c664d55' + aid = '1234' + response_body_json = """ + { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ], + "tagId" : "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + } + """ + expected_response = json.loads(response_body_json) + response = self.api.assign_tag( + + id=id, + + tag_assignment=tag_assignment, + + aid=aid, + + _headers=self.te_headers("assign_tag"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_assign_tag_error_401(self) -> None: + """Integration test for assign_tag error path (HTTP 401)""" + request_body_json = """ + + { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ] + } + + """ + tag_assignment = thousandeyes_sdk.tags.models.TagAssignment.from_json(request_body_json) + id = 'c6b78e57-81a2-4c5f-a11a-d96c3c664d55' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.assign_tag( + + id=id, + + tag_assignment=tag_assignment, + + aid=aid, + + _headers=self.te_headers("assign_tag", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_assign_tag_error_403(self) -> None: + """Integration test for assign_tag error path (HTTP 403)""" + request_body_json = """ + + { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ] + } + + """ + tag_assignment = thousandeyes_sdk.tags.models.TagAssignment.from_json(request_body_json) + id = 'c6b78e57-81a2-4c5f-a11a-d96c3c664d55' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.assign_tag( + + id=id, + + tag_assignment=tag_assignment, + + aid=aid, + + _headers=self.te_headers("assign_tag", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_assign_tag_error_404(self) -> None: + """Integration test for assign_tag error path (HTTP 404)""" + request_body_json = """ + + { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ] + } + + """ + tag_assignment = thousandeyes_sdk.tags.models.TagAssignment.from_json(request_body_json) + id = 'c6b78e57-81a2-4c5f-a11a-d96c3c664d55' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.assign_tag( + + id=id, + + tag_assignment=tag_assignment, + + aid=aid, + + _headers=self.te_headers("assign_tag", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_assign_tag_error_429(self) -> None: + """Integration test for assign_tag error path (HTTP 429)""" + request_body_json = """ + + { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ] + } + + """ + tag_assignment = thousandeyes_sdk.tags.models.TagAssignment.from_json(request_body_json) + id = 'c6b78e57-81a2-4c5f-a11a-d96c3c664d55' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.assign_tag( + + id=id, + + tag_assignment=tag_assignment, + + aid=aid, + + _headers=self.te_headers("assign_tag", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_assign_tag_error_500(self) -> None: + """Integration test for assign_tag error path (HTTP 500)""" + request_body_json = """ + + { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ] + } + + """ + tag_assignment = thousandeyes_sdk.tags.models.TagAssignment.from_json(request_body_json) + id = 'c6b78e57-81a2-4c5f-a11a-d96c3c664d55' + aid = '1234' + error_body_json = """ + { + "path" : "https://api.thousandeyes.com/v7/request/path", + "errors" : "Internal Server Error", + "timestamp" : 1679677853573, + "status" : 500 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.assign_tag( + + id=id, + + tag_assignment=tag_assignment, + + aid=aid, + + _headers=self.te_headers("assign_tag", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_assign_tags_happy_path(self) -> None: + """Integration test for assign_tags success path""" + request_body_json = """ + + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "tags" : [ { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ], + "tagId" : "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + }, { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ], + "tagId" : "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + } ] + } + + """ + bulk_tag_assignments = thousandeyes_sdk.tags.models.BulkTagAssignments.from_json(request_body_json) + aid = '1234' + response_body_json = """ + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "tags" : [ { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ], + "tagId" : "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + }, { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ], + "tagId" : "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + } ] + } + """ + expected_response = json.loads(response_body_json) + response = self.api.assign_tags( + + bulk_tag_assignments=bulk_tag_assignments, + + aid=aid, + + _headers=self.te_headers("assign_tags"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_assign_tags_error_401(self) -> None: + """Integration test for assign_tags error path (HTTP 401)""" + request_body_json = """ + + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "tags" : [ { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ], + "tagId" : "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + }, { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ], + "tagId" : "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + } ] + } + + """ + bulk_tag_assignments = thousandeyes_sdk.tags.models.BulkTagAssignments.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.assign_tags( + + bulk_tag_assignments=bulk_tag_assignments, + + aid=aid, + + _headers=self.te_headers("assign_tags", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_assign_tags_error_403(self) -> None: + """Integration test for assign_tags error path (HTTP 403)""" + request_body_json = """ + + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "tags" : [ { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ], + "tagId" : "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + }, { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ], + "tagId" : "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + } ] + } + + """ + bulk_tag_assignments = thousandeyes_sdk.tags.models.BulkTagAssignments.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.assign_tags( + + bulk_tag_assignments=bulk_tag_assignments, + + aid=aid, + + _headers=self.te_headers("assign_tags", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_assign_tags_error_404(self) -> None: + """Integration test for assign_tags error path (HTTP 404)""" + request_body_json = """ + + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "tags" : [ { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ], + "tagId" : "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + }, { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ], + "tagId" : "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + } ] + } + + """ + bulk_tag_assignments = thousandeyes_sdk.tags.models.BulkTagAssignments.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.assign_tags( + + bulk_tag_assignments=bulk_tag_assignments, + + aid=aid, + + _headers=self.te_headers("assign_tags", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_assign_tags_error_429(self) -> None: + """Integration test for assign_tags error path (HTTP 429)""" + request_body_json = """ + + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "tags" : [ { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ], + "tagId" : "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + }, { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ], + "tagId" : "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + } ] + } + + """ + bulk_tag_assignments = thousandeyes_sdk.tags.models.BulkTagAssignments.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.assign_tags( + + bulk_tag_assignments=bulk_tag_assignments, + + aid=aid, + + _headers=self.te_headers("assign_tags", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_assign_tags_error_500(self) -> None: + """Integration test for assign_tags error path (HTTP 500)""" + request_body_json = """ + + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "tags" : [ { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ], + "tagId" : "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + }, { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ], + "tagId" : "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + } ] + } + + """ + bulk_tag_assignments = thousandeyes_sdk.tags.models.BulkTagAssignments.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "path" : "https://api.thousandeyes.com/v7/request/path", + "errors" : "Internal Server Error", + "timestamp" : 1679677853573, + "status" : 500 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.assign_tags( + + bulk_tag_assignments=bulk_tag_assignments, + + aid=aid, + + _headers=self.te_headers("assign_tags", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_unassign_tag_happy_path(self) -> None: + """Integration test for unassign_tag success path""" + request_body_json = """ + + { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ] + } + + """ + tag_assignment = thousandeyes_sdk.tags.models.TagAssignment.from_json(request_body_json) + id = 'c6b78e57-81a2-4c5f-a11a-d96c3c664d55' + aid = '1234' + response = self.api.unassign_tag_with_http_info( + + id=id, + + tag_assignment=tag_assignment, + + aid=aid, + + _headers=self.te_headers("unassign_tag"), + ) + self.assertEqual(204, response.status_code) + self.assertIsNone(response.data) + + + def test_unassign_tag_error_401(self) -> None: + """Integration test for unassign_tag error path (HTTP 401)""" + request_body_json = """ + + { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ] + } + + """ + tag_assignment = thousandeyes_sdk.tags.models.TagAssignment.from_json(request_body_json) + id = 'c6b78e57-81a2-4c5f-a11a-d96c3c664d55' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.unassign_tag( + + id=id, + + tag_assignment=tag_assignment, + + aid=aid, + + _headers=self.te_headers("unassign_tag", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_unassign_tag_error_403(self) -> None: + """Integration test for unassign_tag error path (HTTP 403)""" + request_body_json = """ + + { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ] + } + + """ + tag_assignment = thousandeyes_sdk.tags.models.TagAssignment.from_json(request_body_json) + id = 'c6b78e57-81a2-4c5f-a11a-d96c3c664d55' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.unassign_tag( + + id=id, + + tag_assignment=tag_assignment, + + aid=aid, + + _headers=self.te_headers("unassign_tag", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_unassign_tag_error_404(self) -> None: + """Integration test for unassign_tag error path (HTTP 404)""" + request_body_json = """ + + { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ] + } + + """ + tag_assignment = thousandeyes_sdk.tags.models.TagAssignment.from_json(request_body_json) + id = 'c6b78e57-81a2-4c5f-a11a-d96c3c664d55' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.unassign_tag( + + id=id, + + tag_assignment=tag_assignment, + + aid=aid, + + _headers=self.te_headers("unassign_tag", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_unassign_tag_error_429(self) -> None: + """Integration test for unassign_tag error path (HTTP 429)""" + request_body_json = """ + + { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ] + } + + """ + tag_assignment = thousandeyes_sdk.tags.models.TagAssignment.from_json(request_body_json) + id = 'c6b78e57-81a2-4c5f-a11a-d96c3c664d55' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.unassign_tag( + + id=id, + + tag_assignment=tag_assignment, + + aid=aid, + + _headers=self.te_headers("unassign_tag", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_unassign_tag_error_500(self) -> None: + """Integration test for unassign_tag error path (HTTP 500)""" + request_body_json = """ + + { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ] + } + + """ + tag_assignment = thousandeyes_sdk.tags.models.TagAssignment.from_json(request_body_json) + id = 'c6b78e57-81a2-4c5f-a11a-d96c3c664d55' + aid = '1234' + error_body_json = """ + { + "path" : "https://api.thousandeyes.com/v7/request/path", + "errors" : "Internal Server Error", + "timestamp" : 1679677853573, + "status" : 500 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.unassign_tag( + + id=id, + + tag_assignment=tag_assignment, + + aid=aid, + + _headers=self.te_headers("unassign_tag", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_unassign_tags_happy_path(self) -> None: + """Integration test for unassign_tags success path""" + request_body_json = """ + + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "tags" : [ { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ], + "tagId" : "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + }, { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ], + "tagId" : "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + } ] + } + + """ + bulk_tag_assignments = thousandeyes_sdk.tags.models.BulkTagAssignments.from_json(request_body_json) + aid = '1234' + response_body_json = """ + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "tags" : [ { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ], + "tagId" : "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + }, { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ], + "tagId" : "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + } ] + } + """ + expected_response = json.loads(response_body_json) + response = self.api.unassign_tags( + + bulk_tag_assignments=bulk_tag_assignments, + + aid=aid, + + _headers=self.te_headers("unassign_tags"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_unassign_tags_error_401(self) -> None: + """Integration test for unassign_tags error path (HTTP 401)""" + request_body_json = """ + + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "tags" : [ { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ], + "tagId" : "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + }, { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ], + "tagId" : "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + } ] + } + + """ + bulk_tag_assignments = thousandeyes_sdk.tags.models.BulkTagAssignments.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.unassign_tags( + + bulk_tag_assignments=bulk_tag_assignments, + + aid=aid, + + _headers=self.te_headers("unassign_tags", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_unassign_tags_error_403(self) -> None: + """Integration test for unassign_tags error path (HTTP 403)""" + request_body_json = """ + + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "tags" : [ { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ], + "tagId" : "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + }, { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ], + "tagId" : "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + } ] + } + + """ + bulk_tag_assignments = thousandeyes_sdk.tags.models.BulkTagAssignments.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.unassign_tags( + + bulk_tag_assignments=bulk_tag_assignments, + + aid=aid, + + _headers=self.te_headers("unassign_tags", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_unassign_tags_error_404(self) -> None: + """Integration test for unassign_tags error path (HTTP 404)""" + request_body_json = """ + + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "tags" : [ { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ], + "tagId" : "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + }, { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ], + "tagId" : "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + } ] + } + + """ + bulk_tag_assignments = thousandeyes_sdk.tags.models.BulkTagAssignments.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.unassign_tags( + + bulk_tag_assignments=bulk_tag_assignments, + + aid=aid, + + _headers=self.te_headers("unassign_tags", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_unassign_tags_error_429(self) -> None: + """Integration test for unassign_tags error path (HTTP 429)""" + request_body_json = """ + + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "tags" : [ { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ], + "tagId" : "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + }, { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ], + "tagId" : "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + } ] + } + + """ + bulk_tag_assignments = thousandeyes_sdk.tags.models.BulkTagAssignments.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.unassign_tags( + + bulk_tag_assignments=bulk_tag_assignments, + + aid=aid, + + _headers=self.te_headers("unassign_tags", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_unassign_tags_error_500(self) -> None: + """Integration test for unassign_tags error path (HTTP 500)""" + request_body_json = """ + + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "tags" : [ { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ], + "tagId" : "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + }, { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ], + "tagId" : "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + } ] + } + + """ + bulk_tag_assignments = thousandeyes_sdk.tags.models.BulkTagAssignments.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "path" : "https://api.thousandeyes.com/v7/request/path", + "errors" : "Internal Server Error", + "timestamp" : 1679677853573, + "status" : 500 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.unassign_tags( + + bulk_tag_assignments=bulk_tag_assignments, + + aid=aid, + + _headers=self.te_headers("unassign_tags", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-tags/test/test_tags_api_integration.py b/thousandeyes-sdk-tags/test/test_tags_api_integration.py new file mode 100644 index 00000000..c2652462 --- /dev/null +++ b/thousandeyes-sdk-tags/test/test_tags_api_integration.py @@ -0,0 +1,2469 @@ +# coding: utf-8 + +""" + Tags API + + The ThousandEyes Tags API provides a tagging system with key/value pairs. It allows you to tag assets within the ThousandEyes platform (such as agents, tests, or dashboards) with meaningful metadata. For example: `branch:sfo`, `branch:nyc`, and `team:netops`. This feature provides: * Support for automation. * Powerful and flexible reports/dashboards. * Support for third-party integrations. Things to note with the ThousandEyes Tags API: * Tags are backwards-compatible with existing labels. * Tags are separated by Tests (CEA), Agents (CEA), Endpoint Agents, Scheduled Endpoint Tests, and Reports. A single tag can only apply to one type of target object, so each tag must specify the target type of object via a `type` field. * Tags are defined in a single table so that they can be represented using a single model - `Tag`. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.tags.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.tags.api.tags_api import TagsApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestTagsApiIntegration(IntegrationTestBase): + """TagsApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = TagsApi(self.api_client) + + + def test_create_tag_happy_path(self) -> None: + """Integration test for create_tag success path""" + request_body_json = """ + + { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ], + "color" : "#FF0000", + "matchType" : "and", + "builtIn" : true, + "icon" : "icon", + "description" : "To tag assets in San Francisco", + "filters" : [ { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + }, { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + } ], + "type" : "static", + "objectType" : "test", + "accessType" : "all", + "modifiedDate" : "2022-03-01T23:31:11Z", + "legacyId" : 0.8008281904610115, + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "aid" : 1234, + "value" : "sfo", + "key" : "branch", + "createDate" : "2022-03-01T23:31:11Z" + } + + """ + tag_info = thousandeyes_sdk.tags.models.TagInfo.from_json(request_body_json) + aid = '1234' + response_body_json = """ + { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ], + "color" : "#FF0000", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "matchType" : "and", + "builtIn" : true, + "icon" : "icon", + "description" : "To tag assets in San Francisco", + "filters" : [ { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + }, { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + } ], + "type" : "static", + "objectType" : "test", + "accessType" : "all", + "modifiedDate" : "2022-03-01T23:31:11Z", + "legacyId" : 0.8008281904610115, + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "aid" : 1234, + "value" : "sfo", + "key" : "branch", + "createDate" : "2022-03-01T23:31:11Z" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.create_tag( + + aid=aid, + + tag_info=tag_info, + + _headers=self.te_headers("create_tag"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_create_tag_error_400(self) -> None: + """Integration test for create_tag error path (HTTP 400)""" + request_body_json = """ + + { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ], + "color" : "#FF0000", + "matchType" : "and", + "builtIn" : true, + "icon" : "icon", + "description" : "To tag assets in San Francisco", + "filters" : [ { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + }, { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + } ], + "type" : "static", + "objectType" : "test", + "accessType" : "all", + "modifiedDate" : "2022-03-01T23:31:11Z", + "legacyId" : 0.8008281904610115, + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "aid" : 1234, + "value" : "sfo", + "key" : "branch", + "createDate" : "2022-03-01T23:31:11Z" + } + + """ + tag_info = thousandeyes_sdk.tags.models.TagInfo.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.create_tag( + + aid=aid, + + tag_info=tag_info, + + _headers=self.te_headers("create_tag", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_tag_error_401(self) -> None: + """Integration test for create_tag error path (HTTP 401)""" + request_body_json = """ + + { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ], + "color" : "#FF0000", + "matchType" : "and", + "builtIn" : true, + "icon" : "icon", + "description" : "To tag assets in San Francisco", + "filters" : [ { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + }, { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + } ], + "type" : "static", + "objectType" : "test", + "accessType" : "all", + "modifiedDate" : "2022-03-01T23:31:11Z", + "legacyId" : 0.8008281904610115, + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "aid" : 1234, + "value" : "sfo", + "key" : "branch", + "createDate" : "2022-03-01T23:31:11Z" + } + + """ + tag_info = thousandeyes_sdk.tags.models.TagInfo.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.create_tag( + + aid=aid, + + tag_info=tag_info, + + _headers=self.te_headers("create_tag", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_tag_error_500(self) -> None: + """Integration test for create_tag error path (HTTP 500)""" + request_body_json = """ + + { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ], + "color" : "#FF0000", + "matchType" : "and", + "builtIn" : true, + "icon" : "icon", + "description" : "To tag assets in San Francisco", + "filters" : [ { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + }, { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + } ], + "type" : "static", + "objectType" : "test", + "accessType" : "all", + "modifiedDate" : "2022-03-01T23:31:11Z", + "legacyId" : 0.8008281904610115, + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "aid" : 1234, + "value" : "sfo", + "key" : "branch", + "createDate" : "2022-03-01T23:31:11Z" + } + + """ + tag_info = thousandeyes_sdk.tags.models.TagInfo.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "path" : "https://api.thousandeyes.com/v7/request/path", + "errors" : "Internal Server Error", + "timestamp" : 1679677853573, + "status" : 500 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.create_tag( + + aid=aid, + + tag_info=tag_info, + + _headers=self.te_headers("create_tag", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_create_tags_happy_path(self) -> None: + """Integration test for create_tags success path""" + request_body_json = """ + + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "errors" : [ { + "tag" : { + "key" : { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ], + "color" : "#FF0000", + "matchType" : "and", + "builtIn" : true, + "icon" : "icon", + "description" : "To tag assets in San Francisco", + "filters" : [ { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + }, { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + } ], + "type" : "static", + "objectType" : "test", + "accessType" : "all", + "modifiedDate" : "2022-03-01T23:31:11Z", + "legacyId" : 0.8008281904610115, + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "aid" : 1234, + "value" : "sfo", + "key" : "branch", + "createDate" : "2022-03-01T23:31:11Z" + } + }, + "message" : "Object successfully created", + "responseCode" : 200 + }, { + "tag" : { + "key" : { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ], + "color" : "#FF0000", + "matchType" : "and", + "builtIn" : true, + "icon" : "icon", + "description" : "To tag assets in San Francisco", + "filters" : [ { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + }, { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + } ], + "type" : "static", + "objectType" : "test", + "accessType" : "all", + "modifiedDate" : "2022-03-01T23:31:11Z", + "legacyId" : 0.8008281904610115, + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "aid" : 1234, + "value" : "sfo", + "key" : "branch", + "createDate" : "2022-03-01T23:31:11Z" + } + }, + "message" : "Object successfully created", + "responseCode" : 200 + } ], + "tags" : [ { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ], + "color" : "#FF0000", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "matchType" : "and", + "builtIn" : true, + "icon" : "icon", + "description" : "To tag assets in San Francisco", + "filters" : [ { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + }, { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + } ], + "type" : "static", + "objectType" : "test", + "accessType" : "all", + "modifiedDate" : "2022-03-01T23:31:11Z", + "legacyId" : 0.8008281904610115, + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "aid" : 1234, + "value" : "sfo", + "key" : "branch", + "createDate" : "2022-03-01T23:31:11Z" + }, { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ], + "color" : "#FF0000", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "matchType" : "and", + "builtIn" : true, + "icon" : "icon", + "description" : "To tag assets in San Francisco", + "filters" : [ { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + }, { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + } ], + "type" : "static", + "objectType" : "test", + "accessType" : "all", + "modifiedDate" : "2022-03-01T23:31:11Z", + "legacyId" : 0.8008281904610115, + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "aid" : 1234, + "value" : "sfo", + "key" : "branch", + "createDate" : "2022-03-01T23:31:11Z" + } ] + } + + """ + bulk_tag_response = thousandeyes_sdk.tags.models.BulkTagResponse.from_json(request_body_json) + aid = '1234' + response_body_json = """ + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "errors" : [ { + "tag" : { + "key" : { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ], + "color" : "#FF0000", + "matchType" : "and", + "builtIn" : true, + "icon" : "icon", + "description" : "To tag assets in San Francisco", + "filters" : [ { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + }, { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + } ], + "type" : "static", + "objectType" : "test", + "accessType" : "all", + "modifiedDate" : "2022-03-01T23:31:11Z", + "legacyId" : 0.8008281904610115, + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "aid" : 1234, + "value" : "sfo", + "key" : "branch", + "createDate" : "2022-03-01T23:31:11Z" + } + }, + "message" : "Object successfully created", + "responseCode" : 200 + }, { + "tag" : { + "key" : { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ], + "color" : "#FF0000", + "matchType" : "and", + "builtIn" : true, + "icon" : "icon", + "description" : "To tag assets in San Francisco", + "filters" : [ { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + }, { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + } ], + "type" : "static", + "objectType" : "test", + "accessType" : "all", + "modifiedDate" : "2022-03-01T23:31:11Z", + "legacyId" : 0.8008281904610115, + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "aid" : 1234, + "value" : "sfo", + "key" : "branch", + "createDate" : "2022-03-01T23:31:11Z" + } + }, + "message" : "Object successfully created", + "responseCode" : 200 + } ], + "tags" : [ { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ], + "color" : "#FF0000", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "matchType" : "and", + "builtIn" : true, + "icon" : "icon", + "description" : "To tag assets in San Francisco", + "filters" : [ { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + }, { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + } ], + "type" : "static", + "objectType" : "test", + "accessType" : "all", + "modifiedDate" : "2022-03-01T23:31:11Z", + "legacyId" : 0.8008281904610115, + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "aid" : 1234, + "value" : "sfo", + "key" : "branch", + "createDate" : "2022-03-01T23:31:11Z" + }, { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ], + "color" : "#FF0000", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "matchType" : "and", + "builtIn" : true, + "icon" : "icon", + "description" : "To tag assets in San Francisco", + "filters" : [ { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + }, { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + } ], + "type" : "static", + "objectType" : "test", + "accessType" : "all", + "modifiedDate" : "2022-03-01T23:31:11Z", + "legacyId" : 0.8008281904610115, + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "aid" : 1234, + "value" : "sfo", + "key" : "branch", + "createDate" : "2022-03-01T23:31:11Z" + } ] + } + """ + expected_response = json.loads(response_body_json) + response = self.api.create_tags( + + aid=aid, + + bulk_tag_response=bulk_tag_response, + + _headers=self.te_headers("create_tags"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_create_tags_error_400(self) -> None: + """Integration test for create_tags error path (HTTP 400)""" + request_body_json = """ + + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "errors" : [ { + "tag" : { + "key" : { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ], + "color" : "#FF0000", + "matchType" : "and", + "builtIn" : true, + "icon" : "icon", + "description" : "To tag assets in San Francisco", + "filters" : [ { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + }, { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + } ], + "type" : "static", + "objectType" : "test", + "accessType" : "all", + "modifiedDate" : "2022-03-01T23:31:11Z", + "legacyId" : 0.8008281904610115, + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "aid" : 1234, + "value" : "sfo", + "key" : "branch", + "createDate" : "2022-03-01T23:31:11Z" + } + }, + "message" : "Object successfully created", + "responseCode" : 200 + }, { + "tag" : { + "key" : { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ], + "color" : "#FF0000", + "matchType" : "and", + "builtIn" : true, + "icon" : "icon", + "description" : "To tag assets in San Francisco", + "filters" : [ { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + }, { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + } ], + "type" : "static", + "objectType" : "test", + "accessType" : "all", + "modifiedDate" : "2022-03-01T23:31:11Z", + "legacyId" : 0.8008281904610115, + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "aid" : 1234, + "value" : "sfo", + "key" : "branch", + "createDate" : "2022-03-01T23:31:11Z" + } + }, + "message" : "Object successfully created", + "responseCode" : 200 + } ], + "tags" : [ { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ], + "color" : "#FF0000", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "matchType" : "and", + "builtIn" : true, + "icon" : "icon", + "description" : "To tag assets in San Francisco", + "filters" : [ { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + }, { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + } ], + "type" : "static", + "objectType" : "test", + "accessType" : "all", + "modifiedDate" : "2022-03-01T23:31:11Z", + "legacyId" : 0.8008281904610115, + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "aid" : 1234, + "value" : "sfo", + "key" : "branch", + "createDate" : "2022-03-01T23:31:11Z" + }, { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ], + "color" : "#FF0000", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "matchType" : "and", + "builtIn" : true, + "icon" : "icon", + "description" : "To tag assets in San Francisco", + "filters" : [ { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + }, { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + } ], + "type" : "static", + "objectType" : "test", + "accessType" : "all", + "modifiedDate" : "2022-03-01T23:31:11Z", + "legacyId" : 0.8008281904610115, + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "aid" : 1234, + "value" : "sfo", + "key" : "branch", + "createDate" : "2022-03-01T23:31:11Z" + } ] + } + + """ + bulk_tag_response = thousandeyes_sdk.tags.models.BulkTagResponse.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.create_tags( + + aid=aid, + + bulk_tag_response=bulk_tag_response, + + _headers=self.te_headers("create_tags", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_tags_error_401(self) -> None: + """Integration test for create_tags error path (HTTP 401)""" + request_body_json = """ + + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "errors" : [ { + "tag" : { + "key" : { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ], + "color" : "#FF0000", + "matchType" : "and", + "builtIn" : true, + "icon" : "icon", + "description" : "To tag assets in San Francisco", + "filters" : [ { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + }, { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + } ], + "type" : "static", + "objectType" : "test", + "accessType" : "all", + "modifiedDate" : "2022-03-01T23:31:11Z", + "legacyId" : 0.8008281904610115, + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "aid" : 1234, + "value" : "sfo", + "key" : "branch", + "createDate" : "2022-03-01T23:31:11Z" + } + }, + "message" : "Object successfully created", + "responseCode" : 200 + }, { + "tag" : { + "key" : { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ], + "color" : "#FF0000", + "matchType" : "and", + "builtIn" : true, + "icon" : "icon", + "description" : "To tag assets in San Francisco", + "filters" : [ { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + }, { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + } ], + "type" : "static", + "objectType" : "test", + "accessType" : "all", + "modifiedDate" : "2022-03-01T23:31:11Z", + "legacyId" : 0.8008281904610115, + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "aid" : 1234, + "value" : "sfo", + "key" : "branch", + "createDate" : "2022-03-01T23:31:11Z" + } + }, + "message" : "Object successfully created", + "responseCode" : 200 + } ], + "tags" : [ { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ], + "color" : "#FF0000", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "matchType" : "and", + "builtIn" : true, + "icon" : "icon", + "description" : "To tag assets in San Francisco", + "filters" : [ { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + }, { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + } ], + "type" : "static", + "objectType" : "test", + "accessType" : "all", + "modifiedDate" : "2022-03-01T23:31:11Z", + "legacyId" : 0.8008281904610115, + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "aid" : 1234, + "value" : "sfo", + "key" : "branch", + "createDate" : "2022-03-01T23:31:11Z" + }, { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ], + "color" : "#FF0000", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "matchType" : "and", + "builtIn" : true, + "icon" : "icon", + "description" : "To tag assets in San Francisco", + "filters" : [ { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + }, { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + } ], + "type" : "static", + "objectType" : "test", + "accessType" : "all", + "modifiedDate" : "2022-03-01T23:31:11Z", + "legacyId" : 0.8008281904610115, + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "aid" : 1234, + "value" : "sfo", + "key" : "branch", + "createDate" : "2022-03-01T23:31:11Z" + } ] + } + + """ + bulk_tag_response = thousandeyes_sdk.tags.models.BulkTagResponse.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.create_tags( + + aid=aid, + + bulk_tag_response=bulk_tag_response, + + _headers=self.te_headers("create_tags", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_tags_error_500(self) -> None: + """Integration test for create_tags error path (HTTP 500)""" + request_body_json = """ + + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "errors" : [ { + "tag" : { + "key" : { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ], + "color" : "#FF0000", + "matchType" : "and", + "builtIn" : true, + "icon" : "icon", + "description" : "To tag assets in San Francisco", + "filters" : [ { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + }, { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + } ], + "type" : "static", + "objectType" : "test", + "accessType" : "all", + "modifiedDate" : "2022-03-01T23:31:11Z", + "legacyId" : 0.8008281904610115, + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "aid" : 1234, + "value" : "sfo", + "key" : "branch", + "createDate" : "2022-03-01T23:31:11Z" + } + }, + "message" : "Object successfully created", + "responseCode" : 200 + }, { + "tag" : { + "key" : { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ], + "color" : "#FF0000", + "matchType" : "and", + "builtIn" : true, + "icon" : "icon", + "description" : "To tag assets in San Francisco", + "filters" : [ { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + }, { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + } ], + "type" : "static", + "objectType" : "test", + "accessType" : "all", + "modifiedDate" : "2022-03-01T23:31:11Z", + "legacyId" : 0.8008281904610115, + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "aid" : 1234, + "value" : "sfo", + "key" : "branch", + "createDate" : "2022-03-01T23:31:11Z" + } + }, + "message" : "Object successfully created", + "responseCode" : 200 + } ], + "tags" : [ { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ], + "color" : "#FF0000", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "matchType" : "and", + "builtIn" : true, + "icon" : "icon", + "description" : "To tag assets in San Francisco", + "filters" : [ { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + }, { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + } ], + "type" : "static", + "objectType" : "test", + "accessType" : "all", + "modifiedDate" : "2022-03-01T23:31:11Z", + "legacyId" : 0.8008281904610115, + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "aid" : 1234, + "value" : "sfo", + "key" : "branch", + "createDate" : "2022-03-01T23:31:11Z" + }, { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ], + "color" : "#FF0000", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "matchType" : "and", + "builtIn" : true, + "icon" : "icon", + "description" : "To tag assets in San Francisco", + "filters" : [ { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + }, { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + } ], + "type" : "static", + "objectType" : "test", + "accessType" : "all", + "modifiedDate" : "2022-03-01T23:31:11Z", + "legacyId" : 0.8008281904610115, + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "aid" : 1234, + "value" : "sfo", + "key" : "branch", + "createDate" : "2022-03-01T23:31:11Z" + } ] + } + + """ + bulk_tag_response = thousandeyes_sdk.tags.models.BulkTagResponse.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "path" : "https://api.thousandeyes.com/v7/request/path", + "errors" : "Internal Server Error", + "timestamp" : 1679677853573, + "status" : 500 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.create_tags( + + aid=aid, + + bulk_tag_response=bulk_tag_response, + + _headers=self.te_headers("create_tags", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_delete_tag_happy_path(self) -> None: + """Integration test for delete_tag success path""" + id = 'c6b78e57-81a2-4c5f-a11a-d96c3c664d55' + aid = '1234' + response = self.api.delete_tag_with_http_info( + + id=id, + + aid=aid, + + _headers=self.te_headers("delete_tag"), + ) + self.assertEqual(204, response.status_code) + self.assertIsNone(response.data) + + + def test_delete_tag_error_401(self) -> None: + """Integration test for delete_tag error path (HTTP 401)""" + id = 'c6b78e57-81a2-4c5f-a11a-d96c3c664d55' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.delete_tag( + + id=id, + + aid=aid, + + _headers=self.te_headers("delete_tag", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_tag_error_403(self) -> None: + """Integration test for delete_tag error path (HTTP 403)""" + id = 'c6b78e57-81a2-4c5f-a11a-d96c3c664d55' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.delete_tag( + + id=id, + + aid=aid, + + _headers=self.te_headers("delete_tag", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_tag_error_404(self) -> None: + """Integration test for delete_tag error path (HTTP 404)""" + id = 'c6b78e57-81a2-4c5f-a11a-d96c3c664d55' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.delete_tag( + + id=id, + + aid=aid, + + _headers=self.te_headers("delete_tag", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_tag_error_429(self) -> None: + """Integration test for delete_tag error path (HTTP 429)""" + id = 'c6b78e57-81a2-4c5f-a11a-d96c3c664d55' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.delete_tag( + + id=id, + + aid=aid, + + _headers=self.te_headers("delete_tag", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_tag_error_500(self) -> None: + """Integration test for delete_tag error path (HTTP 500)""" + id = 'c6b78e57-81a2-4c5f-a11a-d96c3c664d55' + aid = '1234' + error_body_json = """ + { + "path" : "https://api.thousandeyes.com/v7/request/path", + "errors" : "Internal Server Error", + "timestamp" : 1679677853573, + "status" : 500 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.delete_tag( + + id=id, + + aid=aid, + + _headers=self.te_headers("delete_tag", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_tag_happy_path(self) -> None: + """Integration test for get_tag success path""" + id = 'c6b78e57-81a2-4c5f-a11a-d96c3c664d55' + aid = '1234' + response_body_json = """ + { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ], + "color" : "#FF0000", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "matchType" : "and", + "builtIn" : true, + "icon" : "icon", + "description" : "To tag assets in San Francisco", + "filters" : [ { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + }, { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + } ], + "type" : "static", + "objectType" : "test", + "accessType" : "all", + "modifiedDate" : "2022-03-01T23:31:11Z", + "legacyId" : 0.8008281904610115, + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "aid" : 1234, + "value" : "sfo", + "key" : "branch", + "createDate" : "2022-03-01T23:31:11Z" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_tag( + + id=id, + + aid=aid, + + _headers=self.te_headers("get_tag"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_tag_error_401(self) -> None: + """Integration test for get_tag error path (HTTP 401)""" + id = 'c6b78e57-81a2-4c5f-a11a-d96c3c664d55' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_tag( + + id=id, + + aid=aid, + + _headers=self.te_headers("get_tag", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_tag_error_403(self) -> None: + """Integration test for get_tag error path (HTTP 403)""" + id = 'c6b78e57-81a2-4c5f-a11a-d96c3c664d55' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_tag( + + id=id, + + aid=aid, + + _headers=self.te_headers("get_tag", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_tag_error_404(self) -> None: + """Integration test for get_tag error path (HTTP 404)""" + id = 'c6b78e57-81a2-4c5f-a11a-d96c3c664d55' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_tag( + + id=id, + + aid=aid, + + _headers=self.te_headers("get_tag", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_tag_error_429(self) -> None: + """Integration test for get_tag error path (HTTP 429)""" + id = 'c6b78e57-81a2-4c5f-a11a-d96c3c664d55' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_tag( + + id=id, + + aid=aid, + + _headers=self.te_headers("get_tag", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_tag_error_500(self) -> None: + """Integration test for get_tag error path (HTTP 500)""" + id = 'c6b78e57-81a2-4c5f-a11a-d96c3c664d55' + aid = '1234' + error_body_json = """ + { + "path" : "https://api.thousandeyes.com/v7/request/path", + "errors" : "Internal Server Error", + "timestamp" : 1679677853573, + "status" : 500 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_tag( + + id=id, + + aid=aid, + + _headers=self.te_headers("get_tag", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_tags_happy_path(self) -> None: + """Integration test for get_tags success path""" + aid = '1234' + response_body_json = """ + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "tags" : [ { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ], + "color" : "#FF0000", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "matchType" : "and", + "builtIn" : true, + "icon" : "icon", + "description" : "To tag assets in San Francisco", + "filters" : [ { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + }, { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + } ], + "type" : "static", + "objectType" : "test", + "accessType" : "all", + "modifiedDate" : "2022-03-01T23:31:11Z", + "legacyId" : 0.8008281904610115, + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "aid" : 1234, + "value" : "sfo", + "key" : "branch", + "createDate" : "2022-03-01T23:31:11Z" + }, { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ], + "color" : "#FF0000", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "matchType" : "and", + "builtIn" : true, + "icon" : "icon", + "description" : "To tag assets in San Francisco", + "filters" : [ { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + }, { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + } ], + "type" : "static", + "objectType" : "test", + "accessType" : "all", + "modifiedDate" : "2022-03-01T23:31:11Z", + "legacyId" : 0.8008281904610115, + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "aid" : 1234, + "value" : "sfo", + "key" : "branch", + "createDate" : "2022-03-01T23:31:11Z" + } ] + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_tags( + + aid=aid, + + _headers=self.te_headers("get_tags"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_tags_error_401(self) -> None: + """Integration test for get_tags error path (HTTP 401)""" + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_tags( + + aid=aid, + + _headers=self.te_headers("get_tags", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_tags_error_403(self) -> None: + """Integration test for get_tags error path (HTTP 403)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_tags( + + aid=aid, + + _headers=self.te_headers("get_tags", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_tags_error_404(self) -> None: + """Integration test for get_tags error path (HTTP 404)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_tags( + + aid=aid, + + _headers=self.te_headers("get_tags", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_tags_error_429(self) -> None: + """Integration test for get_tags error path (HTTP 429)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_tags( + + aid=aid, + + _headers=self.te_headers("get_tags", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_tags_error_500(self) -> None: + """Integration test for get_tags error path (HTTP 500)""" + aid = '1234' + error_body_json = """ + { + "path" : "https://api.thousandeyes.com/v7/request/path", + "errors" : "Internal Server Error", + "timestamp" : 1679677853573, + "status" : 500 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_tags( + + aid=aid, + + _headers=self.te_headers("get_tags", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_update_tag_happy_path(self) -> None: + """Integration test for update_tag success path""" + request_body_json = """ + + { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ], + "color" : "#FF0000", + "matchType" : "and", + "builtIn" : true, + "icon" : "icon", + "description" : "To tag assets in San Francisco", + "filters" : [ { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + }, { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + } ], + "type" : "static", + "objectType" : "test", + "accessType" : "all", + "modifiedDate" : "2022-03-01T23:31:11Z", + "legacyId" : 0.8008281904610115, + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "aid" : 1234, + "value" : "sfo", + "key" : "branch", + "createDate" : "2022-03-01T23:31:11Z" + } + + """ + tag_info = thousandeyes_sdk.tags.models.TagInfo.from_json(request_body_json) + id = 'c6b78e57-81a2-4c5f-a11a-d96c3c664d55' + aid = '1234' + response_body_json = """ + { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ], + "color" : "#FF0000", + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "matchType" : "and", + "builtIn" : true, + "icon" : "icon", + "description" : "To tag assets in San Francisco", + "filters" : [ { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + }, { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + } ], + "type" : "static", + "objectType" : "test", + "accessType" : "all", + "modifiedDate" : "2022-03-01T23:31:11Z", + "legacyId" : 0.8008281904610115, + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "aid" : 1234, + "value" : "sfo", + "key" : "branch", + "createDate" : "2022-03-01T23:31:11Z" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.update_tag( + + id=id, + + aid=aid, + + tag_info=tag_info, + + _headers=self.te_headers("update_tag"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_update_tag_error_401(self) -> None: + """Integration test for update_tag error path (HTTP 401)""" + request_body_json = """ + + { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ], + "color" : "#FF0000", + "matchType" : "and", + "builtIn" : true, + "icon" : "icon", + "description" : "To tag assets in San Francisco", + "filters" : [ { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + }, { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + } ], + "type" : "static", + "objectType" : "test", + "accessType" : "all", + "modifiedDate" : "2022-03-01T23:31:11Z", + "legacyId" : 0.8008281904610115, + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "aid" : 1234, + "value" : "sfo", + "key" : "branch", + "createDate" : "2022-03-01T23:31:11Z" + } + + """ + tag_info = thousandeyes_sdk.tags.models.TagInfo.from_json(request_body_json) + id = 'c6b78e57-81a2-4c5f-a11a-d96c3c664d55' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.update_tag( + + id=id, + + aid=aid, + + tag_info=tag_info, + + _headers=self.te_headers("update_tag", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_tag_error_403(self) -> None: + """Integration test for update_tag error path (HTTP 403)""" + request_body_json = """ + + { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ], + "color" : "#FF0000", + "matchType" : "and", + "builtIn" : true, + "icon" : "icon", + "description" : "To tag assets in San Francisco", + "filters" : [ { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + }, { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + } ], + "type" : "static", + "objectType" : "test", + "accessType" : "all", + "modifiedDate" : "2022-03-01T23:31:11Z", + "legacyId" : 0.8008281904610115, + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "aid" : 1234, + "value" : "sfo", + "key" : "branch", + "createDate" : "2022-03-01T23:31:11Z" + } + + """ + tag_info = thousandeyes_sdk.tags.models.TagInfo.from_json(request_body_json) + id = 'c6b78e57-81a2-4c5f-a11a-d96c3c664d55' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.update_tag( + + id=id, + + aid=aid, + + tag_info=tag_info, + + _headers=self.te_headers("update_tag", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_tag_error_404(self) -> None: + """Integration test for update_tag error path (HTTP 404)""" + request_body_json = """ + + { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ], + "color" : "#FF0000", + "matchType" : "and", + "builtIn" : true, + "icon" : "icon", + "description" : "To tag assets in San Francisco", + "filters" : [ { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + }, { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + } ], + "type" : "static", + "objectType" : "test", + "accessType" : "all", + "modifiedDate" : "2022-03-01T23:31:11Z", + "legacyId" : 0.8008281904610115, + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "aid" : 1234, + "value" : "sfo", + "key" : "branch", + "createDate" : "2022-03-01T23:31:11Z" + } + + """ + tag_info = thousandeyes_sdk.tags.models.TagInfo.from_json(request_body_json) + id = 'c6b78e57-81a2-4c5f-a11a-d96c3c664d55' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.update_tag( + + id=id, + + aid=aid, + + tag_info=tag_info, + + _headers=self.te_headers("update_tag", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_tag_error_429(self) -> None: + """Integration test for update_tag error path (HTTP 429)""" + request_body_json = """ + + { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ], + "color" : "#FF0000", + "matchType" : "and", + "builtIn" : true, + "icon" : "icon", + "description" : "To tag assets in San Francisco", + "filters" : [ { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + }, { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + } ], + "type" : "static", + "objectType" : "test", + "accessType" : "all", + "modifiedDate" : "2022-03-01T23:31:11Z", + "legacyId" : 0.8008281904610115, + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "aid" : 1234, + "value" : "sfo", + "key" : "branch", + "createDate" : "2022-03-01T23:31:11Z" + } + + """ + tag_info = thousandeyes_sdk.tags.models.TagInfo.from_json(request_body_json) + id = 'c6b78e57-81a2-4c5f-a11a-d96c3c664d55' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.update_tag( + + id=id, + + aid=aid, + + tag_info=tag_info, + + _headers=self.te_headers("update_tag", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_tag_error_500(self) -> None: + """Integration test for update_tag error path (HTTP 500)""" + request_body_json = """ + + { + "assignments" : [ { + "id" : "123", + "type" : "test" + }, { + "id" : "123", + "type" : "test" + } ], + "color" : "#FF0000", + "matchType" : "and", + "builtIn" : true, + "icon" : "icon", + "description" : "To tag assets in San Francisco", + "filters" : [ { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + }, { + "mode" : "in", + "values" : [ "10.1.1.0/24", "192.168.1.0/24" ], + "scope" : "custom", + "key" : "vpn-client-network" + } ], + "type" : "static", + "objectType" : "test", + "accessType" : "all", + "modifiedDate" : "2022-03-01T23:31:11Z", + "legacyId" : 0.8008281904610115, + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "aid" : 1234, + "value" : "sfo", + "key" : "branch", + "createDate" : "2022-03-01T23:31:11Z" + } + + """ + tag_info = thousandeyes_sdk.tags.models.TagInfo.from_json(request_body_json) + id = 'c6b78e57-81a2-4c5f-a11a-d96c3c664d55' + aid = '1234' + error_body_json = """ + { + "path" : "https://api.thousandeyes.com/v7/request/path", + "errors" : "Internal Server Error", + "timestamp" : 1679677853573, + "status" : 500 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.update_tag( + + id=id, + + aid=aid, + + tag_info=tag_info, + + _headers=self.te_headers("update_tag", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-tags/test/test_utils.py b/thousandeyes-sdk-tags/test/test_utils.py index 930528d9..37913f62 100644 --- a/thousandeyes-sdk-tags/test/test_utils.py +++ b/thousandeyes-sdk-tags/test/test_utils.py @@ -2,15 +2,36 @@ import json import unittest +from typing import Any from pydantic import BaseModel +def _project_onto_constructed(expected: Any, constructed: Any) -> Any: + """Keep only example fields that appear in the constructed model output.""" + if isinstance(constructed, dict): + if not isinstance(expected, dict): + return expected + return { + key: _project_onto_constructed(expected.get(key), value) + for key, value in constructed.items() + } + if isinstance(constructed, list): + if not isinstance(expected, list): + return expected + return [ + _project_onto_constructed(expected[index], value) + for index, value in enumerate(constructed) + ] + return expected + + def assert_constructed_model_matches_example_json(model: BaseModel, loaded_json: dict): test_case = unittest.TestCase() test_case.maxDiff = None test_case.assertIsNotNone(model) constructed_json = json.loads(model.to_json()) - sorted_loaded_json = json.dumps(loaded_json, sort_keys=True) + projected_loaded_json = _project_onto_constructed(loaded_json, constructed_json) + sorted_loaded_json = json.dumps(projected_loaded_json, sort_keys=True) sorted_constructed_json = json.dumps(constructed_json, sort_keys=True) test_case.assertEqual(sorted_loaded_json, sorted_constructed_json) diff --git a/thousandeyes-sdk-test-results/test/conftest.py b/thousandeyes-sdk-test-results/test/conftest.py new file mode 100644 index 00000000..2edba7b3 --- /dev/null +++ b/thousandeyes-sdk-test-results/test/conftest.py @@ -0,0 +1,7 @@ +import sys +from pathlib import Path + +_repo_root = Path(__file__).resolve().parents[2] +_core_test_support = _repo_root / "thousandeyes-sdk-core" / "test" +if str(_core_test_support) not in sys.path: + sys.path.insert(0, str(_core_test_support)) diff --git a/thousandeyes-sdk-test-results/test/integration_test_utils.py b/thousandeyes-sdk-test-results/test/integration_test_utils.py new file mode 100644 index 00000000..27d6ab3a --- /dev/null +++ b/thousandeyes-sdk-test-results/test/integration_test_utils.py @@ -0,0 +1,37 @@ +# coding: utf-8 + +""" + Test Results API + + Get test result metrics for Network and Application Synthetics tests. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from thousandeyes_sdk.core.api_client import ApiClient +from thousandeyes_sdk.core.configuration import Configuration +from sdk_test_support.mock_server import ERROR_STATUS_HEADER, OPERATION_ID_HEADER, MockApiServer + +from .mock_manifest import OPERATION_MANIFEST + + +class IntegrationTestBase(unittest.TestCase): + def setUp(self) -> None: + self.server = MockApiServer(OPERATION_MANIFEST) + self.server.start() + configuration = Configuration(host=self.server.base_url, access_token="test-token") + self.api_client = ApiClient(configuration=configuration) + + def tearDown(self) -> None: + self.server.stop() + + def te_headers(self, operation_id: str, error_status=None): + headers = {OPERATION_ID_HEADER: operation_id} + if error_status is not None: + headers[ERROR_STATUS_HEADER] = error_status + return headers diff --git a/thousandeyes-sdk-test-results/test/mock_manifest.py b/thousandeyes-sdk-test-results/test/mock_manifest.py new file mode 100644 index 00000000..1317b5e7 --- /dev/null +++ b/thousandeyes-sdk-test-results/test/mock_manifest.py @@ -0,0 +1,6272 @@ +# coding: utf-8 + +""" + Test Results API + + Get test result metrics for Network and Application Synthetics tests. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json + +from sdk_test_support.mock_server_types import ErrorResponseExpectation, OperationExpectation + +OPERATION_MANIFEST = { + + "get_test_api_agent_round_results": OperationExpectation( + operation_id="get_test_api_agent_round_results", + method="GET", + path="/test-results/{testId}/api/agent/{agentId}/round/{roundId}", + path_param_examples={ + "testId": '202701', + "agentId": '11', + "roundId": '1384309800', + }, + success_status=200, + success_body=json.loads(""" + + { + "test" : { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + }, + "_links" : { + "next" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "previous" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "results" : [ { + "date" : "2022-07-17T22:00:54Z", + "completion" : 100, + "agent" : { + "agentId" : "281474976710706", + "agentName" : "thousandeyes-stg-va-254", + "location" : "San Francisco Bay Area", + "countryId" : "US" + }, + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "errorType" : "None", + "apiTransactionTime" : 990.1, + "startTime" : 1384309800, + "endTime" : 1384309800, + "requests" : [ { + "completion" : 100, + "stepType" : "default", + "responseTime" : 440.8, + "apiCallTime" : 900.9, + "processingTime" : 59.9, + "url" : "https://api.thousandeyes.com/v7/status", + "sendTime" : 8.1, + "receiveTime" : 224.1, + "connectTime" : 12.1, + "dnsTime" : 11.1, + "name" : "First Step to Acquire Token", + "stepNumber" : 1, + "assertions" : [ { + "hasFailed" : false, + "step" : 1 + }, { + "hasFailed" : false, + "step" : 1 + } ], + "assertErrorCount" : 0, + "blockedTime" : 49.9, + "stepTime" : 990.1, + "waitTime" : 18.1 + }, { + "completion" : 100, + "stepType" : "default", + "responseTime" : 440.8, + "apiCallTime" : 900.9, + "processingTime" : 59.9, + "url" : "https://api.thousandeyes.com/v7/status", + "sendTime" : 8.1, + "receiveTime" : 224.1, + "connectTime" : 12.1, + "dnsTime" : 11.1, + "name" : "First Step to Acquire Token", + "stepNumber" : 1, + "assertions" : [ { + "hasFailed" : false, + "step" : 1 + }, { + "hasFailed" : false, + "step" : 1 + } ], + "assertErrorCount" : 0, + "blockedTime" : 49.9, + "stepTime" : 990.1, + "waitTime" : 18.1 + } ], + "roundId" : 1384309800, + "errorDetails" : "Connection error" + }, { + "date" : "2022-07-17T22:00:54Z", + "completion" : 100, + "agent" : { + "agentId" : "281474976710706", + "agentName" : "thousandeyes-stg-va-254", + "location" : "San Francisco Bay Area", + "countryId" : "US" + }, + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "errorType" : "None", + "apiTransactionTime" : 990.1, + "startTime" : 1384309800, + "endTime" : 1384309800, + "requests" : [ { + "completion" : 100, + "stepType" : "default", + "responseTime" : 440.8, + "apiCallTime" : 900.9, + "processingTime" : 59.9, + "url" : "https://api.thousandeyes.com/v7/status", + "sendTime" : 8.1, + "receiveTime" : 224.1, + "connectTime" : 12.1, + "dnsTime" : 11.1, + "name" : "First Step to Acquire Token", + "stepNumber" : 1, + "assertions" : [ { + "hasFailed" : false, + "step" : 1 + }, { + "hasFailed" : false, + "step" : 1 + } ], + "assertErrorCount" : 0, + "blockedTime" : 49.9, + "stepTime" : 990.1, + "waitTime" : 18.1 + }, { + "completion" : 100, + "stepType" : "default", + "responseTime" : 440.8, + "apiCallTime" : 900.9, + "processingTime" : 59.9, + "url" : "https://api.thousandeyes.com/v7/status", + "sendTime" : 8.1, + "receiveTime" : 224.1, + "connectTime" : 12.1, + "dnsTime" : 11.1, + "name" : "First Step to Acquire Token", + "stepNumber" : 1, + "assertions" : [ { + "hasFailed" : false, + "step" : 1 + }, { + "hasFailed" : false, + "step" : 1 + } ], + "assertErrorCount" : 0, + "blockedTime" : 49.9, + "stepTime" : 990.1, + "waitTime" : 18.1 + } ], + "roundId" : 1384309800, + "errorDetails" : "Connection error" + } ] + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_test_api_results": OperationExpectation( + operation_id="get_test_api_results", + method="GET", + path="/test-results/{testId}/api", + path_param_examples={ + "testId": '202701', + }, + success_status=200, + success_body=json.loads(""" + + { + "test" : { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + }, + "endDate" : "2022-07-18T22:00:54Z", + "_links" : { + "next" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "previous" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "results" : [ { + "date" : "2022-07-17T22:00:54Z", + "completion" : 100, + "agent" : { + "agentId" : "281474976710706", + "agentName" : "thousandeyes-stg-va-254", + "location" : "San Francisco Bay Area", + "countryId" : "US" + }, + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "errorType" : "None", + "apiTransactionTime" : 990.1, + "startTime" : 1384309800, + "endTime" : 1384309800, + "roundId" : 1384309800, + "errorDetails" : "Connection error" + }, { + "date" : "2022-07-17T22:00:54Z", + "completion" : 100, + "agent" : { + "agentId" : "281474976710706", + "agentName" : "thousandeyes-stg-va-254", + "location" : "San Francisco Bay Area", + "countryId" : "US" + }, + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "errorType" : "None", + "apiTransactionTime" : 990.1, + "startTime" : 1384309800, + "endTime" : 1384309800, + "roundId" : 1384309800, + "errorDetails" : "Connection error" + } ], + "startDate" : "2022-07-17T22:00:54Z" + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_test_dns_sec_results": OperationExpectation( + operation_id="get_test_dns_sec_results", + method="GET", + path="/test-results/{testId}/dnssec", + path_param_examples={ + "testId": '202701', + }, + success_status=200, + success_body=json.loads(""" + + { + "test" : { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + }, + "endDate" : "2022-07-18T22:00:54Z", + "_links" : { + "next" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "previous" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "results" : [ { + "date" : "2022-07-17T22:00:54Z", + "agent" : { + "agentId" : "281474976710706", + "agentName" : "thousandeyes-stg-va-254", + "location" : "San Francisco Bay Area", + "countryId" : "US" + }, + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isValid" : true, + "startTime" : 1384309800, + "endTime" : 1384309800, + "roundId" : 1384309800, + "errorDetails" : "Connection error" + }, { + "date" : "2022-07-17T22:00:54Z", + "agent" : { + "agentId" : "281474976710706", + "agentName" : "thousandeyes-stg-va-254", + "location" : "San Francisco Bay Area", + "countryId" : "US" + }, + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isValid" : true, + "startTime" : 1384309800, + "endTime" : 1384309800, + "roundId" : 1384309800, + "errorDetails" : "Connection error" + } ], + "startDate" : "2022-07-17T22:00:54Z" + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_test_dns_server_result": OperationExpectation( + operation_id="get_test_dns_server_result", + method="GET", + path="/test-results/{testId}/dns-server/{serverId}", + path_param_examples={ + "testId": '202701', + "serverId": '281474976710706', + }, + success_status=200, + success_body=json.loads(""" + + { + "test" : { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + }, + "endDate" : "2022-07-18T22:00:54Z", + "_links" : { + "next" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "previous" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "results" : [ { + "date" : "2022-07-17T22:00:54Z", + "server" : "a1.verisigndns.com.", + "agent" : { + "agentId" : "281474976710706", + "agentName" : "thousandeyes-stg-va-254", + "location" : "San Francisco Bay Area", + "countryId" : "US" + }, + "mappings" : "208.185.7.120", + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "startTime" : 1384309800, + "endTime" : 1384309800, + "resolutionTime" : 3, + "roundId" : 1384309800, + "serverId" : "456", + "errorDetails" : "Connection error" + }, { + "date" : "2022-07-17T22:00:54Z", + "server" : "a1.verisigndns.com.", + "agent" : { + "agentId" : "281474976710706", + "agentName" : "thousandeyes-stg-va-254", + "location" : "San Francisco Bay Area", + "countryId" : "US" + }, + "mappings" : "208.185.7.120", + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "startTime" : 1384309800, + "endTime" : 1384309800, + "resolutionTime" : 3, + "roundId" : 1384309800, + "serverId" : "456", + "errorDetails" : "Connection error" + } ], + "startDate" : "2022-07-17T22:00:54Z" + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_test_dns_servers_results": OperationExpectation( + operation_id="get_test_dns_servers_results", + method="GET", + path="/test-results/{testId}/dns-server", + path_param_examples={ + "testId": '202701', + }, + success_status=200, + success_body=json.loads(""" + + { + "test" : { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + }, + "endDate" : "2022-07-18T22:00:54Z", + "_links" : { + "next" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "previous" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "results" : [ { + "date" : "2022-07-17T22:00:54Z", + "server" : "a1.verisigndns.com.", + "agent" : { + "agentId" : "281474976710706", + "agentName" : "thousandeyes-stg-va-254", + "location" : "San Francisco Bay Area", + "countryId" : "US" + }, + "mappings" : "208.185.7.120", + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "startTime" : 1384309800, + "endTime" : 1384309800, + "resolutionTime" : 3, + "roundId" : 1384309800, + "serverId" : "456", + "errorDetails" : "Connection error" + }, { + "date" : "2022-07-17T22:00:54Z", + "server" : "a1.verisigndns.com.", + "agent" : { + "agentId" : "281474976710706", + "agentName" : "thousandeyes-stg-va-254", + "location" : "San Francisco Bay Area", + "countryId" : "US" + }, + "mappings" : "208.185.7.120", + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "startTime" : 1384309800, + "endTime" : 1384309800, + "resolutionTime" : 3, + "roundId" : 1384309800, + "serverId" : "456", + "errorDetails" : "Connection error" + } ], + "startDate" : "2022-07-17T22:00:54Z" + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_test_dns_trace_results": OperationExpectation( + operation_id="get_test_dns_trace_results", + method="GET", + path="/test-results/{testId}/dns-trace", + path_param_examples={ + "testId": '202701', + }, + success_status=200, + success_body=json.loads(""" + + { + "test" : { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + }, + "endDate" : "2022-07-18T22:00:54Z", + "_links" : { + "next" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "previous" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "results" : [ { + "date" : "2022-07-17T22:00:54Z", + "agent" : { + "agentId" : "281474976710706", + "agentName" : "thousandeyes-stg-va-254", + "location" : "San Francisco Bay Area", + "countryId" : "US" + }, + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "finalServerQueried" : "a1.verisigndns.com.", + "finalQueryTime" : 178, + "queries" : 3, + "failedQueries" : 0, + "output" : "com.\\t172800\\tIN\\tNS\\ta.gtld-servers.net.\\ncom.\\t172800\\tIN\\tNS\\tf.gtld-servers.net.\\ncom.\\t172800\\tIN\\tNS\\tc.gtld-servers.net.\\ncom.\\t172800\\tIN\\tNS\\tb.gtld-servers.net.\\ncom.\\t172800\\tIN\\tNS\\td.gtld-servers.net.\\ncom.\\t172800\\tIN\\tNS\\te.gtld-servers.net.\\ncom.\\t172800\\tIN\\tNS\\tg.gtld-servers.net.\\ncom.\\t172800\\tIN\\tNS\\tm.gtld-servers.net.\\ncom.\\t172800\\tIN\\tNS\\th.gtld-servers.net.\\ncom.\\t172800\\tIN\\tNS\\tj.gtld-servers.net.\\ncom.\\t172800\\tIN\\tNS\\ti.gtld-servers.net.\\ncom.\\t172800\\tIN\\tNS\\tl.gtld-servers.net.\\ncom.\\t172800\\tIN\\tNS\\tk.gtld-servers.net.\\n;; Received 498 bytes from 199.7.91.13(d.root-servers.net.) in 119 ms\\n\\nthousandeyes.com.\\t172800\\tIN\\tNS\\ta1.verisigndns.com.\\nthousandeyes.com.\\t172800\\tIN\\tNS\\ta2.verisigndns.com.\\nthousandeyes.com.\\t172800\\tIN\\tNS\\ta3.verisigndns.com.\\nthousandeyes.com.\\t172800\\tIN\\tNS\\tu1.verisigndns.com.\\n;; Received 266 bytes from 192.5.6.30(a.gtld-servers.net.) in 178 ms\\n\\napp.thousandeyes.com.\\t300\\tIN\\tCNAME\\tweb.thousandeyes.com.\\nweb.thousandeyes.com.\\t300\\tIN\\tCNAME\\tlb-app.thousandeyes.com.\\nlb-app.thousandeyes.com.\\t3600\\tIN\\tA\\t208.185.7.120\\n;; Received 173 bytes from 209.112.113.33(a1.verisigndns.com.) in 178 ms\\n\\n", + "mappings" : "208.185.7.120", + "startTime" : 1384309800, + "endTime" : 1384309800, + "roundId" : 1384309800, + "errorDetails" : "Connection error" + }, { + "date" : "2022-07-17T22:00:54Z", + "agent" : { + "agentId" : "281474976710706", + "agentName" : "thousandeyes-stg-va-254", + "location" : "San Francisco Bay Area", + "countryId" : "US" + }, + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "finalServerQueried" : "a1.verisigndns.com.", + "finalQueryTime" : 178, + "queries" : 3, + "failedQueries" : 0, + "output" : "com.\\t172800\\tIN\\tNS\\ta.gtld-servers.net.\\ncom.\\t172800\\tIN\\tNS\\tf.gtld-servers.net.\\ncom.\\t172800\\tIN\\tNS\\tc.gtld-servers.net.\\ncom.\\t172800\\tIN\\tNS\\tb.gtld-servers.net.\\ncom.\\t172800\\tIN\\tNS\\td.gtld-servers.net.\\ncom.\\t172800\\tIN\\tNS\\te.gtld-servers.net.\\ncom.\\t172800\\tIN\\tNS\\tg.gtld-servers.net.\\ncom.\\t172800\\tIN\\tNS\\tm.gtld-servers.net.\\ncom.\\t172800\\tIN\\tNS\\th.gtld-servers.net.\\ncom.\\t172800\\tIN\\tNS\\tj.gtld-servers.net.\\ncom.\\t172800\\tIN\\tNS\\ti.gtld-servers.net.\\ncom.\\t172800\\tIN\\tNS\\tl.gtld-servers.net.\\ncom.\\t172800\\tIN\\tNS\\tk.gtld-servers.net.\\n;; Received 498 bytes from 199.7.91.13(d.root-servers.net.) in 119 ms\\n\\nthousandeyes.com.\\t172800\\tIN\\tNS\\ta1.verisigndns.com.\\nthousandeyes.com.\\t172800\\tIN\\tNS\\ta2.verisigndns.com.\\nthousandeyes.com.\\t172800\\tIN\\tNS\\ta3.verisigndns.com.\\nthousandeyes.com.\\t172800\\tIN\\tNS\\tu1.verisigndns.com.\\n;; Received 266 bytes from 192.5.6.30(a.gtld-servers.net.) in 178 ms\\n\\napp.thousandeyes.com.\\t300\\tIN\\tCNAME\\tweb.thousandeyes.com.\\nweb.thousandeyes.com.\\t300\\tIN\\tCNAME\\tlb-app.thousandeyes.com.\\nlb-app.thousandeyes.com.\\t3600\\tIN\\tA\\t208.185.7.120\\n;; Received 173 bytes from 209.112.113.33(a1.verisigndns.com.) in 178 ms\\n\\n", + "mappings" : "208.185.7.120", + "startTime" : 1384309800, + "endTime" : 1384309800, + "roundId" : 1384309800, + "errorDetails" : "Connection error" + } ], + "startDate" : "2022-07-17T22:00:54Z" + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_test_bgp_results": OperationExpectation( + operation_id="get_test_bgp_results", + method="GET", + path="/test-results/{testId}/bgp", + path_param_examples={ + "testId": '202701', + }, + success_status=200, + success_body=json.loads(""" + + { + "test" : { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + }, + "endDate" : "2022-07-18T22:00:54Z", + "_links" : { + "next" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "previous" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "results" : [ { + "date" : "2022-07-17T22:00:54Z", + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "prefix" : "99.128.0.0/11", + "monitor" : { + "monitorId" : "281474976710706", + "monitorName" : "Vancouver, Canada - Bell Canada (AS 6539)", + "countryId" : "US" + }, + "startTime" : 1384309800, + "endTime" : 1384309800, + "reachability" : 0, + "updates" : 0, + "pathChanges" : 0, + "roundId" : 1384309800, + "prefixId" : "215" + }, { + "date" : "2022-07-17T22:00:54Z", + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "prefix" : "99.128.0.0/11", + "monitor" : { + "monitorId" : "281474976710706", + "monitorName" : "Vancouver, Canada - Bell Canada (AS 6539)", + "countryId" : "US" + }, + "startTime" : 1384309800, + "endTime" : 1384309800, + "reachability" : 0, + "updates" : 0, + "pathChanges" : 0, + "roundId" : 1384309800, + "prefixId" : "215" + } ], + "startDate" : "2022-07-17T22:00:54Z" + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_test_bgp_routes_prefix_round_results": OperationExpectation( + operation_id="get_test_bgp_routes_prefix_round_results", + method="GET", + path="/test-results/{testId}/bgp/routes/prefix/{prefixId}/round/{roundId}", + path_param_examples={ + "testId": '202701', + "prefixId": '3789376546', + "roundId": '1384309800', + }, + success_status=200, + success_body=json.loads(""" + + { + "test" : { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + }, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "results" : [ { + "date" : "2022-07-17T22:00:54Z", + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "prefix" : "99.128.0.0/11", + "monitor" : { + "monitorId" : "281474976710706", + "monitorName" : "Vancouver, Canada - Bell Canada (AS 6539)", + "countryId" : "US" + }, + "hops" : [ { + "asName" : "Telus Advanced Communications", + "asn" : 852 + }, { + "asName" : "Telus Advanced Communications", + "asn" : 852 + } ], + "isActive" : true, + "roundId" : 1384309800, + "prefixId" : "215" + }, { + "date" : "2022-07-17T22:00:54Z", + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "prefix" : "99.128.0.0/11", + "monitor" : { + "monitorId" : "281474976710706", + "monitorName" : "Vancouver, Canada - Bell Canada (AS 6539)", + "countryId" : "US" + }, + "hops" : [ { + "asName" : "Telus Advanced Communications", + "asn" : 852 + }, { + "asName" : "Telus Advanced Communications", + "asn" : 852 + } ], + "isActive" : true, + "roundId" : 1384309800, + "prefixId" : "215" + } ] + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_test_network_results": OperationExpectation( + operation_id="get_test_network_results", + method="GET", + path="/test-results/{testId}/network", + path_param_examples={ + "testId": '202701', + }, + success_status=200, + success_body=json.loads(""" + + { + "test" : { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + }, + "endDate" : "2022-07-18T22:00:54Z", + "_links" : { + "next" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "previous" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "results" : [ { + "date" : "2022-07-17T22:00:54Z", + "server" : "www.thousandeyes.com:80", + "availableBandwidth" : 9.100464, + "agent" : { + "agentId" : "281474976710706", + "agentName" : "thousandeyes-stg-va-254", + "location" : "San Francisco Bay Area", + "countryId" : "US" + }, + "packetsBySecond" : [ [ ], [ 0 ], [ 2 ], [ 2, 1 ], [ 1, 1 ] ], + "avgLatency" : 167.04, + "bandwidth" : 4.3313155, + "minLatency" : 167, + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "maxLatency" : 168, + "proxyJitter" : 1.2, + "proxyAverageLatency" : 45, + "proxyLoss" : 2.5, + "healthScore" : 0.98, + "capacity" : 210.10854, + "loss" : 0, + "proxyMinLatency" : 40, + "jitter" : 0.076808, + "serverIp" : "50.18.127.223", + "startTime" : 1384309800, + "endTime" : 1384309800, + "proxyMaxLatency" : 50, + "roundId" : 1384309800, + "direction" : "to-target" + }, { + "date" : "2022-07-17T22:00:54Z", + "server" : "www.thousandeyes.com:80", + "availableBandwidth" : 9.100464, + "agent" : { + "agentId" : "281474976710706", + "agentName" : "thousandeyes-stg-va-254", + "location" : "San Francisco Bay Area", + "countryId" : "US" + }, + "packetsBySecond" : [ [ ], [ 0 ], [ 2 ], [ 2, 1 ], [ 1, 1 ] ], + "avgLatency" : 167.04, + "bandwidth" : 4.3313155, + "minLatency" : 167, + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "maxLatency" : 168, + "proxyJitter" : 1.2, + "proxyAverageLatency" : 45, + "proxyLoss" : 2.5, + "healthScore" : 0.98, + "capacity" : 210.10854, + "loss" : 0, + "proxyMinLatency" : 40, + "jitter" : 0.076808, + "serverIp" : "50.18.127.223", + "startTime" : 1384309800, + "endTime" : 1384309800, + "proxyMaxLatency" : 50, + "roundId" : 1384309800, + "direction" : "to-target" + } ], + "startDate" : "2022-07-17T22:00:54Z" + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_test_path_vis_agent_round_results": OperationExpectation( + operation_id="get_test_path_vis_agent_round_results", + method="GET", + path="/test-results/{testId}/path-vis/agent/{agentId}/round/{roundId}", + path_param_examples={ + "testId": '202701', + "agentId": '11', + "roundId": '1384309800', + }, + success_status=200, + success_body=json.loads(""" + + { + "test" : { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + }, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "results" : [ { + "date" : "2022-07-17T22:00:54Z", + "server" : "www.google.com:443", + "agent" : { + "agentId" : "281474976710706", + "agentName" : "thousandeyes-stg-va-254", + "location" : "San Francisco Bay Area", + "countryId" : "US" + }, + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "targetIsProxy" : true, + "sourcePrefix" : "196.40.96.0/20", + "sourceIp" : "196.40.106.237", + "pathTraces" : [ { + "hops" : [ { + "rdns" : "core-router1.cpt2.host-h.net", + "prefix" : "196.40.96.0/20", + "responseTime" : 1, + "hop" : 1, + "ipAddress" : "196.40.106.237", + "mpls" : "mpls", + "location" : "Cape Town, South Africa", + "network" : "HETZNER (Pty) Ltd (AS 37153)" + }, { + "rdns" : "core-router1.cpt2.host-h.net", + "prefix" : "196.40.96.0/20", + "responseTime" : 1, + "hop" : 1, + "ipAddress" : "196.40.106.237", + "mpls" : "mpls", + "location" : "Cape Town, South Africa", + "network" : "HETZNER (Pty) Ltd (AS 37153)" + } ], + "pathId" : "4711301366345855606023718047703941305741293841502186803" + }, { + "hops" : [ { + "rdns" : "core-router1.cpt2.host-h.net", + "prefix" : "196.40.96.0/20", + "responseTime" : 1, + "hop" : 1, + "ipAddress" : "196.40.106.237", + "mpls" : "mpls", + "location" : "Cape Town, South Africa", + "network" : "HETZNER (Pty) Ltd (AS 37153)" + }, { + "rdns" : "core-router1.cpt2.host-h.net", + "prefix" : "196.40.96.0/20", + "responseTime" : 1, + "hop" : 1, + "ipAddress" : "196.40.106.237", + "mpls" : "mpls", + "location" : "Cape Town, South Africa", + "network" : "HETZNER (Pty) Ltd (AS 37153)" + } ], + "pathId" : "4711301366345855606023718047703941305741293841502186803" + } ], + "serverIp" : "172.217.170.68", + "startTime" : 1384309800, + "endTime" : 1384309800, + "roundId" : 1384309800, + "direction" : "to-target" + }, { + "date" : "2022-07-17T22:00:54Z", + "server" : "www.google.com:443", + "agent" : { + "agentId" : "281474976710706", + "agentName" : "thousandeyes-stg-va-254", + "location" : "San Francisco Bay Area", + "countryId" : "US" + }, + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "targetIsProxy" : true, + "sourcePrefix" : "196.40.96.0/20", + "sourceIp" : "196.40.106.237", + "pathTraces" : [ { + "hops" : [ { + "rdns" : "core-router1.cpt2.host-h.net", + "prefix" : "196.40.96.0/20", + "responseTime" : 1, + "hop" : 1, + "ipAddress" : "196.40.106.237", + "mpls" : "mpls", + "location" : "Cape Town, South Africa", + "network" : "HETZNER (Pty) Ltd (AS 37153)" + }, { + "rdns" : "core-router1.cpt2.host-h.net", + "prefix" : "196.40.96.0/20", + "responseTime" : 1, + "hop" : 1, + "ipAddress" : "196.40.106.237", + "mpls" : "mpls", + "location" : "Cape Town, South Africa", + "network" : "HETZNER (Pty) Ltd (AS 37153)" + } ], + "pathId" : "4711301366345855606023718047703941305741293841502186803" + }, { + "hops" : [ { + "rdns" : "core-router1.cpt2.host-h.net", + "prefix" : "196.40.96.0/20", + "responseTime" : 1, + "hop" : 1, + "ipAddress" : "196.40.106.237", + "mpls" : "mpls", + "location" : "Cape Town, South Africa", + "network" : "HETZNER (Pty) Ltd (AS 37153)" + }, { + "rdns" : "core-router1.cpt2.host-h.net", + "prefix" : "196.40.96.0/20", + "responseTime" : 1, + "hop" : 1, + "ipAddress" : "196.40.106.237", + "mpls" : "mpls", + "location" : "Cape Town, South Africa", + "network" : "HETZNER (Pty) Ltd (AS 37153)" + } ], + "pathId" : "4711301366345855606023718047703941305741293841502186803" + } ], + "serverIp" : "172.217.170.68", + "startTime" : 1384309800, + "endTime" : 1384309800, + "roundId" : 1384309800, + "direction" : "to-target" + } ] + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_test_path_vis_results": OperationExpectation( + operation_id="get_test_path_vis_results", + method="GET", + path="/test-results/{testId}/path-vis", + path_param_examples={ + "testId": '202701', + }, + success_status=200, + success_body=json.loads(""" + + { + "test" : { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + }, + "endDate" : "2022-07-18T22:00:54Z", + "_links" : { + "next" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "previous" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "results" : [ { + "date" : "2022-07-17T22:00:54Z", + "server" : "www.google.com:443", + "agent" : { + "agentId" : "281474976710706", + "agentName" : "thousandeyes-stg-va-254", + "location" : "San Francisco Bay Area", + "countryId" : "US" + }, + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "targetIsProxy" : true, + "sourcePrefix" : "196.40.96.0/20", + "sourceIp" : "196.40.106.237", + "pathTraces" : [ { + "numberOfHops" : 15, + "responseTime" : 1500, + "ipAddress" : "196.40.106.237", + "pathMtu" : 1500, + "pathId" : "1230899668701775614109128428722974545787322404682781961521", + "mss" : 1460 + }, { + "numberOfHops" : 15, + "responseTime" : 1500, + "ipAddress" : "196.40.106.237", + "pathMtu" : 1500, + "pathId" : "1230899668701775614109128428722974545787322404682781961521", + "mss" : 1460 + } ], + "serverIp" : "172.217.170.68", + "startTime" : 1384309800, + "endTime" : 1384309800, + "roundId" : 1384309800, + "direction" : "to-target" + }, { + "date" : "2022-07-17T22:00:54Z", + "server" : "www.google.com:443", + "agent" : { + "agentId" : "281474976710706", + "agentName" : "thousandeyes-stg-va-254", + "location" : "San Francisco Bay Area", + "countryId" : "US" + }, + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "targetIsProxy" : true, + "sourcePrefix" : "196.40.96.0/20", + "sourceIp" : "196.40.106.237", + "pathTraces" : [ { + "numberOfHops" : 15, + "responseTime" : 1500, + "ipAddress" : "196.40.106.237", + "pathMtu" : 1500, + "pathId" : "1230899668701775614109128428722974545787322404682781961521", + "mss" : 1460 + }, { + "numberOfHops" : 15, + "responseTime" : 1500, + "ipAddress" : "196.40.106.237", + "pathMtu" : 1500, + "pathId" : "1230899668701775614109128428722974545787322404682781961521", + "mss" : 1460 + } ], + "serverIp" : "172.217.170.68", + "startTime" : 1384309800, + "endTime" : 1384309800, + "roundId" : 1384309800, + "direction" : "to-target" + } ], + "startDate" : "2022-07-17T22:00:54Z" + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_test_rtp_server_results": OperationExpectation( + operation_id="get_test_rtp_server_results", + method="GET", + path="/test-results/{testId}/rtp-server", + path_param_examples={ + "testId": '202701', + }, + success_status=200, + success_body=json.loads(""" + + { + "test" : { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + }, + "endDate" : "2022-07-18T22:00:54Z", + "_links" : { + "next" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "previous" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "results" : [ { + "date" : "2022-07-17T22:00:54Z", + "agent" : { + "agentId" : "281474976710706", + "agentName" : "thousandeyes-stg-va-254", + "location" : "San Francisco Bay Area", + "countryId" : "US" + }, + "pdv" : 1, + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dscpName" : "EF (DSCP 46)", + "latency" : 103, + "mos" : 4.351024, + "loss" : 0, + "dscp" : "46", + "codecMaxMos" : 4.41, + "discards" : 0, + "serverIp" : "172.97.102.37", + "errorDetail" : "Connection error", + "startTime" : 1384309800, + "endTime" : 1384309800, + "codecName" : "G.711 @ 64 Kbps", + "roundId" : 1384309800 + }, { + "date" : "2022-07-17T22:00:54Z", + "agent" : { + "agentId" : "281474976710706", + "agentName" : "thousandeyes-stg-va-254", + "location" : "San Francisco Bay Area", + "countryId" : "US" + }, + "pdv" : 1, + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dscpName" : "EF (DSCP 46)", + "latency" : 103, + "mos" : 4.351024, + "loss" : 0, + "dscp" : "46", + "codecMaxMos" : 4.41, + "discards" : 0, + "serverIp" : "172.97.102.37", + "errorDetail" : "Connection error", + "startTime" : 1384309800, + "endTime" : 1384309800, + "codecName" : "G.711 @ 64 Kbps", + "roundId" : 1384309800 + } ], + "startDate" : "2022-07-17T22:00:54Z" + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_test_sip_server_results": OperationExpectation( + operation_id="get_test_sip_server_results", + method="GET", + path="/test-results/{testId}/sip-server", + path_param_examples={ + "testId": '202701', + }, + success_status=200, + success_body=json.loads(""" + + { + "test" : { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + }, + "endDate" : "2022-07-18T22:00:54Z", + "_links" : { + "next" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "previous" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "results" : [ { + "date" : "2022-07-17T22:00:54Z", + "agent" : { + "agentId" : "281474976710706", + "agentName" : "thousandeyes-stg-va-254", + "location" : "San Francisco Bay Area", + "countryId" : "US" + }, + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "numRedirects" : 0, + "registerTime" : 21, + "optionsTime" : 17, + "optionsRequest" : "OPTIONS sip:6054@voice.sfo2.notarealco.com SIP/2.0\\r\\nVia: SIP/2.0/TCP 38.140.61.68:55431;branch=z9hG4bKRTzPzMoVh0;rport\\r\\nFrom: ;tag=cGaJDNKQFE\\r\\nTo: \\r\\nCall-ID: oO9WaL3av8@38.140.61.68\\r\\nCSeq: 3 OPTIONS\\r\\nContact: \\r\\nUser-Agent: ThousandEyes Test Call\\r\\nAllow: INVITE, ACK, CANCEL, BYE\\r\\nSupported: outbound, path\\r\\nMax-Forwards: 70\\r\\nExpires: 60\\r\\nContent-Length: 0\\r\\n\\r\\n\\nOPTIONS sip:6054@voice.sfo2.notarealco.com SIP/2.0\\r\\nVia: SIP/2.0/TCP 38.140.61.68:55431;branch=z9hG4bKRTzPzMoVh0;rport\\r\\nFrom: ;tag=cGaJDNKQFE\\r\\nTo: \\r\\nCall-ID: oO9WaL3av8@38.140.61.68\\r\\nCSeq: 4 OPTIONS\\r\\nContact: \\r\\nAuthorization: Digest username=\\"al6054\\", realm=\\"asterisk\\", nonce=\\"1598728080/4e3bef2c789bdfa45ce9123221e08c8f\\", uri=\\"sip:6054@voice.sfo2.notarealco.com\\", response=\\"83c538a39ff766cf75ffd1d62317b442\\", algorithm=MD5, cnonce=\\"0a4f113b\\", opaque=\\"748ffa241d840721\\", qop=auth, nc=00000001\\r\\nUser-Agent: ThousandEyes Test Call\\r\\nAllow: INVITE, ACK, CANCEL, BYE\\r\\nSupported: outbound, path\\r\\nMax-Forwards: 70\\r\\nExpires: 60\\r\\nContent-Length: 0\\r\\n\\r\\n", + "responseTime" : 12, + "totalTime" : 40, + "errorType" : "none", + "availability" : 100, + "responseCode" : 200, + "optionsResponse" : "SIP/2.0 401 Unauthorized\\r\\nVia: SIP/2.0/TCP 38.140.61.68:55431;rport=55431;received=38.140.61.68;branch=z9hG4bKRTzPzMoVh0\\r\\nCall-ID: oO9WaL3av8@38.140.61.68\\r\\nFrom: ;tag=cGaJDNKQFE\\r\\nTo: ;tag=z9hG4bKRTzPzMoVh0\\r\\nCSeq: 3 OPTIONS\\r\\nWWW-Authenticate: Digest realm=\\"asterisk\\",nonce=\\"1598728080/4e3bef2c789bdfa45ce9123221e08c8f\\",opaque=\\"748ffa241d840721\\",algorithm=md5,qop=\\"auth\\"\\r\\nServer: Asterisk PBX 16.4.0\\r\\nContent-Length: 0\\r\\n\\r\\n\\nSIP/2.0 200 OK\\r\\nVia: SIP/2.0/TCP 38.140.61.68:55431;rport=55431;received=38.140.61.68;branch=z9hG4bKRTzPzMoVh0\\r\\nCall-ID: oO9WaL3av8@38.140.61.68\\r\\nFrom: ;tag=cGaJDNKQFE\\r\\nTo: ;tag=z9hG4bKRTzPzMoVh0\\r\\nCSeq: 4 OPTIONS\\r\\nAccept: application/xpidf+xml, application/cpim-pidf+xml, application/simple-message-summary, application/pidf+xml, application/dialog-info+xml, application/simple-message-summary, application/pidf+xml, application/dialog-info+xml, application/sdp, message/sipfrag;version=2.0\\r\\nAllow: OPTIONS, REGISTER, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, MESSAGE, REFER\\r\\nSupported: 100rel, timer, replaces, norefersub\\r\\nAccept-Encoding: text/plain\\r\\nAccept-Language: en\\r\\nServer: Asterisk PBX 16.4.0\\r\\nContent-Length: 0\\r\\n\\r\\n", + "problemDetail" : "problemDetail", + "connectTime" : 5, + "dnsTime" : 2, + "serverIp" : "193.2.1.88", + "startTime" : 1384309800, + "endTime" : 1384309800, + "roundId" : 1384309800, + "waitTime" : 5, + "inviteTime" : 10 + }, { + "date" : "2022-07-17T22:00:54Z", + "agent" : { + "agentId" : "281474976710706", + "agentName" : "thousandeyes-stg-va-254", + "location" : "San Francisco Bay Area", + "countryId" : "US" + }, + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "numRedirects" : 0, + "registerTime" : 21, + "optionsTime" : 17, + "optionsRequest" : "OPTIONS sip:6054@voice.sfo2.notarealco.com SIP/2.0\\r\\nVia: SIP/2.0/TCP 38.140.61.68:55431;branch=z9hG4bKRTzPzMoVh0;rport\\r\\nFrom: ;tag=cGaJDNKQFE\\r\\nTo: \\r\\nCall-ID: oO9WaL3av8@38.140.61.68\\r\\nCSeq: 3 OPTIONS\\r\\nContact: \\r\\nUser-Agent: ThousandEyes Test Call\\r\\nAllow: INVITE, ACK, CANCEL, BYE\\r\\nSupported: outbound, path\\r\\nMax-Forwards: 70\\r\\nExpires: 60\\r\\nContent-Length: 0\\r\\n\\r\\n\\nOPTIONS sip:6054@voice.sfo2.notarealco.com SIP/2.0\\r\\nVia: SIP/2.0/TCP 38.140.61.68:55431;branch=z9hG4bKRTzPzMoVh0;rport\\r\\nFrom: ;tag=cGaJDNKQFE\\r\\nTo: \\r\\nCall-ID: oO9WaL3av8@38.140.61.68\\r\\nCSeq: 4 OPTIONS\\r\\nContact: \\r\\nAuthorization: Digest username=\\"al6054\\", realm=\\"asterisk\\", nonce=\\"1598728080/4e3bef2c789bdfa45ce9123221e08c8f\\", uri=\\"sip:6054@voice.sfo2.notarealco.com\\", response=\\"83c538a39ff766cf75ffd1d62317b442\\", algorithm=MD5, cnonce=\\"0a4f113b\\", opaque=\\"748ffa241d840721\\", qop=auth, nc=00000001\\r\\nUser-Agent: ThousandEyes Test Call\\r\\nAllow: INVITE, ACK, CANCEL, BYE\\r\\nSupported: outbound, path\\r\\nMax-Forwards: 70\\r\\nExpires: 60\\r\\nContent-Length: 0\\r\\n\\r\\n", + "responseTime" : 12, + "totalTime" : 40, + "errorType" : "none", + "availability" : 100, + "responseCode" : 200, + "optionsResponse" : "SIP/2.0 401 Unauthorized\\r\\nVia: SIP/2.0/TCP 38.140.61.68:55431;rport=55431;received=38.140.61.68;branch=z9hG4bKRTzPzMoVh0\\r\\nCall-ID: oO9WaL3av8@38.140.61.68\\r\\nFrom: ;tag=cGaJDNKQFE\\r\\nTo: ;tag=z9hG4bKRTzPzMoVh0\\r\\nCSeq: 3 OPTIONS\\r\\nWWW-Authenticate: Digest realm=\\"asterisk\\",nonce=\\"1598728080/4e3bef2c789bdfa45ce9123221e08c8f\\",opaque=\\"748ffa241d840721\\",algorithm=md5,qop=\\"auth\\"\\r\\nServer: Asterisk PBX 16.4.0\\r\\nContent-Length: 0\\r\\n\\r\\n\\nSIP/2.0 200 OK\\r\\nVia: SIP/2.0/TCP 38.140.61.68:55431;rport=55431;received=38.140.61.68;branch=z9hG4bKRTzPzMoVh0\\r\\nCall-ID: oO9WaL3av8@38.140.61.68\\r\\nFrom: ;tag=cGaJDNKQFE\\r\\nTo: ;tag=z9hG4bKRTzPzMoVh0\\r\\nCSeq: 4 OPTIONS\\r\\nAccept: application/xpidf+xml, application/cpim-pidf+xml, application/simple-message-summary, application/pidf+xml, application/dialog-info+xml, application/simple-message-summary, application/pidf+xml, application/dialog-info+xml, application/sdp, message/sipfrag;version=2.0\\r\\nAllow: OPTIONS, REGISTER, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, MESSAGE, REFER\\r\\nSupported: 100rel, timer, replaces, norefersub\\r\\nAccept-Encoding: text/plain\\r\\nAccept-Language: en\\r\\nServer: Asterisk PBX 16.4.0\\r\\nContent-Length: 0\\r\\n\\r\\n", + "problemDetail" : "problemDetail", + "connectTime" : 5, + "dnsTime" : 2, + "serverIp" : "193.2.1.88", + "startTime" : 1384309800, + "endTime" : 1384309800, + "roundId" : 1384309800, + "waitTime" : 5, + "inviteTime" : 10 + } ], + "startDate" : "2022-07-17T22:00:54Z" + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_test_ftp_server_results": OperationExpectation( + operation_id="get_test_ftp_server_results", + method="GET", + path="/test-results/{testId}/ftp-server", + path_param_examples={ + "testId": '202701', + }, + success_status=200, + success_body=json.loads(""" + + { + "test" : { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + }, + "endDate" : "2022-07-18T22:00:54Z", + "_links" : { + "next" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "previous" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "results" : [ { + "date" : "2022-07-17T22:00:54Z", + "agent" : { + "agentId" : "281474976710706", + "agentName" : "thousandeyes-stg-va-254", + "location" : "San Francisco Bay Area", + "countryId" : "US" + }, + "transferTime" : 99.865, + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "negotiationTime" : 503.413, + "responseTime" : 0.589, + "totalTime" : 705.554, + "errorType" : "None", + "responseCode" : 226, + "dnsTime" : 0.589, + "connectTime" : 50.153, + "serverIp" : "193.2.1.88", + "startTime" : 1384309800, + "endTime" : 1384309800, + "throughput" : 123, + "roundId" : 1384309800, + "waitTime" : 52.1, + "wireSize" : 22172, + "errorDetails" : "Connection error" + }, { + "date" : "2022-07-17T22:00:54Z", + "agent" : { + "agentId" : "281474976710706", + "agentName" : "thousandeyes-stg-va-254", + "location" : "San Francisco Bay Area", + "countryId" : "US" + }, + "transferTime" : 99.865, + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "negotiationTime" : 503.413, + "responseTime" : 0.589, + "totalTime" : 705.554, + "errorType" : "None", + "responseCode" : 226, + "dnsTime" : 0.589, + "connectTime" : 50.153, + "serverIp" : "193.2.1.88", + "startTime" : 1384309800, + "endTime" : 1384309800, + "throughput" : 123, + "roundId" : 1384309800, + "waitTime" : 52.1, + "wireSize" : 22172, + "errorDetails" : "Connection error" + } ], + "startDate" : "2022-07-17T22:00:54Z" + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_test_http_server_results": OperationExpectation( + operation_id="get_test_http_server_results", + method="GET", + path="/test-results/{testId}/http-server", + path_param_examples={ + "testId": '202701', + }, + success_status=200, + success_body=json.loads(""" + + { + "test" : { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + }, + "endDate" : "2022-07-18T22:00:54Z", + "_links" : { + "next" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "previous" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "results" : [ { + "date" : "2022-07-17T22:00:54Z", + "agent" : { + "agentId" : "281474976710706", + "agentName" : "thousandeyes-stg-va-254", + "location" : "San Francisco Bay Area", + "countryId" : "US" + }, + "sslVersion" : "TLSv1.3", + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "numRedirects" : 0, + "errorType" : "None", + "healthScore" : 0.98, + "responseCode" : 200, + "connectTime" : 2, + "startTime" : 1384309800, + "throughput" : 123, + "roundId" : 1384309800, + "headers" : { + "requestHeaders" : "GET / HTTP/1.1\\r\\nHost: www.thousandeyes.com\\r\\nUser-Agent: curl/7.58.0-DEV\\r\\nAccept: */*\\r\\nAccept-Encoding: deflate, gzip\\r\\nX-ThousandEyes-Agent: yes\\r\\n", + "responseHeaders" : "HTTP/1.1 200 OK\\r\\nContent-Type: text/html;charset=UTF-8\\r\\nContent-Length: 9993\\r\\nConnection: keep-alive\\r\\nDate: Mon, 04 May 2020 16:13:00 GMT\\r\\nServer: Apache\\r\\nContent-Language: en-US\\r\\nContent-Encoding: gzip\\r\\nX-Frame-Options: sameorigin\\r\\nCache-Control: max-age=600, must-revalidate\\r\\nStrict-Transport-Security: max-age=31536000\\r\\nX-Content-Type-Options: nosniff\\r\\nX-XSS-Protection: 1; mode=block\\r\\nVary: Accept-Encoding\\r\\nX-Cache: Hit from cloudfront\\r\\nVia: 1.1 7ba3caf71ae7a52dd411d1a543e80cd8.cloudfront.net (CloudFront)\\r\\nX-Amz-Cf-Pop: SFO5-C3\\r\\nX-Amz-Cf-Id: w4h42tkoJD-rEpkRDZUvnQBmy26GVGe6pUsuRr1Dphf7oajYbjXaOA==\\r\\nAge: 132\\r\\n" + }, + "sslCipher" : "sslCipher", + "redirectTime" : 10, + "sslCertificates" : [ { + "hasValidSigningCert" : false, + "issuerName" : "DigiCert SHA2 Extended Validation Server CA", + "subjectAlternativeNames" : [ "www.thousandeyes.com", "thousandeyes.com" ], + "isFetchDateInValidCertDateRange" : true, + "validBefore" : "2020-05-12T12:00:00Z", + "daysUntilExpiry" : 0, + "validAfter" : "2018-03-27T00:00:00Z", + "subjectName" : "www.thousandeyes.com" + }, { + "hasValidSigningCert" : false, + "issuerName" : "DigiCert SHA2 Extended Validation Server CA", + "subjectAlternativeNames" : [ "www.thousandeyes.com", "thousandeyes.com" ], + "isFetchDateInValidCertDateRange" : true, + "validBefore" : "2020-05-12T12:00:00Z", + "daysUntilExpiry" : 0, + "validAfter" : "2018-03-27T00:00:00Z", + "subjectName" : "www.thousandeyes.com" + } ], + "responseTime" : 14, + "totalTime" : 15, + "receiveTime" : 1, + "dnsTime" : 0, + "serverIp" : "193.2.1.88", + "sslTime" : 9, + "endTime" : 1384309800, + "waitTime" : 3, + "dnsServerMeasurement" : { + "usedDnsResponse" : { + "id" : 41837, + "qr" : "response", + "opcode" : "query", + "authoritativeAnswer" : false, + "truncation" : false, + "recursionDesired" : true, + "recursionAvailable" : true, + "zero" : false, + "authenticData" : false, + "checkingDisabled" : false, + "responseCode" : "noerror", + "question" : [ { + "name" : "www.example.com", + "type" : "a", + "class" : "in", + "ttl" : 0, + "data" : "" + } ], + "answer" : [ { + "name" : "www.example.com", + "type" : "a", + "class" : "in", + "ttl" : 300, + "data" : "203.0.113.10" + } ], + "dnsResolver" : "8.8.8.8", + "timing" : { + "startTimeUs" : "1769706600000000", + "totalTimeUs" : 19304 + }, + "protocol" : "udp" + }, + "unusedDnsResponses" : [ { + "id" : 41838, + "qr" : "response", + "opcode" : "query", + "authoritativeAnswer" : false, + "truncation" : false, + "recursionDesired" : true, + "recursionAvailable" : true, + "zero" : false, + "authenticData" : false, + "checkingDisabled" : false, + "responseCode" : "nxdomain", + "question" : [ { + "name" : "www.example.com", + "type" : "aaaa", + "class" : "in", + "ttl" : 0, + "data" : "" + } ], + "dnsResolver" : "8.8.4.4", + "timing" : { + "startTimeUs" : "1769706600020000", + "totalTimeUs" : 15420 + }, + "protocol" : "udp" + } ], + "usedHostsFile" : false, + "resolvedIp" : "203.0.113.10" + }, + "wireSize" : 9993, + "errorDetails" : "Connection error" + }, { + "date" : "2022-07-17T22:00:54Z", + "agent" : { + "agentId" : "281474976710706", + "agentName" : "thousandeyes-stg-va-254", + "location" : "San Francisco Bay Area", + "countryId" : "US" + }, + "sslVersion" : "TLSv1.3", + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "numRedirects" : 0, + "errorType" : "None", + "healthScore" : 0.98, + "responseCode" : 200, + "connectTime" : 2, + "startTime" : 1384309800, + "throughput" : 123, + "roundId" : 1384309800, + "headers" : { + "requestHeaders" : "GET / HTTP/1.1\\r\\nHost: www.thousandeyes.com\\r\\nUser-Agent: curl/7.58.0-DEV\\r\\nAccept: */*\\r\\nAccept-Encoding: deflate, gzip\\r\\nX-ThousandEyes-Agent: yes\\r\\n", + "responseHeaders" : "HTTP/1.1 200 OK\\r\\nContent-Type: text/html;charset=UTF-8\\r\\nContent-Length: 9993\\r\\nConnection: keep-alive\\r\\nDate: Mon, 04 May 2020 16:13:00 GMT\\r\\nServer: Apache\\r\\nContent-Language: en-US\\r\\nContent-Encoding: gzip\\r\\nX-Frame-Options: sameorigin\\r\\nCache-Control: max-age=600, must-revalidate\\r\\nStrict-Transport-Security: max-age=31536000\\r\\nX-Content-Type-Options: nosniff\\r\\nX-XSS-Protection: 1; mode=block\\r\\nVary: Accept-Encoding\\r\\nX-Cache: Hit from cloudfront\\r\\nVia: 1.1 7ba3caf71ae7a52dd411d1a543e80cd8.cloudfront.net (CloudFront)\\r\\nX-Amz-Cf-Pop: SFO5-C3\\r\\nX-Amz-Cf-Id: w4h42tkoJD-rEpkRDZUvnQBmy26GVGe6pUsuRr1Dphf7oajYbjXaOA==\\r\\nAge: 132\\r\\n" + }, + "sslCipher" : "sslCipher", + "redirectTime" : 10, + "sslCertificates" : [ { + "hasValidSigningCert" : false, + "issuerName" : "DigiCert SHA2 Extended Validation Server CA", + "subjectAlternativeNames" : [ "www.thousandeyes.com", "thousandeyes.com" ], + "isFetchDateInValidCertDateRange" : true, + "validBefore" : "2020-05-12T12:00:00Z", + "daysUntilExpiry" : 0, + "validAfter" : "2018-03-27T00:00:00Z", + "subjectName" : "www.thousandeyes.com" + }, { + "hasValidSigningCert" : false, + "issuerName" : "DigiCert SHA2 Extended Validation Server CA", + "subjectAlternativeNames" : [ "www.thousandeyes.com", "thousandeyes.com" ], + "isFetchDateInValidCertDateRange" : true, + "validBefore" : "2020-05-12T12:00:00Z", + "daysUntilExpiry" : 0, + "validAfter" : "2018-03-27T00:00:00Z", + "subjectName" : "www.thousandeyes.com" + } ], + "responseTime" : 14, + "totalTime" : 15, + "receiveTime" : 1, + "dnsTime" : 0, + "serverIp" : "193.2.1.88", + "sslTime" : 9, + "endTime" : 1384309800, + "waitTime" : 3, + "dnsServerMeasurement" : { + "usedDnsResponse" : { + "id" : 41837, + "qr" : "response", + "opcode" : "query", + "authoritativeAnswer" : false, + "truncation" : false, + "recursionDesired" : true, + "recursionAvailable" : true, + "zero" : false, + "authenticData" : false, + "checkingDisabled" : false, + "responseCode" : "noerror", + "question" : [ { + "name" : "www.example.com", + "type" : "a", + "class" : "in", + "ttl" : 0, + "data" : "" + } ], + "answer" : [ { + "name" : "www.example.com", + "type" : "a", + "class" : "in", + "ttl" : 300, + "data" : "203.0.113.10" + } ], + "dnsResolver" : "8.8.8.8", + "timing" : { + "startTimeUs" : "1769706600000000", + "totalTimeUs" : 19304 + }, + "protocol" : "udp" + }, + "unusedDnsResponses" : [ { + "id" : 41838, + "qr" : "response", + "opcode" : "query", + "authoritativeAnswer" : false, + "truncation" : false, + "recursionDesired" : true, + "recursionAvailable" : true, + "zero" : false, + "authenticData" : false, + "checkingDisabled" : false, + "responseCode" : "nxdomain", + "question" : [ { + "name" : "www.example.com", + "type" : "aaaa", + "class" : "in", + "ttl" : 0, + "data" : "" + } ], + "dnsResolver" : "8.8.4.4", + "timing" : { + "startTimeUs" : "1769706600020000", + "totalTimeUs" : 15420 + }, + "protocol" : "udp" + } ], + "usedHostsFile" : false, + "resolvedIp" : "203.0.113.10" + }, + "wireSize" : 9993, + "errorDetails" : "Connection error" + } ], + "startDate" : "2022-07-17T22:00:54Z" + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_test_page_load_agent_round_results": OperationExpectation( + operation_id="get_test_page_load_agent_round_results", + method="GET", + path="/test-results/{testId}/page-load/agent/{agentId}/round/{roundId}", + path_param_examples={ + "testId": '202701', + "agentId": '11', + "roundId": '1384309800', + }, + success_status=200, + success_body=json.loads(""" + + { + "test" : { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + }, + "_links" : { + "next" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "previous" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "results" : [ { + "date" : "2022-07-17T22:00:54Z", + "agent" : { + "agentId" : "281474976710706", + "agentName" : "thousandeyes-stg-va-254", + "location" : "San Francisco Bay Area", + "countryId" : "US" + }, + "numErrors" : 0, + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "responseTime" : 34.35, + "pageLoadTime" : 352, + "numObjects" : 17, + "totalSize" : 403301, + "domLoadTime" : 352, + "har" : { + "log" : { + "creator" : { + "name" : "ThousandEyes DB Exporter" + }, + "entries" : [ { + "pageref" : "page_0", + "request" : { + "headers" : [ { + "name" : ":authority", + "value" : "google.com" + }, { + "name" : ":method", + "value" : "GET" + }, { + "name" : ":path", + "value" : "/" + }, { + "name" : ":scheme", + "value" : "https" + }, { + "name" : "accept", + "value" : "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8" + }, { + "name" : "accept-encoding", + "value" : "gzip, deflate, br" + }, { + "name" : "accept-language", + "value" : "en-US,en;q=0.9" + }, { + "name" : "upgrade-insecure-requests", + "value" : "1" + }, { + "name" : "user-agent", + "value" : "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.83 Safari/537.36" + }, { + "name" : "x-thousandeyes-agent", + "value" : "yes" + } ], + "method" : "GET", + "url" : "https://google.com/" + }, + "response" : { + "bodySize" : 220, + "content" : { + "mimeType" : "text/html", + "size" : 220 + }, + "headers" : [ { + "name" : "alt-svc", + "value" : "quic=\\":443\\"; ma=2592000; v=\\"46,43\\",h3-Q050=\\":443\\"; ma=2592000,h3-Q049=\\":443\\"; ma=2592000,h3-Q048=\\":443\\"; ma=2592000,h3-Q046=\\":443\\"; ma=2592000,h3-Q043=\\":443\\"; ma=2592000" + }, { + "name" : "cache-control", + "value" : "public, max-age=2592000" + }, { + "name" : "content-length", + "value" : "220" + }, { + "name" : "content-type", + "value" : "text/html; charset=UTF-8" + }, { + "name" : "date", + "value" : "Fri, 15 Nov 2019 16:41:54 GMT" + }, { + "name" : "expires", + "value" : "Sun, 15 Dec 2019 16:41:54 GMT" + }, { + "name" : "location", + "value" : "https://www.google.com/" + }, { + "name" : "server", + "value" : "gws" + }, { + "name" : "status", + "value" : "301" + }, { + "name" : "x-frame-options", + "value" : "SAMEORIGIN" + }, { + "name" : "x-xss-protection", + "value" : "0" + } ], + "headersSize" : 471, + "redirectURL" : "", + "status" : 301, + "statusText" : "MOVED_PERMANENTLY" + }, + "serverIPAddress" : "172.217.6.110", + "startedDateTime" : "2019-11-15T16:41:54.798Z", + "time" : 71, + "timings" : { + "blocked" : 2, + "connect" : 16, + "dns" : 1, + "receive" : 1, + "send" : 0, + "ssl" : 14, + "wait" : 50 + } + }, { + "pageref" : "page_0", + "request" : { + "headers" : [ { + "name" : ":authority", + "value" : "www.google.com" + }, { + "name" : ":method", + "value" : "GET" + }, { + "name" : ":path", + "value" : "/" + }, { + "name" : ":scheme", + "value" : "https" + }, { + "name" : "accept", + "value" : "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8" + }, { + "name" : "accept-encoding", + "value" : "gzip, deflate, br" + }, { + "name" : "accept-language", + "value" : "en-US,en;q=0.9" + }, { + "name" : "upgrade-insecure-requests", + "value" : "1" + }, { + "name" : "user-agent", + "value" : "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.83 Safari/537.36" + }, { + "name" : "x-thousandeyes-agent", + "value" : "yes" + } ], + "method" : "GET", + "url" : "https://www.google.com/" + }, + "response" : { + "bodySize" : 65214, + "content" : { + "mimeType" : "text/html", + "size" : 225039 + }, + "headers" : [ { + "name" : "alt-svc", + "value" : "quic=\\":443\\"; ma=2592000; v=\\"46,43\\",h3-Q050=\\":443\\"; ma=2592000,h3-Q049=\\":443\\"; ma=2592000,h3-Q048=\\":443\\"; ma=2592000,h3-Q046=\\":443\\"; ma=2592000,h3-Q043=\\":443\\"; ma=2592000" + }, { + "name" : "cache-control", + "value" : "private, max-age=0" + }, { + "name" : "content-encoding", + "value" : "br" + }, { + "name" : "content-length", + "value" : "65214" + }, { + "name" : "content-type", + "value" : "text/html; charset=UTF-8" + }, { + "name" : "date", + "value" : "Fri, 15 Nov 2019 16:41:54 GMT" + }, { + "name" : "expires", + "value" : "-1" + }, { + "name" : "p3p", + "value" : "CP=\\"This is not a P3P policy! See g.co/p3phelp for more info.\\"" + }, { + "name" : "server", + "value" : "gws" + }, { + "name" : "set-cookie", + "value" : "(removed)" + }, { + "name" : "status", + "value" : "200" + }, { + "name" : "strict-transport-security", + "value" : "max-age=31536000" + }, { + "name" : "x-frame-options", + "value" : "SAMEORIGIN" + }, { + "name" : "x-xss-protection", + "value" : "0" + } ], + "headersSize" : 915, + "redirectURL" : "", + "status" : 200, + "statusText" : "OK" + }, + "serverIPAddress" : "172.217.4.196", + "startedDateTime" : "2019-11-15T16:41:54.870Z", + "time" : 182, + "timings" : { + "blocked" : 2, + "connect" : 4, + "dns" : 0, + "receive" : 58, + "send" : 0, + "ssl" : 2, + "wait" : 118 + } + } ], + "pages" : [ { + "id" : "page_0", + "pageTimings" : { + "onContentLoad" : 367, + "onLoad" : 737 + }, + "responseCode" : 0, + "startedDateTime" : "2019-11-15T16:41:54.796Z", + "title" : "Google" + } ], + "version" : "1.2" + } + }, + "startTime" : 1384309800, + "endTime" : 1384309800, + "roundId" : 1384309800 + }, { + "date" : "2022-07-17T22:00:54Z", + "agent" : { + "agentId" : "281474976710706", + "agentName" : "thousandeyes-stg-va-254", + "location" : "San Francisco Bay Area", + "countryId" : "US" + }, + "numErrors" : 0, + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "responseTime" : 34.35, + "pageLoadTime" : 352, + "numObjects" : 17, + "totalSize" : 403301, + "domLoadTime" : 352, + "har" : { + "log" : { + "creator" : { + "name" : "ThousandEyes DB Exporter" + }, + "entries" : [ { + "pageref" : "page_0", + "request" : { + "headers" : [ { + "name" : ":authority", + "value" : "google.com" + }, { + "name" : ":method", + "value" : "GET" + }, { + "name" : ":path", + "value" : "/" + }, { + "name" : ":scheme", + "value" : "https" + }, { + "name" : "accept", + "value" : "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8" + }, { + "name" : "accept-encoding", + "value" : "gzip, deflate, br" + }, { + "name" : "accept-language", + "value" : "en-US,en;q=0.9" + }, { + "name" : "upgrade-insecure-requests", + "value" : "1" + }, { + "name" : "user-agent", + "value" : "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.83 Safari/537.36" + }, { + "name" : "x-thousandeyes-agent", + "value" : "yes" + } ], + "method" : "GET", + "url" : "https://google.com/" + }, + "response" : { + "bodySize" : 220, + "content" : { + "mimeType" : "text/html", + "size" : 220 + }, + "headers" : [ { + "name" : "alt-svc", + "value" : "quic=\\":443\\"; ma=2592000; v=\\"46,43\\",h3-Q050=\\":443\\"; ma=2592000,h3-Q049=\\":443\\"; ma=2592000,h3-Q048=\\":443\\"; ma=2592000,h3-Q046=\\":443\\"; ma=2592000,h3-Q043=\\":443\\"; ma=2592000" + }, { + "name" : "cache-control", + "value" : "public, max-age=2592000" + }, { + "name" : "content-length", + "value" : "220" + }, { + "name" : "content-type", + "value" : "text/html; charset=UTF-8" + }, { + "name" : "date", + "value" : "Fri, 15 Nov 2019 16:41:54 GMT" + }, { + "name" : "expires", + "value" : "Sun, 15 Dec 2019 16:41:54 GMT" + }, { + "name" : "location", + "value" : "https://www.google.com/" + }, { + "name" : "server", + "value" : "gws" + }, { + "name" : "status", + "value" : "301" + }, { + "name" : "x-frame-options", + "value" : "SAMEORIGIN" + }, { + "name" : "x-xss-protection", + "value" : "0" + } ], + "headersSize" : 471, + "redirectURL" : "", + "status" : 301, + "statusText" : "MOVED_PERMANENTLY" + }, + "serverIPAddress" : "172.217.6.110", + "startedDateTime" : "2019-11-15T16:41:54.798Z", + "time" : 71, + "timings" : { + "blocked" : 2, + "connect" : 16, + "dns" : 1, + "receive" : 1, + "send" : 0, + "ssl" : 14, + "wait" : 50 + } + }, { + "pageref" : "page_0", + "request" : { + "headers" : [ { + "name" : ":authority", + "value" : "www.google.com" + }, { + "name" : ":method", + "value" : "GET" + }, { + "name" : ":path", + "value" : "/" + }, { + "name" : ":scheme", + "value" : "https" + }, { + "name" : "accept", + "value" : "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8" + }, { + "name" : "accept-encoding", + "value" : "gzip, deflate, br" + }, { + "name" : "accept-language", + "value" : "en-US,en;q=0.9" + }, { + "name" : "upgrade-insecure-requests", + "value" : "1" + }, { + "name" : "user-agent", + "value" : "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.83 Safari/537.36" + }, { + "name" : "x-thousandeyes-agent", + "value" : "yes" + } ], + "method" : "GET", + "url" : "https://www.google.com/" + }, + "response" : { + "bodySize" : 65214, + "content" : { + "mimeType" : "text/html", + "size" : 225039 + }, + "headers" : [ { + "name" : "alt-svc", + "value" : "quic=\\":443\\"; ma=2592000; v=\\"46,43\\",h3-Q050=\\":443\\"; ma=2592000,h3-Q049=\\":443\\"; ma=2592000,h3-Q048=\\":443\\"; ma=2592000,h3-Q046=\\":443\\"; ma=2592000,h3-Q043=\\":443\\"; ma=2592000" + }, { + "name" : "cache-control", + "value" : "private, max-age=0" + }, { + "name" : "content-encoding", + "value" : "br" + }, { + "name" : "content-length", + "value" : "65214" + }, { + "name" : "content-type", + "value" : "text/html; charset=UTF-8" + }, { + "name" : "date", + "value" : "Fri, 15 Nov 2019 16:41:54 GMT" + }, { + "name" : "expires", + "value" : "-1" + }, { + "name" : "p3p", + "value" : "CP=\\"This is not a P3P policy! See g.co/p3phelp for more info.\\"" + }, { + "name" : "server", + "value" : "gws" + }, { + "name" : "set-cookie", + "value" : "(removed)" + }, { + "name" : "status", + "value" : "200" + }, { + "name" : "strict-transport-security", + "value" : "max-age=31536000" + }, { + "name" : "x-frame-options", + "value" : "SAMEORIGIN" + }, { + "name" : "x-xss-protection", + "value" : "0" + } ], + "headersSize" : 915, + "redirectURL" : "", + "status" : 200, + "statusText" : "OK" + }, + "serverIPAddress" : "172.217.4.196", + "startedDateTime" : "2019-11-15T16:41:54.870Z", + "time" : 182, + "timings" : { + "blocked" : 2, + "connect" : 4, + "dns" : 0, + "receive" : 58, + "send" : 0, + "ssl" : 2, + "wait" : 118 + } + } ], + "pages" : [ { + "id" : "page_0", + "pageTimings" : { + "onContentLoad" : 367, + "onLoad" : 737 + }, + "responseCode" : 0, + "startedDateTime" : "2019-11-15T16:41:54.796Z", + "title" : "Google" + } ], + "version" : "1.2" + } + }, + "startTime" : 1384309800, + "endTime" : 1384309800, + "roundId" : 1384309800 + } ] + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_test_page_load_results": OperationExpectation( + operation_id="get_test_page_load_results", + method="GET", + path="/test-results/{testId}/page-load", + path_param_examples={ + "testId": '202701', + }, + success_status=200, + success_body=json.loads(""" + + { + "test" : { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + }, + "endDate" : "2022-07-18T22:00:54Z", + "_links" : { + "next" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "previous" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "results" : [ { + "date" : "2022-07-17T22:00:54Z", + "agent" : { + "agentId" : "281474976710706", + "agentName" : "thousandeyes-stg-va-254", + "location" : "San Francisco Bay Area", + "countryId" : "US" + }, + "totalSize" : 403301, + "numErrors" : 0, + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "responseTime" : 34.35, + "domLoadTime" : 352, + "startTime" : 1384309800, + "pageLoadTime" : 352, + "endTime" : 1384309800, + "roundId" : 1384309800, + "numObjects" : 17 + }, { + "date" : "2022-07-17T22:00:54Z", + "agent" : { + "agentId" : "281474976710706", + "agentName" : "thousandeyes-stg-va-254", + "location" : "San Francisco Bay Area", + "countryId" : "US" + }, + "totalSize" : 403301, + "numErrors" : 0, + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "responseTime" : 34.35, + "domLoadTime" : 352, + "startTime" : 1384309800, + "pageLoadTime" : 352, + "endTime" : 1384309800, + "roundId" : 1384309800, + "numObjects" : 17 + } ], + "startDate" : "2022-07-17T22:00:54Z" + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_test_web_transaction_agent_round_page_results": OperationExpectation( + operation_id="get_test_web_transaction_agent_round_page_results", + method="GET", + path="/test-results/{testId}/web-transactions/agent/{agentId}/round/{roundId}/page/{pageId}", + path_param_examples={ + "testId": '202701', + "agentId": '11', + "roundId": '1384309800', + "pageId": '281474976710706', + }, + success_status=200, + success_body=json.loads(""" + + { + "test" : { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + }, + "_links" : { + "next" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "previous" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "results" : [ { + "date" : "2022-07-17T22:00:54Z", + "agent" : { + "agentId" : "281474976710706", + "agentName" : "thousandeyes-stg-va-254", + "location" : "San Francisco Bay Area", + "countryId" : "US" + }, + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "componentErrors" : 5, + "errorType" : "None", + "transactionTime" : 2379, + "pages" : [ { + "duration" : 1117.5660001039505, + "componentCount" : 136, + "pageNum" : 0, + "pageName" : "Google", + "errorCount" : 0 + }, { + "duration" : 1117.5660001039505, + "componentCount" : 136, + "pageNum" : 0, + "pageName" : "Google", + "errorCount" : 0 + } ], + "har" : { + "log" : { + "creator" : { + "name" : "ThousandEyes DB Exporter" + }, + "entries" : [ { + "pageref" : "page_0", + "request" : { + "headers" : [ { + "name" : ":authority", + "value" : "google.com" + }, { + "name" : ":method", + "value" : "GET" + }, { + "name" : ":path", + "value" : "/" + }, { + "name" : ":scheme", + "value" : "https" + }, { + "name" : "accept", + "value" : "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8" + }, { + "name" : "accept-encoding", + "value" : "gzip, deflate, br" + }, { + "name" : "accept-language", + "value" : "en-US,en;q=0.9" + }, { + "name" : "upgrade-insecure-requests", + "value" : "1" + }, { + "name" : "user-agent", + "value" : "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.83 Safari/537.36" + }, { + "name" : "x-thousandeyes-agent", + "value" : "yes" + } ], + "method" : "GET", + "url" : "https://google.com/" + }, + "response" : { + "bodySize" : 220, + "content" : { + "mimeType" : "text/html", + "size" : 220 + }, + "headers" : [ { + "name" : "alt-svc", + "value" : "quic=\\":443\\"; ma=2592000; v=\\"46,43\\",h3-Q050=\\":443\\"; ma=2592000,h3-Q049=\\":443\\"; ma=2592000,h3-Q048=\\":443\\"; ma=2592000,h3-Q046=\\":443\\"; ma=2592000,h3-Q043=\\":443\\"; ma=2592000" + }, { + "name" : "cache-control", + "value" : "public, max-age=2592000" + }, { + "name" : "content-length", + "value" : "220" + }, { + "name" : "content-type", + "value" : "text/html; charset=UTF-8" + }, { + "name" : "date", + "value" : "Fri, 15 Nov 2019 16:41:54 GMT" + }, { + "name" : "expires", + "value" : "Sun, 15 Dec 2019 16:41:54 GMT" + }, { + "name" : "location", + "value" : "https://www.google.com/" + }, { + "name" : "server", + "value" : "gws" + }, { + "name" : "status", + "value" : "301" + }, { + "name" : "x-frame-options", + "value" : "SAMEORIGIN" + }, { + "name" : "x-xss-protection", + "value" : "0" + } ], + "headersSize" : 471, + "redirectURL" : "", + "status" : 301, + "statusText" : "MOVED_PERMANENTLY" + }, + "serverIPAddress" : "172.217.6.110", + "startedDateTime" : "2019-11-15T16:41:54.798Z", + "time" : 71, + "timings" : { + "blocked" : 2, + "connect" : 16, + "dns" : 1, + "receive" : 1, + "send" : 0, + "ssl" : 14, + "wait" : 50 + } + }, { + "pageref" : "page_0", + "request" : { + "headers" : [ { + "name" : ":authority", + "value" : "www.google.com" + }, { + "name" : ":method", + "value" : "GET" + }, { + "name" : ":path", + "value" : "/" + }, { + "name" : ":scheme", + "value" : "https" + }, { + "name" : "accept", + "value" : "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8" + }, { + "name" : "accept-encoding", + "value" : "gzip, deflate, br" + }, { + "name" : "accept-language", + "value" : "en-US,en;q=0.9" + }, { + "name" : "upgrade-insecure-requests", + "value" : "1" + }, { + "name" : "user-agent", + "value" : "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.83 Safari/537.36" + }, { + "name" : "x-thousandeyes-agent", + "value" : "yes" + } ], + "method" : "GET", + "url" : "https://www.google.com/" + }, + "response" : { + "bodySize" : 65214, + "content" : { + "mimeType" : "text/html", + "size" : 225039 + }, + "headers" : [ { + "name" : "alt-svc", + "value" : "quic=\\":443\\"; ma=2592000; v=\\"46,43\\",h3-Q050=\\":443\\"; ma=2592000,h3-Q049=\\":443\\"; ma=2592000,h3-Q048=\\":443\\"; ma=2592000,h3-Q046=\\":443\\"; ma=2592000,h3-Q043=\\":443\\"; ma=2592000" + }, { + "name" : "cache-control", + "value" : "private, max-age=0" + }, { + "name" : "content-encoding", + "value" : "br" + }, { + "name" : "content-length", + "value" : "65214" + }, { + "name" : "content-type", + "value" : "text/html; charset=UTF-8" + }, { + "name" : "date", + "value" : "Fri, 15 Nov 2019 16:41:54 GMT" + }, { + "name" : "expires", + "value" : "-1" + }, { + "name" : "p3p", + "value" : "CP=\\"This is not a P3P policy! See g.co/p3phelp for more info.\\"" + }, { + "name" : "server", + "value" : "gws" + }, { + "name" : "set-cookie", + "value" : "(removed)" + }, { + "name" : "status", + "value" : "200" + }, { + "name" : "strict-transport-security", + "value" : "max-age=31536000" + }, { + "name" : "x-frame-options", + "value" : "SAMEORIGIN" + }, { + "name" : "x-xss-protection", + "value" : "0" + } ], + "headersSize" : 915, + "redirectURL" : "", + "status" : 200, + "statusText" : "OK" + }, + "serverIPAddress" : "172.217.4.196", + "startedDateTime" : "2019-11-15T16:41:54.870Z", + "time" : 182, + "timings" : { + "blocked" : 2, + "connect" : 4, + "dns" : 0, + "receive" : 58, + "send" : 0, + "ssl" : 2, + "wait" : 118 + } + } ], + "pages" : [ { + "id" : "page_0", + "pageTimings" : { + "onContentLoad" : 367, + "onLoad" : 737 + }, + "responseCode" : 0, + "startedDateTime" : "2019-11-15T16:41:54.796Z", + "title" : "Google" + } ], + "version" : "1.2" + } + }, + "startTime" : 1384309800, + "endTime" : 1384309800, + "markers" : [ { + "duration" : 1360, + "name" : "SearchForWebdriver" + }, { + "duration" : 1360, + "name" : "SearchForWebdriver" + } ], + "roundId" : 1384309800, + "errorDetails" : "Connection error" + }, { + "date" : "2022-07-17T22:00:54Z", + "agent" : { + "agentId" : "281474976710706", + "agentName" : "thousandeyes-stg-va-254", + "location" : "San Francisco Bay Area", + "countryId" : "US" + }, + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "componentErrors" : 5, + "errorType" : "None", + "transactionTime" : 2379, + "pages" : [ { + "duration" : 1117.5660001039505, + "componentCount" : 136, + "pageNum" : 0, + "pageName" : "Google", + "errorCount" : 0 + }, { + "duration" : 1117.5660001039505, + "componentCount" : 136, + "pageNum" : 0, + "pageName" : "Google", + "errorCount" : 0 + } ], + "har" : { + "log" : { + "creator" : { + "name" : "ThousandEyes DB Exporter" + }, + "entries" : [ { + "pageref" : "page_0", + "request" : { + "headers" : [ { + "name" : ":authority", + "value" : "google.com" + }, { + "name" : ":method", + "value" : "GET" + }, { + "name" : ":path", + "value" : "/" + }, { + "name" : ":scheme", + "value" : "https" + }, { + "name" : "accept", + "value" : "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8" + }, { + "name" : "accept-encoding", + "value" : "gzip, deflate, br" + }, { + "name" : "accept-language", + "value" : "en-US,en;q=0.9" + }, { + "name" : "upgrade-insecure-requests", + "value" : "1" + }, { + "name" : "user-agent", + "value" : "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.83 Safari/537.36" + }, { + "name" : "x-thousandeyes-agent", + "value" : "yes" + } ], + "method" : "GET", + "url" : "https://google.com/" + }, + "response" : { + "bodySize" : 220, + "content" : { + "mimeType" : "text/html", + "size" : 220 + }, + "headers" : [ { + "name" : "alt-svc", + "value" : "quic=\\":443\\"; ma=2592000; v=\\"46,43\\",h3-Q050=\\":443\\"; ma=2592000,h3-Q049=\\":443\\"; ma=2592000,h3-Q048=\\":443\\"; ma=2592000,h3-Q046=\\":443\\"; ma=2592000,h3-Q043=\\":443\\"; ma=2592000" + }, { + "name" : "cache-control", + "value" : "public, max-age=2592000" + }, { + "name" : "content-length", + "value" : "220" + }, { + "name" : "content-type", + "value" : "text/html; charset=UTF-8" + }, { + "name" : "date", + "value" : "Fri, 15 Nov 2019 16:41:54 GMT" + }, { + "name" : "expires", + "value" : "Sun, 15 Dec 2019 16:41:54 GMT" + }, { + "name" : "location", + "value" : "https://www.google.com/" + }, { + "name" : "server", + "value" : "gws" + }, { + "name" : "status", + "value" : "301" + }, { + "name" : "x-frame-options", + "value" : "SAMEORIGIN" + }, { + "name" : "x-xss-protection", + "value" : "0" + } ], + "headersSize" : 471, + "redirectURL" : "", + "status" : 301, + "statusText" : "MOVED_PERMANENTLY" + }, + "serverIPAddress" : "172.217.6.110", + "startedDateTime" : "2019-11-15T16:41:54.798Z", + "time" : 71, + "timings" : { + "blocked" : 2, + "connect" : 16, + "dns" : 1, + "receive" : 1, + "send" : 0, + "ssl" : 14, + "wait" : 50 + } + }, { + "pageref" : "page_0", + "request" : { + "headers" : [ { + "name" : ":authority", + "value" : "www.google.com" + }, { + "name" : ":method", + "value" : "GET" + }, { + "name" : ":path", + "value" : "/" + }, { + "name" : ":scheme", + "value" : "https" + }, { + "name" : "accept", + "value" : "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8" + }, { + "name" : "accept-encoding", + "value" : "gzip, deflate, br" + }, { + "name" : "accept-language", + "value" : "en-US,en;q=0.9" + }, { + "name" : "upgrade-insecure-requests", + "value" : "1" + }, { + "name" : "user-agent", + "value" : "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.83 Safari/537.36" + }, { + "name" : "x-thousandeyes-agent", + "value" : "yes" + } ], + "method" : "GET", + "url" : "https://www.google.com/" + }, + "response" : { + "bodySize" : 65214, + "content" : { + "mimeType" : "text/html", + "size" : 225039 + }, + "headers" : [ { + "name" : "alt-svc", + "value" : "quic=\\":443\\"; ma=2592000; v=\\"46,43\\",h3-Q050=\\":443\\"; ma=2592000,h3-Q049=\\":443\\"; ma=2592000,h3-Q048=\\":443\\"; ma=2592000,h3-Q046=\\":443\\"; ma=2592000,h3-Q043=\\":443\\"; ma=2592000" + }, { + "name" : "cache-control", + "value" : "private, max-age=0" + }, { + "name" : "content-encoding", + "value" : "br" + }, { + "name" : "content-length", + "value" : "65214" + }, { + "name" : "content-type", + "value" : "text/html; charset=UTF-8" + }, { + "name" : "date", + "value" : "Fri, 15 Nov 2019 16:41:54 GMT" + }, { + "name" : "expires", + "value" : "-1" + }, { + "name" : "p3p", + "value" : "CP=\\"This is not a P3P policy! See g.co/p3phelp for more info.\\"" + }, { + "name" : "server", + "value" : "gws" + }, { + "name" : "set-cookie", + "value" : "(removed)" + }, { + "name" : "status", + "value" : "200" + }, { + "name" : "strict-transport-security", + "value" : "max-age=31536000" + }, { + "name" : "x-frame-options", + "value" : "SAMEORIGIN" + }, { + "name" : "x-xss-protection", + "value" : "0" + } ], + "headersSize" : 915, + "redirectURL" : "", + "status" : 200, + "statusText" : "OK" + }, + "serverIPAddress" : "172.217.4.196", + "startedDateTime" : "2019-11-15T16:41:54.870Z", + "time" : 182, + "timings" : { + "blocked" : 2, + "connect" : 4, + "dns" : 0, + "receive" : 58, + "send" : 0, + "ssl" : 2, + "wait" : 118 + } + } ], + "pages" : [ { + "id" : "page_0", + "pageTimings" : { + "onContentLoad" : 367, + "onLoad" : 737 + }, + "responseCode" : 0, + "startedDateTime" : "2019-11-15T16:41:54.796Z", + "title" : "Google" + } ], + "version" : "1.2" + } + }, + "startTime" : 1384309800, + "endTime" : 1384309800, + "markers" : [ { + "duration" : 1360, + "name" : "SearchForWebdriver" + }, { + "duration" : 1360, + "name" : "SearchForWebdriver" + } ], + "roundId" : 1384309800, + "errorDetails" : "Connection error" + } ] + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_test_web_transaction_agent_round_results": OperationExpectation( + operation_id="get_test_web_transaction_agent_round_results", + method="GET", + path="/test-results/{testId}/web-transactions/agent/{agentId}/round/{roundId}", + path_param_examples={ + "testId": '202701', + "agentId": '11', + "roundId": '1384309800', + }, + success_status=200, + success_body=json.loads(""" + + { + "test" : { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + }, + "_links" : { + "next" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "previous" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "results" : [ { + "date" : "2022-07-17T22:00:54Z", + "agent" : { + "agentId" : "281474976710706", + "agentName" : "thousandeyes-stg-va-254", + "location" : "San Francisco Bay Area", + "countryId" : "US" + }, + "pages" : [ { + "duration" : 1117.5660001039505, + "componentCount" : 136, + "pageNum" : 0, + "pageName" : "Google", + "errorCount" : 0 + }, { + "duration" : 1117.5660001039505, + "componentCount" : 136, + "pageNum" : 0, + "pageName" : "Google", + "errorCount" : 0 + } ], + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "componentErrors" : 5, + "errorType" : "None", + "startTime" : 1384309800, + "endTime" : 1384309800, + "transactionTime" : 2379, + "markers" : [ { + "duration" : 1360, + "name" : "SearchForWebdriver" + }, { + "duration" : 1360, + "name" : "SearchForWebdriver" + } ], + "roundId" : 1384309800, + "errorDetails" : "Connection error" + }, { + "date" : "2022-07-17T22:00:54Z", + "agent" : { + "agentId" : "281474976710706", + "agentName" : "thousandeyes-stg-va-254", + "location" : "San Francisco Bay Area", + "countryId" : "US" + }, + "pages" : [ { + "duration" : 1117.5660001039505, + "componentCount" : 136, + "pageNum" : 0, + "pageName" : "Google", + "errorCount" : 0 + }, { + "duration" : 1117.5660001039505, + "componentCount" : 136, + "pageNum" : 0, + "pageName" : "Google", + "errorCount" : 0 + } ], + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "componentErrors" : 5, + "errorType" : "None", + "startTime" : 1384309800, + "endTime" : 1384309800, + "transactionTime" : 2379, + "markers" : [ { + "duration" : 1360, + "name" : "SearchForWebdriver" + }, { + "duration" : 1360, + "name" : "SearchForWebdriver" + } ], + "roundId" : 1384309800, + "errorDetails" : "Connection error" + } ] + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_test_web_transaction_results": OperationExpectation( + operation_id="get_test_web_transaction_results", + method="GET", + path="/test-results/{testId}/web-transactions", + path_param_examples={ + "testId": '202701', + }, + success_status=200, + success_body=json.loads(""" + + { + "test" : { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + }, + "endDate" : "2022-07-18T22:00:54Z", + "_links" : { + "next" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "previous" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "results" : [ { + "date" : "2022-07-17T22:00:54Z", + "agent" : { + "agentId" : "281474976710706", + "agentName" : "thousandeyes-stg-va-254", + "location" : "San Francisco Bay Area", + "countryId" : "US" + }, + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "componentErrors" : 5, + "errorType" : "None", + "startTime" : 1384309800, + "endTime" : 1384309800, + "transactionTime" : 2379, + "roundId" : 1384309800, + "errorDetails" : "Connection error" + }, { + "date" : "2022-07-17T22:00:54Z", + "agent" : { + "agentId" : "281474976710706", + "agentName" : "thousandeyes-stg-va-254", + "location" : "San Francisco Bay Area", + "countryId" : "US" + }, + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "componentErrors" : 5, + "errorType" : "None", + "startTime" : 1384309800, + "endTime" : 1384309800, + "transactionTime" : 2379, + "roundId" : 1384309800, + "errorDetails" : "Connection error" + } ], + "startDate" : "2022-07-17T22:00:54Z" + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + +} diff --git a/thousandeyes-sdk-test-results/test/test_api_test_results_api_integration.py b/thousandeyes-sdk-test-results/test/test_api_test_results_api_integration.py new file mode 100644 index 00000000..d9d14a54 --- /dev/null +++ b/thousandeyes-sdk-test-results/test/test_api_test_results_api_integration.py @@ -0,0 +1,965 @@ +# coding: utf-8 + +""" + Test Results API + + Get test result metrics for Network and Application Synthetics tests. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.test_results.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.test_results.api.api_test_results_api import APITestResultsApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestAPITestResultsApiIntegration(IntegrationTestBase): + """APITestResultsApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = APITestResultsApi(self.api_client) + + + def test_get_test_api_agent_round_results_happy_path(self) -> None: + """Integration test for get_test_api_agent_round_results success path""" + test_id = '202701' + agent_id = '11' + round_id = '1384309800' + aid = '1234' + response_body_json = """ + { + "test" : { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + }, + "_links" : { + "next" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "previous" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "results" : [ { + "date" : "2022-07-17T22:00:54Z", + "completion" : 100, + "agent" : { + "agentId" : "281474976710706", + "agentName" : "thousandeyes-stg-va-254", + "location" : "San Francisco Bay Area", + "countryId" : "US" + }, + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "errorType" : "None", + "apiTransactionTime" : 990.1, + "startTime" : 1384309800, + "endTime" : 1384309800, + "requests" : [ { + "completion" : 100, + "stepType" : "default", + "responseTime" : 440.8, + "apiCallTime" : 900.9, + "processingTime" : 59.9, + "url" : "https://api.thousandeyes.com/v7/status", + "sendTime" : 8.1, + "receiveTime" : 224.1, + "connectTime" : 12.1, + "dnsTime" : 11.1, + "name" : "First Step to Acquire Token", + "stepNumber" : 1, + "assertions" : [ { + "hasFailed" : false, + "step" : 1 + }, { + "hasFailed" : false, + "step" : 1 + } ], + "assertErrorCount" : 0, + "blockedTime" : 49.9, + "stepTime" : 990.1, + "waitTime" : 18.1 + }, { + "completion" : 100, + "stepType" : "default", + "responseTime" : 440.8, + "apiCallTime" : 900.9, + "processingTime" : 59.9, + "url" : "https://api.thousandeyes.com/v7/status", + "sendTime" : 8.1, + "receiveTime" : 224.1, + "connectTime" : 12.1, + "dnsTime" : 11.1, + "name" : "First Step to Acquire Token", + "stepNumber" : 1, + "assertions" : [ { + "hasFailed" : false, + "step" : 1 + }, { + "hasFailed" : false, + "step" : 1 + } ], + "assertErrorCount" : 0, + "blockedTime" : 49.9, + "stepTime" : 990.1, + "waitTime" : 18.1 + } ], + "roundId" : 1384309800, + "errorDetails" : "Connection error" + }, { + "date" : "2022-07-17T22:00:54Z", + "completion" : 100, + "agent" : { + "agentId" : "281474976710706", + "agentName" : "thousandeyes-stg-va-254", + "location" : "San Francisco Bay Area", + "countryId" : "US" + }, + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "errorType" : "None", + "apiTransactionTime" : 990.1, + "startTime" : 1384309800, + "endTime" : 1384309800, + "requests" : [ { + "completion" : 100, + "stepType" : "default", + "responseTime" : 440.8, + "apiCallTime" : 900.9, + "processingTime" : 59.9, + "url" : "https://api.thousandeyes.com/v7/status", + "sendTime" : 8.1, + "receiveTime" : 224.1, + "connectTime" : 12.1, + "dnsTime" : 11.1, + "name" : "First Step to Acquire Token", + "stepNumber" : 1, + "assertions" : [ { + "hasFailed" : false, + "step" : 1 + }, { + "hasFailed" : false, + "step" : 1 + } ], + "assertErrorCount" : 0, + "blockedTime" : 49.9, + "stepTime" : 990.1, + "waitTime" : 18.1 + }, { + "completion" : 100, + "stepType" : "default", + "responseTime" : 440.8, + "apiCallTime" : 900.9, + "processingTime" : 59.9, + "url" : "https://api.thousandeyes.com/v7/status", + "sendTime" : 8.1, + "receiveTime" : 224.1, + "connectTime" : 12.1, + "dnsTime" : 11.1, + "name" : "First Step to Acquire Token", + "stepNumber" : 1, + "assertions" : [ { + "hasFailed" : false, + "step" : 1 + }, { + "hasFailed" : false, + "step" : 1 + } ], + "assertErrorCount" : 0, + "blockedTime" : 49.9, + "stepTime" : 990.1, + "waitTime" : 18.1 + } ], + "roundId" : 1384309800, + "errorDetails" : "Connection error" + } ] + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_test_api_agent_round_results( + + test_id=test_id, + + agent_id=agent_id, + + round_id=round_id, + + aid=aid, + + _headers=self.te_headers("get_test_api_agent_round_results"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_test_api_agent_round_results_error_400(self) -> None: + """Integration test for get_test_api_agent_round_results error path (HTTP 400)""" + test_id = '202701' + agent_id = '11' + round_id = '1384309800' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.get_test_api_agent_round_results( + + test_id=test_id, + + agent_id=agent_id, + + round_id=round_id, + + aid=aid, + + _headers=self.te_headers("get_test_api_agent_round_results", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_api_agent_round_results_error_401(self) -> None: + """Integration test for get_test_api_agent_round_results error path (HTTP 401)""" + test_id = '202701' + agent_id = '11' + round_id = '1384309800' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_test_api_agent_round_results( + + test_id=test_id, + + agent_id=agent_id, + + round_id=round_id, + + aid=aid, + + _headers=self.te_headers("get_test_api_agent_round_results", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_api_agent_round_results_error_403(self) -> None: + """Integration test for get_test_api_agent_round_results error path (HTTP 403)""" + test_id = '202701' + agent_id = '11' + round_id = '1384309800' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_test_api_agent_round_results( + + test_id=test_id, + + agent_id=agent_id, + + round_id=round_id, + + aid=aid, + + _headers=self.te_headers("get_test_api_agent_round_results", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_api_agent_round_results_error_404(self) -> None: + """Integration test for get_test_api_agent_round_results error path (HTTP 404)""" + test_id = '202701' + agent_id = '11' + round_id = '1384309800' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_test_api_agent_round_results( + + test_id=test_id, + + agent_id=agent_id, + + round_id=round_id, + + aid=aid, + + _headers=self.te_headers("get_test_api_agent_round_results", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_api_agent_round_results_error_429(self) -> None: + """Integration test for get_test_api_agent_round_results error path (HTTP 429)""" + test_id = '202701' + agent_id = '11' + round_id = '1384309800' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_test_api_agent_round_results( + + test_id=test_id, + + agent_id=agent_id, + + round_id=round_id, + + aid=aid, + + _headers=self.te_headers("get_test_api_agent_round_results", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_api_agent_round_results_error_500(self) -> None: + """Integration test for get_test_api_agent_round_results error path (HTTP 500)""" + test_id = '202701' + agent_id = '11' + round_id = '1384309800' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_test_api_agent_round_results( + + test_id=test_id, + + agent_id=agent_id, + + round_id=round_id, + + aid=aid, + + _headers=self.te_headers("get_test_api_agent_round_results", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_api_agent_round_results_error_502(self) -> None: + """Integration test for get_test_api_agent_round_results error path (HTTP 502)""" + test_id = '202701' + agent_id = '11' + round_id = '1384309800' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.get_test_api_agent_round_results( + + test_id=test_id, + + agent_id=agent_id, + + round_id=round_id, + + aid=aid, + + _headers=self.te_headers("get_test_api_agent_round_results", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_test_api_results_happy_path(self) -> None: + """Integration test for get_test_api_results success path""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + response_body_json = """ + { + "test" : { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + }, + "endDate" : "2022-07-18T22:00:54Z", + "_links" : { + "next" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "previous" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "results" : [ { + "date" : "2022-07-17T22:00:54Z", + "completion" : 100, + "agent" : { + "agentId" : "281474976710706", + "agentName" : "thousandeyes-stg-va-254", + "location" : "San Francisco Bay Area", + "countryId" : "US" + }, + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "errorType" : "None", + "apiTransactionTime" : 990.1, + "startTime" : 1384309800, + "endTime" : 1384309800, + "roundId" : 1384309800, + "errorDetails" : "Connection error" + }, { + "date" : "2022-07-17T22:00:54Z", + "completion" : 100, + "agent" : { + "agentId" : "281474976710706", + "agentName" : "thousandeyes-stg-va-254", + "location" : "San Francisco Bay Area", + "countryId" : "US" + }, + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "errorType" : "None", + "apiTransactionTime" : 990.1, + "startTime" : 1384309800, + "endTime" : 1384309800, + "roundId" : 1384309800, + "errorDetails" : "Connection error" + } ], + "startDate" : "2022-07-17T22:00:54Z" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_test_api_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_api_results"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_test_api_results_error_400(self) -> None: + """Integration test for get_test_api_results error path (HTTP 400)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.get_test_api_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_api_results", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_api_results_error_401(self) -> None: + """Integration test for get_test_api_results error path (HTTP 401)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_test_api_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_api_results", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_api_results_error_403(self) -> None: + """Integration test for get_test_api_results error path (HTTP 403)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_test_api_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_api_results", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_api_results_error_404(self) -> None: + """Integration test for get_test_api_results error path (HTTP 404)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_test_api_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_api_results", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_api_results_error_429(self) -> None: + """Integration test for get_test_api_results error path (HTTP 429)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_test_api_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_api_results", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_api_results_error_500(self) -> None: + """Integration test for get_test_api_results error path (HTTP 500)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_test_api_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_api_results", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_api_results_error_502(self) -> None: + """Integration test for get_test_api_results error path (HTTP 502)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.get_test_api_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_api_results", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-test-results/test/test_dns_server_test_results_api_integration.py b/thousandeyes-sdk-test-results/test/test_dns_server_test_results_api_integration.py new file mode 100644 index 00000000..d813920f --- /dev/null +++ b/thousandeyes-sdk-test-results/test/test_dns_server_test_results_api_integration.py @@ -0,0 +1,945 @@ +# coding: utf-8 + +""" + Test Results API + + Get test result metrics for Network and Application Synthetics tests. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.test_results.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.test_results.api.dns_server_test_results_api import DNSServerTestResultsApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestDNSServerTestResultsApiIntegration(IntegrationTestBase): + """DNSServerTestResultsApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = DNSServerTestResultsApi(self.api_client) + + + def test_get_test_dns_server_result_happy_path(self) -> None: + """Integration test for get_test_dns_server_result success path""" + test_id = '202701' + server_id = '281474976710706' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + response_body_json = """ + { + "test" : { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + }, + "endDate" : "2022-07-18T22:00:54Z", + "_links" : { + "next" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "previous" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "results" : [ { + "date" : "2022-07-17T22:00:54Z", + "server" : "a1.verisigndns.com.", + "agent" : { + "agentId" : "281474976710706", + "agentName" : "thousandeyes-stg-va-254", + "location" : "San Francisco Bay Area", + "countryId" : "US" + }, + "mappings" : "208.185.7.120", + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "startTime" : 1384309800, + "endTime" : 1384309800, + "resolutionTime" : 3, + "roundId" : 1384309800, + "serverId" : "456", + "errorDetails" : "Connection error" + }, { + "date" : "2022-07-17T22:00:54Z", + "server" : "a1.verisigndns.com.", + "agent" : { + "agentId" : "281474976710706", + "agentName" : "thousandeyes-stg-va-254", + "location" : "San Francisco Bay Area", + "countryId" : "US" + }, + "mappings" : "208.185.7.120", + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "startTime" : 1384309800, + "endTime" : 1384309800, + "resolutionTime" : 3, + "roundId" : 1384309800, + "serverId" : "456", + "errorDetails" : "Connection error" + } ], + "startDate" : "2022-07-17T22:00:54Z" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_test_dns_server_result( + + test_id=test_id, + + server_id=server_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_dns_server_result"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_test_dns_server_result_error_400(self) -> None: + """Integration test for get_test_dns_server_result error path (HTTP 400)""" + test_id = '202701' + server_id = '281474976710706' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.get_test_dns_server_result( + + test_id=test_id, + + server_id=server_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_dns_server_result", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_dns_server_result_error_401(self) -> None: + """Integration test for get_test_dns_server_result error path (HTTP 401)""" + test_id = '202701' + server_id = '281474976710706' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_test_dns_server_result( + + test_id=test_id, + + server_id=server_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_dns_server_result", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_dns_server_result_error_403(self) -> None: + """Integration test for get_test_dns_server_result error path (HTTP 403)""" + test_id = '202701' + server_id = '281474976710706' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_test_dns_server_result( + + test_id=test_id, + + server_id=server_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_dns_server_result", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_dns_server_result_error_404(self) -> None: + """Integration test for get_test_dns_server_result error path (HTTP 404)""" + test_id = '202701' + server_id = '281474976710706' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_test_dns_server_result( + + test_id=test_id, + + server_id=server_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_dns_server_result", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_dns_server_result_error_429(self) -> None: + """Integration test for get_test_dns_server_result error path (HTTP 429)""" + test_id = '202701' + server_id = '281474976710706' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_test_dns_server_result( + + test_id=test_id, + + server_id=server_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_dns_server_result", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_dns_server_result_error_500(self) -> None: + """Integration test for get_test_dns_server_result error path (HTTP 500)""" + test_id = '202701' + server_id = '281474976710706' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_test_dns_server_result( + + test_id=test_id, + + server_id=server_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_dns_server_result", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_dns_server_result_error_502(self) -> None: + """Integration test for get_test_dns_server_result error path (HTTP 502)""" + test_id = '202701' + server_id = '281474976710706' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.get_test_dns_server_result( + + test_id=test_id, + + server_id=server_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_dns_server_result", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_test_dns_servers_results_happy_path(self) -> None: + """Integration test for get_test_dns_servers_results success path""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + response_body_json = """ + { + "test" : { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + }, + "endDate" : "2022-07-18T22:00:54Z", + "_links" : { + "next" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "previous" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "results" : [ { + "date" : "2022-07-17T22:00:54Z", + "server" : "a1.verisigndns.com.", + "agent" : { + "agentId" : "281474976710706", + "agentName" : "thousandeyes-stg-va-254", + "location" : "San Francisco Bay Area", + "countryId" : "US" + }, + "mappings" : "208.185.7.120", + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "startTime" : 1384309800, + "endTime" : 1384309800, + "resolutionTime" : 3, + "roundId" : 1384309800, + "serverId" : "456", + "errorDetails" : "Connection error" + }, { + "date" : "2022-07-17T22:00:54Z", + "server" : "a1.verisigndns.com.", + "agent" : { + "agentId" : "281474976710706", + "agentName" : "thousandeyes-stg-va-254", + "location" : "San Francisco Bay Area", + "countryId" : "US" + }, + "mappings" : "208.185.7.120", + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "startTime" : 1384309800, + "endTime" : 1384309800, + "resolutionTime" : 3, + "roundId" : 1384309800, + "serverId" : "456", + "errorDetails" : "Connection error" + } ], + "startDate" : "2022-07-17T22:00:54Z" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_test_dns_servers_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_dns_servers_results"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_test_dns_servers_results_error_400(self) -> None: + """Integration test for get_test_dns_servers_results error path (HTTP 400)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.get_test_dns_servers_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_dns_servers_results", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_dns_servers_results_error_401(self) -> None: + """Integration test for get_test_dns_servers_results error path (HTTP 401)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_test_dns_servers_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_dns_servers_results", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_dns_servers_results_error_403(self) -> None: + """Integration test for get_test_dns_servers_results error path (HTTP 403)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_test_dns_servers_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_dns_servers_results", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_dns_servers_results_error_404(self) -> None: + """Integration test for get_test_dns_servers_results error path (HTTP 404)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_test_dns_servers_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_dns_servers_results", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_dns_servers_results_error_429(self) -> None: + """Integration test for get_test_dns_servers_results error path (HTTP 429)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_test_dns_servers_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_dns_servers_results", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_dns_servers_results_error_500(self) -> None: + """Integration test for get_test_dns_servers_results error path (HTTP 500)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_test_dns_servers_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_dns_servers_results", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_dns_servers_results_error_502(self) -> None: + """Integration test for get_test_dns_servers_results error path (HTTP 502)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.get_test_dns_servers_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_dns_servers_results", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-test-results/test/test_dns_trace_test_results_api_integration.py b/thousandeyes-sdk-test-results/test/test_dns_trace_test_results_api_integration.py new file mode 100644 index 00000000..70345c51 --- /dev/null +++ b/thousandeyes-sdk-test-results/test/test_dns_trace_test_results_api_integration.py @@ -0,0 +1,482 @@ +# coding: utf-8 + +""" + Test Results API + + Get test result metrics for Network and Application Synthetics tests. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.test_results.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.test_results.api.dns_trace_test_results_api import DNSTraceTestResultsApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestDNSTraceTestResultsApiIntegration(IntegrationTestBase): + """DNSTraceTestResultsApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = DNSTraceTestResultsApi(self.api_client) + + + def test_get_test_dns_trace_results_happy_path(self) -> None: + """Integration test for get_test_dns_trace_results success path""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + response_body_json = """ + { + "test" : { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + }, + "endDate" : "2022-07-18T22:00:54Z", + "_links" : { + "next" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "previous" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "results" : [ { + "date" : "2022-07-17T22:00:54Z", + "agent" : { + "agentId" : "281474976710706", + "agentName" : "thousandeyes-stg-va-254", + "location" : "San Francisco Bay Area", + "countryId" : "US" + }, + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "finalServerQueried" : "a1.verisigndns.com.", + "finalQueryTime" : 178, + "queries" : 3, + "failedQueries" : 0, + "output" : "com.\\t172800\\tIN\\tNS\\ta.gtld-servers.net.\\ncom.\\t172800\\tIN\\tNS\\tf.gtld-servers.net.\\ncom.\\t172800\\tIN\\tNS\\tc.gtld-servers.net.\\ncom.\\t172800\\tIN\\tNS\\tb.gtld-servers.net.\\ncom.\\t172800\\tIN\\tNS\\td.gtld-servers.net.\\ncom.\\t172800\\tIN\\tNS\\te.gtld-servers.net.\\ncom.\\t172800\\tIN\\tNS\\tg.gtld-servers.net.\\ncom.\\t172800\\tIN\\tNS\\tm.gtld-servers.net.\\ncom.\\t172800\\tIN\\tNS\\th.gtld-servers.net.\\ncom.\\t172800\\tIN\\tNS\\tj.gtld-servers.net.\\ncom.\\t172800\\tIN\\tNS\\ti.gtld-servers.net.\\ncom.\\t172800\\tIN\\tNS\\tl.gtld-servers.net.\\ncom.\\t172800\\tIN\\tNS\\tk.gtld-servers.net.\\n;; Received 498 bytes from 199.7.91.13(d.root-servers.net.) in 119 ms\\n\\nthousandeyes.com.\\t172800\\tIN\\tNS\\ta1.verisigndns.com.\\nthousandeyes.com.\\t172800\\tIN\\tNS\\ta2.verisigndns.com.\\nthousandeyes.com.\\t172800\\tIN\\tNS\\ta3.verisigndns.com.\\nthousandeyes.com.\\t172800\\tIN\\tNS\\tu1.verisigndns.com.\\n;; Received 266 bytes from 192.5.6.30(a.gtld-servers.net.) in 178 ms\\n\\napp.thousandeyes.com.\\t300\\tIN\\tCNAME\\tweb.thousandeyes.com.\\nweb.thousandeyes.com.\\t300\\tIN\\tCNAME\\tlb-app.thousandeyes.com.\\nlb-app.thousandeyes.com.\\t3600\\tIN\\tA\\t208.185.7.120\\n;; Received 173 bytes from 209.112.113.33(a1.verisigndns.com.) in 178 ms\\n\\n", + "mappings" : "208.185.7.120", + "startTime" : 1384309800, + "endTime" : 1384309800, + "roundId" : 1384309800, + "errorDetails" : "Connection error" + }, { + "date" : "2022-07-17T22:00:54Z", + "agent" : { + "agentId" : "281474976710706", + "agentName" : "thousandeyes-stg-va-254", + "location" : "San Francisco Bay Area", + "countryId" : "US" + }, + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "finalServerQueried" : "a1.verisigndns.com.", + "finalQueryTime" : 178, + "queries" : 3, + "failedQueries" : 0, + "output" : "com.\\t172800\\tIN\\tNS\\ta.gtld-servers.net.\\ncom.\\t172800\\tIN\\tNS\\tf.gtld-servers.net.\\ncom.\\t172800\\tIN\\tNS\\tc.gtld-servers.net.\\ncom.\\t172800\\tIN\\tNS\\tb.gtld-servers.net.\\ncom.\\t172800\\tIN\\tNS\\td.gtld-servers.net.\\ncom.\\t172800\\tIN\\tNS\\te.gtld-servers.net.\\ncom.\\t172800\\tIN\\tNS\\tg.gtld-servers.net.\\ncom.\\t172800\\tIN\\tNS\\tm.gtld-servers.net.\\ncom.\\t172800\\tIN\\tNS\\th.gtld-servers.net.\\ncom.\\t172800\\tIN\\tNS\\tj.gtld-servers.net.\\ncom.\\t172800\\tIN\\tNS\\ti.gtld-servers.net.\\ncom.\\t172800\\tIN\\tNS\\tl.gtld-servers.net.\\ncom.\\t172800\\tIN\\tNS\\tk.gtld-servers.net.\\n;; Received 498 bytes from 199.7.91.13(d.root-servers.net.) in 119 ms\\n\\nthousandeyes.com.\\t172800\\tIN\\tNS\\ta1.verisigndns.com.\\nthousandeyes.com.\\t172800\\tIN\\tNS\\ta2.verisigndns.com.\\nthousandeyes.com.\\t172800\\tIN\\tNS\\ta3.verisigndns.com.\\nthousandeyes.com.\\t172800\\tIN\\tNS\\tu1.verisigndns.com.\\n;; Received 266 bytes from 192.5.6.30(a.gtld-servers.net.) in 178 ms\\n\\napp.thousandeyes.com.\\t300\\tIN\\tCNAME\\tweb.thousandeyes.com.\\nweb.thousandeyes.com.\\t300\\tIN\\tCNAME\\tlb-app.thousandeyes.com.\\nlb-app.thousandeyes.com.\\t3600\\tIN\\tA\\t208.185.7.120\\n;; Received 173 bytes from 209.112.113.33(a1.verisigndns.com.) in 178 ms\\n\\n", + "mappings" : "208.185.7.120", + "startTime" : 1384309800, + "endTime" : 1384309800, + "roundId" : 1384309800, + "errorDetails" : "Connection error" + } ], + "startDate" : "2022-07-17T22:00:54Z" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_test_dns_trace_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_dns_trace_results"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_test_dns_trace_results_error_400(self) -> None: + """Integration test for get_test_dns_trace_results error path (HTTP 400)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.get_test_dns_trace_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_dns_trace_results", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_dns_trace_results_error_401(self) -> None: + """Integration test for get_test_dns_trace_results error path (HTTP 401)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_test_dns_trace_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_dns_trace_results", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_dns_trace_results_error_403(self) -> None: + """Integration test for get_test_dns_trace_results error path (HTTP 403)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_test_dns_trace_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_dns_trace_results", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_dns_trace_results_error_404(self) -> None: + """Integration test for get_test_dns_trace_results error path (HTTP 404)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_test_dns_trace_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_dns_trace_results", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_dns_trace_results_error_429(self) -> None: + """Integration test for get_test_dns_trace_results error path (HTTP 429)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_test_dns_trace_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_dns_trace_results", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_dns_trace_results_error_500(self) -> None: + """Integration test for get_test_dns_trace_results error path (HTTP 500)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_test_dns_trace_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_dns_trace_results", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_dns_trace_results_error_502(self) -> None: + """Integration test for get_test_dns_trace_results error path (HTTP 502)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.get_test_dns_trace_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_dns_trace_results", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-test-results/test/test_dnssec_test_results_api_integration.py b/thousandeyes-sdk-test-results/test/test_dnssec_test_results_api_integration.py new file mode 100644 index 00000000..18e9c670 --- /dev/null +++ b/thousandeyes-sdk-test-results/test/test_dnssec_test_results_api_integration.py @@ -0,0 +1,472 @@ +# coding: utf-8 + +""" + Test Results API + + Get test result metrics for Network and Application Synthetics tests. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.test_results.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.test_results.api.dnssec_test_results_api import DNSSECTestResultsApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestDNSSECTestResultsApiIntegration(IntegrationTestBase): + """DNSSECTestResultsApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = DNSSECTestResultsApi(self.api_client) + + + def test_get_test_dns_sec_results_happy_path(self) -> None: + """Integration test for get_test_dns_sec_results success path""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + response_body_json = """ + { + "test" : { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + }, + "endDate" : "2022-07-18T22:00:54Z", + "_links" : { + "next" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "previous" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "results" : [ { + "date" : "2022-07-17T22:00:54Z", + "agent" : { + "agentId" : "281474976710706", + "agentName" : "thousandeyes-stg-va-254", + "location" : "San Francisco Bay Area", + "countryId" : "US" + }, + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isValid" : true, + "startTime" : 1384309800, + "endTime" : 1384309800, + "roundId" : 1384309800, + "errorDetails" : "Connection error" + }, { + "date" : "2022-07-17T22:00:54Z", + "agent" : { + "agentId" : "281474976710706", + "agentName" : "thousandeyes-stg-va-254", + "location" : "San Francisco Bay Area", + "countryId" : "US" + }, + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "isValid" : true, + "startTime" : 1384309800, + "endTime" : 1384309800, + "roundId" : 1384309800, + "errorDetails" : "Connection error" + } ], + "startDate" : "2022-07-17T22:00:54Z" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_test_dns_sec_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_dns_sec_results"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_test_dns_sec_results_error_400(self) -> None: + """Integration test for get_test_dns_sec_results error path (HTTP 400)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.get_test_dns_sec_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_dns_sec_results", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_dns_sec_results_error_401(self) -> None: + """Integration test for get_test_dns_sec_results error path (HTTP 401)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_test_dns_sec_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_dns_sec_results", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_dns_sec_results_error_403(self) -> None: + """Integration test for get_test_dns_sec_results error path (HTTP 403)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_test_dns_sec_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_dns_sec_results", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_dns_sec_results_error_404(self) -> None: + """Integration test for get_test_dns_sec_results error path (HTTP 404)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_test_dns_sec_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_dns_sec_results", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_dns_sec_results_error_429(self) -> None: + """Integration test for get_test_dns_sec_results error path (HTTP 429)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_test_dns_sec_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_dns_sec_results", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_dns_sec_results_error_500(self) -> None: + """Integration test for get_test_dns_sec_results error path (HTTP 500)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_test_dns_sec_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_dns_sec_results", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_dns_sec_results_error_502(self) -> None: + """Integration test for get_test_dns_sec_results error path (HTTP 502)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.get_test_dns_sec_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_dns_sec_results", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-test-results/test/test_network_bgp_test_results_api_integration.py b/thousandeyes-sdk-test-results/test/test_network_bgp_test_results_api_integration.py new file mode 100644 index 00000000..562ab1b2 --- /dev/null +++ b/thousandeyes-sdk-test-results/test/test_network_bgp_test_results_api_integration.py @@ -0,0 +1,853 @@ +# coding: utf-8 + +""" + Test Results API + + Get test result metrics for Network and Application Synthetics tests. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.test_results.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.test_results.api.network_bgp_test_results_api import NetworkBGPTestResultsApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestNetworkBGPTestResultsApiIntegration(IntegrationTestBase): + """NetworkBGPTestResultsApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = NetworkBGPTestResultsApi(self.api_client) + + + def test_get_test_bgp_results_happy_path(self) -> None: + """Integration test for get_test_bgp_results success path""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + response_body_json = """ + { + "test" : { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + }, + "endDate" : "2022-07-18T22:00:54Z", + "_links" : { + "next" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "previous" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "results" : [ { + "date" : "2022-07-17T22:00:54Z", + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "prefix" : "99.128.0.0/11", + "monitor" : { + "monitorId" : "281474976710706", + "monitorName" : "Vancouver, Canada - Bell Canada (AS 6539)", + "countryId" : "US" + }, + "startTime" : 1384309800, + "endTime" : 1384309800, + "reachability" : 0, + "updates" : 0, + "pathChanges" : 0, + "roundId" : 1384309800, + "prefixId" : "215" + }, { + "date" : "2022-07-17T22:00:54Z", + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "prefix" : "99.128.0.0/11", + "monitor" : { + "monitorId" : "281474976710706", + "monitorName" : "Vancouver, Canada - Bell Canada (AS 6539)", + "countryId" : "US" + }, + "startTime" : 1384309800, + "endTime" : 1384309800, + "reachability" : 0, + "updates" : 0, + "pathChanges" : 0, + "roundId" : 1384309800, + "prefixId" : "215" + } ], + "startDate" : "2022-07-17T22:00:54Z" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_test_bgp_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_bgp_results"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_test_bgp_results_error_400(self) -> None: + """Integration test for get_test_bgp_results error path (HTTP 400)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.get_test_bgp_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_bgp_results", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_bgp_results_error_401(self) -> None: + """Integration test for get_test_bgp_results error path (HTTP 401)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_test_bgp_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_bgp_results", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_bgp_results_error_403(self) -> None: + """Integration test for get_test_bgp_results error path (HTTP 403)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_test_bgp_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_bgp_results", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_bgp_results_error_404(self) -> None: + """Integration test for get_test_bgp_results error path (HTTP 404)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_test_bgp_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_bgp_results", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_bgp_results_error_429(self) -> None: + """Integration test for get_test_bgp_results error path (HTTP 429)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_test_bgp_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_bgp_results", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_bgp_results_error_500(self) -> None: + """Integration test for get_test_bgp_results error path (HTTP 500)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_test_bgp_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_bgp_results", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_bgp_results_error_502(self) -> None: + """Integration test for get_test_bgp_results error path (HTTP 502)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.get_test_bgp_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_bgp_results", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_test_bgp_routes_prefix_round_results_happy_path(self) -> None: + """Integration test for get_test_bgp_routes_prefix_round_results success path""" + test_id = '202701' + prefix_id = '3789376546' + round_id = '1384309800' + aid = '1234' + response_body_json = """ + { + "test" : { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + }, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "results" : [ { + "date" : "2022-07-17T22:00:54Z", + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "prefix" : "99.128.0.0/11", + "monitor" : { + "monitorId" : "281474976710706", + "monitorName" : "Vancouver, Canada - Bell Canada (AS 6539)", + "countryId" : "US" + }, + "hops" : [ { + "asName" : "Telus Advanced Communications", + "asn" : 852 + }, { + "asName" : "Telus Advanced Communications", + "asn" : 852 + } ], + "isActive" : true, + "roundId" : 1384309800, + "prefixId" : "215" + }, { + "date" : "2022-07-17T22:00:54Z", + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "prefix" : "99.128.0.0/11", + "monitor" : { + "monitorId" : "281474976710706", + "monitorName" : "Vancouver, Canada - Bell Canada (AS 6539)", + "countryId" : "US" + }, + "hops" : [ { + "asName" : "Telus Advanced Communications", + "asn" : 852 + }, { + "asName" : "Telus Advanced Communications", + "asn" : 852 + } ], + "isActive" : true, + "roundId" : 1384309800, + "prefixId" : "215" + } ] + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_test_bgp_routes_prefix_round_results( + + test_id=test_id, + + prefix_id=prefix_id, + + round_id=round_id, + + aid=aid, + + _headers=self.te_headers("get_test_bgp_routes_prefix_round_results"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_test_bgp_routes_prefix_round_results_error_400(self) -> None: + """Integration test for get_test_bgp_routes_prefix_round_results error path (HTTP 400)""" + test_id = '202701' + prefix_id = '3789376546' + round_id = '1384309800' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.get_test_bgp_routes_prefix_round_results( + + test_id=test_id, + + prefix_id=prefix_id, + + round_id=round_id, + + aid=aid, + + _headers=self.te_headers("get_test_bgp_routes_prefix_round_results", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_bgp_routes_prefix_round_results_error_401(self) -> None: + """Integration test for get_test_bgp_routes_prefix_round_results error path (HTTP 401)""" + test_id = '202701' + prefix_id = '3789376546' + round_id = '1384309800' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_test_bgp_routes_prefix_round_results( + + test_id=test_id, + + prefix_id=prefix_id, + + round_id=round_id, + + aid=aid, + + _headers=self.te_headers("get_test_bgp_routes_prefix_round_results", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_bgp_routes_prefix_round_results_error_403(self) -> None: + """Integration test for get_test_bgp_routes_prefix_round_results error path (HTTP 403)""" + test_id = '202701' + prefix_id = '3789376546' + round_id = '1384309800' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_test_bgp_routes_prefix_round_results( + + test_id=test_id, + + prefix_id=prefix_id, + + round_id=round_id, + + aid=aid, + + _headers=self.te_headers("get_test_bgp_routes_prefix_round_results", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_bgp_routes_prefix_round_results_error_404(self) -> None: + """Integration test for get_test_bgp_routes_prefix_round_results error path (HTTP 404)""" + test_id = '202701' + prefix_id = '3789376546' + round_id = '1384309800' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_test_bgp_routes_prefix_round_results( + + test_id=test_id, + + prefix_id=prefix_id, + + round_id=round_id, + + aid=aid, + + _headers=self.te_headers("get_test_bgp_routes_prefix_round_results", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_bgp_routes_prefix_round_results_error_429(self) -> None: + """Integration test for get_test_bgp_routes_prefix_round_results error path (HTTP 429)""" + test_id = '202701' + prefix_id = '3789376546' + round_id = '1384309800' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_test_bgp_routes_prefix_round_results( + + test_id=test_id, + + prefix_id=prefix_id, + + round_id=round_id, + + aid=aid, + + _headers=self.te_headers("get_test_bgp_routes_prefix_round_results", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_bgp_routes_prefix_round_results_error_500(self) -> None: + """Integration test for get_test_bgp_routes_prefix_round_results error path (HTTP 500)""" + test_id = '202701' + prefix_id = '3789376546' + round_id = '1384309800' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_test_bgp_routes_prefix_round_results( + + test_id=test_id, + + prefix_id=prefix_id, + + round_id=round_id, + + aid=aid, + + _headers=self.te_headers("get_test_bgp_routes_prefix_round_results", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_bgp_routes_prefix_round_results_error_502(self) -> None: + """Integration test for get_test_bgp_routes_prefix_round_results error path (HTTP 502)""" + test_id = '202701' + prefix_id = '3789376546' + round_id = '1384309800' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.get_test_bgp_routes_prefix_round_results( + + test_id=test_id, + + prefix_id=prefix_id, + + round_id=round_id, + + aid=aid, + + _headers=self.te_headers("get_test_bgp_routes_prefix_round_results", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-test-results/test/test_network_test_results_api_integration.py b/thousandeyes-sdk-test-results/test/test_network_test_results_api_integration.py new file mode 100644 index 00000000..d0cc370b --- /dev/null +++ b/thousandeyes-sdk-test-results/test/test_network_test_results_api_integration.py @@ -0,0 +1,1440 @@ +# coding: utf-8 + +""" + Test Results API + + Get test result metrics for Network and Application Synthetics tests. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.test_results.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.test_results.api.network_test_results_api import NetworkTestResultsApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestNetworkTestResultsApiIntegration(IntegrationTestBase): + """NetworkTestResultsApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = NetworkTestResultsApi(self.api_client) + + + def test_get_test_network_results_happy_path(self) -> None: + """Integration test for get_test_network_results success path""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + response_body_json = """ + { + "test" : { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + }, + "endDate" : "2022-07-18T22:00:54Z", + "_links" : { + "next" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "previous" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "results" : [ { + "date" : "2022-07-17T22:00:54Z", + "server" : "www.thousandeyes.com:80", + "availableBandwidth" : 9.100464, + "agent" : { + "agentId" : "281474976710706", + "agentName" : "thousandeyes-stg-va-254", + "location" : "San Francisco Bay Area", + "countryId" : "US" + }, + "packetsBySecond" : [ [ ], [ 0 ], [ 2 ], [ 2, 1 ], [ 1, 1 ] ], + "avgLatency" : 167.04, + "bandwidth" : 4.3313155, + "minLatency" : 167, + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "maxLatency" : 168, + "proxyJitter" : 1.2, + "proxyAverageLatency" : 45, + "proxyLoss" : 2.5, + "healthScore" : 0.98, + "capacity" : 210.10854, + "loss" : 0, + "proxyMinLatency" : 40, + "jitter" : 0.076808, + "serverIp" : "50.18.127.223", + "startTime" : 1384309800, + "endTime" : 1384309800, + "proxyMaxLatency" : 50, + "roundId" : 1384309800, + "direction" : "to-target" + }, { + "date" : "2022-07-17T22:00:54Z", + "server" : "www.thousandeyes.com:80", + "availableBandwidth" : 9.100464, + "agent" : { + "agentId" : "281474976710706", + "agentName" : "thousandeyes-stg-va-254", + "location" : "San Francisco Bay Area", + "countryId" : "US" + }, + "packetsBySecond" : [ [ ], [ 0 ], [ 2 ], [ 2, 1 ], [ 1, 1 ] ], + "avgLatency" : 167.04, + "bandwidth" : 4.3313155, + "minLatency" : 167, + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "maxLatency" : 168, + "proxyJitter" : 1.2, + "proxyAverageLatency" : 45, + "proxyLoss" : 2.5, + "healthScore" : 0.98, + "capacity" : 210.10854, + "loss" : 0, + "proxyMinLatency" : 40, + "jitter" : 0.076808, + "serverIp" : "50.18.127.223", + "startTime" : 1384309800, + "endTime" : 1384309800, + "proxyMaxLatency" : 50, + "roundId" : 1384309800, + "direction" : "to-target" + } ], + "startDate" : "2022-07-17T22:00:54Z" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_test_network_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_network_results"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_test_network_results_error_400(self) -> None: + """Integration test for get_test_network_results error path (HTTP 400)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.get_test_network_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_network_results", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_network_results_error_401(self) -> None: + """Integration test for get_test_network_results error path (HTTP 401)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_test_network_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_network_results", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_network_results_error_403(self) -> None: + """Integration test for get_test_network_results error path (HTTP 403)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_test_network_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_network_results", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_network_results_error_404(self) -> None: + """Integration test for get_test_network_results error path (HTTP 404)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_test_network_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_network_results", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_network_results_error_429(self) -> None: + """Integration test for get_test_network_results error path (HTTP 429)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_test_network_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_network_results", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_network_results_error_500(self) -> None: + """Integration test for get_test_network_results error path (HTTP 500)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_test_network_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_network_results", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_network_results_error_502(self) -> None: + """Integration test for get_test_network_results error path (HTTP 502)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.get_test_network_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_network_results", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_test_path_vis_agent_round_results_happy_path(self) -> None: + """Integration test for get_test_path_vis_agent_round_results success path""" + test_id = '202701' + agent_id = '11' + round_id = '1384309800' + aid = '1234' + response_body_json = """ + { + "test" : { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + }, + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "results" : [ { + "date" : "2022-07-17T22:00:54Z", + "server" : "www.google.com:443", + "agent" : { + "agentId" : "281474976710706", + "agentName" : "thousandeyes-stg-va-254", + "location" : "San Francisco Bay Area", + "countryId" : "US" + }, + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "targetIsProxy" : true, + "sourcePrefix" : "196.40.96.0/20", + "sourceIp" : "196.40.106.237", + "pathTraces" : [ { + "hops" : [ { + "rdns" : "core-router1.cpt2.host-h.net", + "prefix" : "196.40.96.0/20", + "responseTime" : 1, + "hop" : 1, + "ipAddress" : "196.40.106.237", + "mpls" : "mpls", + "location" : "Cape Town, South Africa", + "network" : "HETZNER (Pty) Ltd (AS 37153)" + }, { + "rdns" : "core-router1.cpt2.host-h.net", + "prefix" : "196.40.96.0/20", + "responseTime" : 1, + "hop" : 1, + "ipAddress" : "196.40.106.237", + "mpls" : "mpls", + "location" : "Cape Town, South Africa", + "network" : "HETZNER (Pty) Ltd (AS 37153)" + } ], + "pathId" : "4711301366345855606023718047703941305741293841502186803" + }, { + "hops" : [ { + "rdns" : "core-router1.cpt2.host-h.net", + "prefix" : "196.40.96.0/20", + "responseTime" : 1, + "hop" : 1, + "ipAddress" : "196.40.106.237", + "mpls" : "mpls", + "location" : "Cape Town, South Africa", + "network" : "HETZNER (Pty) Ltd (AS 37153)" + }, { + "rdns" : "core-router1.cpt2.host-h.net", + "prefix" : "196.40.96.0/20", + "responseTime" : 1, + "hop" : 1, + "ipAddress" : "196.40.106.237", + "mpls" : "mpls", + "location" : "Cape Town, South Africa", + "network" : "HETZNER (Pty) Ltd (AS 37153)" + } ], + "pathId" : "4711301366345855606023718047703941305741293841502186803" + } ], + "serverIp" : "172.217.170.68", + "startTime" : 1384309800, + "endTime" : 1384309800, + "roundId" : 1384309800, + "direction" : "to-target" + }, { + "date" : "2022-07-17T22:00:54Z", + "server" : "www.google.com:443", + "agent" : { + "agentId" : "281474976710706", + "agentName" : "thousandeyes-stg-va-254", + "location" : "San Francisco Bay Area", + "countryId" : "US" + }, + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "targetIsProxy" : true, + "sourcePrefix" : "196.40.96.0/20", + "sourceIp" : "196.40.106.237", + "pathTraces" : [ { + "hops" : [ { + "rdns" : "core-router1.cpt2.host-h.net", + "prefix" : "196.40.96.0/20", + "responseTime" : 1, + "hop" : 1, + "ipAddress" : "196.40.106.237", + "mpls" : "mpls", + "location" : "Cape Town, South Africa", + "network" : "HETZNER (Pty) Ltd (AS 37153)" + }, { + "rdns" : "core-router1.cpt2.host-h.net", + "prefix" : "196.40.96.0/20", + "responseTime" : 1, + "hop" : 1, + "ipAddress" : "196.40.106.237", + "mpls" : "mpls", + "location" : "Cape Town, South Africa", + "network" : "HETZNER (Pty) Ltd (AS 37153)" + } ], + "pathId" : "4711301366345855606023718047703941305741293841502186803" + }, { + "hops" : [ { + "rdns" : "core-router1.cpt2.host-h.net", + "prefix" : "196.40.96.0/20", + "responseTime" : 1, + "hop" : 1, + "ipAddress" : "196.40.106.237", + "mpls" : "mpls", + "location" : "Cape Town, South Africa", + "network" : "HETZNER (Pty) Ltd (AS 37153)" + }, { + "rdns" : "core-router1.cpt2.host-h.net", + "prefix" : "196.40.96.0/20", + "responseTime" : 1, + "hop" : 1, + "ipAddress" : "196.40.106.237", + "mpls" : "mpls", + "location" : "Cape Town, South Africa", + "network" : "HETZNER (Pty) Ltd (AS 37153)" + } ], + "pathId" : "4711301366345855606023718047703941305741293841502186803" + } ], + "serverIp" : "172.217.170.68", + "startTime" : 1384309800, + "endTime" : 1384309800, + "roundId" : 1384309800, + "direction" : "to-target" + } ] + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_test_path_vis_agent_round_results( + + test_id=test_id, + + agent_id=agent_id, + + round_id=round_id, + + aid=aid, + + _headers=self.te_headers("get_test_path_vis_agent_round_results"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_test_path_vis_agent_round_results_error_400(self) -> None: + """Integration test for get_test_path_vis_agent_round_results error path (HTTP 400)""" + test_id = '202701' + agent_id = '11' + round_id = '1384309800' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.get_test_path_vis_agent_round_results( + + test_id=test_id, + + agent_id=agent_id, + + round_id=round_id, + + aid=aid, + + _headers=self.te_headers("get_test_path_vis_agent_round_results", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_path_vis_agent_round_results_error_401(self) -> None: + """Integration test for get_test_path_vis_agent_round_results error path (HTTP 401)""" + test_id = '202701' + agent_id = '11' + round_id = '1384309800' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_test_path_vis_agent_round_results( + + test_id=test_id, + + agent_id=agent_id, + + round_id=round_id, + + aid=aid, + + _headers=self.te_headers("get_test_path_vis_agent_round_results", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_path_vis_agent_round_results_error_403(self) -> None: + """Integration test for get_test_path_vis_agent_round_results error path (HTTP 403)""" + test_id = '202701' + agent_id = '11' + round_id = '1384309800' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_test_path_vis_agent_round_results( + + test_id=test_id, + + agent_id=agent_id, + + round_id=round_id, + + aid=aid, + + _headers=self.te_headers("get_test_path_vis_agent_round_results", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_path_vis_agent_round_results_error_404(self) -> None: + """Integration test for get_test_path_vis_agent_round_results error path (HTTP 404)""" + test_id = '202701' + agent_id = '11' + round_id = '1384309800' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_test_path_vis_agent_round_results( + + test_id=test_id, + + agent_id=agent_id, + + round_id=round_id, + + aid=aid, + + _headers=self.te_headers("get_test_path_vis_agent_round_results", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_path_vis_agent_round_results_error_429(self) -> None: + """Integration test for get_test_path_vis_agent_round_results error path (HTTP 429)""" + test_id = '202701' + agent_id = '11' + round_id = '1384309800' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_test_path_vis_agent_round_results( + + test_id=test_id, + + agent_id=agent_id, + + round_id=round_id, + + aid=aid, + + _headers=self.te_headers("get_test_path_vis_agent_round_results", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_path_vis_agent_round_results_error_500(self) -> None: + """Integration test for get_test_path_vis_agent_round_results error path (HTTP 500)""" + test_id = '202701' + agent_id = '11' + round_id = '1384309800' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_test_path_vis_agent_round_results( + + test_id=test_id, + + agent_id=agent_id, + + round_id=round_id, + + aid=aid, + + _headers=self.te_headers("get_test_path_vis_agent_round_results", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_path_vis_agent_round_results_error_502(self) -> None: + """Integration test for get_test_path_vis_agent_round_results error path (HTTP 502)""" + test_id = '202701' + agent_id = '11' + round_id = '1384309800' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.get_test_path_vis_agent_round_results( + + test_id=test_id, + + agent_id=agent_id, + + round_id=round_id, + + aid=aid, + + _headers=self.te_headers("get_test_path_vis_agent_round_results", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_test_path_vis_results_happy_path(self) -> None: + """Integration test for get_test_path_vis_results success path""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + response_body_json = """ + { + "test" : { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + }, + "endDate" : "2022-07-18T22:00:54Z", + "_links" : { + "next" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "previous" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "results" : [ { + "date" : "2022-07-17T22:00:54Z", + "server" : "www.google.com:443", + "agent" : { + "agentId" : "281474976710706", + "agentName" : "thousandeyes-stg-va-254", + "location" : "San Francisco Bay Area", + "countryId" : "US" + }, + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "targetIsProxy" : true, + "sourcePrefix" : "196.40.96.0/20", + "sourceIp" : "196.40.106.237", + "pathTraces" : [ { + "numberOfHops" : 15, + "responseTime" : 1500, + "ipAddress" : "196.40.106.237", + "pathMtu" : 1500, + "pathId" : "1230899668701775614109128428722974545787322404682781961521", + "mss" : 1460 + }, { + "numberOfHops" : 15, + "responseTime" : 1500, + "ipAddress" : "196.40.106.237", + "pathMtu" : 1500, + "pathId" : "1230899668701775614109128428722974545787322404682781961521", + "mss" : 1460 + } ], + "serverIp" : "172.217.170.68", + "startTime" : 1384309800, + "endTime" : 1384309800, + "roundId" : 1384309800, + "direction" : "to-target" + }, { + "date" : "2022-07-17T22:00:54Z", + "server" : "www.google.com:443", + "agent" : { + "agentId" : "281474976710706", + "agentName" : "thousandeyes-stg-va-254", + "location" : "San Francisco Bay Area", + "countryId" : "US" + }, + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "targetIsProxy" : true, + "sourcePrefix" : "196.40.96.0/20", + "sourceIp" : "196.40.106.237", + "pathTraces" : [ { + "numberOfHops" : 15, + "responseTime" : 1500, + "ipAddress" : "196.40.106.237", + "pathMtu" : 1500, + "pathId" : "1230899668701775614109128428722974545787322404682781961521", + "mss" : 1460 + }, { + "numberOfHops" : 15, + "responseTime" : 1500, + "ipAddress" : "196.40.106.237", + "pathMtu" : 1500, + "pathId" : "1230899668701775614109128428722974545787322404682781961521", + "mss" : 1460 + } ], + "serverIp" : "172.217.170.68", + "startTime" : 1384309800, + "endTime" : 1384309800, + "roundId" : 1384309800, + "direction" : "to-target" + } ], + "startDate" : "2022-07-17T22:00:54Z" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_test_path_vis_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_path_vis_results"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_test_path_vis_results_error_400(self) -> None: + """Integration test for get_test_path_vis_results error path (HTTP 400)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.get_test_path_vis_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_path_vis_results", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_path_vis_results_error_401(self) -> None: + """Integration test for get_test_path_vis_results error path (HTTP 401)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_test_path_vis_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_path_vis_results", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_path_vis_results_error_403(self) -> None: + """Integration test for get_test_path_vis_results error path (HTTP 403)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_test_path_vis_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_path_vis_results", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_path_vis_results_error_404(self) -> None: + """Integration test for get_test_path_vis_results error path (HTTP 404)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_test_path_vis_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_path_vis_results", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_path_vis_results_error_429(self) -> None: + """Integration test for get_test_path_vis_results error path (HTTP 429)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_test_path_vis_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_path_vis_results", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_path_vis_results_error_500(self) -> None: + """Integration test for get_test_path_vis_results error path (HTTP 500)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_test_path_vis_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_path_vis_results", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_path_vis_results_error_502(self) -> None: + """Integration test for get_test_path_vis_results error path (HTTP 502)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.get_test_path_vis_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_path_vis_results", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-test-results/test/test_utils.py b/thousandeyes-sdk-test-results/test/test_utils.py index 930528d9..37913f62 100644 --- a/thousandeyes-sdk-test-results/test/test_utils.py +++ b/thousandeyes-sdk-test-results/test/test_utils.py @@ -2,15 +2,36 @@ import json import unittest +from typing import Any from pydantic import BaseModel +def _project_onto_constructed(expected: Any, constructed: Any) -> Any: + """Keep only example fields that appear in the constructed model output.""" + if isinstance(constructed, dict): + if not isinstance(expected, dict): + return expected + return { + key: _project_onto_constructed(expected.get(key), value) + for key, value in constructed.items() + } + if isinstance(constructed, list): + if not isinstance(expected, list): + return expected + return [ + _project_onto_constructed(expected[index], value) + for index, value in enumerate(constructed) + ] + return expected + + def assert_constructed_model_matches_example_json(model: BaseModel, loaded_json: dict): test_case = unittest.TestCase() test_case.maxDiff = None test_case.assertIsNotNone(model) constructed_json = json.loads(model.to_json()) - sorted_loaded_json = json.dumps(loaded_json, sort_keys=True) + projected_loaded_json = _project_onto_constructed(loaded_json, constructed_json) + sorted_loaded_json = json.dumps(projected_loaded_json, sort_keys=True) sorted_constructed_json = json.dumps(constructed_json, sort_keys=True) test_case.assertEqual(sorted_loaded_json, sorted_constructed_json) diff --git a/thousandeyes-sdk-test-results/test/test_voice_rtp_server_test_results_api_integration.py b/thousandeyes-sdk-test-results/test/test_voice_rtp_server_test_results_api_integration.py new file mode 100644 index 00000000..7614c5e1 --- /dev/null +++ b/thousandeyes-sdk-test-results/test/test_voice_rtp_server_test_results_api_integration.py @@ -0,0 +1,490 @@ +# coding: utf-8 + +""" + Test Results API + + Get test result metrics for Network and Application Synthetics tests. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.test_results.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.test_results.api.voice_rtp_server_test_results_api import VoiceRTPServerTestResultsApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestVoiceRTPServerTestResultsApiIntegration(IntegrationTestBase): + """VoiceRTPServerTestResultsApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = VoiceRTPServerTestResultsApi(self.api_client) + + + def test_get_test_rtp_server_results_happy_path(self) -> None: + """Integration test for get_test_rtp_server_results success path""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + response_body_json = """ + { + "test" : { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + }, + "endDate" : "2022-07-18T22:00:54Z", + "_links" : { + "next" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "previous" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "results" : [ { + "date" : "2022-07-17T22:00:54Z", + "agent" : { + "agentId" : "281474976710706", + "agentName" : "thousandeyes-stg-va-254", + "location" : "San Francisco Bay Area", + "countryId" : "US" + }, + "pdv" : 1, + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dscpName" : "EF (DSCP 46)", + "latency" : 103, + "mos" : 4.351024, + "loss" : 0, + "dscp" : "46", + "codecMaxMos" : 4.41, + "discards" : 0, + "serverIp" : "172.97.102.37", + "errorDetail" : "Connection error", + "startTime" : 1384309800, + "endTime" : 1384309800, + "codecName" : "G.711 @ 64 Kbps", + "roundId" : 1384309800 + }, { + "date" : "2022-07-17T22:00:54Z", + "agent" : { + "agentId" : "281474976710706", + "agentName" : "thousandeyes-stg-va-254", + "location" : "San Francisco Bay Area", + "countryId" : "US" + }, + "pdv" : 1, + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dscpName" : "EF (DSCP 46)", + "latency" : 103, + "mos" : 4.351024, + "loss" : 0, + "dscp" : "46", + "codecMaxMos" : 4.41, + "discards" : 0, + "serverIp" : "172.97.102.37", + "errorDetail" : "Connection error", + "startTime" : 1384309800, + "endTime" : 1384309800, + "codecName" : "G.711 @ 64 Kbps", + "roundId" : 1384309800 + } ], + "startDate" : "2022-07-17T22:00:54Z" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_test_rtp_server_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_rtp_server_results"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_test_rtp_server_results_error_400(self) -> None: + """Integration test for get_test_rtp_server_results error path (HTTP 400)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.get_test_rtp_server_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_rtp_server_results", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_rtp_server_results_error_401(self) -> None: + """Integration test for get_test_rtp_server_results error path (HTTP 401)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_test_rtp_server_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_rtp_server_results", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_rtp_server_results_error_403(self) -> None: + """Integration test for get_test_rtp_server_results error path (HTTP 403)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_test_rtp_server_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_rtp_server_results", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_rtp_server_results_error_404(self) -> None: + """Integration test for get_test_rtp_server_results error path (HTTP 404)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_test_rtp_server_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_rtp_server_results", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_rtp_server_results_error_429(self) -> None: + """Integration test for get_test_rtp_server_results error path (HTTP 429)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_test_rtp_server_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_rtp_server_results", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_rtp_server_results_error_500(self) -> None: + """Integration test for get_test_rtp_server_results error path (HTTP 500)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_test_rtp_server_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_rtp_server_results", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_rtp_server_results_error_502(self) -> None: + """Integration test for get_test_rtp_server_results error path (HTTP 502)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.get_test_rtp_server_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_rtp_server_results", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-test-results/test/test_voice_sip_server_test_results_api_integration.py b/thousandeyes-sdk-test-results/test/test_voice_sip_server_test_results_api_integration.py new file mode 100644 index 00000000..73ccce68 --- /dev/null +++ b/thousandeyes-sdk-test-results/test/test_voice_sip_server_test_results_api_integration.py @@ -0,0 +1,500 @@ +# coding: utf-8 + +""" + Test Results API + + Get test result metrics for Network and Application Synthetics tests. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.test_results.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.test_results.api.voice_sip_server_test_results_api import VoiceSIPServerTestResultsApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestVoiceSIPServerTestResultsApiIntegration(IntegrationTestBase): + """VoiceSIPServerTestResultsApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = VoiceSIPServerTestResultsApi(self.api_client) + + + def test_get_test_sip_server_results_happy_path(self) -> None: + """Integration test for get_test_sip_server_results success path""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + response_body_json = """ + { + "test" : { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + }, + "endDate" : "2022-07-18T22:00:54Z", + "_links" : { + "next" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "previous" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "results" : [ { + "date" : "2022-07-17T22:00:54Z", + "agent" : { + "agentId" : "281474976710706", + "agentName" : "thousandeyes-stg-va-254", + "location" : "San Francisco Bay Area", + "countryId" : "US" + }, + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "numRedirects" : 0, + "registerTime" : 21, + "optionsTime" : 17, + "optionsRequest" : "OPTIONS sip:6054@voice.sfo2.notarealco.com SIP/2.0\\r\\nVia: SIP/2.0/TCP 38.140.61.68:55431;branch=z9hG4bKRTzPzMoVh0;rport\\r\\nFrom: ;tag=cGaJDNKQFE\\r\\nTo: \\r\\nCall-ID: oO9WaL3av8@38.140.61.68\\r\\nCSeq: 3 OPTIONS\\r\\nContact: \\r\\nUser-Agent: ThousandEyes Test Call\\r\\nAllow: INVITE, ACK, CANCEL, BYE\\r\\nSupported: outbound, path\\r\\nMax-Forwards: 70\\r\\nExpires: 60\\r\\nContent-Length: 0\\r\\n\\r\\n\\nOPTIONS sip:6054@voice.sfo2.notarealco.com SIP/2.0\\r\\nVia: SIP/2.0/TCP 38.140.61.68:55431;branch=z9hG4bKRTzPzMoVh0;rport\\r\\nFrom: ;tag=cGaJDNKQFE\\r\\nTo: \\r\\nCall-ID: oO9WaL3av8@38.140.61.68\\r\\nCSeq: 4 OPTIONS\\r\\nContact: \\r\\nAuthorization: Digest username=\\"al6054\\", realm=\\"asterisk\\", nonce=\\"1598728080/4e3bef2c789bdfa45ce9123221e08c8f\\", uri=\\"sip:6054@voice.sfo2.notarealco.com\\", response=\\"83c538a39ff766cf75ffd1d62317b442\\", algorithm=MD5, cnonce=\\"0a4f113b\\", opaque=\\"748ffa241d840721\\", qop=auth, nc=00000001\\r\\nUser-Agent: ThousandEyes Test Call\\r\\nAllow: INVITE, ACK, CANCEL, BYE\\r\\nSupported: outbound, path\\r\\nMax-Forwards: 70\\r\\nExpires: 60\\r\\nContent-Length: 0\\r\\n\\r\\n", + "responseTime" : 12, + "totalTime" : 40, + "errorType" : "none", + "availability" : 100, + "responseCode" : 200, + "optionsResponse" : "SIP/2.0 401 Unauthorized\\r\\nVia: SIP/2.0/TCP 38.140.61.68:55431;rport=55431;received=38.140.61.68;branch=z9hG4bKRTzPzMoVh0\\r\\nCall-ID: oO9WaL3av8@38.140.61.68\\r\\nFrom: ;tag=cGaJDNKQFE\\r\\nTo: ;tag=z9hG4bKRTzPzMoVh0\\r\\nCSeq: 3 OPTIONS\\r\\nWWW-Authenticate: Digest realm=\\"asterisk\\",nonce=\\"1598728080/4e3bef2c789bdfa45ce9123221e08c8f\\",opaque=\\"748ffa241d840721\\",algorithm=md5,qop=\\"auth\\"\\r\\nServer: Asterisk PBX 16.4.0\\r\\nContent-Length: 0\\r\\n\\r\\n\\nSIP/2.0 200 OK\\r\\nVia: SIP/2.0/TCP 38.140.61.68:55431;rport=55431;received=38.140.61.68;branch=z9hG4bKRTzPzMoVh0\\r\\nCall-ID: oO9WaL3av8@38.140.61.68\\r\\nFrom: ;tag=cGaJDNKQFE\\r\\nTo: ;tag=z9hG4bKRTzPzMoVh0\\r\\nCSeq: 4 OPTIONS\\r\\nAccept: application/xpidf+xml, application/cpim-pidf+xml, application/simple-message-summary, application/pidf+xml, application/dialog-info+xml, application/simple-message-summary, application/pidf+xml, application/dialog-info+xml, application/sdp, message/sipfrag;version=2.0\\r\\nAllow: OPTIONS, REGISTER, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, MESSAGE, REFER\\r\\nSupported: 100rel, timer, replaces, norefersub\\r\\nAccept-Encoding: text/plain\\r\\nAccept-Language: en\\r\\nServer: Asterisk PBX 16.4.0\\r\\nContent-Length: 0\\r\\n\\r\\n", + "problemDetail" : "problemDetail", + "connectTime" : 5, + "dnsTime" : 2, + "serverIp" : "193.2.1.88", + "startTime" : 1384309800, + "endTime" : 1384309800, + "roundId" : 1384309800, + "waitTime" : 5, + "inviteTime" : 10 + }, { + "date" : "2022-07-17T22:00:54Z", + "agent" : { + "agentId" : "281474976710706", + "agentName" : "thousandeyes-stg-va-254", + "location" : "San Francisco Bay Area", + "countryId" : "US" + }, + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "numRedirects" : 0, + "registerTime" : 21, + "optionsTime" : 17, + "optionsRequest" : "OPTIONS sip:6054@voice.sfo2.notarealco.com SIP/2.0\\r\\nVia: SIP/2.0/TCP 38.140.61.68:55431;branch=z9hG4bKRTzPzMoVh0;rport\\r\\nFrom: ;tag=cGaJDNKQFE\\r\\nTo: \\r\\nCall-ID: oO9WaL3av8@38.140.61.68\\r\\nCSeq: 3 OPTIONS\\r\\nContact: \\r\\nUser-Agent: ThousandEyes Test Call\\r\\nAllow: INVITE, ACK, CANCEL, BYE\\r\\nSupported: outbound, path\\r\\nMax-Forwards: 70\\r\\nExpires: 60\\r\\nContent-Length: 0\\r\\n\\r\\n\\nOPTIONS sip:6054@voice.sfo2.notarealco.com SIP/2.0\\r\\nVia: SIP/2.0/TCP 38.140.61.68:55431;branch=z9hG4bKRTzPzMoVh0;rport\\r\\nFrom: ;tag=cGaJDNKQFE\\r\\nTo: \\r\\nCall-ID: oO9WaL3av8@38.140.61.68\\r\\nCSeq: 4 OPTIONS\\r\\nContact: \\r\\nAuthorization: Digest username=\\"al6054\\", realm=\\"asterisk\\", nonce=\\"1598728080/4e3bef2c789bdfa45ce9123221e08c8f\\", uri=\\"sip:6054@voice.sfo2.notarealco.com\\", response=\\"83c538a39ff766cf75ffd1d62317b442\\", algorithm=MD5, cnonce=\\"0a4f113b\\", opaque=\\"748ffa241d840721\\", qop=auth, nc=00000001\\r\\nUser-Agent: ThousandEyes Test Call\\r\\nAllow: INVITE, ACK, CANCEL, BYE\\r\\nSupported: outbound, path\\r\\nMax-Forwards: 70\\r\\nExpires: 60\\r\\nContent-Length: 0\\r\\n\\r\\n", + "responseTime" : 12, + "totalTime" : 40, + "errorType" : "none", + "availability" : 100, + "responseCode" : 200, + "optionsResponse" : "SIP/2.0 401 Unauthorized\\r\\nVia: SIP/2.0/TCP 38.140.61.68:55431;rport=55431;received=38.140.61.68;branch=z9hG4bKRTzPzMoVh0\\r\\nCall-ID: oO9WaL3av8@38.140.61.68\\r\\nFrom: ;tag=cGaJDNKQFE\\r\\nTo: ;tag=z9hG4bKRTzPzMoVh0\\r\\nCSeq: 3 OPTIONS\\r\\nWWW-Authenticate: Digest realm=\\"asterisk\\",nonce=\\"1598728080/4e3bef2c789bdfa45ce9123221e08c8f\\",opaque=\\"748ffa241d840721\\",algorithm=md5,qop=\\"auth\\"\\r\\nServer: Asterisk PBX 16.4.0\\r\\nContent-Length: 0\\r\\n\\r\\n\\nSIP/2.0 200 OK\\r\\nVia: SIP/2.0/TCP 38.140.61.68:55431;rport=55431;received=38.140.61.68;branch=z9hG4bKRTzPzMoVh0\\r\\nCall-ID: oO9WaL3av8@38.140.61.68\\r\\nFrom: ;tag=cGaJDNKQFE\\r\\nTo: ;tag=z9hG4bKRTzPzMoVh0\\r\\nCSeq: 4 OPTIONS\\r\\nAccept: application/xpidf+xml, application/cpim-pidf+xml, application/simple-message-summary, application/pidf+xml, application/dialog-info+xml, application/simple-message-summary, application/pidf+xml, application/dialog-info+xml, application/sdp, message/sipfrag;version=2.0\\r\\nAllow: OPTIONS, REGISTER, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, MESSAGE, REFER\\r\\nSupported: 100rel, timer, replaces, norefersub\\r\\nAccept-Encoding: text/plain\\r\\nAccept-Language: en\\r\\nServer: Asterisk PBX 16.4.0\\r\\nContent-Length: 0\\r\\n\\r\\n", + "problemDetail" : "problemDetail", + "connectTime" : 5, + "dnsTime" : 2, + "serverIp" : "193.2.1.88", + "startTime" : 1384309800, + "endTime" : 1384309800, + "roundId" : 1384309800, + "waitTime" : 5, + "inviteTime" : 10 + } ], + "startDate" : "2022-07-17T22:00:54Z" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_test_sip_server_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_sip_server_results"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_test_sip_server_results_error_400(self) -> None: + """Integration test for get_test_sip_server_results error path (HTTP 400)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.get_test_sip_server_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_sip_server_results", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_sip_server_results_error_401(self) -> None: + """Integration test for get_test_sip_server_results error path (HTTP 401)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_test_sip_server_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_sip_server_results", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_sip_server_results_error_403(self) -> None: + """Integration test for get_test_sip_server_results error path (HTTP 403)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_test_sip_server_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_sip_server_results", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_sip_server_results_error_404(self) -> None: + """Integration test for get_test_sip_server_results error path (HTTP 404)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_test_sip_server_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_sip_server_results", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_sip_server_results_error_429(self) -> None: + """Integration test for get_test_sip_server_results error path (HTTP 429)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_test_sip_server_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_sip_server_results", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_sip_server_results_error_500(self) -> None: + """Integration test for get_test_sip_server_results error path (HTTP 500)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_test_sip_server_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_sip_server_results", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_sip_server_results_error_502(self) -> None: + """Integration test for get_test_sip_server_results error path (HTTP 502)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.get_test_sip_server_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_sip_server_results", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-test-results/test/test_web_ftp_server_test_results_api_integration.py b/thousandeyes-sdk-test-results/test/test_web_ftp_server_test_results_api_integration.py new file mode 100644 index 00000000..a4e01896 --- /dev/null +++ b/thousandeyes-sdk-test-results/test/test_web_ftp_server_test_results_api_integration.py @@ -0,0 +1,494 @@ +# coding: utf-8 + +""" + Test Results API + + Get test result metrics for Network and Application Synthetics tests. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.test_results.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.test_results.api.web_ftp_server_test_results_api import WebFTPServerTestResultsApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestWebFTPServerTestResultsApiIntegration(IntegrationTestBase): + """WebFTPServerTestResultsApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = WebFTPServerTestResultsApi(self.api_client) + + + def test_get_test_ftp_server_results_happy_path(self) -> None: + """Integration test for get_test_ftp_server_results success path""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + response_body_json = """ + { + "test" : { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + }, + "endDate" : "2022-07-18T22:00:54Z", + "_links" : { + "next" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "previous" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "results" : [ { + "date" : "2022-07-17T22:00:54Z", + "agent" : { + "agentId" : "281474976710706", + "agentName" : "thousandeyes-stg-va-254", + "location" : "San Francisco Bay Area", + "countryId" : "US" + }, + "transferTime" : 99.865, + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "negotiationTime" : 503.413, + "responseTime" : 0.589, + "totalTime" : 705.554, + "errorType" : "None", + "responseCode" : 226, + "dnsTime" : 0.589, + "connectTime" : 50.153, + "serverIp" : "193.2.1.88", + "startTime" : 1384309800, + "endTime" : 1384309800, + "throughput" : 123, + "roundId" : 1384309800, + "waitTime" : 52.1, + "wireSize" : 22172, + "errorDetails" : "Connection error" + }, { + "date" : "2022-07-17T22:00:54Z", + "agent" : { + "agentId" : "281474976710706", + "agentName" : "thousandeyes-stg-va-254", + "location" : "San Francisco Bay Area", + "countryId" : "US" + }, + "transferTime" : 99.865, + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "negotiationTime" : 503.413, + "responseTime" : 0.589, + "totalTime" : 705.554, + "errorType" : "None", + "responseCode" : 226, + "dnsTime" : 0.589, + "connectTime" : 50.153, + "serverIp" : "193.2.1.88", + "startTime" : 1384309800, + "endTime" : 1384309800, + "throughput" : 123, + "roundId" : 1384309800, + "waitTime" : 52.1, + "wireSize" : 22172, + "errorDetails" : "Connection error" + } ], + "startDate" : "2022-07-17T22:00:54Z" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_test_ftp_server_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_ftp_server_results"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_test_ftp_server_results_error_400(self) -> None: + """Integration test for get_test_ftp_server_results error path (HTTP 400)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.get_test_ftp_server_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_ftp_server_results", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_ftp_server_results_error_401(self) -> None: + """Integration test for get_test_ftp_server_results error path (HTTP 401)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_test_ftp_server_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_ftp_server_results", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_ftp_server_results_error_403(self) -> None: + """Integration test for get_test_ftp_server_results error path (HTTP 403)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_test_ftp_server_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_ftp_server_results", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_ftp_server_results_error_404(self) -> None: + """Integration test for get_test_ftp_server_results error path (HTTP 404)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_test_ftp_server_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_ftp_server_results", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_ftp_server_results_error_429(self) -> None: + """Integration test for get_test_ftp_server_results error path (HTTP 429)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_test_ftp_server_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_ftp_server_results", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_ftp_server_results_error_500(self) -> None: + """Integration test for get_test_ftp_server_results error path (HTTP 500)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_test_ftp_server_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_ftp_server_results", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_ftp_server_results_error_502(self) -> None: + """Integration test for get_test_ftp_server_results error path (HTTP 502)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.get_test_ftp_server_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_ftp_server_results", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-test-results/test/test_web_http_server_test_results_api_integration.py b/thousandeyes-sdk-test-results/test/test_web_http_server_test_results_api_integration.py new file mode 100644 index 00000000..7a846289 --- /dev/null +++ b/thousandeyes-sdk-test-results/test/test_web_http_server_test_results_api_integration.py @@ -0,0 +1,676 @@ +# coding: utf-8 + +""" + Test Results API + + Get test result metrics for Network and Application Synthetics tests. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.test_results.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.test_results.api.web_http_server_test_results_api import WebHTTPServerTestResultsApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestWebHTTPServerTestResultsApiIntegration(IntegrationTestBase): + """WebHTTPServerTestResultsApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = WebHTTPServerTestResultsApi(self.api_client) + + + def test_get_test_http_server_results_happy_path(self) -> None: + """Integration test for get_test_http_server_results success path""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + response_body_json = """ + { + "test" : { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + }, + "endDate" : "2022-07-18T22:00:54Z", + "_links" : { + "next" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "previous" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "results" : [ { + "date" : "2022-07-17T22:00:54Z", + "agent" : { + "agentId" : "281474976710706", + "agentName" : "thousandeyes-stg-va-254", + "location" : "San Francisco Bay Area", + "countryId" : "US" + }, + "sslVersion" : "TLSv1.3", + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "numRedirects" : 0, + "errorType" : "None", + "healthScore" : 0.98, + "responseCode" : 200, + "connectTime" : 2, + "startTime" : 1384309800, + "throughput" : 123, + "roundId" : 1384309800, + "headers" : { + "requestHeaders" : "GET / HTTP/1.1\\r\\nHost: www.thousandeyes.com\\r\\nUser-Agent: curl/7.58.0-DEV\\r\\nAccept: */*\\r\\nAccept-Encoding: deflate, gzip\\r\\nX-ThousandEyes-Agent: yes\\r\\n", + "responseHeaders" : "HTTP/1.1 200 OK\\r\\nContent-Type: text/html;charset=UTF-8\\r\\nContent-Length: 9993\\r\\nConnection: keep-alive\\r\\nDate: Mon, 04 May 2020 16:13:00 GMT\\r\\nServer: Apache\\r\\nContent-Language: en-US\\r\\nContent-Encoding: gzip\\r\\nX-Frame-Options: sameorigin\\r\\nCache-Control: max-age=600, must-revalidate\\r\\nStrict-Transport-Security: max-age=31536000\\r\\nX-Content-Type-Options: nosniff\\r\\nX-XSS-Protection: 1; mode=block\\r\\nVary: Accept-Encoding\\r\\nX-Cache: Hit from cloudfront\\r\\nVia: 1.1 7ba3caf71ae7a52dd411d1a543e80cd8.cloudfront.net (CloudFront)\\r\\nX-Amz-Cf-Pop: SFO5-C3\\r\\nX-Amz-Cf-Id: w4h42tkoJD-rEpkRDZUvnQBmy26GVGe6pUsuRr1Dphf7oajYbjXaOA==\\r\\nAge: 132\\r\\n" + }, + "sslCipher" : "sslCipher", + "redirectTime" : 10, + "sslCertificates" : [ { + "hasValidSigningCert" : false, + "issuerName" : "DigiCert SHA2 Extended Validation Server CA", + "subjectAlternativeNames" : [ "www.thousandeyes.com", "thousandeyes.com" ], + "isFetchDateInValidCertDateRange" : true, + "validBefore" : "2020-05-12T12:00:00Z", + "daysUntilExpiry" : 0, + "validAfter" : "2018-03-27T00:00:00Z", + "subjectName" : "www.thousandeyes.com" + }, { + "hasValidSigningCert" : false, + "issuerName" : "DigiCert SHA2 Extended Validation Server CA", + "subjectAlternativeNames" : [ "www.thousandeyes.com", "thousandeyes.com" ], + "isFetchDateInValidCertDateRange" : true, + "validBefore" : "2020-05-12T12:00:00Z", + "daysUntilExpiry" : 0, + "validAfter" : "2018-03-27T00:00:00Z", + "subjectName" : "www.thousandeyes.com" + } ], + "responseTime" : 14, + "totalTime" : 15, + "receiveTime" : 1, + "dnsTime" : 0, + "serverIp" : "193.2.1.88", + "sslTime" : 9, + "endTime" : 1384309800, + "waitTime" : 3, + "dnsServerMeasurement" : { + "usedDnsResponse" : { + "id" : 41837, + "qr" : "response", + "opcode" : "query", + "authoritativeAnswer" : false, + "truncation" : false, + "recursionDesired" : true, + "recursionAvailable" : true, + "zero" : false, + "authenticData" : false, + "checkingDisabled" : false, + "responseCode" : "noerror", + "question" : [ { + "name" : "www.example.com", + "type" : "a", + "class" : "in", + "ttl" : 0, + "data" : "" + } ], + "answer" : [ { + "name" : "www.example.com", + "type" : "a", + "class" : "in", + "ttl" : 300, + "data" : "203.0.113.10" + } ], + "dnsResolver" : "8.8.8.8", + "timing" : { + "startTimeUs" : "1769706600000000", + "totalTimeUs" : 19304 + }, + "protocol" : "udp" + }, + "unusedDnsResponses" : [ { + "id" : 41838, + "qr" : "response", + "opcode" : "query", + "authoritativeAnswer" : false, + "truncation" : false, + "recursionDesired" : true, + "recursionAvailable" : true, + "zero" : false, + "authenticData" : false, + "checkingDisabled" : false, + "responseCode" : "nxdomain", + "question" : [ { + "name" : "www.example.com", + "type" : "aaaa", + "class" : "in", + "ttl" : 0, + "data" : "" + } ], + "dnsResolver" : "8.8.4.4", + "timing" : { + "startTimeUs" : "1769706600020000", + "totalTimeUs" : 15420 + }, + "protocol" : "udp" + } ], + "usedHostsFile" : false, + "resolvedIp" : "203.0.113.10" + }, + "wireSize" : 9993, + "errorDetails" : "Connection error" + }, { + "date" : "2022-07-17T22:00:54Z", + "agent" : { + "agentId" : "281474976710706", + "agentName" : "thousandeyes-stg-va-254", + "location" : "San Francisco Bay Area", + "countryId" : "US" + }, + "sslVersion" : "TLSv1.3", + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "numRedirects" : 0, + "errorType" : "None", + "healthScore" : 0.98, + "responseCode" : 200, + "connectTime" : 2, + "startTime" : 1384309800, + "throughput" : 123, + "roundId" : 1384309800, + "headers" : { + "requestHeaders" : "GET / HTTP/1.1\\r\\nHost: www.thousandeyes.com\\r\\nUser-Agent: curl/7.58.0-DEV\\r\\nAccept: */*\\r\\nAccept-Encoding: deflate, gzip\\r\\nX-ThousandEyes-Agent: yes\\r\\n", + "responseHeaders" : "HTTP/1.1 200 OK\\r\\nContent-Type: text/html;charset=UTF-8\\r\\nContent-Length: 9993\\r\\nConnection: keep-alive\\r\\nDate: Mon, 04 May 2020 16:13:00 GMT\\r\\nServer: Apache\\r\\nContent-Language: en-US\\r\\nContent-Encoding: gzip\\r\\nX-Frame-Options: sameorigin\\r\\nCache-Control: max-age=600, must-revalidate\\r\\nStrict-Transport-Security: max-age=31536000\\r\\nX-Content-Type-Options: nosniff\\r\\nX-XSS-Protection: 1; mode=block\\r\\nVary: Accept-Encoding\\r\\nX-Cache: Hit from cloudfront\\r\\nVia: 1.1 7ba3caf71ae7a52dd411d1a543e80cd8.cloudfront.net (CloudFront)\\r\\nX-Amz-Cf-Pop: SFO5-C3\\r\\nX-Amz-Cf-Id: w4h42tkoJD-rEpkRDZUvnQBmy26GVGe6pUsuRr1Dphf7oajYbjXaOA==\\r\\nAge: 132\\r\\n" + }, + "sslCipher" : "sslCipher", + "redirectTime" : 10, + "sslCertificates" : [ { + "hasValidSigningCert" : false, + "issuerName" : "DigiCert SHA2 Extended Validation Server CA", + "subjectAlternativeNames" : [ "www.thousandeyes.com", "thousandeyes.com" ], + "isFetchDateInValidCertDateRange" : true, + "validBefore" : "2020-05-12T12:00:00Z", + "daysUntilExpiry" : 0, + "validAfter" : "2018-03-27T00:00:00Z", + "subjectName" : "www.thousandeyes.com" + }, { + "hasValidSigningCert" : false, + "issuerName" : "DigiCert SHA2 Extended Validation Server CA", + "subjectAlternativeNames" : [ "www.thousandeyes.com", "thousandeyes.com" ], + "isFetchDateInValidCertDateRange" : true, + "validBefore" : "2020-05-12T12:00:00Z", + "daysUntilExpiry" : 0, + "validAfter" : "2018-03-27T00:00:00Z", + "subjectName" : "www.thousandeyes.com" + } ], + "responseTime" : 14, + "totalTime" : 15, + "receiveTime" : 1, + "dnsTime" : 0, + "serverIp" : "193.2.1.88", + "sslTime" : 9, + "endTime" : 1384309800, + "waitTime" : 3, + "dnsServerMeasurement" : { + "usedDnsResponse" : { + "id" : 41837, + "qr" : "response", + "opcode" : "query", + "authoritativeAnswer" : false, + "truncation" : false, + "recursionDesired" : true, + "recursionAvailable" : true, + "zero" : false, + "authenticData" : false, + "checkingDisabled" : false, + "responseCode" : "noerror", + "question" : [ { + "name" : "www.example.com", + "type" : "a", + "class" : "in", + "ttl" : 0, + "data" : "" + } ], + "answer" : [ { + "name" : "www.example.com", + "type" : "a", + "class" : "in", + "ttl" : 300, + "data" : "203.0.113.10" + } ], + "dnsResolver" : "8.8.8.8", + "timing" : { + "startTimeUs" : "1769706600000000", + "totalTimeUs" : 19304 + }, + "protocol" : "udp" + }, + "unusedDnsResponses" : [ { + "id" : 41838, + "qr" : "response", + "opcode" : "query", + "authoritativeAnswer" : false, + "truncation" : false, + "recursionDesired" : true, + "recursionAvailable" : true, + "zero" : false, + "authenticData" : false, + "checkingDisabled" : false, + "responseCode" : "nxdomain", + "question" : [ { + "name" : "www.example.com", + "type" : "aaaa", + "class" : "in", + "ttl" : 0, + "data" : "" + } ], + "dnsResolver" : "8.8.4.4", + "timing" : { + "startTimeUs" : "1769706600020000", + "totalTimeUs" : 15420 + }, + "protocol" : "udp" + } ], + "usedHostsFile" : false, + "resolvedIp" : "203.0.113.10" + }, + "wireSize" : 9993, + "errorDetails" : "Connection error" + } ], + "startDate" : "2022-07-17T22:00:54Z" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_test_http_server_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_http_server_results"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_test_http_server_results_error_400(self) -> None: + """Integration test for get_test_http_server_results error path (HTTP 400)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.get_test_http_server_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_http_server_results", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_http_server_results_error_401(self) -> None: + """Integration test for get_test_http_server_results error path (HTTP 401)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_test_http_server_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_http_server_results", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_http_server_results_error_403(self) -> None: + """Integration test for get_test_http_server_results error path (HTTP 403)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_test_http_server_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_http_server_results", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_http_server_results_error_404(self) -> None: + """Integration test for get_test_http_server_results error path (HTTP 404)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_test_http_server_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_http_server_results", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_http_server_results_error_429(self) -> None: + """Integration test for get_test_http_server_results error path (HTTP 429)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_test_http_server_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_http_server_results", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_http_server_results_error_500(self) -> None: + """Integration test for get_test_http_server_results error path (HTTP 500)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_test_http_server_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_http_server_results", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_http_server_results_error_502(self) -> None: + """Integration test for get_test_http_server_results error path (HTTP 502)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.get_test_http_server_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_http_server_results", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-test-results/test/test_web_page_load_test_results_api_integration.py b/thousandeyes-sdk-test-results/test/test_web_page_load_test_results_api_integration.py new file mode 100644 index 00000000..79b7a674 --- /dev/null +++ b/thousandeyes-sdk-test-results/test/test_web_page_load_test_results_api_integration.py @@ -0,0 +1,1307 @@ +# coding: utf-8 + +""" + Test Results API + + Get test result metrics for Network and Application Synthetics tests. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.test_results.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.test_results.api.web_page_load_test_results_api import WebPageLoadTestResultsApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestWebPageLoadTestResultsApiIntegration(IntegrationTestBase): + """WebPageLoadTestResultsApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = WebPageLoadTestResultsApi(self.api_client) + + + def test_get_test_page_load_agent_round_results_happy_path(self) -> None: + """Integration test for get_test_page_load_agent_round_results success path""" + test_id = '202701' + agent_id = '11' + round_id = '1384309800' + aid = '1234' + response_body_json = """ + { + "test" : { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + }, + "_links" : { + "next" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "previous" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "results" : [ { + "date" : "2022-07-17T22:00:54Z", + "agent" : { + "agentId" : "281474976710706", + "agentName" : "thousandeyes-stg-va-254", + "location" : "San Francisco Bay Area", + "countryId" : "US" + }, + "numErrors" : 0, + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "responseTime" : 34.35, + "pageLoadTime" : 352, + "numObjects" : 17, + "totalSize" : 403301, + "domLoadTime" : 352, + "har" : { + "log" : { + "creator" : { + "name" : "ThousandEyes DB Exporter" + }, + "entries" : [ { + "pageref" : "page_0", + "request" : { + "headers" : [ { + "name" : ":authority", + "value" : "google.com" + }, { + "name" : ":method", + "value" : "GET" + }, { + "name" : ":path", + "value" : "/" + }, { + "name" : ":scheme", + "value" : "https" + }, { + "name" : "accept", + "value" : "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8" + }, { + "name" : "accept-encoding", + "value" : "gzip, deflate, br" + }, { + "name" : "accept-language", + "value" : "en-US,en;q=0.9" + }, { + "name" : "upgrade-insecure-requests", + "value" : "1" + }, { + "name" : "user-agent", + "value" : "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.83 Safari/537.36" + }, { + "name" : "x-thousandeyes-agent", + "value" : "yes" + } ], + "method" : "GET", + "url" : "https://google.com/" + }, + "response" : { + "bodySize" : 220, + "content" : { + "mimeType" : "text/html", + "size" : 220 + }, + "headers" : [ { + "name" : "alt-svc", + "value" : "quic=\\":443\\"; ma=2592000; v=\\"46,43\\",h3-Q050=\\":443\\"; ma=2592000,h3-Q049=\\":443\\"; ma=2592000,h3-Q048=\\":443\\"; ma=2592000,h3-Q046=\\":443\\"; ma=2592000,h3-Q043=\\":443\\"; ma=2592000" + }, { + "name" : "cache-control", + "value" : "public, max-age=2592000" + }, { + "name" : "content-length", + "value" : "220" + }, { + "name" : "content-type", + "value" : "text/html; charset=UTF-8" + }, { + "name" : "date", + "value" : "Fri, 15 Nov 2019 16:41:54 GMT" + }, { + "name" : "expires", + "value" : "Sun, 15 Dec 2019 16:41:54 GMT" + }, { + "name" : "location", + "value" : "https://www.google.com/" + }, { + "name" : "server", + "value" : "gws" + }, { + "name" : "status", + "value" : "301" + }, { + "name" : "x-frame-options", + "value" : "SAMEORIGIN" + }, { + "name" : "x-xss-protection", + "value" : "0" + } ], + "headersSize" : 471, + "redirectURL" : "", + "status" : 301, + "statusText" : "MOVED_PERMANENTLY" + }, + "serverIPAddress" : "172.217.6.110", + "startedDateTime" : "2019-11-15T16:41:54.798Z", + "time" : 71, + "timings" : { + "blocked" : 2, + "connect" : 16, + "dns" : 1, + "receive" : 1, + "send" : 0, + "ssl" : 14, + "wait" : 50 + } + }, { + "pageref" : "page_0", + "request" : { + "headers" : [ { + "name" : ":authority", + "value" : "www.google.com" + }, { + "name" : ":method", + "value" : "GET" + }, { + "name" : ":path", + "value" : "/" + }, { + "name" : ":scheme", + "value" : "https" + }, { + "name" : "accept", + "value" : "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8" + }, { + "name" : "accept-encoding", + "value" : "gzip, deflate, br" + }, { + "name" : "accept-language", + "value" : "en-US,en;q=0.9" + }, { + "name" : "upgrade-insecure-requests", + "value" : "1" + }, { + "name" : "user-agent", + "value" : "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.83 Safari/537.36" + }, { + "name" : "x-thousandeyes-agent", + "value" : "yes" + } ], + "method" : "GET", + "url" : "https://www.google.com/" + }, + "response" : { + "bodySize" : 65214, + "content" : { + "mimeType" : "text/html", + "size" : 225039 + }, + "headers" : [ { + "name" : "alt-svc", + "value" : "quic=\\":443\\"; ma=2592000; v=\\"46,43\\",h3-Q050=\\":443\\"; ma=2592000,h3-Q049=\\":443\\"; ma=2592000,h3-Q048=\\":443\\"; ma=2592000,h3-Q046=\\":443\\"; ma=2592000,h3-Q043=\\":443\\"; ma=2592000" + }, { + "name" : "cache-control", + "value" : "private, max-age=0" + }, { + "name" : "content-encoding", + "value" : "br" + }, { + "name" : "content-length", + "value" : "65214" + }, { + "name" : "content-type", + "value" : "text/html; charset=UTF-8" + }, { + "name" : "date", + "value" : "Fri, 15 Nov 2019 16:41:54 GMT" + }, { + "name" : "expires", + "value" : "-1" + }, { + "name" : "p3p", + "value" : "CP=\\"This is not a P3P policy! See g.co/p3phelp for more info.\\"" + }, { + "name" : "server", + "value" : "gws" + }, { + "name" : "set-cookie", + "value" : "(removed)" + }, { + "name" : "status", + "value" : "200" + }, { + "name" : "strict-transport-security", + "value" : "max-age=31536000" + }, { + "name" : "x-frame-options", + "value" : "SAMEORIGIN" + }, { + "name" : "x-xss-protection", + "value" : "0" + } ], + "headersSize" : 915, + "redirectURL" : "", + "status" : 200, + "statusText" : "OK" + }, + "serverIPAddress" : "172.217.4.196", + "startedDateTime" : "2019-11-15T16:41:54.870Z", + "time" : 182, + "timings" : { + "blocked" : 2, + "connect" : 4, + "dns" : 0, + "receive" : 58, + "send" : 0, + "ssl" : 2, + "wait" : 118 + } + } ], + "pages" : [ { + "id" : "page_0", + "pageTimings" : { + "onContentLoad" : 367, + "onLoad" : 737 + }, + "responseCode" : 0, + "startedDateTime" : "2019-11-15T16:41:54.796Z", + "title" : "Google" + } ], + "version" : "1.2" + } + }, + "startTime" : 1384309800, + "endTime" : 1384309800, + "roundId" : 1384309800 + }, { + "date" : "2022-07-17T22:00:54Z", + "agent" : { + "agentId" : "281474976710706", + "agentName" : "thousandeyes-stg-va-254", + "location" : "San Francisco Bay Area", + "countryId" : "US" + }, + "numErrors" : 0, + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "responseTime" : 34.35, + "pageLoadTime" : 352, + "numObjects" : 17, + "totalSize" : 403301, + "domLoadTime" : 352, + "har" : { + "log" : { + "creator" : { + "name" : "ThousandEyes DB Exporter" + }, + "entries" : [ { + "pageref" : "page_0", + "request" : { + "headers" : [ { + "name" : ":authority", + "value" : "google.com" + }, { + "name" : ":method", + "value" : "GET" + }, { + "name" : ":path", + "value" : "/" + }, { + "name" : ":scheme", + "value" : "https" + }, { + "name" : "accept", + "value" : "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8" + }, { + "name" : "accept-encoding", + "value" : "gzip, deflate, br" + }, { + "name" : "accept-language", + "value" : "en-US,en;q=0.9" + }, { + "name" : "upgrade-insecure-requests", + "value" : "1" + }, { + "name" : "user-agent", + "value" : "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.83 Safari/537.36" + }, { + "name" : "x-thousandeyes-agent", + "value" : "yes" + } ], + "method" : "GET", + "url" : "https://google.com/" + }, + "response" : { + "bodySize" : 220, + "content" : { + "mimeType" : "text/html", + "size" : 220 + }, + "headers" : [ { + "name" : "alt-svc", + "value" : "quic=\\":443\\"; ma=2592000; v=\\"46,43\\",h3-Q050=\\":443\\"; ma=2592000,h3-Q049=\\":443\\"; ma=2592000,h3-Q048=\\":443\\"; ma=2592000,h3-Q046=\\":443\\"; ma=2592000,h3-Q043=\\":443\\"; ma=2592000" + }, { + "name" : "cache-control", + "value" : "public, max-age=2592000" + }, { + "name" : "content-length", + "value" : "220" + }, { + "name" : "content-type", + "value" : "text/html; charset=UTF-8" + }, { + "name" : "date", + "value" : "Fri, 15 Nov 2019 16:41:54 GMT" + }, { + "name" : "expires", + "value" : "Sun, 15 Dec 2019 16:41:54 GMT" + }, { + "name" : "location", + "value" : "https://www.google.com/" + }, { + "name" : "server", + "value" : "gws" + }, { + "name" : "status", + "value" : "301" + }, { + "name" : "x-frame-options", + "value" : "SAMEORIGIN" + }, { + "name" : "x-xss-protection", + "value" : "0" + } ], + "headersSize" : 471, + "redirectURL" : "", + "status" : 301, + "statusText" : "MOVED_PERMANENTLY" + }, + "serverIPAddress" : "172.217.6.110", + "startedDateTime" : "2019-11-15T16:41:54.798Z", + "time" : 71, + "timings" : { + "blocked" : 2, + "connect" : 16, + "dns" : 1, + "receive" : 1, + "send" : 0, + "ssl" : 14, + "wait" : 50 + } + }, { + "pageref" : "page_0", + "request" : { + "headers" : [ { + "name" : ":authority", + "value" : "www.google.com" + }, { + "name" : ":method", + "value" : "GET" + }, { + "name" : ":path", + "value" : "/" + }, { + "name" : ":scheme", + "value" : "https" + }, { + "name" : "accept", + "value" : "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8" + }, { + "name" : "accept-encoding", + "value" : "gzip, deflate, br" + }, { + "name" : "accept-language", + "value" : "en-US,en;q=0.9" + }, { + "name" : "upgrade-insecure-requests", + "value" : "1" + }, { + "name" : "user-agent", + "value" : "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.83 Safari/537.36" + }, { + "name" : "x-thousandeyes-agent", + "value" : "yes" + } ], + "method" : "GET", + "url" : "https://www.google.com/" + }, + "response" : { + "bodySize" : 65214, + "content" : { + "mimeType" : "text/html", + "size" : 225039 + }, + "headers" : [ { + "name" : "alt-svc", + "value" : "quic=\\":443\\"; ma=2592000; v=\\"46,43\\",h3-Q050=\\":443\\"; ma=2592000,h3-Q049=\\":443\\"; ma=2592000,h3-Q048=\\":443\\"; ma=2592000,h3-Q046=\\":443\\"; ma=2592000,h3-Q043=\\":443\\"; ma=2592000" + }, { + "name" : "cache-control", + "value" : "private, max-age=0" + }, { + "name" : "content-encoding", + "value" : "br" + }, { + "name" : "content-length", + "value" : "65214" + }, { + "name" : "content-type", + "value" : "text/html; charset=UTF-8" + }, { + "name" : "date", + "value" : "Fri, 15 Nov 2019 16:41:54 GMT" + }, { + "name" : "expires", + "value" : "-1" + }, { + "name" : "p3p", + "value" : "CP=\\"This is not a P3P policy! See g.co/p3phelp for more info.\\"" + }, { + "name" : "server", + "value" : "gws" + }, { + "name" : "set-cookie", + "value" : "(removed)" + }, { + "name" : "status", + "value" : "200" + }, { + "name" : "strict-transport-security", + "value" : "max-age=31536000" + }, { + "name" : "x-frame-options", + "value" : "SAMEORIGIN" + }, { + "name" : "x-xss-protection", + "value" : "0" + } ], + "headersSize" : 915, + "redirectURL" : "", + "status" : 200, + "statusText" : "OK" + }, + "serverIPAddress" : "172.217.4.196", + "startedDateTime" : "2019-11-15T16:41:54.870Z", + "time" : 182, + "timings" : { + "blocked" : 2, + "connect" : 4, + "dns" : 0, + "receive" : 58, + "send" : 0, + "ssl" : 2, + "wait" : 118 + } + } ], + "pages" : [ { + "id" : "page_0", + "pageTimings" : { + "onContentLoad" : 367, + "onLoad" : 737 + }, + "responseCode" : 0, + "startedDateTime" : "2019-11-15T16:41:54.796Z", + "title" : "Google" + } ], + "version" : "1.2" + } + }, + "startTime" : 1384309800, + "endTime" : 1384309800, + "roundId" : 1384309800 + } ] + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_test_page_load_agent_round_results( + + test_id=test_id, + + agent_id=agent_id, + + round_id=round_id, + + aid=aid, + + _headers=self.te_headers("get_test_page_load_agent_round_results"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_test_page_load_agent_round_results_error_400(self) -> None: + """Integration test for get_test_page_load_agent_round_results error path (HTTP 400)""" + test_id = '202701' + agent_id = '11' + round_id = '1384309800' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.get_test_page_load_agent_round_results( + + test_id=test_id, + + agent_id=agent_id, + + round_id=round_id, + + aid=aid, + + _headers=self.te_headers("get_test_page_load_agent_round_results", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_page_load_agent_round_results_error_401(self) -> None: + """Integration test for get_test_page_load_agent_round_results error path (HTTP 401)""" + test_id = '202701' + agent_id = '11' + round_id = '1384309800' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_test_page_load_agent_round_results( + + test_id=test_id, + + agent_id=agent_id, + + round_id=round_id, + + aid=aid, + + _headers=self.te_headers("get_test_page_load_agent_round_results", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_page_load_agent_round_results_error_403(self) -> None: + """Integration test for get_test_page_load_agent_round_results error path (HTTP 403)""" + test_id = '202701' + agent_id = '11' + round_id = '1384309800' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_test_page_load_agent_round_results( + + test_id=test_id, + + agent_id=agent_id, + + round_id=round_id, + + aid=aid, + + _headers=self.te_headers("get_test_page_load_agent_round_results", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_page_load_agent_round_results_error_404(self) -> None: + """Integration test for get_test_page_load_agent_round_results error path (HTTP 404)""" + test_id = '202701' + agent_id = '11' + round_id = '1384309800' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_test_page_load_agent_round_results( + + test_id=test_id, + + agent_id=agent_id, + + round_id=round_id, + + aid=aid, + + _headers=self.te_headers("get_test_page_load_agent_round_results", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_page_load_agent_round_results_error_429(self) -> None: + """Integration test for get_test_page_load_agent_round_results error path (HTTP 429)""" + test_id = '202701' + agent_id = '11' + round_id = '1384309800' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_test_page_load_agent_round_results( + + test_id=test_id, + + agent_id=agent_id, + + round_id=round_id, + + aid=aid, + + _headers=self.te_headers("get_test_page_load_agent_round_results", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_page_load_agent_round_results_error_500(self) -> None: + """Integration test for get_test_page_load_agent_round_results error path (HTTP 500)""" + test_id = '202701' + agent_id = '11' + round_id = '1384309800' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_test_page_load_agent_round_results( + + test_id=test_id, + + agent_id=agent_id, + + round_id=round_id, + + aid=aid, + + _headers=self.te_headers("get_test_page_load_agent_round_results", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_page_load_agent_round_results_error_502(self) -> None: + """Integration test for get_test_page_load_agent_round_results error path (HTTP 502)""" + test_id = '202701' + agent_id = '11' + round_id = '1384309800' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.get_test_page_load_agent_round_results( + + test_id=test_id, + + agent_id=agent_id, + + round_id=round_id, + + aid=aid, + + _headers=self.te_headers("get_test_page_load_agent_round_results", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_test_page_load_results_happy_path(self) -> None: + """Integration test for get_test_page_load_results success path""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + response_body_json = """ + { + "test" : { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + }, + "endDate" : "2022-07-18T22:00:54Z", + "_links" : { + "next" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "previous" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "results" : [ { + "date" : "2022-07-17T22:00:54Z", + "agent" : { + "agentId" : "281474976710706", + "agentName" : "thousandeyes-stg-va-254", + "location" : "San Francisco Bay Area", + "countryId" : "US" + }, + "totalSize" : 403301, + "numErrors" : 0, + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "responseTime" : 34.35, + "domLoadTime" : 352, + "startTime" : 1384309800, + "pageLoadTime" : 352, + "endTime" : 1384309800, + "roundId" : 1384309800, + "numObjects" : 17 + }, { + "date" : "2022-07-17T22:00:54Z", + "agent" : { + "agentId" : "281474976710706", + "agentName" : "thousandeyes-stg-va-254", + "location" : "San Francisco Bay Area", + "countryId" : "US" + }, + "totalSize" : 403301, + "numErrors" : 0, + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "responseTime" : 34.35, + "domLoadTime" : 352, + "startTime" : 1384309800, + "pageLoadTime" : 352, + "endTime" : 1384309800, + "roundId" : 1384309800, + "numObjects" : 17 + } ], + "startDate" : "2022-07-17T22:00:54Z" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_test_page_load_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_page_load_results"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_test_page_load_results_error_400(self) -> None: + """Integration test for get_test_page_load_results error path (HTTP 400)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.get_test_page_load_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_page_load_results", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_page_load_results_error_401(self) -> None: + """Integration test for get_test_page_load_results error path (HTTP 401)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_test_page_load_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_page_load_results", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_page_load_results_error_403(self) -> None: + """Integration test for get_test_page_load_results error path (HTTP 403)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_test_page_load_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_page_load_results", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_page_load_results_error_404(self) -> None: + """Integration test for get_test_page_load_results error path (HTTP 404)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_test_page_load_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_page_load_results", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_page_load_results_error_429(self) -> None: + """Integration test for get_test_page_load_results error path (HTTP 429)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_test_page_load_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_page_load_results", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_page_load_results_error_500(self) -> None: + """Integration test for get_test_page_load_results error path (HTTP 500)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_test_page_load_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_page_load_results", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_page_load_results_error_502(self) -> None: + """Integration test for get_test_page_load_results error path (HTTP 502)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.get_test_page_load_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_page_load_results", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-test-results/test/test_web_transactions_test_results_api_integration.py b/thousandeyes-sdk-test-results/test/test_web_transactions_test_results_api_integration.py new file mode 100644 index 00000000..ad56db30 --- /dev/null +++ b/thousandeyes-sdk-test-results/test/test_web_transactions_test_results_api_integration.py @@ -0,0 +1,1794 @@ +# coding: utf-8 + +""" + Test Results API + + Get test result metrics for Network and Application Synthetics tests. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.test_results.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.test_results.api.web_transactions_test_results_api import WebTransactionsTestResultsApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestWebTransactionsTestResultsApiIntegration(IntegrationTestBase): + """WebTransactionsTestResultsApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = WebTransactionsTestResultsApi(self.api_client) + + + def test_get_test_web_transaction_agent_round_page_results_happy_path(self) -> None: + """Integration test for get_test_web_transaction_agent_round_page_results success path""" + test_id = '202701' + agent_id = '11' + round_id = '1384309800' + page_id = '281474976710706' + aid = '1234' + response_body_json = """ + { + "test" : { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + }, + "_links" : { + "next" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "previous" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "results" : [ { + "date" : "2022-07-17T22:00:54Z", + "agent" : { + "agentId" : "281474976710706", + "agentName" : "thousandeyes-stg-va-254", + "location" : "San Francisco Bay Area", + "countryId" : "US" + }, + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "componentErrors" : 5, + "errorType" : "None", + "transactionTime" : 2379, + "pages" : [ { + "duration" : 1117.5660001039505, + "componentCount" : 136, + "pageNum" : 0, + "pageName" : "Google", + "errorCount" : 0 + }, { + "duration" : 1117.5660001039505, + "componentCount" : 136, + "pageNum" : 0, + "pageName" : "Google", + "errorCount" : 0 + } ], + "har" : { + "log" : { + "creator" : { + "name" : "ThousandEyes DB Exporter" + }, + "entries" : [ { + "pageref" : "page_0", + "request" : { + "headers" : [ { + "name" : ":authority", + "value" : "google.com" + }, { + "name" : ":method", + "value" : "GET" + }, { + "name" : ":path", + "value" : "/" + }, { + "name" : ":scheme", + "value" : "https" + }, { + "name" : "accept", + "value" : "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8" + }, { + "name" : "accept-encoding", + "value" : "gzip, deflate, br" + }, { + "name" : "accept-language", + "value" : "en-US,en;q=0.9" + }, { + "name" : "upgrade-insecure-requests", + "value" : "1" + }, { + "name" : "user-agent", + "value" : "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.83 Safari/537.36" + }, { + "name" : "x-thousandeyes-agent", + "value" : "yes" + } ], + "method" : "GET", + "url" : "https://google.com/" + }, + "response" : { + "bodySize" : 220, + "content" : { + "mimeType" : "text/html", + "size" : 220 + }, + "headers" : [ { + "name" : "alt-svc", + "value" : "quic=\\":443\\"; ma=2592000; v=\\"46,43\\",h3-Q050=\\":443\\"; ma=2592000,h3-Q049=\\":443\\"; ma=2592000,h3-Q048=\\":443\\"; ma=2592000,h3-Q046=\\":443\\"; ma=2592000,h3-Q043=\\":443\\"; ma=2592000" + }, { + "name" : "cache-control", + "value" : "public, max-age=2592000" + }, { + "name" : "content-length", + "value" : "220" + }, { + "name" : "content-type", + "value" : "text/html; charset=UTF-8" + }, { + "name" : "date", + "value" : "Fri, 15 Nov 2019 16:41:54 GMT" + }, { + "name" : "expires", + "value" : "Sun, 15 Dec 2019 16:41:54 GMT" + }, { + "name" : "location", + "value" : "https://www.google.com/" + }, { + "name" : "server", + "value" : "gws" + }, { + "name" : "status", + "value" : "301" + }, { + "name" : "x-frame-options", + "value" : "SAMEORIGIN" + }, { + "name" : "x-xss-protection", + "value" : "0" + } ], + "headersSize" : 471, + "redirectURL" : "", + "status" : 301, + "statusText" : "MOVED_PERMANENTLY" + }, + "serverIPAddress" : "172.217.6.110", + "startedDateTime" : "2019-11-15T16:41:54.798Z", + "time" : 71, + "timings" : { + "blocked" : 2, + "connect" : 16, + "dns" : 1, + "receive" : 1, + "send" : 0, + "ssl" : 14, + "wait" : 50 + } + }, { + "pageref" : "page_0", + "request" : { + "headers" : [ { + "name" : ":authority", + "value" : "www.google.com" + }, { + "name" : ":method", + "value" : "GET" + }, { + "name" : ":path", + "value" : "/" + }, { + "name" : ":scheme", + "value" : "https" + }, { + "name" : "accept", + "value" : "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8" + }, { + "name" : "accept-encoding", + "value" : "gzip, deflate, br" + }, { + "name" : "accept-language", + "value" : "en-US,en;q=0.9" + }, { + "name" : "upgrade-insecure-requests", + "value" : "1" + }, { + "name" : "user-agent", + "value" : "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.83 Safari/537.36" + }, { + "name" : "x-thousandeyes-agent", + "value" : "yes" + } ], + "method" : "GET", + "url" : "https://www.google.com/" + }, + "response" : { + "bodySize" : 65214, + "content" : { + "mimeType" : "text/html", + "size" : 225039 + }, + "headers" : [ { + "name" : "alt-svc", + "value" : "quic=\\":443\\"; ma=2592000; v=\\"46,43\\",h3-Q050=\\":443\\"; ma=2592000,h3-Q049=\\":443\\"; ma=2592000,h3-Q048=\\":443\\"; ma=2592000,h3-Q046=\\":443\\"; ma=2592000,h3-Q043=\\":443\\"; ma=2592000" + }, { + "name" : "cache-control", + "value" : "private, max-age=0" + }, { + "name" : "content-encoding", + "value" : "br" + }, { + "name" : "content-length", + "value" : "65214" + }, { + "name" : "content-type", + "value" : "text/html; charset=UTF-8" + }, { + "name" : "date", + "value" : "Fri, 15 Nov 2019 16:41:54 GMT" + }, { + "name" : "expires", + "value" : "-1" + }, { + "name" : "p3p", + "value" : "CP=\\"This is not a P3P policy! See g.co/p3phelp for more info.\\"" + }, { + "name" : "server", + "value" : "gws" + }, { + "name" : "set-cookie", + "value" : "(removed)" + }, { + "name" : "status", + "value" : "200" + }, { + "name" : "strict-transport-security", + "value" : "max-age=31536000" + }, { + "name" : "x-frame-options", + "value" : "SAMEORIGIN" + }, { + "name" : "x-xss-protection", + "value" : "0" + } ], + "headersSize" : 915, + "redirectURL" : "", + "status" : 200, + "statusText" : "OK" + }, + "serverIPAddress" : "172.217.4.196", + "startedDateTime" : "2019-11-15T16:41:54.870Z", + "time" : 182, + "timings" : { + "blocked" : 2, + "connect" : 4, + "dns" : 0, + "receive" : 58, + "send" : 0, + "ssl" : 2, + "wait" : 118 + } + } ], + "pages" : [ { + "id" : "page_0", + "pageTimings" : { + "onContentLoad" : 367, + "onLoad" : 737 + }, + "responseCode" : 0, + "startedDateTime" : "2019-11-15T16:41:54.796Z", + "title" : "Google" + } ], + "version" : "1.2" + } + }, + "startTime" : 1384309800, + "endTime" : 1384309800, + "markers" : [ { + "duration" : 1360, + "name" : "SearchForWebdriver" + }, { + "duration" : 1360, + "name" : "SearchForWebdriver" + } ], + "roundId" : 1384309800, + "errorDetails" : "Connection error" + }, { + "date" : "2022-07-17T22:00:54Z", + "agent" : { + "agentId" : "281474976710706", + "agentName" : "thousandeyes-stg-va-254", + "location" : "San Francisco Bay Area", + "countryId" : "US" + }, + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "componentErrors" : 5, + "errorType" : "None", + "transactionTime" : 2379, + "pages" : [ { + "duration" : 1117.5660001039505, + "componentCount" : 136, + "pageNum" : 0, + "pageName" : "Google", + "errorCount" : 0 + }, { + "duration" : 1117.5660001039505, + "componentCount" : 136, + "pageNum" : 0, + "pageName" : "Google", + "errorCount" : 0 + } ], + "har" : { + "log" : { + "creator" : { + "name" : "ThousandEyes DB Exporter" + }, + "entries" : [ { + "pageref" : "page_0", + "request" : { + "headers" : [ { + "name" : ":authority", + "value" : "google.com" + }, { + "name" : ":method", + "value" : "GET" + }, { + "name" : ":path", + "value" : "/" + }, { + "name" : ":scheme", + "value" : "https" + }, { + "name" : "accept", + "value" : "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8" + }, { + "name" : "accept-encoding", + "value" : "gzip, deflate, br" + }, { + "name" : "accept-language", + "value" : "en-US,en;q=0.9" + }, { + "name" : "upgrade-insecure-requests", + "value" : "1" + }, { + "name" : "user-agent", + "value" : "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.83 Safari/537.36" + }, { + "name" : "x-thousandeyes-agent", + "value" : "yes" + } ], + "method" : "GET", + "url" : "https://google.com/" + }, + "response" : { + "bodySize" : 220, + "content" : { + "mimeType" : "text/html", + "size" : 220 + }, + "headers" : [ { + "name" : "alt-svc", + "value" : "quic=\\":443\\"; ma=2592000; v=\\"46,43\\",h3-Q050=\\":443\\"; ma=2592000,h3-Q049=\\":443\\"; ma=2592000,h3-Q048=\\":443\\"; ma=2592000,h3-Q046=\\":443\\"; ma=2592000,h3-Q043=\\":443\\"; ma=2592000" + }, { + "name" : "cache-control", + "value" : "public, max-age=2592000" + }, { + "name" : "content-length", + "value" : "220" + }, { + "name" : "content-type", + "value" : "text/html; charset=UTF-8" + }, { + "name" : "date", + "value" : "Fri, 15 Nov 2019 16:41:54 GMT" + }, { + "name" : "expires", + "value" : "Sun, 15 Dec 2019 16:41:54 GMT" + }, { + "name" : "location", + "value" : "https://www.google.com/" + }, { + "name" : "server", + "value" : "gws" + }, { + "name" : "status", + "value" : "301" + }, { + "name" : "x-frame-options", + "value" : "SAMEORIGIN" + }, { + "name" : "x-xss-protection", + "value" : "0" + } ], + "headersSize" : 471, + "redirectURL" : "", + "status" : 301, + "statusText" : "MOVED_PERMANENTLY" + }, + "serverIPAddress" : "172.217.6.110", + "startedDateTime" : "2019-11-15T16:41:54.798Z", + "time" : 71, + "timings" : { + "blocked" : 2, + "connect" : 16, + "dns" : 1, + "receive" : 1, + "send" : 0, + "ssl" : 14, + "wait" : 50 + } + }, { + "pageref" : "page_0", + "request" : { + "headers" : [ { + "name" : ":authority", + "value" : "www.google.com" + }, { + "name" : ":method", + "value" : "GET" + }, { + "name" : ":path", + "value" : "/" + }, { + "name" : ":scheme", + "value" : "https" + }, { + "name" : "accept", + "value" : "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8" + }, { + "name" : "accept-encoding", + "value" : "gzip, deflate, br" + }, { + "name" : "accept-language", + "value" : "en-US,en;q=0.9" + }, { + "name" : "upgrade-insecure-requests", + "value" : "1" + }, { + "name" : "user-agent", + "value" : "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.83 Safari/537.36" + }, { + "name" : "x-thousandeyes-agent", + "value" : "yes" + } ], + "method" : "GET", + "url" : "https://www.google.com/" + }, + "response" : { + "bodySize" : 65214, + "content" : { + "mimeType" : "text/html", + "size" : 225039 + }, + "headers" : [ { + "name" : "alt-svc", + "value" : "quic=\\":443\\"; ma=2592000; v=\\"46,43\\",h3-Q050=\\":443\\"; ma=2592000,h3-Q049=\\":443\\"; ma=2592000,h3-Q048=\\":443\\"; ma=2592000,h3-Q046=\\":443\\"; ma=2592000,h3-Q043=\\":443\\"; ma=2592000" + }, { + "name" : "cache-control", + "value" : "private, max-age=0" + }, { + "name" : "content-encoding", + "value" : "br" + }, { + "name" : "content-length", + "value" : "65214" + }, { + "name" : "content-type", + "value" : "text/html; charset=UTF-8" + }, { + "name" : "date", + "value" : "Fri, 15 Nov 2019 16:41:54 GMT" + }, { + "name" : "expires", + "value" : "-1" + }, { + "name" : "p3p", + "value" : "CP=\\"This is not a P3P policy! See g.co/p3phelp for more info.\\"" + }, { + "name" : "server", + "value" : "gws" + }, { + "name" : "set-cookie", + "value" : "(removed)" + }, { + "name" : "status", + "value" : "200" + }, { + "name" : "strict-transport-security", + "value" : "max-age=31536000" + }, { + "name" : "x-frame-options", + "value" : "SAMEORIGIN" + }, { + "name" : "x-xss-protection", + "value" : "0" + } ], + "headersSize" : 915, + "redirectURL" : "", + "status" : 200, + "statusText" : "OK" + }, + "serverIPAddress" : "172.217.4.196", + "startedDateTime" : "2019-11-15T16:41:54.870Z", + "time" : 182, + "timings" : { + "blocked" : 2, + "connect" : 4, + "dns" : 0, + "receive" : 58, + "send" : 0, + "ssl" : 2, + "wait" : 118 + } + } ], + "pages" : [ { + "id" : "page_0", + "pageTimings" : { + "onContentLoad" : 367, + "onLoad" : 737 + }, + "responseCode" : 0, + "startedDateTime" : "2019-11-15T16:41:54.796Z", + "title" : "Google" + } ], + "version" : "1.2" + } + }, + "startTime" : 1384309800, + "endTime" : 1384309800, + "markers" : [ { + "duration" : 1360, + "name" : "SearchForWebdriver" + }, { + "duration" : 1360, + "name" : "SearchForWebdriver" + } ], + "roundId" : 1384309800, + "errorDetails" : "Connection error" + } ] + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_test_web_transaction_agent_round_page_results( + + test_id=test_id, + + agent_id=agent_id, + + round_id=round_id, + + page_id=page_id, + + aid=aid, + + _headers=self.te_headers("get_test_web_transaction_agent_round_page_results"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_test_web_transaction_agent_round_page_results_error_400(self) -> None: + """Integration test for get_test_web_transaction_agent_round_page_results error path (HTTP 400)""" + test_id = '202701' + agent_id = '11' + round_id = '1384309800' + page_id = '281474976710706' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.get_test_web_transaction_agent_round_page_results( + + test_id=test_id, + + agent_id=agent_id, + + round_id=round_id, + + page_id=page_id, + + aid=aid, + + _headers=self.te_headers("get_test_web_transaction_agent_round_page_results", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_web_transaction_agent_round_page_results_error_401(self) -> None: + """Integration test for get_test_web_transaction_agent_round_page_results error path (HTTP 401)""" + test_id = '202701' + agent_id = '11' + round_id = '1384309800' + page_id = '281474976710706' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_test_web_transaction_agent_round_page_results( + + test_id=test_id, + + agent_id=agent_id, + + round_id=round_id, + + page_id=page_id, + + aid=aid, + + _headers=self.te_headers("get_test_web_transaction_agent_round_page_results", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_web_transaction_agent_round_page_results_error_403(self) -> None: + """Integration test for get_test_web_transaction_agent_round_page_results error path (HTTP 403)""" + test_id = '202701' + agent_id = '11' + round_id = '1384309800' + page_id = '281474976710706' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_test_web_transaction_agent_round_page_results( + + test_id=test_id, + + agent_id=agent_id, + + round_id=round_id, + + page_id=page_id, + + aid=aid, + + _headers=self.te_headers("get_test_web_transaction_agent_round_page_results", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_web_transaction_agent_round_page_results_error_404(self) -> None: + """Integration test for get_test_web_transaction_agent_round_page_results error path (HTTP 404)""" + test_id = '202701' + agent_id = '11' + round_id = '1384309800' + page_id = '281474976710706' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_test_web_transaction_agent_round_page_results( + + test_id=test_id, + + agent_id=agent_id, + + round_id=round_id, + + page_id=page_id, + + aid=aid, + + _headers=self.te_headers("get_test_web_transaction_agent_round_page_results", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_web_transaction_agent_round_page_results_error_429(self) -> None: + """Integration test for get_test_web_transaction_agent_round_page_results error path (HTTP 429)""" + test_id = '202701' + agent_id = '11' + round_id = '1384309800' + page_id = '281474976710706' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_test_web_transaction_agent_round_page_results( + + test_id=test_id, + + agent_id=agent_id, + + round_id=round_id, + + page_id=page_id, + + aid=aid, + + _headers=self.te_headers("get_test_web_transaction_agent_round_page_results", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_web_transaction_agent_round_page_results_error_500(self) -> None: + """Integration test for get_test_web_transaction_agent_round_page_results error path (HTTP 500)""" + test_id = '202701' + agent_id = '11' + round_id = '1384309800' + page_id = '281474976710706' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_test_web_transaction_agent_round_page_results( + + test_id=test_id, + + agent_id=agent_id, + + round_id=round_id, + + page_id=page_id, + + aid=aid, + + _headers=self.te_headers("get_test_web_transaction_agent_round_page_results", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_web_transaction_agent_round_page_results_error_502(self) -> None: + """Integration test for get_test_web_transaction_agent_round_page_results error path (HTTP 502)""" + test_id = '202701' + agent_id = '11' + round_id = '1384309800' + page_id = '281474976710706' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.get_test_web_transaction_agent_round_page_results( + + test_id=test_id, + + agent_id=agent_id, + + round_id=round_id, + + page_id=page_id, + + aid=aid, + + _headers=self.te_headers("get_test_web_transaction_agent_round_page_results", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_test_web_transaction_agent_round_results_happy_path(self) -> None: + """Integration test for get_test_web_transaction_agent_round_results success path""" + test_id = '202701' + agent_id = '11' + round_id = '1384309800' + aid = '1234' + response_body_json = """ + { + "test" : { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + }, + "_links" : { + "next" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "previous" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "results" : [ { + "date" : "2022-07-17T22:00:54Z", + "agent" : { + "agentId" : "281474976710706", + "agentName" : "thousandeyes-stg-va-254", + "location" : "San Francisco Bay Area", + "countryId" : "US" + }, + "pages" : [ { + "duration" : 1117.5660001039505, + "componentCount" : 136, + "pageNum" : 0, + "pageName" : "Google", + "errorCount" : 0 + }, { + "duration" : 1117.5660001039505, + "componentCount" : 136, + "pageNum" : 0, + "pageName" : "Google", + "errorCount" : 0 + } ], + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "componentErrors" : 5, + "errorType" : "None", + "startTime" : 1384309800, + "endTime" : 1384309800, + "transactionTime" : 2379, + "markers" : [ { + "duration" : 1360, + "name" : "SearchForWebdriver" + }, { + "duration" : 1360, + "name" : "SearchForWebdriver" + } ], + "roundId" : 1384309800, + "errorDetails" : "Connection error" + }, { + "date" : "2022-07-17T22:00:54Z", + "agent" : { + "agentId" : "281474976710706", + "agentName" : "thousandeyes-stg-va-254", + "location" : "San Francisco Bay Area", + "countryId" : "US" + }, + "pages" : [ { + "duration" : 1117.5660001039505, + "componentCount" : 136, + "pageNum" : 0, + "pageName" : "Google", + "errorCount" : 0 + }, { + "duration" : 1117.5660001039505, + "componentCount" : 136, + "pageNum" : 0, + "pageName" : "Google", + "errorCount" : 0 + } ], + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "componentErrors" : 5, + "errorType" : "None", + "startTime" : 1384309800, + "endTime" : 1384309800, + "transactionTime" : 2379, + "markers" : [ { + "duration" : 1360, + "name" : "SearchForWebdriver" + }, { + "duration" : 1360, + "name" : "SearchForWebdriver" + } ], + "roundId" : 1384309800, + "errorDetails" : "Connection error" + } ] + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_test_web_transaction_agent_round_results( + + test_id=test_id, + + agent_id=agent_id, + + round_id=round_id, + + aid=aid, + + _headers=self.te_headers("get_test_web_transaction_agent_round_results"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_test_web_transaction_agent_round_results_error_400(self) -> None: + """Integration test for get_test_web_transaction_agent_round_results error path (HTTP 400)""" + test_id = '202701' + agent_id = '11' + round_id = '1384309800' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.get_test_web_transaction_agent_round_results( + + test_id=test_id, + + agent_id=agent_id, + + round_id=round_id, + + aid=aid, + + _headers=self.te_headers("get_test_web_transaction_agent_round_results", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_web_transaction_agent_round_results_error_401(self) -> None: + """Integration test for get_test_web_transaction_agent_round_results error path (HTTP 401)""" + test_id = '202701' + agent_id = '11' + round_id = '1384309800' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_test_web_transaction_agent_round_results( + + test_id=test_id, + + agent_id=agent_id, + + round_id=round_id, + + aid=aid, + + _headers=self.te_headers("get_test_web_transaction_agent_round_results", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_web_transaction_agent_round_results_error_403(self) -> None: + """Integration test for get_test_web_transaction_agent_round_results error path (HTTP 403)""" + test_id = '202701' + agent_id = '11' + round_id = '1384309800' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_test_web_transaction_agent_round_results( + + test_id=test_id, + + agent_id=agent_id, + + round_id=round_id, + + aid=aid, + + _headers=self.te_headers("get_test_web_transaction_agent_round_results", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_web_transaction_agent_round_results_error_404(self) -> None: + """Integration test for get_test_web_transaction_agent_round_results error path (HTTP 404)""" + test_id = '202701' + agent_id = '11' + round_id = '1384309800' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_test_web_transaction_agent_round_results( + + test_id=test_id, + + agent_id=agent_id, + + round_id=round_id, + + aid=aid, + + _headers=self.te_headers("get_test_web_transaction_agent_round_results", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_web_transaction_agent_round_results_error_429(self) -> None: + """Integration test for get_test_web_transaction_agent_round_results error path (HTTP 429)""" + test_id = '202701' + agent_id = '11' + round_id = '1384309800' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_test_web_transaction_agent_round_results( + + test_id=test_id, + + agent_id=agent_id, + + round_id=round_id, + + aid=aid, + + _headers=self.te_headers("get_test_web_transaction_agent_round_results", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_web_transaction_agent_round_results_error_500(self) -> None: + """Integration test for get_test_web_transaction_agent_round_results error path (HTTP 500)""" + test_id = '202701' + agent_id = '11' + round_id = '1384309800' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_test_web_transaction_agent_round_results( + + test_id=test_id, + + agent_id=agent_id, + + round_id=round_id, + + aid=aid, + + _headers=self.te_headers("get_test_web_transaction_agent_round_results", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_web_transaction_agent_round_results_error_502(self) -> None: + """Integration test for get_test_web_transaction_agent_round_results error path (HTTP 502)""" + test_id = '202701' + agent_id = '11' + round_id = '1384309800' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.get_test_web_transaction_agent_round_results( + + test_id=test_id, + + agent_id=agent_id, + + round_id=round_id, + + aid=aid, + + _headers=self.te_headers("get_test_web_transaction_agent_round_results", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_test_web_transaction_results_happy_path(self) -> None: + """Integration test for get_test_web_transaction_results success path""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + response_body_json = """ + { + "test" : { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + }, + "endDate" : "2022-07-18T22:00:54Z", + "_links" : { + "next" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "previous" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "results" : [ { + "date" : "2022-07-17T22:00:54Z", + "agent" : { + "agentId" : "281474976710706", + "agentName" : "thousandeyes-stg-va-254", + "location" : "San Francisco Bay Area", + "countryId" : "US" + }, + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "componentErrors" : 5, + "errorType" : "None", + "startTime" : 1384309800, + "endTime" : 1384309800, + "transactionTime" : 2379, + "roundId" : 1384309800, + "errorDetails" : "Connection error" + }, { + "date" : "2022-07-17T22:00:54Z", + "agent" : { + "agentId" : "281474976710706", + "agentName" : "thousandeyes-stg-va-254", + "location" : "San Francisco Bay Area", + "countryId" : "US" + }, + "_links" : { + "appLink" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "componentErrors" : 5, + "errorType" : "None", + "startTime" : 1384309800, + "endTime" : 1384309800, + "transactionTime" : 2379, + "roundId" : 1384309800, + "errorDetails" : "Connection error" + } ], + "startDate" : "2022-07-17T22:00:54Z" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_test_web_transaction_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_web_transaction_results"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_test_web_transaction_results_error_400(self) -> None: + """Integration test for get_test_web_transaction_results error path (HTTP 400)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.get_test_web_transaction_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_web_transaction_results", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_web_transaction_results_error_401(self) -> None: + """Integration test for get_test_web_transaction_results error path (HTTP 401)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_test_web_transaction_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_web_transaction_results", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_web_transaction_results_error_403(self) -> None: + """Integration test for get_test_web_transaction_results error path (HTTP 403)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_test_web_transaction_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_web_transaction_results", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_web_transaction_results_error_404(self) -> None: + """Integration test for get_test_web_transaction_results error path (HTTP 404)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_test_web_transaction_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_web_transaction_results", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_web_transaction_results_error_429(self) -> None: + """Integration test for get_test_web_transaction_results error path (HTTP 429)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_test_web_transaction_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_web_transaction_results", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_web_transaction_results_error_500(self) -> None: + """Integration test for get_test_web_transaction_results error path (HTTP 500)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_test_web_transaction_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_web_transaction_results", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_web_transaction_results_error_502(self) -> None: + """Integration test for get_test_web_transaction_results error path (HTTP 502)""" + test_id = '202701' + aid = '1234' + window = '12h' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.get_test_web_transaction_results( + + test_id=test_id, + + aid=aid, + + window=window, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_test_web_transaction_results", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-tests/test/conftest.py b/thousandeyes-sdk-tests/test/conftest.py new file mode 100644 index 00000000..2edba7b3 --- /dev/null +++ b/thousandeyes-sdk-tests/test/conftest.py @@ -0,0 +1,7 @@ +import sys +from pathlib import Path + +_repo_root = Path(__file__).resolve().parents[2] +_core_test_support = _repo_root / "thousandeyes-sdk-core" / "test" +if str(_core_test_support) not in sys.path: + sys.path.insert(0, str(_core_test_support)) diff --git a/thousandeyes-sdk-tests/test/integration_test_utils.py b/thousandeyes-sdk-tests/test/integration_test_utils.py new file mode 100644 index 00000000..3375a6fd --- /dev/null +++ b/thousandeyes-sdk-tests/test/integration_test_utils.py @@ -0,0 +1,37 @@ +# coding: utf-8 + +""" + Tests API + + **Note:** The Page Load Tests, API Tests, and Web Transaction Tests APIs are not available for ThousandEyes for Government instance. This API allows you to list, create, edit, and delete Network and Application Synthetics tests. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from thousandeyes_sdk.core.api_client import ApiClient +from thousandeyes_sdk.core.configuration import Configuration +from sdk_test_support.mock_server import ERROR_STATUS_HEADER, OPERATION_ID_HEADER, MockApiServer + +from .mock_manifest import OPERATION_MANIFEST + + +class IntegrationTestBase(unittest.TestCase): + def setUp(self) -> None: + self.server = MockApiServer(OPERATION_MANIFEST) + self.server.start() + configuration = Configuration(host=self.server.base_url, access_token="test-token") + self.api_client = ApiClient(configuration=configuration) + + def tearDown(self) -> None: + self.server.stop() + + def te_headers(self, operation_id: str, error_status=None): + headers = {OPERATION_ID_HEADER: operation_id} + if error_status is not None: + headers[ERROR_STATUS_HEADER] = error_status + return headers diff --git a/thousandeyes-sdk-tests/test/mock_manifest.py b/thousandeyes-sdk-tests/test/mock_manifest.py new file mode 100644 index 00000000..c9bad0bb --- /dev/null +++ b/thousandeyes-sdk-tests/test/mock_manifest.py @@ -0,0 +1,18313 @@ +# coding: utf-8 + +""" + Tests API + + **Note:** The Page Load Tests, API Tests, and Web Transaction Tests APIs are not available for ThousandEyes for Government instance. This API allows you to list, create, edit, and delete Network and Application Synthetics tests. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json + +from sdk_test_support.mock_server_types import ErrorResponseExpectation, OperationExpectation + +OPERATION_MANIFEST = { + + "create_api_test": OperationExpectation( + operation_id="create_api_test", + method="POST", + path="/tests/api", + path_param_examples={ + }, + success_status=201, + success_body=json.loads(""" + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "credentials" : [ "3247", "1051" ], + "alertRules" : [ { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + }, { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + } ], + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "requests" : [ { + "headers" : [ { + "value" : "keep-alive", + "key" : "x-custom-header" + }, { + "value" : "keep-alive", + "key" : "x-custom-header" + } ], + "variables" : [ { + "name" : "myTestName", + "value" : "tests[0].name" + }, { + "name" : "myTestName", + "value" : "tests[0].name" + } ], + "clientId" : "client-id", + "tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token", + "method" : "get", + "verifyCertificate" : false, + "body" : "body", + "url" : "https://api.thousandeyes.com/v7/status", + "password" : "basic_pw123", + "bearerToken" : "abcd-1234-...", + "scope" : "read, write, deploy", + "name" : "Step 1", + "waitTimeMs" : 0, + "clientAuthentication" : "basic-auth-header", + "clientSecret" : "client-secret", + "assertions" : [ { + "name" : "status-code", + "value" : "200", + "operator" : "is" + }, { + "name" : "status-code", + "value" : "200", + "operator" : "is" + } ], + "authType" : "none", + "collectApiResponse" : true, + "username" : "ThousandEyesUserName" + }, { + "headers" : [ { + "value" : "keep-alive", + "key" : "x-custom-header" + }, { + "value" : "keep-alive", + "key" : "x-custom-header" + } ], + "variables" : [ { + "name" : "myTestName", + "value" : "tests[0].name" + }, { + "name" : "myTestName", + "value" : "tests[0].name" + } ], + "clientId" : "client-id", + "tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token", + "method" : "get", + "verifyCertificate" : false, + "body" : "body", + "url" : "https://api.thousandeyes.com/v7/status", + "password" : "basic_pw123", + "bearerToken" : "abcd-1234-...", + "scope" : "read, write, deploy", + "name" : "Step 1", + "waitTimeMs" : 0, + "clientAuthentication" : "basic-auth-header", + "clientSecret" : "client-secret", + "assertions" : [ { + "name" : "status-code", + "value" : "200", + "operator" : "is" + }, { + "name" : "status-code", + "value" : "200", + "operator" : "is" + } ], + "authType" : "none", + "collectApiResponse" : true, + "username" : "ThousandEyesUserName" + } ], + "type" : "api", + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "protocol" : "tcp", + "collectProxyNetworkData" : false, + "followRedirects" : true, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "clientCertDomainsAllowList" : "www.thousandeyes.com", + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "overrideAgentProxy" : false, + "predefinedVariables" : [ { + "name" : "myUsername", + "value" : "ThousandEyesAccountUserName" + }, { + "name" : "myUsername", + "value" : "ThousandEyesAccountUserName" + } ], + "liveShare" : false, + "distributedTracing" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "timeLimit" : 19, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "overrideProxyId" : "281474976710706", + "sslVersionId" : "0", + "targetTime" : 1, + "monitors" : [ { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + }, { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + } ] + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "credentials" : [ "3247", "1051" ], + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "requests" : [ { + "headers" : [ { + "value" : "keep-alive", + "key" : "x-custom-header" + }, { + "value" : "keep-alive", + "key" : "x-custom-header" + } ], + "variables" : [ { + "name" : "myTestName", + "value" : "tests[0].name" + }, { + "name" : "myTestName", + "value" : "tests[0].name" + } ], + "clientId" : "client-id", + "tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token", + "method" : "get", + "verifyCertificate" : false, + "body" : "body", + "url" : "https://api.thousandeyes.com/v7/status", + "password" : "basic_pw123", + "bearerToken" : "abcd-1234-...", + "scope" : "read, write, deploy", + "name" : "Step 1", + "waitTimeMs" : 0, + "clientAuthentication" : "basic-auth-header", + "clientSecret" : "client-secret", + "assertions" : [ { + "name" : "status-code", + "value" : "200", + "operator" : "is" + }, { + "name" : "status-code", + "value" : "200", + "operator" : "is" + } ], + "authType" : "none", + "collectApiResponse" : true, + "username" : "ThousandEyesUserName" + }, { + "headers" : [ { + "value" : "keep-alive", + "key" : "x-custom-header" + }, { + "value" : "keep-alive", + "key" : "x-custom-header" + } ], + "variables" : [ { + "name" : "myTestName", + "value" : "tests[0].name" + }, { + "name" : "myTestName", + "value" : "tests[0].name" + } ], + "clientId" : "client-id", + "tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token", + "method" : "get", + "verifyCertificate" : false, + "body" : "body", + "url" : "https://api.thousandeyes.com/v7/status", + "password" : "basic_pw123", + "bearerToken" : "abcd-1234-...", + "scope" : "read, write, deploy", + "name" : "Step 1", + "waitTimeMs" : 0, + "clientAuthentication" : "basic-auth-header", + "clientSecret" : "client-secret", + "assertions" : [ { + "name" : "status-code", + "value" : "200", + "operator" : "is" + }, { + "name" : "status-code", + "value" : "200", + "operator" : "is" + } ], + "authType" : "none", + "collectApiResponse" : true, + "username" : "ThousandEyesUserName" + } ], + "type" : "api", + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "protocol" : "tcp", + "collectProxyNetworkData" : false, + "followRedirects" : true, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "clientCertDomainsAllowList" : "www.thousandeyes.com", + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "overrideAgentProxy" : false, + "predefinedVariables" : [ { + "name" : "myUsername", + "value" : "ThousandEyesAccountUserName" + }, { + "name" : "myUsername", + "value" : "ThousandEyesAccountUserName" + } ], + "liveShare" : false, + "distributedTracing" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "timeLimit" : 19, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "sslVersionId" : "0", + "targetTime" : 1, + "monitors" : [ "17410", "5" ] + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "delete_api_test": OperationExpectation( + operation_id="delete_api_test", + method="DELETE", + path="/tests/api/{testId}", + path_param_examples={ + "testId": '202701', + }, + success_status=204, + success_body=None, + success_content_type="application/json", + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_api_test": OperationExpectation( + operation_id="get_api_test", + method="GET", + path="/tests/api/{testId}", + path_param_examples={ + "testId": '202701', + }, + success_status=200, + success_body=json.loads(""" + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "credentials" : [ "3247", "1051" ], + "alertRules" : [ { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + }, { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + } ], + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "requests" : [ { + "headers" : [ { + "value" : "keep-alive", + "key" : "x-custom-header" + }, { + "value" : "keep-alive", + "key" : "x-custom-header" + } ], + "variables" : [ { + "name" : "myTestName", + "value" : "tests[0].name" + }, { + "name" : "myTestName", + "value" : "tests[0].name" + } ], + "clientId" : "client-id", + "tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token", + "method" : "get", + "verifyCertificate" : false, + "body" : "body", + "url" : "https://api.thousandeyes.com/v7/status", + "password" : "basic_pw123", + "bearerToken" : "abcd-1234-...", + "scope" : "read, write, deploy", + "name" : "Step 1", + "waitTimeMs" : 0, + "clientAuthentication" : "basic-auth-header", + "clientSecret" : "client-secret", + "assertions" : [ { + "name" : "status-code", + "value" : "200", + "operator" : "is" + }, { + "name" : "status-code", + "value" : "200", + "operator" : "is" + } ], + "authType" : "none", + "collectApiResponse" : true, + "username" : "ThousandEyesUserName" + }, { + "headers" : [ { + "value" : "keep-alive", + "key" : "x-custom-header" + }, { + "value" : "keep-alive", + "key" : "x-custom-header" + } ], + "variables" : [ { + "name" : "myTestName", + "value" : "tests[0].name" + }, { + "name" : "myTestName", + "value" : "tests[0].name" + } ], + "clientId" : "client-id", + "tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token", + "method" : "get", + "verifyCertificate" : false, + "body" : "body", + "url" : "https://api.thousandeyes.com/v7/status", + "password" : "basic_pw123", + "bearerToken" : "abcd-1234-...", + "scope" : "read, write, deploy", + "name" : "Step 1", + "waitTimeMs" : 0, + "clientAuthentication" : "basic-auth-header", + "clientSecret" : "client-secret", + "assertions" : [ { + "name" : "status-code", + "value" : "200", + "operator" : "is" + }, { + "name" : "status-code", + "value" : "200", + "operator" : "is" + } ], + "authType" : "none", + "collectApiResponse" : true, + "username" : "ThousandEyesUserName" + } ], + "type" : "api", + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "protocol" : "tcp", + "collectProxyNetworkData" : false, + "followRedirects" : true, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "clientCertDomainsAllowList" : "www.thousandeyes.com", + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "overrideAgentProxy" : false, + "predefinedVariables" : [ { + "name" : "myUsername", + "value" : "ThousandEyesAccountUserName" + }, { + "name" : "myUsername", + "value" : "ThousandEyesAccountUserName" + } ], + "liveShare" : false, + "distributedTracing" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "timeLimit" : 19, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "overrideProxyId" : "281474976710706", + "sslVersionId" : "0", + "targetTime" : 1, + "monitors" : [ { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + }, { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + } ] + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_api_tests": OperationExpectation( + operation_id="get_api_tests", + method="GET", + path="/tests/api", + path_param_examples={ + }, + success_status=200, + success_body=json.loads(""" + + { + "tests" : [ { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "requests" : [ { + "headers" : [ { + "value" : "keep-alive", + "key" : "x-custom-header" + }, { + "value" : "keep-alive", + "key" : "x-custom-header" + } ], + "variables" : [ { + "name" : "myTestName", + "value" : "tests[0].name" + }, { + "name" : "myTestName", + "value" : "tests[0].name" + } ], + "clientId" : "client-id", + "tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token", + "method" : "get", + "verifyCertificate" : false, + "body" : "body", + "url" : "https://api.thousandeyes.com/v7/status", + "password" : "basic_pw123", + "bearerToken" : "abcd-1234-...", + "scope" : "read, write, deploy", + "name" : "Step 1", + "waitTimeMs" : 0, + "clientAuthentication" : "basic-auth-header", + "clientSecret" : "client-secret", + "assertions" : [ { + "name" : "status-code", + "value" : "200", + "operator" : "is" + }, { + "name" : "status-code", + "value" : "200", + "operator" : "is" + } ], + "authType" : "none", + "collectApiResponse" : true, + "username" : "ThousandEyesUserName" + }, { + "headers" : [ { + "value" : "keep-alive", + "key" : "x-custom-header" + }, { + "value" : "keep-alive", + "key" : "x-custom-header" + } ], + "variables" : [ { + "name" : "myTestName", + "value" : "tests[0].name" + }, { + "name" : "myTestName", + "value" : "tests[0].name" + } ], + "clientId" : "client-id", + "tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token", + "method" : "get", + "verifyCertificate" : false, + "body" : "body", + "url" : "https://api.thousandeyes.com/v7/status", + "password" : "basic_pw123", + "bearerToken" : "abcd-1234-...", + "scope" : "read, write, deploy", + "name" : "Step 1", + "waitTimeMs" : 0, + "clientAuthentication" : "basic-auth-header", + "clientSecret" : "client-secret", + "assertions" : [ { + "name" : "status-code", + "value" : "200", + "operator" : "is" + }, { + "name" : "status-code", + "value" : "200", + "operator" : "is" + } ], + "authType" : "none", + "collectApiResponse" : true, + "username" : "ThousandEyesUserName" + } ], + "type" : "api", + "usePublicBgp" : true, + "enabled" : true, + "protocol" : "tcp", + "collectProxyNetworkData" : false, + "followRedirects" : true, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "clientCertDomainsAllowList" : "www.thousandeyes.com", + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "overrideAgentProxy" : false, + "predefinedVariables" : [ { + "name" : "myUsername", + "value" : "ThousandEyesAccountUserName" + }, { + "name" : "myUsername", + "value" : "ThousandEyesAccountUserName" + } ], + "liveShare" : false, + "distributedTracing" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "timeLimit" : 19, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "overrideProxyId" : "281474976710706", + "sslVersionId" : "0", + "targetTime" : 1 + }, { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "requests" : [ { + "headers" : [ { + "value" : "keep-alive", + "key" : "x-custom-header" + }, { + "value" : "keep-alive", + "key" : "x-custom-header" + } ], + "variables" : [ { + "name" : "myTestName", + "value" : "tests[0].name" + }, { + "name" : "myTestName", + "value" : "tests[0].name" + } ], + "clientId" : "client-id", + "tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token", + "method" : "get", + "verifyCertificate" : false, + "body" : "body", + "url" : "https://api.thousandeyes.com/v7/status", + "password" : "basic_pw123", + "bearerToken" : "abcd-1234-...", + "scope" : "read, write, deploy", + "name" : "Step 1", + "waitTimeMs" : 0, + "clientAuthentication" : "basic-auth-header", + "clientSecret" : "client-secret", + "assertions" : [ { + "name" : "status-code", + "value" : "200", + "operator" : "is" + }, { + "name" : "status-code", + "value" : "200", + "operator" : "is" + } ], + "authType" : "none", + "collectApiResponse" : true, + "username" : "ThousandEyesUserName" + }, { + "headers" : [ { + "value" : "keep-alive", + "key" : "x-custom-header" + }, { + "value" : "keep-alive", + "key" : "x-custom-header" + } ], + "variables" : [ { + "name" : "myTestName", + "value" : "tests[0].name" + }, { + "name" : "myTestName", + "value" : "tests[0].name" + } ], + "clientId" : "client-id", + "tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token", + "method" : "get", + "verifyCertificate" : false, + "body" : "body", + "url" : "https://api.thousandeyes.com/v7/status", + "password" : "basic_pw123", + "bearerToken" : "abcd-1234-...", + "scope" : "read, write, deploy", + "name" : "Step 1", + "waitTimeMs" : 0, + "clientAuthentication" : "basic-auth-header", + "clientSecret" : "client-secret", + "assertions" : [ { + "name" : "status-code", + "value" : "200", + "operator" : "is" + }, { + "name" : "status-code", + "value" : "200", + "operator" : "is" + } ], + "authType" : "none", + "collectApiResponse" : true, + "username" : "ThousandEyesUserName" + } ], + "type" : "api", + "usePublicBgp" : true, + "enabled" : true, + "protocol" : "tcp", + "collectProxyNetworkData" : false, + "followRedirects" : true, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "clientCertDomainsAllowList" : "www.thousandeyes.com", + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "overrideAgentProxy" : false, + "predefinedVariables" : [ { + "name" : "myUsername", + "value" : "ThousandEyesAccountUserName" + }, { + "name" : "myUsername", + "value" : "ThousandEyesAccountUserName" + } ], + "liveShare" : false, + "distributedTracing" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "timeLimit" : 19, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "overrideProxyId" : "281474976710706", + "sslVersionId" : "0", + "targetTime" : 1 + } ], + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "update_api_test": OperationExpectation( + operation_id="update_api_test", + method="PUT", + path="/tests/api/{testId}", + path_param_examples={ + "testId": '202701', + }, + success_status=200, + success_body=json.loads(""" + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "credentials" : [ "3247", "1051" ], + "alertRules" : [ { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + }, { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + } ], + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "requests" : [ { + "headers" : [ { + "value" : "keep-alive", + "key" : "x-custom-header" + }, { + "value" : "keep-alive", + "key" : "x-custom-header" + } ], + "variables" : [ { + "name" : "myTestName", + "value" : "tests[0].name" + }, { + "name" : "myTestName", + "value" : "tests[0].name" + } ], + "clientId" : "client-id", + "tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token", + "method" : "get", + "verifyCertificate" : false, + "body" : "body", + "url" : "https://api.thousandeyes.com/v7/status", + "password" : "basic_pw123", + "bearerToken" : "abcd-1234-...", + "scope" : "read, write, deploy", + "name" : "Step 1", + "waitTimeMs" : 0, + "clientAuthentication" : "basic-auth-header", + "clientSecret" : "client-secret", + "assertions" : [ { + "name" : "status-code", + "value" : "200", + "operator" : "is" + }, { + "name" : "status-code", + "value" : "200", + "operator" : "is" + } ], + "authType" : "none", + "collectApiResponse" : true, + "username" : "ThousandEyesUserName" + }, { + "headers" : [ { + "value" : "keep-alive", + "key" : "x-custom-header" + }, { + "value" : "keep-alive", + "key" : "x-custom-header" + } ], + "variables" : [ { + "name" : "myTestName", + "value" : "tests[0].name" + }, { + "name" : "myTestName", + "value" : "tests[0].name" + } ], + "clientId" : "client-id", + "tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token", + "method" : "get", + "verifyCertificate" : false, + "body" : "body", + "url" : "https://api.thousandeyes.com/v7/status", + "password" : "basic_pw123", + "bearerToken" : "abcd-1234-...", + "scope" : "read, write, deploy", + "name" : "Step 1", + "waitTimeMs" : 0, + "clientAuthentication" : "basic-auth-header", + "clientSecret" : "client-secret", + "assertions" : [ { + "name" : "status-code", + "value" : "200", + "operator" : "is" + }, { + "name" : "status-code", + "value" : "200", + "operator" : "is" + } ], + "authType" : "none", + "collectApiResponse" : true, + "username" : "ThousandEyesUserName" + } ], + "type" : "api", + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "protocol" : "tcp", + "collectProxyNetworkData" : false, + "followRedirects" : true, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "clientCertDomainsAllowList" : "www.thousandeyes.com", + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "overrideAgentProxy" : false, + "predefinedVariables" : [ { + "name" : "myUsername", + "value" : "ThousandEyesAccountUserName" + }, { + "name" : "myUsername", + "value" : "ThousandEyesAccountUserName" + } ], + "liveShare" : false, + "distributedTracing" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "timeLimit" : 19, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "overrideProxyId" : "281474976710706", + "sslVersionId" : "0", + "targetTime" : 1, + "monitors" : [ { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + }, { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + } ] + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "credentials" : [ "3247", "1051" ], + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "requests" : [ { + "headers" : [ { + "value" : "keep-alive", + "key" : "x-custom-header" + }, { + "value" : "keep-alive", + "key" : "x-custom-header" + } ], + "variables" : [ { + "name" : "myTestName", + "value" : "tests[0].name" + }, { + "name" : "myTestName", + "value" : "tests[0].name" + } ], + "clientId" : "client-id", + "tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token", + "method" : "get", + "verifyCertificate" : false, + "body" : "body", + "url" : "https://api.thousandeyes.com/v7/status", + "password" : "basic_pw123", + "bearerToken" : "abcd-1234-...", + "scope" : "read, write, deploy", + "name" : "Step 1", + "waitTimeMs" : 0, + "clientAuthentication" : "basic-auth-header", + "clientSecret" : "client-secret", + "assertions" : [ { + "name" : "status-code", + "value" : "200", + "operator" : "is" + }, { + "name" : "status-code", + "value" : "200", + "operator" : "is" + } ], + "authType" : "none", + "collectApiResponse" : true, + "username" : "ThousandEyesUserName" + }, { + "headers" : [ { + "value" : "keep-alive", + "key" : "x-custom-header" + }, { + "value" : "keep-alive", + "key" : "x-custom-header" + } ], + "variables" : [ { + "name" : "myTestName", + "value" : "tests[0].name" + }, { + "name" : "myTestName", + "value" : "tests[0].name" + } ], + "clientId" : "client-id", + "tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token", + "method" : "get", + "verifyCertificate" : false, + "body" : "body", + "url" : "https://api.thousandeyes.com/v7/status", + "password" : "basic_pw123", + "bearerToken" : "abcd-1234-...", + "scope" : "read, write, deploy", + "name" : "Step 1", + "waitTimeMs" : 0, + "clientAuthentication" : "basic-auth-header", + "clientSecret" : "client-secret", + "assertions" : [ { + "name" : "status-code", + "value" : "200", + "operator" : "is" + }, { + "name" : "status-code", + "value" : "200", + "operator" : "is" + } ], + "authType" : "none", + "collectApiResponse" : true, + "username" : "ThousandEyesUserName" + } ], + "type" : "api", + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "protocol" : "tcp", + "collectProxyNetworkData" : false, + "followRedirects" : true, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "clientCertDomainsAllowList" : "www.thousandeyes.com", + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "overrideAgentProxy" : false, + "predefinedVariables" : [ { + "name" : "myUsername", + "value" : "ThousandEyesAccountUserName" + }, { + "name" : "myUsername", + "value" : "ThousandEyesAccountUserName" + } ], + "liveShare" : false, + "distributedTracing" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "timeLimit" : 19, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "sslVersionId" : "0", + "targetTime" : 1, + "monitors" : [ "17410", "5" ] + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "create_agent_to_agent_test": OperationExpectation( + operation_id="create_agent_to_agent_test", + method="POST", + path="/tests/agent-to-agent", + path_param_examples={ + }, + success_status=201, + success_body=json.loads(""" + + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + }, { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + } ], + "description" : "ThousandEyes Test", + "type" : "agent-to-agent", + "mss" : 100, + "usePublicBgp" : true, + "enabled" : true, + "dscpId" : "0", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "dscp" : "Best Effort (DSCP 0)", + "pathTraceMode" : "classic", + "throughputRate" : 10, + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "direction" : "to-target", + "throughputMeasurements" : false, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "liveShare" : false, + "savedEvent" : true, + "throughputDuration" : 10000, + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "port" : 49153, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "targetAgentId" : "2954", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "monitors" : [ { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + }, { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + } ] + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "type" : "agent-to-agent", + "mss" : 100, + "usePublicBgp" : true, + "enabled" : true, + "dscpId" : "0", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "dscp" : "Best Effort (DSCP 0)", + "pathTraceMode" : "classic", + "throughputRate" : 10, + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "direction" : "to-target", + "throughputMeasurements" : false, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "liveShare" : false, + "savedEvent" : true, + "throughputDuration" : 10000, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "port" : 49153, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "targetAgentId" : "2954", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "monitors" : [ "17410", "5" ] + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "delete_agent_to_agent_test": OperationExpectation( + operation_id="delete_agent_to_agent_test", + method="DELETE", + path="/tests/agent-to-agent/{testId}", + path_param_examples={ + "testId": '202701', + }, + success_status=204, + success_body=None, + success_content_type="application/json", + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_agent_to_agent_test": OperationExpectation( + operation_id="get_agent_to_agent_test", + method="GET", + path="/tests/agent-to-agent/{testId}", + path_param_examples={ + "testId": '202701', + }, + success_status=200, + success_body=json.loads(""" + + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + }, { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + } ], + "description" : "ThousandEyes Test", + "type" : "agent-to-agent", + "mss" : 100, + "usePublicBgp" : true, + "enabled" : true, + "dscpId" : "0", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "dscp" : "Best Effort (DSCP 0)", + "pathTraceMode" : "classic", + "throughputRate" : 10, + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "direction" : "to-target", + "throughputMeasurements" : false, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "liveShare" : false, + "savedEvent" : true, + "throughputDuration" : 10000, + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "port" : 49153, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "targetAgentId" : "2954", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "monitors" : [ { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + }, { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + } ] + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_agent_to_agent_tests": OperationExpectation( + operation_id="get_agent_to_agent_tests", + method="GET", + path="/tests/agent-to-agent", + path_param_examples={ + }, + success_status=200, + success_body=json.loads(""" + + { + "tests" : [ { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "description" : "ThousandEyes Test", + "type" : "agent-to-agent", + "mss" : 100, + "usePublicBgp" : true, + "enabled" : true, + "dscpId" : "0", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "dscp" : "Best Effort (DSCP 0)", + "pathTraceMode" : "classic", + "throughputRate" : 10, + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "direction" : "to-target", + "throughputMeasurements" : false, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "liveShare" : false, + "savedEvent" : true, + "throughputDuration" : 10000, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "port" : 49153, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "targetAgentId" : "2954", + "interval" : 60, + "testId" : "281474976710706" + }, { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "description" : "ThousandEyes Test", + "type" : "agent-to-agent", + "mss" : 100, + "usePublicBgp" : true, + "enabled" : true, + "dscpId" : "0", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "dscp" : "Best Effort (DSCP 0)", + "pathTraceMode" : "classic", + "throughputRate" : 10, + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "direction" : "to-target", + "throughputMeasurements" : false, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "liveShare" : false, + "savedEvent" : true, + "throughputDuration" : 10000, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "port" : 49153, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "targetAgentId" : "2954", + "interval" : 60, + "testId" : "281474976710706" + } ], + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "update_agent_to_agent_test": OperationExpectation( + operation_id="update_agent_to_agent_test", + method="PUT", + path="/tests/agent-to-agent/{testId}", + path_param_examples={ + "testId": '202701', + }, + success_status=200, + success_body=json.loads(""" + + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + }, { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + } ], + "description" : "ThousandEyes Test", + "type" : "agent-to-agent", + "mss" : 100, + "usePublicBgp" : true, + "enabled" : true, + "dscpId" : "0", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "dscp" : "Best Effort (DSCP 0)", + "pathTraceMode" : "classic", + "throughputRate" : 10, + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "direction" : "to-target", + "throughputMeasurements" : false, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "liveShare" : false, + "savedEvent" : true, + "throughputDuration" : 10000, + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "port" : 49153, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "targetAgentId" : "2954", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "monitors" : [ { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + }, { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + } ] + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "type" : "agent-to-agent", + "mss" : 100, + "usePublicBgp" : true, + "enabled" : true, + "dscpId" : "0", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "dscp" : "Best Effort (DSCP 0)", + "pathTraceMode" : "classic", + "throughputRate" : 10, + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "direction" : "to-target", + "throughputMeasurements" : false, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "liveShare" : false, + "savedEvent" : true, + "throughputDuration" : 10000, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "port" : 49153, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "targetAgentId" : "2954", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "monitors" : [ "17410", "5" ] + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "create_agent_to_server_test": OperationExpectation( + operation_id="create_agent_to_server_test", + method="POST", + path="/tests/agent-to-server", + path_param_examples={ + }, + success_status=201, + success_body=json.loads(""" + + { + "server" : "www.thousandeyes.com:80", + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + }, { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + } ], + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "type" : "agent-to-server", + "usePublicBgp" : true, + "enabled" : true, + "dscpId" : "0", + "fixedPacketRate" : 25, + "protocol" : "tcp", + "dscp" : "Best Effort (DSCP 0)", + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : false, + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "pingPayloadSize" : 112, + "continuousMode" : false, + "monitors" : [ { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + }, { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + } ] + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "server" : "www.thousandeyes.com:80", + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ "344753", "212697" ], + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "type" : "agent-to-server", + "usePublicBgp" : true, + "enabled" : true, + "dscpId" : "0", + "fixedPacketRate" : 25, + "protocol" : "tcp", + "dscp" : "Best Effort (DSCP 0)", + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : false, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "port" : 443, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "pingPayloadSize" : 112, + "sharedWithAccounts" : [ "1234", "12345" ], + "continuousMode" : false, + "monitors" : [ "17410", "5" ] + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "delete_agent_to_server_test": OperationExpectation( + operation_id="delete_agent_to_server_test", + method="DELETE", + path="/tests/agent-to-server/{testId}", + path_param_examples={ + "testId": '202701', + }, + success_status=204, + success_body=None, + success_content_type="application/json", + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_agent_to_server_test": OperationExpectation( + operation_id="get_agent_to_server_test", + method="GET", + path="/tests/agent-to-server/{testId}", + path_param_examples={ + "testId": '202701', + }, + success_status=200, + success_body=json.loads(""" + + { + "server" : "www.thousandeyes.com:80", + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + }, { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + } ], + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "type" : "agent-to-server", + "usePublicBgp" : true, + "enabled" : true, + "dscpId" : "0", + "fixedPacketRate" : 25, + "protocol" : "tcp", + "dscp" : "Best Effort (DSCP 0)", + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : false, + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "pingPayloadSize" : 112, + "continuousMode" : false, + "monitors" : [ { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + }, { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + } ] + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_agent_to_server_tests": OperationExpectation( + operation_id="get_agent_to_server_tests", + method="GET", + path="/tests/agent-to-server", + path_param_examples={ + }, + success_status=200, + success_body=json.loads(""" + + { + "tests" : [ { + "server" : "www.thousandeyes.com:80", + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "type" : "agent-to-server", + "usePublicBgp" : true, + "enabled" : true, + "dscpId" : "0", + "fixedPacketRate" : 25, + "protocol" : "tcp", + "dscp" : "Best Effort (DSCP 0)", + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : false, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "pingPayloadSize" : 112, + "continuousMode" : false + }, { + "server" : "www.thousandeyes.com:80", + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "type" : "agent-to-server", + "usePublicBgp" : true, + "enabled" : true, + "dscpId" : "0", + "fixedPacketRate" : 25, + "protocol" : "tcp", + "dscp" : "Best Effort (DSCP 0)", + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : false, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "pingPayloadSize" : 112, + "continuousMode" : false + } ], + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "update_agent_to_server_test": OperationExpectation( + operation_id="update_agent_to_server_test", + method="PUT", + path="/tests/agent-to-server/{testId}", + path_param_examples={ + "testId": '202701', + }, + success_status=200, + success_body=json.loads(""" + + { + "server" : "www.thousandeyes.com:80", + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + }, { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + } ], + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "type" : "agent-to-server", + "usePublicBgp" : true, + "enabled" : true, + "dscpId" : "0", + "fixedPacketRate" : 25, + "protocol" : "tcp", + "dscp" : "Best Effort (DSCP 0)", + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : false, + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "pingPayloadSize" : 112, + "continuousMode" : false, + "monitors" : [ { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + }, { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + } ] + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "server" : "www.thousandeyes.com:80", + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "alertRules" : [ "344753", "212697" ], + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "usePublicBgp" : true, + "enabled" : true, + "dscpId" : "0", + "fixedPacketRate" : 25, + "protocol" : "tcp", + "dscp" : "Best Effort (DSCP 0)", + "pathTraceMode" : "classic", + "alertsEnabled" : true, + "testName" : "Test name", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "networkMeasurements" : false, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "randomizedStartTime" : false, + "port" : 443, + "interval" : 60, + "sharedWithAccounts" : [ "1234", "12345" ], + "pingPayloadSize" : 112, + "continuousMode" : false, + "monitors" : [ "17410", "5" ] + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "create_bgp_test": OperationExpectation( + operation_id="create_bgp_test", + method="POST", + path="/tests/bgp", + path_param_examples={ + }, + success_status=201, + success_body=json.loads(""" + + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "prefix" : "prefix", + "savedEvent" : true, + "includeCoveredPrefixes" : true, + "alertRules" : [ { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + }, { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + } ], + "description" : "ThousandEyes Test", + "type" : "bgp", + "usePublicBgp" : true, + "enabled" : true, + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "monitors" : [ { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + }, { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + } ] + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "prefix" : "prefix", + "savedEvent" : true, + "includeCoveredPrefixes" : true, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "type" : "bgp", + "usePublicBgp" : true, + "enabled" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "monitors" : [ "17410", "5" ] + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "delete_bgp_test": OperationExpectation( + operation_id="delete_bgp_test", + method="DELETE", + path="/tests/bgp/{testId}", + path_param_examples={ + "testId": '202701', + }, + success_status=204, + success_body=None, + success_content_type="application/json", + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_bgp_test": OperationExpectation( + operation_id="get_bgp_test", + method="GET", + path="/tests/bgp/{testId}", + path_param_examples={ + "testId": '202701', + }, + success_status=200, + success_body=json.loads(""" + + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "prefix" : "prefix", + "savedEvent" : true, + "includeCoveredPrefixes" : true, + "alertRules" : [ { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + }, { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + } ], + "description" : "ThousandEyes Test", + "type" : "bgp", + "usePublicBgp" : true, + "enabled" : true, + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "monitors" : [ { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + }, { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + } ] + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_bgp_tests": OperationExpectation( + operation_id="get_bgp_tests", + method="GET", + path="/tests/bgp", + path_param_examples={ + }, + success_status=200, + success_body=json.loads(""" + + { + "tests" : [ { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "prefix" : "prefix", + "savedEvent" : true, + "includeCoveredPrefixes" : true, + "description" : "ThousandEyes Test", + "type" : "bgp", + "usePublicBgp" : true, + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + }, { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "prefix" : "prefix", + "savedEvent" : true, + "includeCoveredPrefixes" : true, + "description" : "ThousandEyes Test", + "type" : "bgp", + "usePublicBgp" : true, + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + } ], + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "update_bgp_test": OperationExpectation( + operation_id="update_bgp_test", + method="PUT", + path="/tests/bgp/{testId}", + path_param_examples={ + "testId": '202701', + }, + success_status=200, + success_body=json.loads(""" + + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "prefix" : "prefix", + "savedEvent" : true, + "includeCoveredPrefixes" : true, + "alertRules" : [ { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + }, { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + } ], + "description" : "ThousandEyes Test", + "type" : "bgp", + "usePublicBgp" : true, + "enabled" : true, + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "monitors" : [ { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + }, { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + } ] + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "includeCoveredPrefixes" : true, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "type" : "bgp", + "usePublicBgp" : true, + "enabled" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "monitors" : [ "17410", "5" ] + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "create_dns_sec_test": OperationExpectation( + operation_id="create_dns_sec_test", + method="POST", + path="/tests/dnssec", + path_param_examples={ + }, + success_status=201, + success_body=json.loads(""" + + { + "dnsQueryClass" : "in", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "alertRules" : [ { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + }, { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + } ], + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "dnssec", + "enabled" : true, + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "dnsQueryClass" : "in", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "type" : "dnssec", + "enabled" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "delete_dns_sec_test": OperationExpectation( + operation_id="delete_dns_sec_test", + method="DELETE", + path="/tests/dnssec/{testId}", + path_param_examples={ + "testId": '202701', + }, + success_status=204, + success_body=None, + success_content_type="application/json", + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_dns_sec_test": OperationExpectation( + operation_id="get_dns_sec_test", + method="GET", + path="/tests/dnssec/{testId}", + path_param_examples={ + "testId": '202701', + }, + success_status=200, + success_body=json.loads(""" + + { + "dnsQueryClass" : "in", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "alertRules" : [ { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + }, { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + } ], + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "dnssec", + "enabled" : true, + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_dns_sec_tests": OperationExpectation( + operation_id="get_dns_sec_tests", + method="GET", + path="/tests/dnssec", + path_param_examples={ + }, + success_status=200, + success_body=json.loads(""" + + { + "tests" : [ { + "dnsQueryClass" : "in", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "dnssec", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + }, { + "dnsQueryClass" : "in", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "dnssec", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + } ], + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "update_dns_sec_test": OperationExpectation( + operation_id="update_dns_sec_test", + method="PUT", + path="/tests/dnssec/{testId}", + path_param_examples={ + "testId": '202701', + }, + success_status=200, + success_body=json.loads(""" + + { + "dnsQueryClass" : "in", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "alertRules" : [ { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + }, { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + } ], + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "dnssec", + "enabled" : true, + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "dnsQueryClass" : "in", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "type" : "dnssec", + "enabled" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "create_dns_server_test": OperationExpectation( + operation_id="create_dns_server_test", + method="POST", + path="/tests/dns-server", + path_param_examples={ + }, + success_status=201, + success_body=json.loads(""" + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + }, { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + } ], + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "dnsTransportProtocol" : "udp", + "probeMode" : "auto", + "type" : "dns-server", + "usePublicBgp" : true, + "enabled" : true, + "protocol" : "tcp", + "fixedPacketRate" : 50, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "dnsServers" : [ { + "serverName" : "dns-example.net", + "serverId" : "1447" + }, { + "serverName" : "dns-example.net", + "serverId" : "1447" + } ], + "alertsEnabled" : true, + "recursiveQueries" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "dnsQueryClass" : "in", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "monitors" : [ { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + }, { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + } ] + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ "344753", "212697" ], + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "dnsTransportProtocol" : "udp", + "probeMode" : "auto", + "type" : "dns-server", + "usePublicBgp" : true, + "enabled" : true, + "protocol" : "tcp", + "fixedPacketRate" : 50, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "dnsServers" : [ "dns-example.net", "8.8.8.8" ], + "alertsEnabled" : true, + "recursiveQueries" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "dnsQueryClass" : "in", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "monitors" : [ "17410", "5" ] + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "delete_dns_server_test": OperationExpectation( + operation_id="delete_dns_server_test", + method="DELETE", + path="/tests/dns-server/{testId}", + path_param_examples={ + "testId": '202701', + }, + success_status=204, + success_body=None, + success_content_type="application/json", + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_dns_server_test": OperationExpectation( + operation_id="get_dns_server_test", + method="GET", + path="/tests/dns-server/{testId}", + path_param_examples={ + "testId": '202701', + }, + success_status=200, + success_body=json.loads(""" + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + }, { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + } ], + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "dnsTransportProtocol" : "udp", + "probeMode" : "auto", + "type" : "dns-server", + "usePublicBgp" : true, + "enabled" : true, + "protocol" : "tcp", + "fixedPacketRate" : 50, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "dnsServers" : [ { + "serverName" : "dns-example.net", + "serverId" : "1447" + }, { + "serverName" : "dns-example.net", + "serverId" : "1447" + } ], + "alertsEnabled" : true, + "recursiveQueries" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "dnsQueryClass" : "in", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "monitors" : [ { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + }, { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + } ] + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_dns_server_tests": OperationExpectation( + operation_id="get_dns_server_tests", + method="GET", + path="/tests/dns-server", + path_param_examples={ + }, + success_status=200, + success_body=json.loads(""" + + { + "tests" : [ { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "dnsTransportProtocol" : "udp", + "probeMode" : "auto", + "type" : "dns-server", + "usePublicBgp" : true, + "enabled" : true, + "protocol" : "tcp", + "fixedPacketRate" : 50, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "dnsServers" : [ { + "serverName" : "dns-example.net", + "serverId" : "1447" + }, { + "serverName" : "dns-example.net", + "serverId" : "1447" + } ], + "alertsEnabled" : true, + "recursiveQueries" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "dnsQueryClass" : "in", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706" + }, { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "dnsTransportProtocol" : "udp", + "probeMode" : "auto", + "type" : "dns-server", + "usePublicBgp" : true, + "enabled" : true, + "protocol" : "tcp", + "fixedPacketRate" : 50, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "dnsServers" : [ { + "serverName" : "dns-example.net", + "serverId" : "1447" + }, { + "serverName" : "dns-example.net", + "serverId" : "1447" + } ], + "alertsEnabled" : true, + "recursiveQueries" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "dnsQueryClass" : "in", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706" + } ], + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "update_dns_server_test": OperationExpectation( + operation_id="update_dns_server_test", + method="PUT", + path="/tests/dns-server/{testId}", + path_param_examples={ + "testId": '202701', + }, + success_status=200, + success_body=json.loads(""" + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + }, { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + } ], + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "dnsTransportProtocol" : "udp", + "probeMode" : "auto", + "type" : "dns-server", + "usePublicBgp" : true, + "enabled" : true, + "protocol" : "tcp", + "fixedPacketRate" : 50, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "dnsServers" : [ { + "serverName" : "dns-example.net", + "serverId" : "1447" + }, { + "serverName" : "dns-example.net", + "serverId" : "1447" + } ], + "alertsEnabled" : true, + "recursiveQueries" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "dnsQueryClass" : "in", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "monitors" : [ { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + }, { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + } ] + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ "344753", "212697" ], + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "dnsTransportProtocol" : "udp", + "probeMode" : "auto", + "type" : "dns-server", + "usePublicBgp" : true, + "enabled" : true, + "protocol" : "tcp", + "fixedPacketRate" : 50, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "dnsServers" : [ "dns-example.net", "8.8.8.8" ], + "alertsEnabled" : true, + "recursiveQueries" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "dnsQueryClass" : "in", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "monitors" : [ "17410", "5" ] + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "create_dns_trace_test": OperationExpectation( + operation_id="create_dns_trace_test", + method="POST", + path="/tests/dns-trace", + path_param_examples={ + }, + success_status=201, + success_body=json.loads(""" + + { + "dnsQueryClass" : "in", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "alertRules" : [ { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + }, { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + } ], + "savedEvent" : true, + "description" : "ThousandEyes Test", + "dnsTransportProtocol" : "udp", + "type" : "dns-trace", + "enabled" : true, + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "dnsQueryClass" : "in", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "dnsTransportProtocol" : "udp", + "type" : "dns-trace", + "enabled" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "delete_dns_trace_test": OperationExpectation( + operation_id="delete_dns_trace_test", + method="DELETE", + path="/tests/dns-trace/{testId}", + path_param_examples={ + "testId": '202701', + }, + success_status=204, + success_body=None, + success_content_type="application/json", + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_dns_trace_test": OperationExpectation( + operation_id="get_dns_trace_test", + method="GET", + path="/tests/dns-trace/{testId}", + path_param_examples={ + "testId": '202701', + }, + success_status=200, + success_body=json.loads(""" + + { + "dnsQueryClass" : "in", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "alertRules" : [ { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + }, { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + } ], + "savedEvent" : true, + "description" : "ThousandEyes Test", + "dnsTransportProtocol" : "udp", + "type" : "dns-trace", + "enabled" : true, + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_dns_trace_tests": OperationExpectation( + operation_id="get_dns_trace_tests", + method="GET", + path="/tests/dns-trace", + path_param_examples={ + }, + success_status=200, + success_body=json.loads(""" + + { + "tests" : [ { + "dnsQueryClass" : "in", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "dnsTransportProtocol" : "udp", + "type" : "dns-trace", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + }, { + "dnsQueryClass" : "in", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "dnsTransportProtocol" : "udp", + "type" : "dns-trace", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + } ], + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "update_dns_trace_test": OperationExpectation( + operation_id="update_dns_trace_test", + method="PUT", + path="/tests/dns-trace/{testId}", + path_param_examples={ + "testId": '202701', + }, + success_status=200, + success_body=json.loads(""" + + { + "dnsQueryClass" : "in", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "alertRules" : [ { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + }, { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + } ], + "savedEvent" : true, + "description" : "ThousandEyes Test", + "dnsTransportProtocol" : "udp", + "type" : "dns-trace", + "enabled" : true, + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "dnsQueryClass" : "in", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "dnsTransportProtocol" : "udp", + "type" : "dns-trace", + "enabled" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "create_ftp_server_test": OperationExpectation( + operation_id="create_ftp_server_test", + method="POST", + path="/tests/ftp-server", + path_param_examples={ + }, + success_status=201, + success_body=json.loads(""" + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "downloadLimit" : 1048576, + "alertRules" : [ { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + }, { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + } ], + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "useExplicitFtps" : false, + "probeMode" : "auto", + "type" : "ftp-server", + "usePublicBgp" : true, + "enabled" : true, + "password" : "password", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "ftpTargetTime" : 1400, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "requestType" : "download", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "ftpTimeLimit" : 10, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "useActiveFtp" : false, + "username" : "username", + "monitors" : [ { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + }, { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + } ] + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "downloadLimit" : 1048576, + "alertRules" : [ "344753", "212697" ], + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "useExplicitFtps" : false, + "probeMode" : "auto", + "type" : "ftp-server", + "usePublicBgp" : true, + "enabled" : true, + "password" : "password", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "ftpTargetTime" : 1400, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "requestType" : "download", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "ftpTimeLimit" : 10, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "useActiveFtp" : false, + "username" : "username", + "monitors" : [ "17410", "5" ] + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "delete_ftp_server_test": OperationExpectation( + operation_id="delete_ftp_server_test", + method="DELETE", + path="/tests/ftp-server/{testId}", + path_param_examples={ + "testId": '202701', + }, + success_status=204, + success_body=None, + success_content_type="application/json", + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_ftp_server_test": OperationExpectation( + operation_id="get_ftp_server_test", + method="GET", + path="/tests/ftp-server/{testId}", + path_param_examples={ + "testId": '202701', + }, + success_status=200, + success_body=json.loads(""" + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "downloadLimit" : 1048576, + "alertRules" : [ { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + }, { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + } ], + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "useExplicitFtps" : false, + "probeMode" : "auto", + "type" : "ftp-server", + "usePublicBgp" : true, + "enabled" : true, + "password" : "password", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "ftpTargetTime" : 1400, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "requestType" : "download", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "ftpTimeLimit" : 10, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "useActiveFtp" : false, + "username" : "username", + "monitors" : [ { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + }, { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + } ] + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_ftp_server_tests": OperationExpectation( + operation_id="get_ftp_server_tests", + method="GET", + path="/tests/ftp-server", + path_param_examples={ + }, + success_status=200, + success_body=json.loads(""" + + { + "tests" : [ { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "downloadLimit" : 1048576, + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "useExplicitFtps" : false, + "probeMode" : "auto", + "type" : "ftp-server", + "usePublicBgp" : true, + "enabled" : true, + "password" : "password", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "ftpTargetTime" : 1400, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "requestType" : "download", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "ftpTimeLimit" : 10, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "useActiveFtp" : false, + "username" : "username" + }, { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "downloadLimit" : 1048576, + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "useExplicitFtps" : false, + "probeMode" : "auto", + "type" : "ftp-server", + "usePublicBgp" : true, + "enabled" : true, + "password" : "password", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "ftpTargetTime" : 1400, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "requestType" : "download", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "ftpTimeLimit" : 10, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "useActiveFtp" : false, + "username" : "username" + } ], + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "update_ftp_server_test": OperationExpectation( + operation_id="update_ftp_server_test", + method="PUT", + path="/tests/ftp-server/{testId}", + path_param_examples={ + "testId": '202701', + }, + success_status=200, + success_body=json.loads(""" + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "downloadLimit" : 1048576, + "alertRules" : [ { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + }, { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + } ], + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "useExplicitFtps" : false, + "probeMode" : "auto", + "type" : "ftp-server", + "usePublicBgp" : true, + "enabled" : true, + "password" : "password", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "ftpTargetTime" : 1400, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "requestType" : "download", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "ftpTimeLimit" : 10, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "useActiveFtp" : false, + "username" : "username", + "monitors" : [ { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + }, { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + } ] + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "downloadLimit" : 1048576, + "alertRules" : [ "344753", "212697" ], + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "useExplicitFtps" : false, + "probeMode" : "auto", + "type" : "ftp-server", + "usePublicBgp" : true, + "enabled" : true, + "password" : "password", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "ftpTargetTime" : 1400, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "requestType" : "download", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "ftpTimeLimit" : 10, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "useActiveFtp" : false, + "username" : "username", + "monitors" : [ "17410", "5" ] + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "create_http_server_test": OperationExpectation( + operation_id="create_http_server_test", + method="POST", + path="/tests/http-server", + path_param_examples={ + }, + success_status=201, + success_body=json.loads(""" + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "http-server", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "contentRegex" : "(regex)+", + "testName" : "ThousandEyes Test", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "overrideProxyId" : "281474976710706", + "monitors" : [ { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + }, { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + } ], + "sslVersion" : "Auto", + "useNtlm" : false, + "ipv6Policy" : "use-agent-policy", + "downloadLimit" : 2048, + "alertRules" : [ { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + }, { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + } ], + "requestMethod" : "get", + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "alertsEnabled" : true, + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "headers" : [ "header1: value1", "header2: value2" ], + "numPathTraces" : 3, + "bgpMeasurements" : true, + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "postBody" : "{ \\"example\\" : \\"value\\"}", + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username" + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "http-server", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "contentRegex" : "(regex)+", + "testName" : "ThousandEyes Test", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "monitors" : [ "17410", "5" ], + "sslVersion" : "Auto", + "useNtlm" : false, + "ipv6Policy" : "use-agent-policy", + "downloadLimit" : 2048, + "requestMethod" : "get", + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "alertsEnabled" : true, + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "headers" : [ "header1: value1", "header2: value2" ], + "numPathTraces" : 3, + "bgpMeasurements" : true, + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "postBody" : "{ \\"example\\" : \\"value\\"}", + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username" + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "delete_http_server_test": OperationExpectation( + operation_id="delete_http_server_test", + method="DELETE", + path="/tests/http-server/{testId}", + path_param_examples={ + "testId": '202701', + }, + success_status=204, + success_body=None, + success_content_type="application/json", + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_http_server_test": OperationExpectation( + operation_id="get_http_server_test", + method="GET", + path="/tests/http-server/{testId}", + path_param_examples={ + "testId": '202701', + }, + success_status=200, + success_body=json.loads(""" + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "http-server", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "contentRegex" : "(regex)+", + "testName" : "ThousandEyes Test", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "overrideProxyId" : "281474976710706", + "monitors" : [ { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + }, { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + } ], + "sslVersion" : "Auto", + "useNtlm" : false, + "ipv6Policy" : "use-agent-policy", + "downloadLimit" : 2048, + "alertRules" : [ { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + }, { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + } ], + "requestMethod" : "get", + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "alertsEnabled" : true, + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "headers" : [ "header1: value1", "header2: value2" ], + "numPathTraces" : 3, + "bgpMeasurements" : true, + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "postBody" : "{ \\"example\\" : \\"value\\"}", + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username" + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_http_server_tests": OperationExpectation( + operation_id="get_http_server_tests", + method="GET", + path="/tests/http-server", + path_param_examples={ + }, + success_status=200, + success_body=json.loads(""" + + { + "tests" : [ { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "http-server", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "contentRegex" : "(regex)+", + "testName" : "ThousandEyes Test", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "overrideProxyId" : "281474976710706", + "sslVersion" : "Auto", + "useNtlm" : false, + "ipv6Policy" : "use-agent-policy", + "downloadLimit" : 2048, + "requestMethod" : "get", + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "alertsEnabled" : true, + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "headers" : [ "header1: value1", "header2: value2" ], + "numPathTraces" : 3, + "bgpMeasurements" : true, + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "createdDate" : "2022-07-17T22:00:54Z", + "postBody" : "{ \\"example\\" : \\"value\\"}", + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username" + }, { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "http-server", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "contentRegex" : "(regex)+", + "testName" : "ThousandEyes Test", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "overrideProxyId" : "281474976710706", + "sslVersion" : "Auto", + "useNtlm" : false, + "ipv6Policy" : "use-agent-policy", + "downloadLimit" : 2048, + "requestMethod" : "get", + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "alertsEnabled" : true, + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "headers" : [ "header1: value1", "header2: value2" ], + "numPathTraces" : 3, + "bgpMeasurements" : true, + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "createdDate" : "2022-07-17T22:00:54Z", + "postBody" : "{ \\"example\\" : \\"value\\"}", + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username" + } ], + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "update_http_server_test": OperationExpectation( + operation_id="update_http_server_test", + method="PUT", + path="/tests/http-server/{testId}", + path_param_examples={ + "testId": '202701', + }, + success_status=200, + success_body=json.loads(""" + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "http-server", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "contentRegex" : "(regex)+", + "testName" : "ThousandEyes Test", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "overrideProxyId" : "281474976710706", + "monitors" : [ { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + }, { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + } ], + "sslVersion" : "Auto", + "useNtlm" : false, + "ipv6Policy" : "use-agent-policy", + "downloadLimit" : 2048, + "alertRules" : [ { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + }, { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + } ], + "requestMethod" : "get", + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "alertsEnabled" : true, + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "headers" : [ "header1: value1", "header2: value2" ], + "numPathTraces" : 3, + "bgpMeasurements" : true, + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "postBody" : "{ \\"example\\" : \\"value\\"}", + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username" + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "http-server", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "contentRegex" : "(regex)+", + "testName" : "ThousandEyes Test", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "monitors" : [ "17410", "5" ], + "sslVersion" : "Auto", + "useNtlm" : false, + "ipv6Policy" : "use-agent-policy", + "downloadLimit" : 2048, + "requestMethod" : "get", + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "alertsEnabled" : true, + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "headers" : [ "header1: value1", "header2: value2" ], + "numPathTraces" : 3, + "bgpMeasurements" : true, + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "postBody" : "{ \\"example\\" : \\"value\\"}", + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username" + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "create_page_load_test": OperationExpectation( + operation_id="create_page_load_test", + method="POST", + path="/tests/page-load", + path_param_examples={ + }, + success_status=201, + success_body=json.loads(""" + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "page-load", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "chromePolicies" : "{\\"ProxyMode\\":\\"direct\\"}", + "contentRegex" : "(regex)+", + "pageLoadingStrategy" : "normal", + "testName" : "ThousandEyes Test", + "allowMicAndCamera" : false, + "browserLanguage" : "en-US", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "httpInterval" : 120, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "emulatedDeviceId" : "2", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "overrideProxyId" : "281474976710706", + "monitors" : [ { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + }, { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + } ], + "sslVersion" : "Auto", + "useNtlm" : false, + "downloadLimit" : 2048, + "alertRules" : [ { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + }, { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + } ], + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "blockDomains" : "domain.com/", + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowGeolocation" : false, + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "alertsEnabled" : true, + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "pageLoadTargetTime" : 10, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "pageLoadTimeLimit" : 10, + "identifyAgentTrafficWithUserAgent" : false, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "disableScreenshot" : false, + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "subinterval" : 60, + "chromeOptions" : "--disable-gpu", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username" + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "page-load", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "chromePolicies" : "{\\"ProxyMode\\":\\"direct\\"}", + "contentRegex" : "(regex)+", + "pageLoadingStrategy" : "normal", + "testName" : "ThousandEyes Test", + "allowMicAndCamera" : false, + "browserLanguage" : "en-US", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "httpInterval" : 120, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "emulatedDeviceId" : "2", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "monitors" : [ "17410", "5" ], + "sslVersion" : "Auto", + "useNtlm" : false, + "downloadLimit" : 2048, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "blockDomains" : "domain.com/", + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowGeolocation" : false, + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "alertsEnabled" : true, + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "pageLoadTargetTime" : 10, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "pageLoadTimeLimit" : 10, + "identifyAgentTrafficWithUserAgent" : false, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "disableScreenshot" : false, + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "subinterval" : 60, + "chromeOptions" : "--disable-gpu", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username" + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "delete_page_load_test": OperationExpectation( + operation_id="delete_page_load_test", + method="DELETE", + path="/tests/page-load/{testId}", + path_param_examples={ + "testId": '202701', + }, + success_status=204, + success_body=None, + success_content_type="application/json", + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_page_load_test": OperationExpectation( + operation_id="get_page_load_test", + method="GET", + path="/tests/page-load/{testId}", + path_param_examples={ + "testId": '202701', + }, + success_status=200, + success_body=json.loads(""" + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "page-load", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "chromePolicies" : "{\\"ProxyMode\\":\\"direct\\"}", + "contentRegex" : "(regex)+", + "pageLoadingStrategy" : "normal", + "testName" : "ThousandEyes Test", + "allowMicAndCamera" : false, + "browserLanguage" : "en-US", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "httpInterval" : 120, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "emulatedDeviceId" : "2", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "overrideProxyId" : "281474976710706", + "monitors" : [ { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + }, { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + } ], + "sslVersion" : "Auto", + "useNtlm" : false, + "downloadLimit" : 2048, + "alertRules" : [ { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + }, { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + } ], + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "blockDomains" : "domain.com/", + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowGeolocation" : false, + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "alertsEnabled" : true, + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "pageLoadTargetTime" : 10, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "pageLoadTimeLimit" : 10, + "identifyAgentTrafficWithUserAgent" : false, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "disableScreenshot" : false, + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "subinterval" : 60, + "chromeOptions" : "--disable-gpu", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username" + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_page_load_tests": OperationExpectation( + operation_id="get_page_load_tests", + method="GET", + path="/tests/page-load", + path_param_examples={ + }, + success_status=200, + success_body=json.loads(""" + + { + "tests" : [ { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "page-load", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "chromePolicies" : "{\\"ProxyMode\\":\\"direct\\"}", + "contentRegex" : "(regex)+", + "pageLoadingStrategy" : "normal", + "testName" : "ThousandEyes Test", + "allowMicAndCamera" : false, + "browserLanguage" : "en-US", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "httpInterval" : 120, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "emulatedDeviceId" : "2", + "overrideProxyId" : "281474976710706", + "sslVersion" : "Auto", + "useNtlm" : false, + "downloadLimit" : 2048, + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "blockDomains" : "domain.com/", + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowGeolocation" : false, + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "alertsEnabled" : true, + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "pageLoadTargetTime" : 10, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "pageLoadTimeLimit" : 10, + "identifyAgentTrafficWithUserAgent" : false, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "createdDate" : "2022-07-17T22:00:54Z", + "disableScreenshot" : false, + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "subinterval" : 60, + "chromeOptions" : "--disable-gpu", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username" + }, { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "page-load", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "chromePolicies" : "{\\"ProxyMode\\":\\"direct\\"}", + "contentRegex" : "(regex)+", + "pageLoadingStrategy" : "normal", + "testName" : "ThousandEyes Test", + "allowMicAndCamera" : false, + "browserLanguage" : "en-US", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "httpInterval" : 120, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "emulatedDeviceId" : "2", + "overrideProxyId" : "281474976710706", + "sslVersion" : "Auto", + "useNtlm" : false, + "downloadLimit" : 2048, + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "blockDomains" : "domain.com/", + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowGeolocation" : false, + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "alertsEnabled" : true, + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "pageLoadTargetTime" : 10, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "pageLoadTimeLimit" : 10, + "identifyAgentTrafficWithUserAgent" : false, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "createdDate" : "2022-07-17T22:00:54Z", + "disableScreenshot" : false, + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "subinterval" : 60, + "chromeOptions" : "--disable-gpu", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username" + } ], + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "update_page_load_test": OperationExpectation( + operation_id="update_page_load_test", + method="PUT", + path="/tests/page-load/{testId}", + path_param_examples={ + "testId": '202701', + }, + success_status=200, + success_body=json.loads(""" + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "page-load", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "chromePolicies" : "{\\"ProxyMode\\":\\"direct\\"}", + "contentRegex" : "(regex)+", + "pageLoadingStrategy" : "normal", + "testName" : "ThousandEyes Test", + "allowMicAndCamera" : false, + "browserLanguage" : "en-US", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "httpInterval" : 120, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "emulatedDeviceId" : "2", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "overrideProxyId" : "281474976710706", + "monitors" : [ { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + }, { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + } ], + "sslVersion" : "Auto", + "useNtlm" : false, + "downloadLimit" : 2048, + "alertRules" : [ { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + }, { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + } ], + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "blockDomains" : "domain.com/", + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowGeolocation" : false, + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "alertsEnabled" : true, + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "pageLoadTargetTime" : 10, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "pageLoadTimeLimit" : 10, + "identifyAgentTrafficWithUserAgent" : false, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "disableScreenshot" : false, + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "subinterval" : 60, + "chromeOptions" : "--disable-gpu", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username" + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "page-load", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "chromePolicies" : "{\\"ProxyMode\\":\\"direct\\"}", + "contentRegex" : "(regex)+", + "pageLoadingStrategy" : "normal", + "testName" : "ThousandEyes Test", + "allowMicAndCamera" : false, + "browserLanguage" : "en-US", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "httpInterval" : 120, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "emulatedDeviceId" : "2", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "monitors" : [ "17410", "5" ], + "sslVersion" : "Auto", + "useNtlm" : false, + "downloadLimit" : 2048, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "blockDomains" : "domain.com/", + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowGeolocation" : false, + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "alertsEnabled" : true, + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "pageLoadTargetTime" : 10, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "pageLoadTimeLimit" : 10, + "identifyAgentTrafficWithUserAgent" : false, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "disableScreenshot" : false, + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "subinterval" : 60, + "chromeOptions" : "--disable-gpu", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username" + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "create_path_vis_interface_groups": OperationExpectation( + operation_id="create_path_vis_interface_groups", + method="POST", + path="/network/path-vis/interface-groups", + path_param_examples={ + }, + success_status=201, + success_body=json.loads(""" + + { + "groupName" : "PathVis Interface Group", + "rdnsRegexes" : [ "aggr403b-1.iad3.rackspace.net", "aggr403c-1.iad3.rackspace.net" ], + "groupId" : "281474976710706", + "ipAddresses" : [ "1.1.1.1", "8.8.8.8" ], + "aid" : "1234" + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "groupName" : "PathVis Interface Group", + "rdnsRegexes" : [ "aggr403b-1.iad3.rackspace.net", "aggr403c-1.iad3.rackspace.net" ], + "groupId" : "281474976710706", + "ipAddresses" : [ "1.1.1.1", "8.8.8.8" ], + "aid" : "1234" + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "delete_path_vis_interface_group": OperationExpectation( + operation_id="delete_path_vis_interface_group", + method="DELETE", + path="/network/path-vis/interface-groups/{interfaceGroupId}", + path_param_examples={ + "interfaceGroupId": '281474976710706', + }, + success_status=204, + success_body=None, + success_content_type="application/json", + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_path_vis_interface_groups": OperationExpectation( + operation_id="get_path_vis_interface_groups", + method="GET", + path="/network/path-vis/interface-groups", + path_param_examples={ + }, + success_status=200, + success_body=json.loads(""" + + { + "pathVisInterfaceGroups" : [ { + "groupName" : "PathVis Interface Group", + "rdnsRegexes" : [ "aggr403b-1.iad3.rackspace.net", "aggr403c-1.iad3.rackspace.net" ], + "groupId" : "281474976710706", + "ipAddresses" : [ "1.1.1.1", "8.8.8.8" ], + "aid" : "1234" + }, { + "groupName" : "PathVis Interface Group", + "rdnsRegexes" : [ "aggr403b-1.iad3.rackspace.net", "aggr403c-1.iad3.rackspace.net" ], + "groupId" : "281474976710706", + "ipAddresses" : [ "1.1.1.1", "8.8.8.8" ], + "aid" : "1234" + } ], + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "update_path_vis_interface_group": OperationExpectation( + operation_id="update_path_vis_interface_group", + method="PUT", + path="/network/path-vis/interface-groups/{interfaceGroupId}", + path_param_examples={ + "interfaceGroupId": '281474976710706', + }, + success_status=200, + success_body=json.loads(""" + + { + "groupName" : "PathVis Interface Group", + "rdnsRegexes" : [ "aggr403b-1.iad3.rackspace.net", "aggr403c-1.iad3.rackspace.net" ], + "groupId" : "281474976710706", + "ipAddresses" : [ "1.1.1.1", "8.8.8.8" ], + "aid" : "1234" + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "groupName" : "PathVis Interface Group", + "rdnsRegexes" : [ "aggr403b-1.iad3.rackspace.net", "aggr403c-1.iad3.rackspace.net" ], + "groupId" : "281474976710706", + "ipAddresses" : [ "1.1.1.1", "8.8.8.8" ], + "aid" : "1234" + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "create_sip_server_test": OperationExpectation( + operation_id="create_sip_server_test", + method="POST", + path="/tests/sip-server", + path_param_examples={ + }, + success_status=201, + success_body=json.loads(""" + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "registerEnabled" : false, + "alertRules" : [ { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + }, { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + } ], + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "type" : "sip-server", + "authUser" : "username", + "usePublicBgp" : true, + "enabled" : true, + "fixedPacketRate" : 50, + "password" : "password", + "protocol" : "tcp", + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "sipTargetTime" : 1000, + "bgpMeasurements" : true, + "numPathTraces" : 3, + "optionsRegex" : "[\\"a-z\\"]", + "liveShare" : false, + "savedEvent" : true, + "sipRegistrar" : "voice.thousandeyes.com", + "networkMeasurements" : true, + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "port" : 49153, + "modifiedDate" : "2022-07-17T22:00:54Z", + "sipTimeLimit" : 5, + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "user" : "username", + "monitors" : [ { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + }, { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + } ] + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "registerEnabled" : false, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "type" : "sip-server", + "usePublicBgp" : true, + "enabled" : true, + "fixedPacketRate" : 50, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "targetSipCredentials" : { + "password" : "password", + "protocol" : "tcp", + "port" : 49153, + "sipRegistrar" : "voice.thousandeyes.com", + "authUser" : "username", + "user" : "username" + }, + "testName" : "ThousandEyes Test", + "sipTargetTime" : 1000, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "optionsRegex" : "[\\"a-z\\"]", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "sipTimeLimit" : 5, + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "monitors" : [ "17410", "5" ] + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "delete_sip_server_test": OperationExpectation( + operation_id="delete_sip_server_test", + method="DELETE", + path="/tests/sip-server/{testId}", + path_param_examples={ + "testId": '202701', + }, + success_status=204, + success_body=None, + success_content_type="application/json", + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_sip_server_test": OperationExpectation( + operation_id="get_sip_server_test", + method="GET", + path="/tests/sip-server/{testId}", + path_param_examples={ + "testId": '202701', + }, + success_status=200, + success_body=json.loads(""" + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "registerEnabled" : false, + "alertRules" : [ { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + }, { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + } ], + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "type" : "sip-server", + "authUser" : "username", + "usePublicBgp" : true, + "enabled" : true, + "fixedPacketRate" : 50, + "password" : "password", + "protocol" : "tcp", + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "sipTargetTime" : 1000, + "bgpMeasurements" : true, + "numPathTraces" : 3, + "optionsRegex" : "[\\"a-z\\"]", + "liveShare" : false, + "savedEvent" : true, + "sipRegistrar" : "voice.thousandeyes.com", + "networkMeasurements" : true, + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "port" : 49153, + "modifiedDate" : "2022-07-17T22:00:54Z", + "sipTimeLimit" : 5, + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "user" : "username", + "monitors" : [ { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + }, { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + } ] + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_sip_server_tests": OperationExpectation( + operation_id="get_sip_server_tests", + method="GET", + path="/tests/sip-server", + path_param_examples={ + }, + success_status=200, + success_body=json.loads(""" + + { + "tests" : [ { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "registerEnabled" : false, + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "type" : "sip-server", + "authUser" : "username", + "usePublicBgp" : true, + "enabled" : true, + "fixedPacketRate" : 50, + "password" : "password", + "protocol" : "tcp", + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "sipTargetTime" : 1000, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "optionsRegex" : "[\\"a-z\\"]", + "liveShare" : false, + "savedEvent" : true, + "sipRegistrar" : "voice.thousandeyes.com", + "networkMeasurements" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "port" : 49153, + "modifiedDate" : "2022-07-17T22:00:54Z", + "sipTimeLimit" : 5, + "interval" : 60, + "testId" : "281474976710706", + "user" : "username" + }, { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "registerEnabled" : false, + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "type" : "sip-server", + "authUser" : "username", + "usePublicBgp" : true, + "enabled" : true, + "fixedPacketRate" : 50, + "password" : "password", + "protocol" : "tcp", + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "sipTargetTime" : 1000, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "optionsRegex" : "[\\"a-z\\"]", + "liveShare" : false, + "savedEvent" : true, + "sipRegistrar" : "voice.thousandeyes.com", + "networkMeasurements" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "port" : 49153, + "modifiedDate" : "2022-07-17T22:00:54Z", + "sipTimeLimit" : 5, + "interval" : 60, + "testId" : "281474976710706", + "user" : "username" + } ], + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "update_sip_server_test": OperationExpectation( + operation_id="update_sip_server_test", + method="PUT", + path="/tests/sip-server/{testId}", + path_param_examples={ + "testId": '202701', + }, + success_status=200, + success_body=json.loads(""" + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "registerEnabled" : false, + "alertRules" : [ { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + }, { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + } ], + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "type" : "sip-server", + "authUser" : "username", + "usePublicBgp" : true, + "enabled" : true, + "fixedPacketRate" : 50, + "password" : "password", + "protocol" : "tcp", + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "sipTargetTime" : 1000, + "bgpMeasurements" : true, + "numPathTraces" : 3, + "optionsRegex" : "[\\"a-z\\"]", + "liveShare" : false, + "savedEvent" : true, + "sipRegistrar" : "voice.thousandeyes.com", + "networkMeasurements" : true, + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "port" : 49153, + "modifiedDate" : "2022-07-17T22:00:54Z", + "sipTimeLimit" : 5, + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "user" : "username", + "monitors" : [ { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + }, { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + } ] + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "registerEnabled" : false, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "type" : "sip-server", + "usePublicBgp" : true, + "enabled" : true, + "fixedPacketRate" : 50, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "targetSipCredentials" : { + "password" : "password", + "protocol" : "tcp", + "port" : 49153, + "sipRegistrar" : "voice.thousandeyes.com", + "authUser" : "username", + "user" : "username" + }, + "testName" : "ThousandEyes Test", + "sipTargetTime" : 1000, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "optionsRegex" : "[\\"a-z\\"]", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "sipTimeLimit" : 5, + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "monitors" : [ "17410", "5" ] + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_test_version_history": OperationExpectation( + operation_id="get_test_version_history", + method="GET", + path="/tests/{testId}/history", + path_param_examples={ + "testId": '202701', + }, + success_status=200, + success_body=json.loads(""" + + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "testVersionHistory" : [ { + "versionId" : "1234", + "versionTimestamp" : "2022-07-17T22:00:54Z", + "createdBy" : "user (user@user.com)", + "testId" : "474276" + }, { + "versionId" : "1234", + "versionTimestamp" : "2022-07-17T22:00:54Z", + "createdBy" : "user (user@user.com)", + "testId" : "474276" + } ] + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_tests": OperationExpectation( + operation_id="get_tests", + method="GET", + path="/tests", + path_param_examples={ + }, + success_status=200, + success_body=json.loads(""" + + { + "tests" : [ { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + }, { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + } ], + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "create_voice_test": OperationExpectation( + operation_id="create_voice_test", + method="POST", + path="/tests/voice", + path_param_examples={ + }, + success_status=201, + success_body=json.loads(""" + + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + }, { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + } ], + "description" : "ThousandEyes Test", + "type" : "voice", + "usePublicBgp" : true, + "enabled" : true, + "jitterBuffer" : 40, + "dscpId" : "0", + "duration" : 5, + "dscp" : "Best Effort (DSCP 0)", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "liveShare" : false, + "savedEvent" : true, + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "codec" : "G.711 @ 64 Kbps", + "codecId" : "0", + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "port" : 1024, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "targetAgentId" : "281474976710706", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "monitors" : [ { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + }, { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + } ] + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "type" : "voice", + "usePublicBgp" : true, + "enabled" : true, + "jitterBuffer" : 40, + "dscpId" : "0", + "duration" : 5, + "dscp" : "Best Effort (DSCP 0)", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "liveShare" : false, + "savedEvent" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "codec" : "G.711 @ 64 Kbps", + "codecId" : "0", + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "port" : 1024, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "targetAgentId" : "281474976710706", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "monitors" : [ "17410", "5" ] + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "delete_voice_test": OperationExpectation( + operation_id="delete_voice_test", + method="DELETE", + path="/tests/voice/{testId}", + path_param_examples={ + "testId": '202701', + }, + success_status=204, + success_body=None, + success_content_type="application/json", + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_voice_test": OperationExpectation( + operation_id="get_voice_test", + method="GET", + path="/tests/voice/{testId}", + path_param_examples={ + "testId": '202701', + }, + success_status=200, + success_body=json.loads(""" + + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + }, { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + } ], + "description" : "ThousandEyes Test", + "type" : "voice", + "usePublicBgp" : true, + "enabled" : true, + "jitterBuffer" : 40, + "dscpId" : "0", + "duration" : 5, + "dscp" : "Best Effort (DSCP 0)", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "liveShare" : false, + "savedEvent" : true, + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "codec" : "G.711 @ 64 Kbps", + "codecId" : "0", + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "port" : 1024, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "targetAgentId" : "281474976710706", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "monitors" : [ { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + }, { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + } ] + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_voice_tests": OperationExpectation( + operation_id="get_voice_tests", + method="GET", + path="/tests/voice", + path_param_examples={ + }, + success_status=200, + success_body=json.loads(""" + + { + "tests" : [ { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "description" : "ThousandEyes Test", + "type" : "voice", + "usePublicBgp" : true, + "enabled" : true, + "jitterBuffer" : 40, + "dscpId" : "0", + "duration" : 5, + "dscp" : "Best Effort (DSCP 0)", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "liveShare" : false, + "savedEvent" : true, + "codec" : "G.711 @ 64 Kbps", + "codecId" : "0", + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "port" : 1024, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "targetAgentId" : "281474976710706", + "interval" : 60, + "testId" : "281474976710706" + }, { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "description" : "ThousandEyes Test", + "type" : "voice", + "usePublicBgp" : true, + "enabled" : true, + "jitterBuffer" : 40, + "dscpId" : "0", + "duration" : 5, + "dscp" : "Best Effort (DSCP 0)", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "liveShare" : false, + "savedEvent" : true, + "codec" : "G.711 @ 64 Kbps", + "codecId" : "0", + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "port" : 1024, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "targetAgentId" : "281474976710706", + "interval" : 60, + "testId" : "281474976710706" + } ], + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "update_voice_test": OperationExpectation( + operation_id="update_voice_test", + method="PUT", + path="/tests/voice/{testId}", + path_param_examples={ + "testId": '202701', + }, + success_status=200, + success_body=json.loads(""" + + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + }, { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + } ], + "description" : "ThousandEyes Test", + "type" : "voice", + "usePublicBgp" : true, + "enabled" : true, + "jitterBuffer" : 40, + "dscpId" : "0", + "duration" : 5, + "dscp" : "Best Effort (DSCP 0)", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "liveShare" : false, + "savedEvent" : true, + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "codec" : "G.711 @ 64 Kbps", + "codecId" : "0", + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "port" : 1024, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "targetAgentId" : "281474976710706", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "monitors" : [ { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + }, { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + } ] + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "type" : "voice", + "usePublicBgp" : true, + "enabled" : true, + "jitterBuffer" : 40, + "dscpId" : "0", + "duration" : 5, + "dscp" : "Best Effort (DSCP 0)", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "liveShare" : false, + "savedEvent" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "codec" : "G.711 @ 64 Kbps", + "codecId" : "0", + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "port" : 1024, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "targetAgentId" : "281474976710706", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "monitors" : [ "17410", "5" ] + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "create_web_transactions_test": OperationExpectation( + operation_id="create_web_transactions_test", + method="POST", + path="/tests/web-transactions", + path_param_examples={ + }, + success_status=201, + success_body=json.loads(""" + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "web-transactions", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "chromePolicies" : "{\\"ProxyMode\\":\\"direct\\"}", + "contentRegex" : "(regex)+", + "pageLoadingStrategy" : "normal", + "testName" : "ThousandEyes Test", + "allowMicAndCamera" : false, + "browserLanguage" : "en-US", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "emulatedDeviceId" : "2", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "overrideProxyId" : "281474976710706", + "monitors" : [ { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + }, { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + } ], + "sslVersion" : "Auto", + "useNtlm" : false, + "credentials" : [ "3247", "1051" ], + "downloadLimit" : 2048, + "alertRules" : [ { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + }, { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + } ], + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "blockDomains" : "domain.com/", + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowGeolocation" : false, + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "alertsEnabled" : true, + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "transactionScript" : "if (true) { return true; }", + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "identifyAgentTrafficWithUserAgent" : false, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "timeLimit" : 30, + "createdDate" : "2022-07-17T22:00:54Z", + "disableScreenshot" : false, + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "subinterval" : 60, + "chromeOptions" : "--disable-gpu", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username", + "targetTime" : 1 + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "web-transactions", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "chromePolicies" : "{\\"ProxyMode\\":\\"direct\\"}", + "contentRegex" : "(regex)+", + "pageLoadingStrategy" : "normal", + "testName" : "ThousandEyes Test", + "allowMicAndCamera" : false, + "browserLanguage" : "en-US", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "emulatedDeviceId" : "2", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "monitors" : [ "17410", "5" ], + "sslVersion" : "Auto", + "useNtlm" : false, + "credentials" : [ "3247", "1051" ], + "downloadLimit" : 2048, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "blockDomains" : "domain.com/", + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowGeolocation" : false, + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "alertsEnabled" : true, + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "transactionScript" : "if (true) { return true; }", + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "identifyAgentTrafficWithUserAgent" : false, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "timeLimit" : 30, + "createdDate" : "2022-07-17T22:00:54Z", + "disableScreenshot" : false, + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "subinterval" : 60, + "chromeOptions" : "--disable-gpu", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username", + "targetTime" : 1 + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "delete_web_transactions_test": OperationExpectation( + operation_id="delete_web_transactions_test", + method="DELETE", + path="/tests/web-transactions/{testId}", + path_param_examples={ + "testId": '202701', + }, + success_status=204, + success_body=None, + success_content_type="application/json", + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_web_transactions_test": OperationExpectation( + operation_id="get_web_transactions_test", + method="GET", + path="/tests/web-transactions/{testId}", + path_param_examples={ + "testId": '202701', + }, + success_status=200, + success_body=json.loads(""" + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "web-transactions", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "chromePolicies" : "{\\"ProxyMode\\":\\"direct\\"}", + "contentRegex" : "(regex)+", + "pageLoadingStrategy" : "normal", + "testName" : "ThousandEyes Test", + "allowMicAndCamera" : false, + "browserLanguage" : "en-US", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "emulatedDeviceId" : "2", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "overrideProxyId" : "281474976710706", + "monitors" : [ { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + }, { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + } ], + "sslVersion" : "Auto", + "useNtlm" : false, + "credentials" : [ "3247", "1051" ], + "downloadLimit" : 2048, + "alertRules" : [ { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + }, { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + } ], + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "blockDomains" : "domain.com/", + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowGeolocation" : false, + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "alertsEnabled" : true, + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "transactionScript" : "if (true) { return true; }", + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "identifyAgentTrafficWithUserAgent" : false, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "timeLimit" : 30, + "createdDate" : "2022-07-17T22:00:54Z", + "disableScreenshot" : false, + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "subinterval" : 60, + "chromeOptions" : "--disable-gpu", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username", + "targetTime" : 1 + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_web_transactions_tests": OperationExpectation( + operation_id="get_web_transactions_tests", + method="GET", + path="/tests/web-transactions", + path_param_examples={ + }, + success_status=200, + success_body=json.loads(""" + + { + "tests" : [ { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "web-transactions", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "chromePolicies" : "{\\"ProxyMode\\":\\"direct\\"}", + "contentRegex" : "(regex)+", + "pageLoadingStrategy" : "normal", + "testName" : "ThousandEyes Test", + "allowMicAndCamera" : false, + "browserLanguage" : "en-US", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "emulatedDeviceId" : "2", + "overrideProxyId" : "281474976710706", + "sslVersion" : "Auto", + "useNtlm" : false, + "downloadLimit" : 2048, + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "blockDomains" : "domain.com/", + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowGeolocation" : false, + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "alertsEnabled" : true, + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "transactionScript" : "if (true) { return true; }", + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "identifyAgentTrafficWithUserAgent" : false, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "timeLimit" : 30, + "createdDate" : "2022-07-17T22:00:54Z", + "disableScreenshot" : false, + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "subinterval" : 60, + "chromeOptions" : "--disable-gpu", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username", + "targetTime" : 1 + }, { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "web-transactions", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "chromePolicies" : "{\\"ProxyMode\\":\\"direct\\"}", + "contentRegex" : "(regex)+", + "pageLoadingStrategy" : "normal", + "testName" : "ThousandEyes Test", + "allowMicAndCamera" : false, + "browserLanguage" : "en-US", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "emulatedDeviceId" : "2", + "overrideProxyId" : "281474976710706", + "sslVersion" : "Auto", + "useNtlm" : false, + "downloadLimit" : 2048, + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "blockDomains" : "domain.com/", + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowGeolocation" : false, + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "alertsEnabled" : true, + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "transactionScript" : "if (true) { return true; }", + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "identifyAgentTrafficWithUserAgent" : false, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "timeLimit" : 30, + "createdDate" : "2022-07-17T22:00:54Z", + "disableScreenshot" : false, + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "subinterval" : 60, + "chromeOptions" : "--disable-gpu", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username", + "targetTime" : 1 + } ], + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + + "update_web_transactions_test": OperationExpectation( + operation_id="update_web_transactions_test", + method="PUT", + path="/tests/web-transactions/{testId}", + path_param_examples={ + "testId": '202701', + }, + success_status=200, + success_body=json.loads(""" + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "web-transactions", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "chromePolicies" : "{\\"ProxyMode\\":\\"direct\\"}", + "contentRegex" : "(regex)+", + "pageLoadingStrategy" : "normal", + "testName" : "ThousandEyes Test", + "allowMicAndCamera" : false, + "browserLanguage" : "en-US", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "emulatedDeviceId" : "2", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "overrideProxyId" : "281474976710706", + "monitors" : [ { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + }, { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + } ], + "sslVersion" : "Auto", + "useNtlm" : false, + "credentials" : [ "3247", "1051" ], + "downloadLimit" : 2048, + "alertRules" : [ { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + }, { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + } ], + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "blockDomains" : "domain.com/", + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowGeolocation" : false, + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "alertsEnabled" : true, + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "transactionScript" : "if (true) { return true; }", + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "identifyAgentTrafficWithUserAgent" : false, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "timeLimit" : 30, + "createdDate" : "2022-07-17T22:00:54Z", + "disableScreenshot" : false, + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "subinterval" : 60, + "chromeOptions" : "--disable-gpu", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username", + "targetTime" : 1 + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "web-transactions", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "chromePolicies" : "{\\"ProxyMode\\":\\"direct\\"}", + "contentRegex" : "(regex)+", + "pageLoadingStrategy" : "normal", + "testName" : "ThousandEyes Test", + "allowMicAndCamera" : false, + "browserLanguage" : "en-US", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "emulatedDeviceId" : "2", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "monitors" : [ "17410", "5" ], + "sslVersion" : "Auto", + "useNtlm" : false, + "credentials" : [ "3247", "1051" ], + "downloadLimit" : 2048, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "blockDomains" : "domain.com/", + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowGeolocation" : false, + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "alertsEnabled" : true, + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "transactionScript" : "if (true) { return true; }", + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "identifyAgentTrafficWithUserAgent" : false, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "timeLimit" : 30, + "createdDate" : "2022-07-17T22:00:54Z", + "disableScreenshot" : false, + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "subinterval" : 60, + "chromeOptions" : "--disable-gpu", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username", + "targetTime" : 1 + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + "502": ErrorResponseExpectation( + status=502, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + }"""), + content_type="application/json", + ), + + }, + ), + +} diff --git a/thousandeyes-sdk-tests/test/test_agent_to_agent_tests_api_integration.py b/thousandeyes-sdk-tests/test/test_agent_to_agent_tests_api_integration.py new file mode 100644 index 00000000..84a945e8 --- /dev/null +++ b/thousandeyes-sdk-tests/test/test_agent_to_agent_tests_api_integration.py @@ -0,0 +1,2669 @@ +# coding: utf-8 + +""" + Tests API + + **Note:** The Page Load Tests, API Tests, and Web Transaction Tests APIs are not available for ThousandEyes for Government instance. This API allows you to list, create, edit, and delete Network and Application Synthetics tests. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.tests.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.tests.api.agent_to_agent_tests_api import AgentToAgentTestsApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestAgentToAgentTestsApiIntegration(IntegrationTestBase): + """AgentToAgentTestsApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = AgentToAgentTestsApi(self.api_client) + + + def test_create_agent_to_agent_test_happy_path(self) -> None: + """Integration test for create_agent_to_agent_test success path""" + request_body_json = """ + + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "type" : "agent-to-agent", + "mss" : 100, + "usePublicBgp" : true, + "enabled" : true, + "dscpId" : "0", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "dscp" : "Best Effort (DSCP 0)", + "pathTraceMode" : "classic", + "throughputRate" : 10, + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "direction" : "to-target", + "throughputMeasurements" : false, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "liveShare" : false, + "savedEvent" : true, + "throughputDuration" : 10000, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "port" : 49153, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "targetAgentId" : "2954", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "monitors" : [ "17410", "5" ] + } + + """ + agent_to_agent_test_request = thousandeyes_sdk.tests.models.AgentToAgentTestRequest.from_json(request_body_json) + aid = '1234' + response_body_json = """ + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + }, { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + } ], + "description" : "ThousandEyes Test", + "type" : "agent-to-agent", + "mss" : 100, + "usePublicBgp" : true, + "enabled" : true, + "dscpId" : "0", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "dscp" : "Best Effort (DSCP 0)", + "pathTraceMode" : "classic", + "throughputRate" : 10, + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "direction" : "to-target", + "throughputMeasurements" : false, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "liveShare" : false, + "savedEvent" : true, + "throughputDuration" : 10000, + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "port" : 49153, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "targetAgentId" : "2954", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "monitors" : [ { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + }, { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + } ] + } + """ + expected_response = json.loads(response_body_json) + response = self.api.create_agent_to_agent_test( + + agent_to_agent_test_request=agent_to_agent_test_request, + + aid=aid, + + _headers=self.te_headers("create_agent_to_agent_test"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_create_agent_to_agent_test_error_400(self) -> None: + """Integration test for create_agent_to_agent_test error path (HTTP 400)""" + request_body_json = """ + + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "type" : "agent-to-agent", + "mss" : 100, + "usePublicBgp" : true, + "enabled" : true, + "dscpId" : "0", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "dscp" : "Best Effort (DSCP 0)", + "pathTraceMode" : "classic", + "throughputRate" : 10, + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "direction" : "to-target", + "throughputMeasurements" : false, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "liveShare" : false, + "savedEvent" : true, + "throughputDuration" : 10000, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "port" : 49153, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "targetAgentId" : "2954", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "monitors" : [ "17410", "5" ] + } + + """ + agent_to_agent_test_request = thousandeyes_sdk.tests.models.AgentToAgentTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.create_agent_to_agent_test( + + agent_to_agent_test_request=agent_to_agent_test_request, + + aid=aid, + + _headers=self.te_headers("create_agent_to_agent_test", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_agent_to_agent_test_error_401(self) -> None: + """Integration test for create_agent_to_agent_test error path (HTTP 401)""" + request_body_json = """ + + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "type" : "agent-to-agent", + "mss" : 100, + "usePublicBgp" : true, + "enabled" : true, + "dscpId" : "0", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "dscp" : "Best Effort (DSCP 0)", + "pathTraceMode" : "classic", + "throughputRate" : 10, + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "direction" : "to-target", + "throughputMeasurements" : false, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "liveShare" : false, + "savedEvent" : true, + "throughputDuration" : 10000, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "port" : 49153, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "targetAgentId" : "2954", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "monitors" : [ "17410", "5" ] + } + + """ + agent_to_agent_test_request = thousandeyes_sdk.tests.models.AgentToAgentTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.create_agent_to_agent_test( + + agent_to_agent_test_request=agent_to_agent_test_request, + + aid=aid, + + _headers=self.te_headers("create_agent_to_agent_test", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_agent_to_agent_test_error_403(self) -> None: + """Integration test for create_agent_to_agent_test error path (HTTP 403)""" + request_body_json = """ + + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "type" : "agent-to-agent", + "mss" : 100, + "usePublicBgp" : true, + "enabled" : true, + "dscpId" : "0", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "dscp" : "Best Effort (DSCP 0)", + "pathTraceMode" : "classic", + "throughputRate" : 10, + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "direction" : "to-target", + "throughputMeasurements" : false, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "liveShare" : false, + "savedEvent" : true, + "throughputDuration" : 10000, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "port" : 49153, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "targetAgentId" : "2954", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "monitors" : [ "17410", "5" ] + } + + """ + agent_to_agent_test_request = thousandeyes_sdk.tests.models.AgentToAgentTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.create_agent_to_agent_test( + + agent_to_agent_test_request=agent_to_agent_test_request, + + aid=aid, + + _headers=self.te_headers("create_agent_to_agent_test", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_agent_to_agent_test_error_404(self) -> None: + """Integration test for create_agent_to_agent_test error path (HTTP 404)""" + request_body_json = """ + + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "type" : "agent-to-agent", + "mss" : 100, + "usePublicBgp" : true, + "enabled" : true, + "dscpId" : "0", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "dscp" : "Best Effort (DSCP 0)", + "pathTraceMode" : "classic", + "throughputRate" : 10, + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "direction" : "to-target", + "throughputMeasurements" : false, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "liveShare" : false, + "savedEvent" : true, + "throughputDuration" : 10000, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "port" : 49153, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "targetAgentId" : "2954", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "monitors" : [ "17410", "5" ] + } + + """ + agent_to_agent_test_request = thousandeyes_sdk.tests.models.AgentToAgentTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.create_agent_to_agent_test( + + agent_to_agent_test_request=agent_to_agent_test_request, + + aid=aid, + + _headers=self.te_headers("create_agent_to_agent_test", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_agent_to_agent_test_error_429(self) -> None: + """Integration test for create_agent_to_agent_test error path (HTTP 429)""" + request_body_json = """ + + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "type" : "agent-to-agent", + "mss" : 100, + "usePublicBgp" : true, + "enabled" : true, + "dscpId" : "0", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "dscp" : "Best Effort (DSCP 0)", + "pathTraceMode" : "classic", + "throughputRate" : 10, + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "direction" : "to-target", + "throughputMeasurements" : false, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "liveShare" : false, + "savedEvent" : true, + "throughputDuration" : 10000, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "port" : 49153, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "targetAgentId" : "2954", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "monitors" : [ "17410", "5" ] + } + + """ + agent_to_agent_test_request = thousandeyes_sdk.tests.models.AgentToAgentTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.create_agent_to_agent_test( + + agent_to_agent_test_request=agent_to_agent_test_request, + + aid=aid, + + _headers=self.te_headers("create_agent_to_agent_test", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_agent_to_agent_test_error_500(self) -> None: + """Integration test for create_agent_to_agent_test error path (HTTP 500)""" + request_body_json = """ + + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "type" : "agent-to-agent", + "mss" : 100, + "usePublicBgp" : true, + "enabled" : true, + "dscpId" : "0", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "dscp" : "Best Effort (DSCP 0)", + "pathTraceMode" : "classic", + "throughputRate" : 10, + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "direction" : "to-target", + "throughputMeasurements" : false, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "liveShare" : false, + "savedEvent" : true, + "throughputDuration" : 10000, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "port" : 49153, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "targetAgentId" : "2954", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "monitors" : [ "17410", "5" ] + } + + """ + agent_to_agent_test_request = thousandeyes_sdk.tests.models.AgentToAgentTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.create_agent_to_agent_test( + + agent_to_agent_test_request=agent_to_agent_test_request, + + aid=aid, + + _headers=self.te_headers("create_agent_to_agent_test", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_agent_to_agent_test_error_502(self) -> None: + """Integration test for create_agent_to_agent_test error path (HTTP 502)""" + request_body_json = """ + + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "type" : "agent-to-agent", + "mss" : 100, + "usePublicBgp" : true, + "enabled" : true, + "dscpId" : "0", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "dscp" : "Best Effort (DSCP 0)", + "pathTraceMode" : "classic", + "throughputRate" : 10, + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "direction" : "to-target", + "throughputMeasurements" : false, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "liveShare" : false, + "savedEvent" : true, + "throughputDuration" : 10000, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "port" : 49153, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "targetAgentId" : "2954", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "monitors" : [ "17410", "5" ] + } + + """ + agent_to_agent_test_request = thousandeyes_sdk.tests.models.AgentToAgentTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.create_agent_to_agent_test( + + agent_to_agent_test_request=agent_to_agent_test_request, + + aid=aid, + + _headers=self.te_headers("create_agent_to_agent_test", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_delete_agent_to_agent_test_happy_path(self) -> None: + """Integration test for delete_agent_to_agent_test success path""" + test_id = '202701' + aid = '1234' + response = self.api.delete_agent_to_agent_test_with_http_info( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_agent_to_agent_test"), + ) + self.assertEqual(204, response.status_code) + self.assertIsNone(response.data) + + + def test_delete_agent_to_agent_test_error_401(self) -> None: + """Integration test for delete_agent_to_agent_test error path (HTTP 401)""" + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.delete_agent_to_agent_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_agent_to_agent_test", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_agent_to_agent_test_error_403(self) -> None: + """Integration test for delete_agent_to_agent_test error path (HTTP 403)""" + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.delete_agent_to_agent_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_agent_to_agent_test", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_agent_to_agent_test_error_404(self) -> None: + """Integration test for delete_agent_to_agent_test error path (HTTP 404)""" + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.delete_agent_to_agent_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_agent_to_agent_test", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_agent_to_agent_test_error_429(self) -> None: + """Integration test for delete_agent_to_agent_test error path (HTTP 429)""" + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.delete_agent_to_agent_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_agent_to_agent_test", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_agent_to_agent_test_error_500(self) -> None: + """Integration test for delete_agent_to_agent_test error path (HTTP 500)""" + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.delete_agent_to_agent_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_agent_to_agent_test", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_agent_to_agent_test_error_502(self) -> None: + """Integration test for delete_agent_to_agent_test error path (HTTP 502)""" + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.delete_agent_to_agent_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_agent_to_agent_test", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_agent_to_agent_test_happy_path(self) -> None: + """Integration test for get_agent_to_agent_test success path""" + test_id = '202701' + aid = '1234' + version_id = '1234' + response_body_json = """ + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + }, { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + } ], + "description" : "ThousandEyes Test", + "type" : "agent-to-agent", + "mss" : 100, + "usePublicBgp" : true, + "enabled" : true, + "dscpId" : "0", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "dscp" : "Best Effort (DSCP 0)", + "pathTraceMode" : "classic", + "throughputRate" : 10, + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "direction" : "to-target", + "throughputMeasurements" : false, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "liveShare" : false, + "savedEvent" : true, + "throughputDuration" : 10000, + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "port" : 49153, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "targetAgentId" : "2954", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "monitors" : [ { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + }, { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + } ] + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_agent_to_agent_test( + + test_id=test_id, + + aid=aid, + + version_id=version_id, + + _headers=self.te_headers("get_agent_to_agent_test"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_agent_to_agent_test_error_401(self) -> None: + """Integration test for get_agent_to_agent_test error path (HTTP 401)""" + test_id = '202701' + aid = '1234' + version_id = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_agent_to_agent_test( + + test_id=test_id, + + aid=aid, + + version_id=version_id, + + _headers=self.te_headers("get_agent_to_agent_test", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_agent_to_agent_test_error_403(self) -> None: + """Integration test for get_agent_to_agent_test error path (HTTP 403)""" + test_id = '202701' + aid = '1234' + version_id = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_agent_to_agent_test( + + test_id=test_id, + + aid=aid, + + version_id=version_id, + + _headers=self.te_headers("get_agent_to_agent_test", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_agent_to_agent_test_error_404(self) -> None: + """Integration test for get_agent_to_agent_test error path (HTTP 404)""" + test_id = '202701' + aid = '1234' + version_id = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_agent_to_agent_test( + + test_id=test_id, + + aid=aid, + + version_id=version_id, + + _headers=self.te_headers("get_agent_to_agent_test", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_agent_to_agent_test_error_429(self) -> None: + """Integration test for get_agent_to_agent_test error path (HTTP 429)""" + test_id = '202701' + aid = '1234' + version_id = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_agent_to_agent_test( + + test_id=test_id, + + aid=aid, + + version_id=version_id, + + _headers=self.te_headers("get_agent_to_agent_test", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_agent_to_agent_test_error_500(self) -> None: + """Integration test for get_agent_to_agent_test error path (HTTP 500)""" + test_id = '202701' + aid = '1234' + version_id = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_agent_to_agent_test( + + test_id=test_id, + + aid=aid, + + version_id=version_id, + + _headers=self.te_headers("get_agent_to_agent_test", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_agent_to_agent_test_error_502(self) -> None: + """Integration test for get_agent_to_agent_test error path (HTTP 502)""" + test_id = '202701' + aid = '1234' + version_id = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.get_agent_to_agent_test( + + test_id=test_id, + + aid=aid, + + version_id=version_id, + + _headers=self.te_headers("get_agent_to_agent_test", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_agent_to_agent_tests_happy_path(self) -> None: + """Integration test for get_agent_to_agent_tests success path""" + aid = '1234' + response_body_json = """ + { + "tests" : [ { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "description" : "ThousandEyes Test", + "type" : "agent-to-agent", + "mss" : 100, + "usePublicBgp" : true, + "enabled" : true, + "dscpId" : "0", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "dscp" : "Best Effort (DSCP 0)", + "pathTraceMode" : "classic", + "throughputRate" : 10, + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "direction" : "to-target", + "throughputMeasurements" : false, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "liveShare" : false, + "savedEvent" : true, + "throughputDuration" : 10000, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "port" : 49153, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "targetAgentId" : "2954", + "interval" : 60, + "testId" : "281474976710706" + }, { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "description" : "ThousandEyes Test", + "type" : "agent-to-agent", + "mss" : 100, + "usePublicBgp" : true, + "enabled" : true, + "dscpId" : "0", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "dscp" : "Best Effort (DSCP 0)", + "pathTraceMode" : "classic", + "throughputRate" : 10, + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "direction" : "to-target", + "throughputMeasurements" : false, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "liveShare" : false, + "savedEvent" : true, + "throughputDuration" : 10000, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "port" : 49153, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "targetAgentId" : "2954", + "interval" : 60, + "testId" : "281474976710706" + } ], + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_agent_to_agent_tests( + + aid=aid, + + _headers=self.te_headers("get_agent_to_agent_tests"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_agent_to_agent_tests_error_401(self) -> None: + """Integration test for get_agent_to_agent_tests error path (HTTP 401)""" + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_agent_to_agent_tests( + + aid=aid, + + _headers=self.te_headers("get_agent_to_agent_tests", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_agent_to_agent_tests_error_403(self) -> None: + """Integration test for get_agent_to_agent_tests error path (HTTP 403)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_agent_to_agent_tests( + + aid=aid, + + _headers=self.te_headers("get_agent_to_agent_tests", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_agent_to_agent_tests_error_404(self) -> None: + """Integration test for get_agent_to_agent_tests error path (HTTP 404)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_agent_to_agent_tests( + + aid=aid, + + _headers=self.te_headers("get_agent_to_agent_tests", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_agent_to_agent_tests_error_429(self) -> None: + """Integration test for get_agent_to_agent_tests error path (HTTP 429)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_agent_to_agent_tests( + + aid=aid, + + _headers=self.te_headers("get_agent_to_agent_tests", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_agent_to_agent_tests_error_500(self) -> None: + """Integration test for get_agent_to_agent_tests error path (HTTP 500)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_agent_to_agent_tests( + + aid=aid, + + _headers=self.te_headers("get_agent_to_agent_tests", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_agent_to_agent_tests_error_502(self) -> None: + """Integration test for get_agent_to_agent_tests error path (HTTP 502)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.get_agent_to_agent_tests( + + aid=aid, + + _headers=self.te_headers("get_agent_to_agent_tests", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_update_agent_to_agent_test_happy_path(self) -> None: + """Integration test for update_agent_to_agent_test success path""" + request_body_json = """ + + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "type" : "agent-to-agent", + "mss" : 100, + "usePublicBgp" : true, + "enabled" : true, + "dscpId" : "0", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "dscp" : "Best Effort (DSCP 0)", + "pathTraceMode" : "classic", + "throughputRate" : 10, + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "direction" : "to-target", + "throughputMeasurements" : false, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "liveShare" : false, + "savedEvent" : true, + "throughputDuration" : 10000, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "port" : 49153, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "targetAgentId" : "2954", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "monitors" : [ "17410", "5" ] + } + + """ + agent_to_agent_test_request = thousandeyes_sdk.tests.models.AgentToAgentTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + response_body_json = """ + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + }, { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + } ], + "description" : "ThousandEyes Test", + "type" : "agent-to-agent", + "mss" : 100, + "usePublicBgp" : true, + "enabled" : true, + "dscpId" : "0", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "dscp" : "Best Effort (DSCP 0)", + "pathTraceMode" : "classic", + "throughputRate" : 10, + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "direction" : "to-target", + "throughputMeasurements" : false, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "liveShare" : false, + "savedEvent" : true, + "throughputDuration" : 10000, + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "port" : 49153, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "targetAgentId" : "2954", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "monitors" : [ { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + }, { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + } ] + } + """ + expected_response = json.loads(response_body_json) + response = self.api.update_agent_to_agent_test( + + test_id=test_id, + + agent_to_agent_test_request=agent_to_agent_test_request, + + aid=aid, + + _headers=self.te_headers("update_agent_to_agent_test"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_update_agent_to_agent_test_error_400(self) -> None: + """Integration test for update_agent_to_agent_test error path (HTTP 400)""" + request_body_json = """ + + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "type" : "agent-to-agent", + "mss" : 100, + "usePublicBgp" : true, + "enabled" : true, + "dscpId" : "0", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "dscp" : "Best Effort (DSCP 0)", + "pathTraceMode" : "classic", + "throughputRate" : 10, + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "direction" : "to-target", + "throughputMeasurements" : false, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "liveShare" : false, + "savedEvent" : true, + "throughputDuration" : 10000, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "port" : 49153, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "targetAgentId" : "2954", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "monitors" : [ "17410", "5" ] + } + + """ + agent_to_agent_test_request = thousandeyes_sdk.tests.models.AgentToAgentTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.update_agent_to_agent_test( + + test_id=test_id, + + agent_to_agent_test_request=agent_to_agent_test_request, + + aid=aid, + + _headers=self.te_headers("update_agent_to_agent_test", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_agent_to_agent_test_error_401(self) -> None: + """Integration test for update_agent_to_agent_test error path (HTTP 401)""" + request_body_json = """ + + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "type" : "agent-to-agent", + "mss" : 100, + "usePublicBgp" : true, + "enabled" : true, + "dscpId" : "0", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "dscp" : "Best Effort (DSCP 0)", + "pathTraceMode" : "classic", + "throughputRate" : 10, + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "direction" : "to-target", + "throughputMeasurements" : false, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "liveShare" : false, + "savedEvent" : true, + "throughputDuration" : 10000, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "port" : 49153, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "targetAgentId" : "2954", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "monitors" : [ "17410", "5" ] + } + + """ + agent_to_agent_test_request = thousandeyes_sdk.tests.models.AgentToAgentTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.update_agent_to_agent_test( + + test_id=test_id, + + agent_to_agent_test_request=agent_to_agent_test_request, + + aid=aid, + + _headers=self.te_headers("update_agent_to_agent_test", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_agent_to_agent_test_error_403(self) -> None: + """Integration test for update_agent_to_agent_test error path (HTTP 403)""" + request_body_json = """ + + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "type" : "agent-to-agent", + "mss" : 100, + "usePublicBgp" : true, + "enabled" : true, + "dscpId" : "0", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "dscp" : "Best Effort (DSCP 0)", + "pathTraceMode" : "classic", + "throughputRate" : 10, + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "direction" : "to-target", + "throughputMeasurements" : false, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "liveShare" : false, + "savedEvent" : true, + "throughputDuration" : 10000, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "port" : 49153, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "targetAgentId" : "2954", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "monitors" : [ "17410", "5" ] + } + + """ + agent_to_agent_test_request = thousandeyes_sdk.tests.models.AgentToAgentTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.update_agent_to_agent_test( + + test_id=test_id, + + agent_to_agent_test_request=agent_to_agent_test_request, + + aid=aid, + + _headers=self.te_headers("update_agent_to_agent_test", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_agent_to_agent_test_error_404(self) -> None: + """Integration test for update_agent_to_agent_test error path (HTTP 404)""" + request_body_json = """ + + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "type" : "agent-to-agent", + "mss" : 100, + "usePublicBgp" : true, + "enabled" : true, + "dscpId" : "0", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "dscp" : "Best Effort (DSCP 0)", + "pathTraceMode" : "classic", + "throughputRate" : 10, + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "direction" : "to-target", + "throughputMeasurements" : false, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "liveShare" : false, + "savedEvent" : true, + "throughputDuration" : 10000, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "port" : 49153, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "targetAgentId" : "2954", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "monitors" : [ "17410", "5" ] + } + + """ + agent_to_agent_test_request = thousandeyes_sdk.tests.models.AgentToAgentTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.update_agent_to_agent_test( + + test_id=test_id, + + agent_to_agent_test_request=agent_to_agent_test_request, + + aid=aid, + + _headers=self.te_headers("update_agent_to_agent_test", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_agent_to_agent_test_error_429(self) -> None: + """Integration test for update_agent_to_agent_test error path (HTTP 429)""" + request_body_json = """ + + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "type" : "agent-to-agent", + "mss" : 100, + "usePublicBgp" : true, + "enabled" : true, + "dscpId" : "0", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "dscp" : "Best Effort (DSCP 0)", + "pathTraceMode" : "classic", + "throughputRate" : 10, + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "direction" : "to-target", + "throughputMeasurements" : false, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "liveShare" : false, + "savedEvent" : true, + "throughputDuration" : 10000, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "port" : 49153, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "targetAgentId" : "2954", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "monitors" : [ "17410", "5" ] + } + + """ + agent_to_agent_test_request = thousandeyes_sdk.tests.models.AgentToAgentTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.update_agent_to_agent_test( + + test_id=test_id, + + agent_to_agent_test_request=agent_to_agent_test_request, + + aid=aid, + + _headers=self.te_headers("update_agent_to_agent_test", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_agent_to_agent_test_error_500(self) -> None: + """Integration test for update_agent_to_agent_test error path (HTTP 500)""" + request_body_json = """ + + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "type" : "agent-to-agent", + "mss" : 100, + "usePublicBgp" : true, + "enabled" : true, + "dscpId" : "0", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "dscp" : "Best Effort (DSCP 0)", + "pathTraceMode" : "classic", + "throughputRate" : 10, + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "direction" : "to-target", + "throughputMeasurements" : false, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "liveShare" : false, + "savedEvent" : true, + "throughputDuration" : 10000, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "port" : 49153, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "targetAgentId" : "2954", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "monitors" : [ "17410", "5" ] + } + + """ + agent_to_agent_test_request = thousandeyes_sdk.tests.models.AgentToAgentTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.update_agent_to_agent_test( + + test_id=test_id, + + agent_to_agent_test_request=agent_to_agent_test_request, + + aid=aid, + + _headers=self.te_headers("update_agent_to_agent_test", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_agent_to_agent_test_error_502(self) -> None: + """Integration test for update_agent_to_agent_test error path (HTTP 502)""" + request_body_json = """ + + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "type" : "agent-to-agent", + "mss" : 100, + "usePublicBgp" : true, + "enabled" : true, + "dscpId" : "0", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "dscp" : "Best Effort (DSCP 0)", + "pathTraceMode" : "classic", + "throughputRate" : 10, + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "direction" : "to-target", + "throughputMeasurements" : false, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "liveShare" : false, + "savedEvent" : true, + "throughputDuration" : 10000, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "port" : 49153, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "targetAgentId" : "2954", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "monitors" : [ "17410", "5" ] + } + + """ + agent_to_agent_test_request = thousandeyes_sdk.tests.models.AgentToAgentTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.update_agent_to_agent_test( + + test_id=test_id, + + agent_to_agent_test_request=agent_to_agent_test_request, + + aid=aid, + + _headers=self.te_headers("update_agent_to_agent_test", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-tests/test/test_agent_to_server_tests_api_integration.py b/thousandeyes-sdk-tests/test/test_agent_to_server_tests_api_integration.py new file mode 100644 index 00000000..47c8025a --- /dev/null +++ b/thousandeyes-sdk-tests/test/test_agent_to_server_tests_api_integration.py @@ -0,0 +1,2506 @@ +# coding: utf-8 + +""" + Tests API + + **Note:** The Page Load Tests, API Tests, and Web Transaction Tests APIs are not available for ThousandEyes for Government instance. This API allows you to list, create, edit, and delete Network and Application Synthetics tests. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.tests.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.tests.api.agent_to_server_tests_api import AgentToServerTestsApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestAgentToServerTestsApiIntegration(IntegrationTestBase): + """AgentToServerTestsApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = AgentToServerTestsApi(self.api_client) + + + def test_create_agent_to_server_test_happy_path(self) -> None: + """Integration test for create_agent_to_server_test success path""" + request_body_json = """ + + { + "server" : "www.thousandeyes.com:80", + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ "344753", "212697" ], + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "type" : "agent-to-server", + "usePublicBgp" : true, + "enabled" : true, + "dscpId" : "0", + "fixedPacketRate" : 25, + "protocol" : "tcp", + "dscp" : "Best Effort (DSCP 0)", + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : false, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "port" : 443, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "pingPayloadSize" : 112, + "sharedWithAccounts" : [ "1234", "12345" ], + "continuousMode" : false, + "monitors" : [ "17410", "5" ] + } + + """ + agent_to_server_test_request = thousandeyes_sdk.tests.models.AgentToServerTestRequest.from_json(request_body_json) + aid = '1234' + response_body_json = """ + { + "server" : "www.thousandeyes.com:80", + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + }, { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + } ], + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "type" : "agent-to-server", + "usePublicBgp" : true, + "enabled" : true, + "dscpId" : "0", + "fixedPacketRate" : 25, + "protocol" : "tcp", + "dscp" : "Best Effort (DSCP 0)", + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : false, + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "pingPayloadSize" : 112, + "continuousMode" : false, + "monitors" : [ { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + }, { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + } ] + } + """ + expected_response = json.loads(response_body_json) + response = self.api.create_agent_to_server_test( + + agent_to_server_test_request=agent_to_server_test_request, + + aid=aid, + + _headers=self.te_headers("create_agent_to_server_test"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_create_agent_to_server_test_error_400(self) -> None: + """Integration test for create_agent_to_server_test error path (HTTP 400)""" + request_body_json = """ + + { + "server" : "www.thousandeyes.com:80", + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ "344753", "212697" ], + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "type" : "agent-to-server", + "usePublicBgp" : true, + "enabled" : true, + "dscpId" : "0", + "fixedPacketRate" : 25, + "protocol" : "tcp", + "dscp" : "Best Effort (DSCP 0)", + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : false, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "port" : 443, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "pingPayloadSize" : 112, + "sharedWithAccounts" : [ "1234", "12345" ], + "continuousMode" : false, + "monitors" : [ "17410", "5" ] + } + + """ + agent_to_server_test_request = thousandeyes_sdk.tests.models.AgentToServerTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.create_agent_to_server_test( + + agent_to_server_test_request=agent_to_server_test_request, + + aid=aid, + + _headers=self.te_headers("create_agent_to_server_test", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_agent_to_server_test_error_401(self) -> None: + """Integration test for create_agent_to_server_test error path (HTTP 401)""" + request_body_json = """ + + { + "server" : "www.thousandeyes.com:80", + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ "344753", "212697" ], + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "type" : "agent-to-server", + "usePublicBgp" : true, + "enabled" : true, + "dscpId" : "0", + "fixedPacketRate" : 25, + "protocol" : "tcp", + "dscp" : "Best Effort (DSCP 0)", + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : false, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "port" : 443, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "pingPayloadSize" : 112, + "sharedWithAccounts" : [ "1234", "12345" ], + "continuousMode" : false, + "monitors" : [ "17410", "5" ] + } + + """ + agent_to_server_test_request = thousandeyes_sdk.tests.models.AgentToServerTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.create_agent_to_server_test( + + agent_to_server_test_request=agent_to_server_test_request, + + aid=aid, + + _headers=self.te_headers("create_agent_to_server_test", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_agent_to_server_test_error_403(self) -> None: + """Integration test for create_agent_to_server_test error path (HTTP 403)""" + request_body_json = """ + + { + "server" : "www.thousandeyes.com:80", + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ "344753", "212697" ], + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "type" : "agent-to-server", + "usePublicBgp" : true, + "enabled" : true, + "dscpId" : "0", + "fixedPacketRate" : 25, + "protocol" : "tcp", + "dscp" : "Best Effort (DSCP 0)", + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : false, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "port" : 443, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "pingPayloadSize" : 112, + "sharedWithAccounts" : [ "1234", "12345" ], + "continuousMode" : false, + "monitors" : [ "17410", "5" ] + } + + """ + agent_to_server_test_request = thousandeyes_sdk.tests.models.AgentToServerTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.create_agent_to_server_test( + + agent_to_server_test_request=agent_to_server_test_request, + + aid=aid, + + _headers=self.te_headers("create_agent_to_server_test", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_agent_to_server_test_error_404(self) -> None: + """Integration test for create_agent_to_server_test error path (HTTP 404)""" + request_body_json = """ + + { + "server" : "www.thousandeyes.com:80", + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ "344753", "212697" ], + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "type" : "agent-to-server", + "usePublicBgp" : true, + "enabled" : true, + "dscpId" : "0", + "fixedPacketRate" : 25, + "protocol" : "tcp", + "dscp" : "Best Effort (DSCP 0)", + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : false, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "port" : 443, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "pingPayloadSize" : 112, + "sharedWithAccounts" : [ "1234", "12345" ], + "continuousMode" : false, + "monitors" : [ "17410", "5" ] + } + + """ + agent_to_server_test_request = thousandeyes_sdk.tests.models.AgentToServerTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.create_agent_to_server_test( + + agent_to_server_test_request=agent_to_server_test_request, + + aid=aid, + + _headers=self.te_headers("create_agent_to_server_test", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_agent_to_server_test_error_429(self) -> None: + """Integration test for create_agent_to_server_test error path (HTTP 429)""" + request_body_json = """ + + { + "server" : "www.thousandeyes.com:80", + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ "344753", "212697" ], + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "type" : "agent-to-server", + "usePublicBgp" : true, + "enabled" : true, + "dscpId" : "0", + "fixedPacketRate" : 25, + "protocol" : "tcp", + "dscp" : "Best Effort (DSCP 0)", + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : false, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "port" : 443, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "pingPayloadSize" : 112, + "sharedWithAccounts" : [ "1234", "12345" ], + "continuousMode" : false, + "monitors" : [ "17410", "5" ] + } + + """ + agent_to_server_test_request = thousandeyes_sdk.tests.models.AgentToServerTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.create_agent_to_server_test( + + agent_to_server_test_request=agent_to_server_test_request, + + aid=aid, + + _headers=self.te_headers("create_agent_to_server_test", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_agent_to_server_test_error_500(self) -> None: + """Integration test for create_agent_to_server_test error path (HTTP 500)""" + request_body_json = """ + + { + "server" : "www.thousandeyes.com:80", + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ "344753", "212697" ], + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "type" : "agent-to-server", + "usePublicBgp" : true, + "enabled" : true, + "dscpId" : "0", + "fixedPacketRate" : 25, + "protocol" : "tcp", + "dscp" : "Best Effort (DSCP 0)", + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : false, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "port" : 443, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "pingPayloadSize" : 112, + "sharedWithAccounts" : [ "1234", "12345" ], + "continuousMode" : false, + "monitors" : [ "17410", "5" ] + } + + """ + agent_to_server_test_request = thousandeyes_sdk.tests.models.AgentToServerTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.create_agent_to_server_test( + + agent_to_server_test_request=agent_to_server_test_request, + + aid=aid, + + _headers=self.te_headers("create_agent_to_server_test", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_agent_to_server_test_error_502(self) -> None: + """Integration test for create_agent_to_server_test error path (HTTP 502)""" + request_body_json = """ + + { + "server" : "www.thousandeyes.com:80", + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ "344753", "212697" ], + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "type" : "agent-to-server", + "usePublicBgp" : true, + "enabled" : true, + "dscpId" : "0", + "fixedPacketRate" : 25, + "protocol" : "tcp", + "dscp" : "Best Effort (DSCP 0)", + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : false, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "port" : 443, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "pingPayloadSize" : 112, + "sharedWithAccounts" : [ "1234", "12345" ], + "continuousMode" : false, + "monitors" : [ "17410", "5" ] + } + + """ + agent_to_server_test_request = thousandeyes_sdk.tests.models.AgentToServerTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.create_agent_to_server_test( + + agent_to_server_test_request=agent_to_server_test_request, + + aid=aid, + + _headers=self.te_headers("create_agent_to_server_test", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_delete_agent_to_server_test_happy_path(self) -> None: + """Integration test for delete_agent_to_server_test success path""" + test_id = '202701' + aid = '1234' + response = self.api.delete_agent_to_server_test_with_http_info( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_agent_to_server_test"), + ) + self.assertEqual(204, response.status_code) + self.assertIsNone(response.data) + + + def test_delete_agent_to_server_test_error_401(self) -> None: + """Integration test for delete_agent_to_server_test error path (HTTP 401)""" + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.delete_agent_to_server_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_agent_to_server_test", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_agent_to_server_test_error_403(self) -> None: + """Integration test for delete_agent_to_server_test error path (HTTP 403)""" + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.delete_agent_to_server_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_agent_to_server_test", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_agent_to_server_test_error_404(self) -> None: + """Integration test for delete_agent_to_server_test error path (HTTP 404)""" + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.delete_agent_to_server_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_agent_to_server_test", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_agent_to_server_test_error_429(self) -> None: + """Integration test for delete_agent_to_server_test error path (HTTP 429)""" + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.delete_agent_to_server_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_agent_to_server_test", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_agent_to_server_test_error_500(self) -> None: + """Integration test for delete_agent_to_server_test error path (HTTP 500)""" + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.delete_agent_to_server_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_agent_to_server_test", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_agent_to_server_test_error_502(self) -> None: + """Integration test for delete_agent_to_server_test error path (HTTP 502)""" + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.delete_agent_to_server_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_agent_to_server_test", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_agent_to_server_test_happy_path(self) -> None: + """Integration test for get_agent_to_server_test success path""" + test_id = '202701' + aid = '1234' + version_id = '1234' + response_body_json = """ + { + "server" : "www.thousandeyes.com:80", + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + }, { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + } ], + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "type" : "agent-to-server", + "usePublicBgp" : true, + "enabled" : true, + "dscpId" : "0", + "fixedPacketRate" : 25, + "protocol" : "tcp", + "dscp" : "Best Effort (DSCP 0)", + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : false, + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "pingPayloadSize" : 112, + "continuousMode" : false, + "monitors" : [ { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + }, { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + } ] + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_agent_to_server_test( + + test_id=test_id, + + aid=aid, + + version_id=version_id, + + _headers=self.te_headers("get_agent_to_server_test"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_agent_to_server_test_error_401(self) -> None: + """Integration test for get_agent_to_server_test error path (HTTP 401)""" + test_id = '202701' + aid = '1234' + version_id = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_agent_to_server_test( + + test_id=test_id, + + aid=aid, + + version_id=version_id, + + _headers=self.te_headers("get_agent_to_server_test", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_agent_to_server_test_error_403(self) -> None: + """Integration test for get_agent_to_server_test error path (HTTP 403)""" + test_id = '202701' + aid = '1234' + version_id = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_agent_to_server_test( + + test_id=test_id, + + aid=aid, + + version_id=version_id, + + _headers=self.te_headers("get_agent_to_server_test", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_agent_to_server_test_error_404(self) -> None: + """Integration test for get_agent_to_server_test error path (HTTP 404)""" + test_id = '202701' + aid = '1234' + version_id = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_agent_to_server_test( + + test_id=test_id, + + aid=aid, + + version_id=version_id, + + _headers=self.te_headers("get_agent_to_server_test", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_agent_to_server_test_error_429(self) -> None: + """Integration test for get_agent_to_server_test error path (HTTP 429)""" + test_id = '202701' + aid = '1234' + version_id = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_agent_to_server_test( + + test_id=test_id, + + aid=aid, + + version_id=version_id, + + _headers=self.te_headers("get_agent_to_server_test", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_agent_to_server_test_error_500(self) -> None: + """Integration test for get_agent_to_server_test error path (HTTP 500)""" + test_id = '202701' + aid = '1234' + version_id = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_agent_to_server_test( + + test_id=test_id, + + aid=aid, + + version_id=version_id, + + _headers=self.te_headers("get_agent_to_server_test", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_agent_to_server_test_error_502(self) -> None: + """Integration test for get_agent_to_server_test error path (HTTP 502)""" + test_id = '202701' + aid = '1234' + version_id = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.get_agent_to_server_test( + + test_id=test_id, + + aid=aid, + + version_id=version_id, + + _headers=self.te_headers("get_agent_to_server_test", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_agent_to_server_tests_happy_path(self) -> None: + """Integration test for get_agent_to_server_tests success path""" + aid = '1234' + response_body_json = """ + { + "tests" : [ { + "server" : "www.thousandeyes.com:80", + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "type" : "agent-to-server", + "usePublicBgp" : true, + "enabled" : true, + "dscpId" : "0", + "fixedPacketRate" : 25, + "protocol" : "tcp", + "dscp" : "Best Effort (DSCP 0)", + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : false, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "pingPayloadSize" : 112, + "continuousMode" : false + }, { + "server" : "www.thousandeyes.com:80", + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "type" : "agent-to-server", + "usePublicBgp" : true, + "enabled" : true, + "dscpId" : "0", + "fixedPacketRate" : 25, + "protocol" : "tcp", + "dscp" : "Best Effort (DSCP 0)", + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : false, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "pingPayloadSize" : 112, + "continuousMode" : false + } ], + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_agent_to_server_tests( + + aid=aid, + + _headers=self.te_headers("get_agent_to_server_tests"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_agent_to_server_tests_error_401(self) -> None: + """Integration test for get_agent_to_server_tests error path (HTTP 401)""" + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_agent_to_server_tests( + + aid=aid, + + _headers=self.te_headers("get_agent_to_server_tests", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_agent_to_server_tests_error_403(self) -> None: + """Integration test for get_agent_to_server_tests error path (HTTP 403)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_agent_to_server_tests( + + aid=aid, + + _headers=self.te_headers("get_agent_to_server_tests", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_agent_to_server_tests_error_404(self) -> None: + """Integration test for get_agent_to_server_tests error path (HTTP 404)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_agent_to_server_tests( + + aid=aid, + + _headers=self.te_headers("get_agent_to_server_tests", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_agent_to_server_tests_error_429(self) -> None: + """Integration test for get_agent_to_server_tests error path (HTTP 429)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_agent_to_server_tests( + + aid=aid, + + _headers=self.te_headers("get_agent_to_server_tests", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_agent_to_server_tests_error_500(self) -> None: + """Integration test for get_agent_to_server_tests error path (HTTP 500)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_agent_to_server_tests( + + aid=aid, + + _headers=self.te_headers("get_agent_to_server_tests", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_agent_to_server_tests_error_502(self) -> None: + """Integration test for get_agent_to_server_tests error path (HTTP 502)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.get_agent_to_server_tests( + + aid=aid, + + _headers=self.te_headers("get_agent_to_server_tests", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_update_agent_to_server_test_happy_path(self) -> None: + """Integration test for update_agent_to_server_test success path""" + request_body_json = """ + + { + "server" : "www.thousandeyes.com:80", + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "alertRules" : [ "344753", "212697" ], + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "usePublicBgp" : true, + "enabled" : true, + "dscpId" : "0", + "fixedPacketRate" : 25, + "protocol" : "tcp", + "dscp" : "Best Effort (DSCP 0)", + "pathTraceMode" : "classic", + "alertsEnabled" : true, + "testName" : "Test name", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "networkMeasurements" : false, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "randomizedStartTime" : false, + "port" : 443, + "interval" : 60, + "sharedWithAccounts" : [ "1234", "12345" ], + "pingPayloadSize" : 112, + "continuousMode" : false, + "monitors" : [ "17410", "5" ] + } + + """ + update_agent_to_server_test_request = thousandeyes_sdk.tests.models.UpdateAgentToServerTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + response_body_json = """ + { + "server" : "www.thousandeyes.com:80", + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + }, { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + } ], + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "type" : "agent-to-server", + "usePublicBgp" : true, + "enabled" : true, + "dscpId" : "0", + "fixedPacketRate" : 25, + "protocol" : "tcp", + "dscp" : "Best Effort (DSCP 0)", + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : false, + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "pingPayloadSize" : 112, + "continuousMode" : false, + "monitors" : [ { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + }, { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + } ] + } + """ + expected_response = json.loads(response_body_json) + response = self.api.update_agent_to_server_test( + + test_id=test_id, + + update_agent_to_server_test_request=update_agent_to_server_test_request, + + aid=aid, + + _headers=self.te_headers("update_agent_to_server_test"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_update_agent_to_server_test_error_400(self) -> None: + """Integration test for update_agent_to_server_test error path (HTTP 400)""" + request_body_json = """ + + { + "server" : "www.thousandeyes.com:80", + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "alertRules" : [ "344753", "212697" ], + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "usePublicBgp" : true, + "enabled" : true, + "dscpId" : "0", + "fixedPacketRate" : 25, + "protocol" : "tcp", + "dscp" : "Best Effort (DSCP 0)", + "pathTraceMode" : "classic", + "alertsEnabled" : true, + "testName" : "Test name", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "networkMeasurements" : false, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "randomizedStartTime" : false, + "port" : 443, + "interval" : 60, + "sharedWithAccounts" : [ "1234", "12345" ], + "pingPayloadSize" : 112, + "continuousMode" : false, + "monitors" : [ "17410", "5" ] + } + + """ + update_agent_to_server_test_request = thousandeyes_sdk.tests.models.UpdateAgentToServerTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.update_agent_to_server_test( + + test_id=test_id, + + update_agent_to_server_test_request=update_agent_to_server_test_request, + + aid=aid, + + _headers=self.te_headers("update_agent_to_server_test", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_agent_to_server_test_error_401(self) -> None: + """Integration test for update_agent_to_server_test error path (HTTP 401)""" + request_body_json = """ + + { + "server" : "www.thousandeyes.com:80", + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "alertRules" : [ "344753", "212697" ], + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "usePublicBgp" : true, + "enabled" : true, + "dscpId" : "0", + "fixedPacketRate" : 25, + "protocol" : "tcp", + "dscp" : "Best Effort (DSCP 0)", + "pathTraceMode" : "classic", + "alertsEnabled" : true, + "testName" : "Test name", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "networkMeasurements" : false, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "randomizedStartTime" : false, + "port" : 443, + "interval" : 60, + "sharedWithAccounts" : [ "1234", "12345" ], + "pingPayloadSize" : 112, + "continuousMode" : false, + "monitors" : [ "17410", "5" ] + } + + """ + update_agent_to_server_test_request = thousandeyes_sdk.tests.models.UpdateAgentToServerTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.update_agent_to_server_test( + + test_id=test_id, + + update_agent_to_server_test_request=update_agent_to_server_test_request, + + aid=aid, + + _headers=self.te_headers("update_agent_to_server_test", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_agent_to_server_test_error_403(self) -> None: + """Integration test for update_agent_to_server_test error path (HTTP 403)""" + request_body_json = """ + + { + "server" : "www.thousandeyes.com:80", + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "alertRules" : [ "344753", "212697" ], + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "usePublicBgp" : true, + "enabled" : true, + "dscpId" : "0", + "fixedPacketRate" : 25, + "protocol" : "tcp", + "dscp" : "Best Effort (DSCP 0)", + "pathTraceMode" : "classic", + "alertsEnabled" : true, + "testName" : "Test name", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "networkMeasurements" : false, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "randomizedStartTime" : false, + "port" : 443, + "interval" : 60, + "sharedWithAccounts" : [ "1234", "12345" ], + "pingPayloadSize" : 112, + "continuousMode" : false, + "monitors" : [ "17410", "5" ] + } + + """ + update_agent_to_server_test_request = thousandeyes_sdk.tests.models.UpdateAgentToServerTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.update_agent_to_server_test( + + test_id=test_id, + + update_agent_to_server_test_request=update_agent_to_server_test_request, + + aid=aid, + + _headers=self.te_headers("update_agent_to_server_test", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_agent_to_server_test_error_404(self) -> None: + """Integration test for update_agent_to_server_test error path (HTTP 404)""" + request_body_json = """ + + { + "server" : "www.thousandeyes.com:80", + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "alertRules" : [ "344753", "212697" ], + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "usePublicBgp" : true, + "enabled" : true, + "dscpId" : "0", + "fixedPacketRate" : 25, + "protocol" : "tcp", + "dscp" : "Best Effort (DSCP 0)", + "pathTraceMode" : "classic", + "alertsEnabled" : true, + "testName" : "Test name", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "networkMeasurements" : false, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "randomizedStartTime" : false, + "port" : 443, + "interval" : 60, + "sharedWithAccounts" : [ "1234", "12345" ], + "pingPayloadSize" : 112, + "continuousMode" : false, + "monitors" : [ "17410", "5" ] + } + + """ + update_agent_to_server_test_request = thousandeyes_sdk.tests.models.UpdateAgentToServerTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.update_agent_to_server_test( + + test_id=test_id, + + update_agent_to_server_test_request=update_agent_to_server_test_request, + + aid=aid, + + _headers=self.te_headers("update_agent_to_server_test", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_agent_to_server_test_error_429(self) -> None: + """Integration test for update_agent_to_server_test error path (HTTP 429)""" + request_body_json = """ + + { + "server" : "www.thousandeyes.com:80", + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "alertRules" : [ "344753", "212697" ], + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "usePublicBgp" : true, + "enabled" : true, + "dscpId" : "0", + "fixedPacketRate" : 25, + "protocol" : "tcp", + "dscp" : "Best Effort (DSCP 0)", + "pathTraceMode" : "classic", + "alertsEnabled" : true, + "testName" : "Test name", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "networkMeasurements" : false, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "randomizedStartTime" : false, + "port" : 443, + "interval" : 60, + "sharedWithAccounts" : [ "1234", "12345" ], + "pingPayloadSize" : 112, + "continuousMode" : false, + "monitors" : [ "17410", "5" ] + } + + """ + update_agent_to_server_test_request = thousandeyes_sdk.tests.models.UpdateAgentToServerTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.update_agent_to_server_test( + + test_id=test_id, + + update_agent_to_server_test_request=update_agent_to_server_test_request, + + aid=aid, + + _headers=self.te_headers("update_agent_to_server_test", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_agent_to_server_test_error_500(self) -> None: + """Integration test for update_agent_to_server_test error path (HTTP 500)""" + request_body_json = """ + + { + "server" : "www.thousandeyes.com:80", + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "alertRules" : [ "344753", "212697" ], + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "usePublicBgp" : true, + "enabled" : true, + "dscpId" : "0", + "fixedPacketRate" : 25, + "protocol" : "tcp", + "dscp" : "Best Effort (DSCP 0)", + "pathTraceMode" : "classic", + "alertsEnabled" : true, + "testName" : "Test name", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "networkMeasurements" : false, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "randomizedStartTime" : false, + "port" : 443, + "interval" : 60, + "sharedWithAccounts" : [ "1234", "12345" ], + "pingPayloadSize" : 112, + "continuousMode" : false, + "monitors" : [ "17410", "5" ] + } + + """ + update_agent_to_server_test_request = thousandeyes_sdk.tests.models.UpdateAgentToServerTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.update_agent_to_server_test( + + test_id=test_id, + + update_agent_to_server_test_request=update_agent_to_server_test_request, + + aid=aid, + + _headers=self.te_headers("update_agent_to_server_test", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_agent_to_server_test_error_502(self) -> None: + """Integration test for update_agent_to_server_test error path (HTTP 502)""" + request_body_json = """ + + { + "server" : "www.thousandeyes.com:80", + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "alertRules" : [ "344753", "212697" ], + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "usePublicBgp" : true, + "enabled" : true, + "dscpId" : "0", + "fixedPacketRate" : 25, + "protocol" : "tcp", + "dscp" : "Best Effort (DSCP 0)", + "pathTraceMode" : "classic", + "alertsEnabled" : true, + "testName" : "Test name", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "networkMeasurements" : false, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "randomizedStartTime" : false, + "port" : 443, + "interval" : 60, + "sharedWithAccounts" : [ "1234", "12345" ], + "pingPayloadSize" : 112, + "continuousMode" : false, + "monitors" : [ "17410", "5" ] + } + + """ + update_agent_to_server_test_request = thousandeyes_sdk.tests.models.UpdateAgentToServerTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.update_agent_to_server_test( + + test_id=test_id, + + update_agent_to_server_test_request=update_agent_to_server_test_request, + + aid=aid, + + _headers=self.te_headers("update_agent_to_server_test", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-tests/test/test_api_tests_api_integration.py b/thousandeyes-sdk-tests/test/test_api_tests_api_integration.py new file mode 100644 index 00000000..2ff5379d --- /dev/null +++ b/thousandeyes-sdk-tests/test/test_api_tests_api_integration.py @@ -0,0 +1,4753 @@ +# coding: utf-8 + +""" + Tests API + + **Note:** The Page Load Tests, API Tests, and Web Transaction Tests APIs are not available for ThousandEyes for Government instance. This API allows you to list, create, edit, and delete Network and Application Synthetics tests. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.tests.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.tests.api.api_tests_api import APITestsApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestAPITestsApiIntegration(IntegrationTestBase): + """APITestsApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = APITestsApi(self.api_client) + + + def test_create_api_test_happy_path(self) -> None: + """Integration test for create_api_test success path""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "credentials" : [ "3247", "1051" ], + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "requests" : [ { + "headers" : [ { + "value" : "keep-alive", + "key" : "x-custom-header" + }, { + "value" : "keep-alive", + "key" : "x-custom-header" + } ], + "variables" : [ { + "name" : "myTestName", + "value" : "tests[0].name" + }, { + "name" : "myTestName", + "value" : "tests[0].name" + } ], + "clientId" : "client-id", + "tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token", + "method" : "get", + "verifyCertificate" : false, + "body" : "body", + "url" : "https://api.thousandeyes.com/v7/status", + "password" : "basic_pw123", + "bearerToken" : "abcd-1234-...", + "scope" : "read, write, deploy", + "name" : "Step 1", + "waitTimeMs" : 0, + "clientAuthentication" : "basic-auth-header", + "clientSecret" : "client-secret", + "assertions" : [ { + "name" : "status-code", + "value" : "200", + "operator" : "is" + }, { + "name" : "status-code", + "value" : "200", + "operator" : "is" + } ], + "authType" : "none", + "collectApiResponse" : true, + "username" : "ThousandEyesUserName" + }, { + "headers" : [ { + "value" : "keep-alive", + "key" : "x-custom-header" + }, { + "value" : "keep-alive", + "key" : "x-custom-header" + } ], + "variables" : [ { + "name" : "myTestName", + "value" : "tests[0].name" + }, { + "name" : "myTestName", + "value" : "tests[0].name" + } ], + "clientId" : "client-id", + "tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token", + "method" : "get", + "verifyCertificate" : false, + "body" : "body", + "url" : "https://api.thousandeyes.com/v7/status", + "password" : "basic_pw123", + "bearerToken" : "abcd-1234-...", + "scope" : "read, write, deploy", + "name" : "Step 1", + "waitTimeMs" : 0, + "clientAuthentication" : "basic-auth-header", + "clientSecret" : "client-secret", + "assertions" : [ { + "name" : "status-code", + "value" : "200", + "operator" : "is" + }, { + "name" : "status-code", + "value" : "200", + "operator" : "is" + } ], + "authType" : "none", + "collectApiResponse" : true, + "username" : "ThousandEyesUserName" + } ], + "type" : "api", + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "protocol" : "tcp", + "collectProxyNetworkData" : false, + "followRedirects" : true, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "clientCertDomainsAllowList" : "www.thousandeyes.com", + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "overrideAgentProxy" : false, + "predefinedVariables" : [ { + "name" : "myUsername", + "value" : "ThousandEyesAccountUserName" + }, { + "name" : "myUsername", + "value" : "ThousandEyesAccountUserName" + } ], + "liveShare" : false, + "distributedTracing" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "timeLimit" : 19, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "sslVersionId" : "0", + "targetTime" : 1, + "monitors" : [ "17410", "5" ] + } + + """ + api_test_request = thousandeyes_sdk.tests.models.ApiTestRequest.from_json(request_body_json) + aid = '1234' + response_body_json = """ + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "credentials" : [ "3247", "1051" ], + "alertRules" : [ { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + }, { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + } ], + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "requests" : [ { + "headers" : [ { + "value" : "keep-alive", + "key" : "x-custom-header" + }, { + "value" : "keep-alive", + "key" : "x-custom-header" + } ], + "variables" : [ { + "name" : "myTestName", + "value" : "tests[0].name" + }, { + "name" : "myTestName", + "value" : "tests[0].name" + } ], + "clientId" : "client-id", + "tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token", + "method" : "get", + "verifyCertificate" : false, + "body" : "body", + "url" : "https://api.thousandeyes.com/v7/status", + "password" : "basic_pw123", + "bearerToken" : "abcd-1234-...", + "scope" : "read, write, deploy", + "name" : "Step 1", + "waitTimeMs" : 0, + "clientAuthentication" : "basic-auth-header", + "clientSecret" : "client-secret", + "assertions" : [ { + "name" : "status-code", + "value" : "200", + "operator" : "is" + }, { + "name" : "status-code", + "value" : "200", + "operator" : "is" + } ], + "authType" : "none", + "collectApiResponse" : true, + "username" : "ThousandEyesUserName" + }, { + "headers" : [ { + "value" : "keep-alive", + "key" : "x-custom-header" + }, { + "value" : "keep-alive", + "key" : "x-custom-header" + } ], + "variables" : [ { + "name" : "myTestName", + "value" : "tests[0].name" + }, { + "name" : "myTestName", + "value" : "tests[0].name" + } ], + "clientId" : "client-id", + "tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token", + "method" : "get", + "verifyCertificate" : false, + "body" : "body", + "url" : "https://api.thousandeyes.com/v7/status", + "password" : "basic_pw123", + "bearerToken" : "abcd-1234-...", + "scope" : "read, write, deploy", + "name" : "Step 1", + "waitTimeMs" : 0, + "clientAuthentication" : "basic-auth-header", + "clientSecret" : "client-secret", + "assertions" : [ { + "name" : "status-code", + "value" : "200", + "operator" : "is" + }, { + "name" : "status-code", + "value" : "200", + "operator" : "is" + } ], + "authType" : "none", + "collectApiResponse" : true, + "username" : "ThousandEyesUserName" + } ], + "type" : "api", + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "protocol" : "tcp", + "collectProxyNetworkData" : false, + "followRedirects" : true, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "clientCertDomainsAllowList" : "www.thousandeyes.com", + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "overrideAgentProxy" : false, + "predefinedVariables" : [ { + "name" : "myUsername", + "value" : "ThousandEyesAccountUserName" + }, { + "name" : "myUsername", + "value" : "ThousandEyesAccountUserName" + } ], + "liveShare" : false, + "distributedTracing" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "timeLimit" : 19, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "overrideProxyId" : "281474976710706", + "sslVersionId" : "0", + "targetTime" : 1, + "monitors" : [ { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + }, { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + } ] + } + """ + expected_response = json.loads(response_body_json) + response = self.api.create_api_test( + + api_test_request=api_test_request, + + aid=aid, + + _headers=self.te_headers("create_api_test"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_create_api_test_error_400(self) -> None: + """Integration test for create_api_test error path (HTTP 400)""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "credentials" : [ "3247", "1051" ], + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "requests" : [ { + "headers" : [ { + "value" : "keep-alive", + "key" : "x-custom-header" + }, { + "value" : "keep-alive", + "key" : "x-custom-header" + } ], + "variables" : [ { + "name" : "myTestName", + "value" : "tests[0].name" + }, { + "name" : "myTestName", + "value" : "tests[0].name" + } ], + "clientId" : "client-id", + "tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token", + "method" : "get", + "verifyCertificate" : false, + "body" : "body", + "url" : "https://api.thousandeyes.com/v7/status", + "password" : "basic_pw123", + "bearerToken" : "abcd-1234-...", + "scope" : "read, write, deploy", + "name" : "Step 1", + "waitTimeMs" : 0, + "clientAuthentication" : "basic-auth-header", + "clientSecret" : "client-secret", + "assertions" : [ { + "name" : "status-code", + "value" : "200", + "operator" : "is" + }, { + "name" : "status-code", + "value" : "200", + "operator" : "is" + } ], + "authType" : "none", + "collectApiResponse" : true, + "username" : "ThousandEyesUserName" + }, { + "headers" : [ { + "value" : "keep-alive", + "key" : "x-custom-header" + }, { + "value" : "keep-alive", + "key" : "x-custom-header" + } ], + "variables" : [ { + "name" : "myTestName", + "value" : "tests[0].name" + }, { + "name" : "myTestName", + "value" : "tests[0].name" + } ], + "clientId" : "client-id", + "tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token", + "method" : "get", + "verifyCertificate" : false, + "body" : "body", + "url" : "https://api.thousandeyes.com/v7/status", + "password" : "basic_pw123", + "bearerToken" : "abcd-1234-...", + "scope" : "read, write, deploy", + "name" : "Step 1", + "waitTimeMs" : 0, + "clientAuthentication" : "basic-auth-header", + "clientSecret" : "client-secret", + "assertions" : [ { + "name" : "status-code", + "value" : "200", + "operator" : "is" + }, { + "name" : "status-code", + "value" : "200", + "operator" : "is" + } ], + "authType" : "none", + "collectApiResponse" : true, + "username" : "ThousandEyesUserName" + } ], + "type" : "api", + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "protocol" : "tcp", + "collectProxyNetworkData" : false, + "followRedirects" : true, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "clientCertDomainsAllowList" : "www.thousandeyes.com", + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "overrideAgentProxy" : false, + "predefinedVariables" : [ { + "name" : "myUsername", + "value" : "ThousandEyesAccountUserName" + }, { + "name" : "myUsername", + "value" : "ThousandEyesAccountUserName" + } ], + "liveShare" : false, + "distributedTracing" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "timeLimit" : 19, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "sslVersionId" : "0", + "targetTime" : 1, + "monitors" : [ "17410", "5" ] + } + + """ + api_test_request = thousandeyes_sdk.tests.models.ApiTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.create_api_test( + + api_test_request=api_test_request, + + aid=aid, + + _headers=self.te_headers("create_api_test", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_api_test_error_401(self) -> None: + """Integration test for create_api_test error path (HTTP 401)""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "credentials" : [ "3247", "1051" ], + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "requests" : [ { + "headers" : [ { + "value" : "keep-alive", + "key" : "x-custom-header" + }, { + "value" : "keep-alive", + "key" : "x-custom-header" + } ], + "variables" : [ { + "name" : "myTestName", + "value" : "tests[0].name" + }, { + "name" : "myTestName", + "value" : "tests[0].name" + } ], + "clientId" : "client-id", + "tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token", + "method" : "get", + "verifyCertificate" : false, + "body" : "body", + "url" : "https://api.thousandeyes.com/v7/status", + "password" : "basic_pw123", + "bearerToken" : "abcd-1234-...", + "scope" : "read, write, deploy", + "name" : "Step 1", + "waitTimeMs" : 0, + "clientAuthentication" : "basic-auth-header", + "clientSecret" : "client-secret", + "assertions" : [ { + "name" : "status-code", + "value" : "200", + "operator" : "is" + }, { + "name" : "status-code", + "value" : "200", + "operator" : "is" + } ], + "authType" : "none", + "collectApiResponse" : true, + "username" : "ThousandEyesUserName" + }, { + "headers" : [ { + "value" : "keep-alive", + "key" : "x-custom-header" + }, { + "value" : "keep-alive", + "key" : "x-custom-header" + } ], + "variables" : [ { + "name" : "myTestName", + "value" : "tests[0].name" + }, { + "name" : "myTestName", + "value" : "tests[0].name" + } ], + "clientId" : "client-id", + "tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token", + "method" : "get", + "verifyCertificate" : false, + "body" : "body", + "url" : "https://api.thousandeyes.com/v7/status", + "password" : "basic_pw123", + "bearerToken" : "abcd-1234-...", + "scope" : "read, write, deploy", + "name" : "Step 1", + "waitTimeMs" : 0, + "clientAuthentication" : "basic-auth-header", + "clientSecret" : "client-secret", + "assertions" : [ { + "name" : "status-code", + "value" : "200", + "operator" : "is" + }, { + "name" : "status-code", + "value" : "200", + "operator" : "is" + } ], + "authType" : "none", + "collectApiResponse" : true, + "username" : "ThousandEyesUserName" + } ], + "type" : "api", + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "protocol" : "tcp", + "collectProxyNetworkData" : false, + "followRedirects" : true, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "clientCertDomainsAllowList" : "www.thousandeyes.com", + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "overrideAgentProxy" : false, + "predefinedVariables" : [ { + "name" : "myUsername", + "value" : "ThousandEyesAccountUserName" + }, { + "name" : "myUsername", + "value" : "ThousandEyesAccountUserName" + } ], + "liveShare" : false, + "distributedTracing" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "timeLimit" : 19, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "sslVersionId" : "0", + "targetTime" : 1, + "monitors" : [ "17410", "5" ] + } + + """ + api_test_request = thousandeyes_sdk.tests.models.ApiTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.create_api_test( + + api_test_request=api_test_request, + + aid=aid, + + _headers=self.te_headers("create_api_test", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_api_test_error_403(self) -> None: + """Integration test for create_api_test error path (HTTP 403)""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "credentials" : [ "3247", "1051" ], + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "requests" : [ { + "headers" : [ { + "value" : "keep-alive", + "key" : "x-custom-header" + }, { + "value" : "keep-alive", + "key" : "x-custom-header" + } ], + "variables" : [ { + "name" : "myTestName", + "value" : "tests[0].name" + }, { + "name" : "myTestName", + "value" : "tests[0].name" + } ], + "clientId" : "client-id", + "tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token", + "method" : "get", + "verifyCertificate" : false, + "body" : "body", + "url" : "https://api.thousandeyes.com/v7/status", + "password" : "basic_pw123", + "bearerToken" : "abcd-1234-...", + "scope" : "read, write, deploy", + "name" : "Step 1", + "waitTimeMs" : 0, + "clientAuthentication" : "basic-auth-header", + "clientSecret" : "client-secret", + "assertions" : [ { + "name" : "status-code", + "value" : "200", + "operator" : "is" + }, { + "name" : "status-code", + "value" : "200", + "operator" : "is" + } ], + "authType" : "none", + "collectApiResponse" : true, + "username" : "ThousandEyesUserName" + }, { + "headers" : [ { + "value" : "keep-alive", + "key" : "x-custom-header" + }, { + "value" : "keep-alive", + "key" : "x-custom-header" + } ], + "variables" : [ { + "name" : "myTestName", + "value" : "tests[0].name" + }, { + "name" : "myTestName", + "value" : "tests[0].name" + } ], + "clientId" : "client-id", + "tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token", + "method" : "get", + "verifyCertificate" : false, + "body" : "body", + "url" : "https://api.thousandeyes.com/v7/status", + "password" : "basic_pw123", + "bearerToken" : "abcd-1234-...", + "scope" : "read, write, deploy", + "name" : "Step 1", + "waitTimeMs" : 0, + "clientAuthentication" : "basic-auth-header", + "clientSecret" : "client-secret", + "assertions" : [ { + "name" : "status-code", + "value" : "200", + "operator" : "is" + }, { + "name" : "status-code", + "value" : "200", + "operator" : "is" + } ], + "authType" : "none", + "collectApiResponse" : true, + "username" : "ThousandEyesUserName" + } ], + "type" : "api", + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "protocol" : "tcp", + "collectProxyNetworkData" : false, + "followRedirects" : true, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "clientCertDomainsAllowList" : "www.thousandeyes.com", + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "overrideAgentProxy" : false, + "predefinedVariables" : [ { + "name" : "myUsername", + "value" : "ThousandEyesAccountUserName" + }, { + "name" : "myUsername", + "value" : "ThousandEyesAccountUserName" + } ], + "liveShare" : false, + "distributedTracing" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "timeLimit" : 19, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "sslVersionId" : "0", + "targetTime" : 1, + "monitors" : [ "17410", "5" ] + } + + """ + api_test_request = thousandeyes_sdk.tests.models.ApiTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.create_api_test( + + api_test_request=api_test_request, + + aid=aid, + + _headers=self.te_headers("create_api_test", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_api_test_error_404(self) -> None: + """Integration test for create_api_test error path (HTTP 404)""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "credentials" : [ "3247", "1051" ], + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "requests" : [ { + "headers" : [ { + "value" : "keep-alive", + "key" : "x-custom-header" + }, { + "value" : "keep-alive", + "key" : "x-custom-header" + } ], + "variables" : [ { + "name" : "myTestName", + "value" : "tests[0].name" + }, { + "name" : "myTestName", + "value" : "tests[0].name" + } ], + "clientId" : "client-id", + "tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token", + "method" : "get", + "verifyCertificate" : false, + "body" : "body", + "url" : "https://api.thousandeyes.com/v7/status", + "password" : "basic_pw123", + "bearerToken" : "abcd-1234-...", + "scope" : "read, write, deploy", + "name" : "Step 1", + "waitTimeMs" : 0, + "clientAuthentication" : "basic-auth-header", + "clientSecret" : "client-secret", + "assertions" : [ { + "name" : "status-code", + "value" : "200", + "operator" : "is" + }, { + "name" : "status-code", + "value" : "200", + "operator" : "is" + } ], + "authType" : "none", + "collectApiResponse" : true, + "username" : "ThousandEyesUserName" + }, { + "headers" : [ { + "value" : "keep-alive", + "key" : "x-custom-header" + }, { + "value" : "keep-alive", + "key" : "x-custom-header" + } ], + "variables" : [ { + "name" : "myTestName", + "value" : "tests[0].name" + }, { + "name" : "myTestName", + "value" : "tests[0].name" + } ], + "clientId" : "client-id", + "tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token", + "method" : "get", + "verifyCertificate" : false, + "body" : "body", + "url" : "https://api.thousandeyes.com/v7/status", + "password" : "basic_pw123", + "bearerToken" : "abcd-1234-...", + "scope" : "read, write, deploy", + "name" : "Step 1", + "waitTimeMs" : 0, + "clientAuthentication" : "basic-auth-header", + "clientSecret" : "client-secret", + "assertions" : [ { + "name" : "status-code", + "value" : "200", + "operator" : "is" + }, { + "name" : "status-code", + "value" : "200", + "operator" : "is" + } ], + "authType" : "none", + "collectApiResponse" : true, + "username" : "ThousandEyesUserName" + } ], + "type" : "api", + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "protocol" : "tcp", + "collectProxyNetworkData" : false, + "followRedirects" : true, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "clientCertDomainsAllowList" : "www.thousandeyes.com", + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "overrideAgentProxy" : false, + "predefinedVariables" : [ { + "name" : "myUsername", + "value" : "ThousandEyesAccountUserName" + }, { + "name" : "myUsername", + "value" : "ThousandEyesAccountUserName" + } ], + "liveShare" : false, + "distributedTracing" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "timeLimit" : 19, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "sslVersionId" : "0", + "targetTime" : 1, + "monitors" : [ "17410", "5" ] + } + + """ + api_test_request = thousandeyes_sdk.tests.models.ApiTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.create_api_test( + + api_test_request=api_test_request, + + aid=aid, + + _headers=self.te_headers("create_api_test", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_api_test_error_429(self) -> None: + """Integration test for create_api_test error path (HTTP 429)""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "credentials" : [ "3247", "1051" ], + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "requests" : [ { + "headers" : [ { + "value" : "keep-alive", + "key" : "x-custom-header" + }, { + "value" : "keep-alive", + "key" : "x-custom-header" + } ], + "variables" : [ { + "name" : "myTestName", + "value" : "tests[0].name" + }, { + "name" : "myTestName", + "value" : "tests[0].name" + } ], + "clientId" : "client-id", + "tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token", + "method" : "get", + "verifyCertificate" : false, + "body" : "body", + "url" : "https://api.thousandeyes.com/v7/status", + "password" : "basic_pw123", + "bearerToken" : "abcd-1234-...", + "scope" : "read, write, deploy", + "name" : "Step 1", + "waitTimeMs" : 0, + "clientAuthentication" : "basic-auth-header", + "clientSecret" : "client-secret", + "assertions" : [ { + "name" : "status-code", + "value" : "200", + "operator" : "is" + }, { + "name" : "status-code", + "value" : "200", + "operator" : "is" + } ], + "authType" : "none", + "collectApiResponse" : true, + "username" : "ThousandEyesUserName" + }, { + "headers" : [ { + "value" : "keep-alive", + "key" : "x-custom-header" + }, { + "value" : "keep-alive", + "key" : "x-custom-header" + } ], + "variables" : [ { + "name" : "myTestName", + "value" : "tests[0].name" + }, { + "name" : "myTestName", + "value" : "tests[0].name" + } ], + "clientId" : "client-id", + "tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token", + "method" : "get", + "verifyCertificate" : false, + "body" : "body", + "url" : "https://api.thousandeyes.com/v7/status", + "password" : "basic_pw123", + "bearerToken" : "abcd-1234-...", + "scope" : "read, write, deploy", + "name" : "Step 1", + "waitTimeMs" : 0, + "clientAuthentication" : "basic-auth-header", + "clientSecret" : "client-secret", + "assertions" : [ { + "name" : "status-code", + "value" : "200", + "operator" : "is" + }, { + "name" : "status-code", + "value" : "200", + "operator" : "is" + } ], + "authType" : "none", + "collectApiResponse" : true, + "username" : "ThousandEyesUserName" + } ], + "type" : "api", + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "protocol" : "tcp", + "collectProxyNetworkData" : false, + "followRedirects" : true, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "clientCertDomainsAllowList" : "www.thousandeyes.com", + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "overrideAgentProxy" : false, + "predefinedVariables" : [ { + "name" : "myUsername", + "value" : "ThousandEyesAccountUserName" + }, { + "name" : "myUsername", + "value" : "ThousandEyesAccountUserName" + } ], + "liveShare" : false, + "distributedTracing" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "timeLimit" : 19, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "sslVersionId" : "0", + "targetTime" : 1, + "monitors" : [ "17410", "5" ] + } + + """ + api_test_request = thousandeyes_sdk.tests.models.ApiTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.create_api_test( + + api_test_request=api_test_request, + + aid=aid, + + _headers=self.te_headers("create_api_test", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_api_test_error_500(self) -> None: + """Integration test for create_api_test error path (HTTP 500)""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "credentials" : [ "3247", "1051" ], + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "requests" : [ { + "headers" : [ { + "value" : "keep-alive", + "key" : "x-custom-header" + }, { + "value" : "keep-alive", + "key" : "x-custom-header" + } ], + "variables" : [ { + "name" : "myTestName", + "value" : "tests[0].name" + }, { + "name" : "myTestName", + "value" : "tests[0].name" + } ], + "clientId" : "client-id", + "tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token", + "method" : "get", + "verifyCertificate" : false, + "body" : "body", + "url" : "https://api.thousandeyes.com/v7/status", + "password" : "basic_pw123", + "bearerToken" : "abcd-1234-...", + "scope" : "read, write, deploy", + "name" : "Step 1", + "waitTimeMs" : 0, + "clientAuthentication" : "basic-auth-header", + "clientSecret" : "client-secret", + "assertions" : [ { + "name" : "status-code", + "value" : "200", + "operator" : "is" + }, { + "name" : "status-code", + "value" : "200", + "operator" : "is" + } ], + "authType" : "none", + "collectApiResponse" : true, + "username" : "ThousandEyesUserName" + }, { + "headers" : [ { + "value" : "keep-alive", + "key" : "x-custom-header" + }, { + "value" : "keep-alive", + "key" : "x-custom-header" + } ], + "variables" : [ { + "name" : "myTestName", + "value" : "tests[0].name" + }, { + "name" : "myTestName", + "value" : "tests[0].name" + } ], + "clientId" : "client-id", + "tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token", + "method" : "get", + "verifyCertificate" : false, + "body" : "body", + "url" : "https://api.thousandeyes.com/v7/status", + "password" : "basic_pw123", + "bearerToken" : "abcd-1234-...", + "scope" : "read, write, deploy", + "name" : "Step 1", + "waitTimeMs" : 0, + "clientAuthentication" : "basic-auth-header", + "clientSecret" : "client-secret", + "assertions" : [ { + "name" : "status-code", + "value" : "200", + "operator" : "is" + }, { + "name" : "status-code", + "value" : "200", + "operator" : "is" + } ], + "authType" : "none", + "collectApiResponse" : true, + "username" : "ThousandEyesUserName" + } ], + "type" : "api", + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "protocol" : "tcp", + "collectProxyNetworkData" : false, + "followRedirects" : true, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "clientCertDomainsAllowList" : "www.thousandeyes.com", + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "overrideAgentProxy" : false, + "predefinedVariables" : [ { + "name" : "myUsername", + "value" : "ThousandEyesAccountUserName" + }, { + "name" : "myUsername", + "value" : "ThousandEyesAccountUserName" + } ], + "liveShare" : false, + "distributedTracing" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "timeLimit" : 19, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "sslVersionId" : "0", + "targetTime" : 1, + "monitors" : [ "17410", "5" ] + } + + """ + api_test_request = thousandeyes_sdk.tests.models.ApiTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.create_api_test( + + api_test_request=api_test_request, + + aid=aid, + + _headers=self.te_headers("create_api_test", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_api_test_error_502(self) -> None: + """Integration test for create_api_test error path (HTTP 502)""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "credentials" : [ "3247", "1051" ], + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "requests" : [ { + "headers" : [ { + "value" : "keep-alive", + "key" : "x-custom-header" + }, { + "value" : "keep-alive", + "key" : "x-custom-header" + } ], + "variables" : [ { + "name" : "myTestName", + "value" : "tests[0].name" + }, { + "name" : "myTestName", + "value" : "tests[0].name" + } ], + "clientId" : "client-id", + "tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token", + "method" : "get", + "verifyCertificate" : false, + "body" : "body", + "url" : "https://api.thousandeyes.com/v7/status", + "password" : "basic_pw123", + "bearerToken" : "abcd-1234-...", + "scope" : "read, write, deploy", + "name" : "Step 1", + "waitTimeMs" : 0, + "clientAuthentication" : "basic-auth-header", + "clientSecret" : "client-secret", + "assertions" : [ { + "name" : "status-code", + "value" : "200", + "operator" : "is" + }, { + "name" : "status-code", + "value" : "200", + "operator" : "is" + } ], + "authType" : "none", + "collectApiResponse" : true, + "username" : "ThousandEyesUserName" + }, { + "headers" : [ { + "value" : "keep-alive", + "key" : "x-custom-header" + }, { + "value" : "keep-alive", + "key" : "x-custom-header" + } ], + "variables" : [ { + "name" : "myTestName", + "value" : "tests[0].name" + }, { + "name" : "myTestName", + "value" : "tests[0].name" + } ], + "clientId" : "client-id", + "tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token", + "method" : "get", + "verifyCertificate" : false, + "body" : "body", + "url" : "https://api.thousandeyes.com/v7/status", + "password" : "basic_pw123", + "bearerToken" : "abcd-1234-...", + "scope" : "read, write, deploy", + "name" : "Step 1", + "waitTimeMs" : 0, + "clientAuthentication" : "basic-auth-header", + "clientSecret" : "client-secret", + "assertions" : [ { + "name" : "status-code", + "value" : "200", + "operator" : "is" + }, { + "name" : "status-code", + "value" : "200", + "operator" : "is" + } ], + "authType" : "none", + "collectApiResponse" : true, + "username" : "ThousandEyesUserName" + } ], + "type" : "api", + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "protocol" : "tcp", + "collectProxyNetworkData" : false, + "followRedirects" : true, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "clientCertDomainsAllowList" : "www.thousandeyes.com", + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "overrideAgentProxy" : false, + "predefinedVariables" : [ { + "name" : "myUsername", + "value" : "ThousandEyesAccountUserName" + }, { + "name" : "myUsername", + "value" : "ThousandEyesAccountUserName" + } ], + "liveShare" : false, + "distributedTracing" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "timeLimit" : 19, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "sslVersionId" : "0", + "targetTime" : 1, + "monitors" : [ "17410", "5" ] + } + + """ + api_test_request = thousandeyes_sdk.tests.models.ApiTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.create_api_test( + + api_test_request=api_test_request, + + aid=aid, + + _headers=self.te_headers("create_api_test", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_delete_api_test_happy_path(self) -> None: + """Integration test for delete_api_test success path""" + test_id = '202701' + aid = '1234' + response = self.api.delete_api_test_with_http_info( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_api_test"), + ) + self.assertEqual(204, response.status_code) + self.assertIsNone(response.data) + + + def test_delete_api_test_error_401(self) -> None: + """Integration test for delete_api_test error path (HTTP 401)""" + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.delete_api_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_api_test", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_api_test_error_403(self) -> None: + """Integration test for delete_api_test error path (HTTP 403)""" + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.delete_api_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_api_test", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_api_test_error_404(self) -> None: + """Integration test for delete_api_test error path (HTTP 404)""" + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.delete_api_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_api_test", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_api_test_error_429(self) -> None: + """Integration test for delete_api_test error path (HTTP 429)""" + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.delete_api_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_api_test", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_api_test_error_500(self) -> None: + """Integration test for delete_api_test error path (HTTP 500)""" + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.delete_api_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_api_test", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_api_test_error_502(self) -> None: + """Integration test for delete_api_test error path (HTTP 502)""" + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.delete_api_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_api_test", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_api_test_happy_path(self) -> None: + """Integration test for get_api_test success path""" + test_id = '202701' + aid = '1234' + version_id = '1234' + response_body_json = """ + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "credentials" : [ "3247", "1051" ], + "alertRules" : [ { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + }, { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + } ], + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "requests" : [ { + "headers" : [ { + "value" : "keep-alive", + "key" : "x-custom-header" + }, { + "value" : "keep-alive", + "key" : "x-custom-header" + } ], + "variables" : [ { + "name" : "myTestName", + "value" : "tests[0].name" + }, { + "name" : "myTestName", + "value" : "tests[0].name" + } ], + "clientId" : "client-id", + "tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token", + "method" : "get", + "verifyCertificate" : false, + "body" : "body", + "url" : "https://api.thousandeyes.com/v7/status", + "password" : "basic_pw123", + "bearerToken" : "abcd-1234-...", + "scope" : "read, write, deploy", + "name" : "Step 1", + "waitTimeMs" : 0, + "clientAuthentication" : "basic-auth-header", + "clientSecret" : "client-secret", + "assertions" : [ { + "name" : "status-code", + "value" : "200", + "operator" : "is" + }, { + "name" : "status-code", + "value" : "200", + "operator" : "is" + } ], + "authType" : "none", + "collectApiResponse" : true, + "username" : "ThousandEyesUserName" + }, { + "headers" : [ { + "value" : "keep-alive", + "key" : "x-custom-header" + }, { + "value" : "keep-alive", + "key" : "x-custom-header" + } ], + "variables" : [ { + "name" : "myTestName", + "value" : "tests[0].name" + }, { + "name" : "myTestName", + "value" : "tests[0].name" + } ], + "clientId" : "client-id", + "tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token", + "method" : "get", + "verifyCertificate" : false, + "body" : "body", + "url" : "https://api.thousandeyes.com/v7/status", + "password" : "basic_pw123", + "bearerToken" : "abcd-1234-...", + "scope" : "read, write, deploy", + "name" : "Step 1", + "waitTimeMs" : 0, + "clientAuthentication" : "basic-auth-header", + "clientSecret" : "client-secret", + "assertions" : [ { + "name" : "status-code", + "value" : "200", + "operator" : "is" + }, { + "name" : "status-code", + "value" : "200", + "operator" : "is" + } ], + "authType" : "none", + "collectApiResponse" : true, + "username" : "ThousandEyesUserName" + } ], + "type" : "api", + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "protocol" : "tcp", + "collectProxyNetworkData" : false, + "followRedirects" : true, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "clientCertDomainsAllowList" : "www.thousandeyes.com", + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "overrideAgentProxy" : false, + "predefinedVariables" : [ { + "name" : "myUsername", + "value" : "ThousandEyesAccountUserName" + }, { + "name" : "myUsername", + "value" : "ThousandEyesAccountUserName" + } ], + "liveShare" : false, + "distributedTracing" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "timeLimit" : 19, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "overrideProxyId" : "281474976710706", + "sslVersionId" : "0", + "targetTime" : 1, + "monitors" : [ { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + }, { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + } ] + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_api_test( + + test_id=test_id, + + aid=aid, + + version_id=version_id, + + _headers=self.te_headers("get_api_test"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_api_test_error_401(self) -> None: + """Integration test for get_api_test error path (HTTP 401)""" + test_id = '202701' + aid = '1234' + version_id = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_api_test( + + test_id=test_id, + + aid=aid, + + version_id=version_id, + + _headers=self.te_headers("get_api_test", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_api_test_error_403(self) -> None: + """Integration test for get_api_test error path (HTTP 403)""" + test_id = '202701' + aid = '1234' + version_id = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_api_test( + + test_id=test_id, + + aid=aid, + + version_id=version_id, + + _headers=self.te_headers("get_api_test", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_api_test_error_404(self) -> None: + """Integration test for get_api_test error path (HTTP 404)""" + test_id = '202701' + aid = '1234' + version_id = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_api_test( + + test_id=test_id, + + aid=aid, + + version_id=version_id, + + _headers=self.te_headers("get_api_test", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_api_test_error_429(self) -> None: + """Integration test for get_api_test error path (HTTP 429)""" + test_id = '202701' + aid = '1234' + version_id = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_api_test( + + test_id=test_id, + + aid=aid, + + version_id=version_id, + + _headers=self.te_headers("get_api_test", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_api_test_error_500(self) -> None: + """Integration test for get_api_test error path (HTTP 500)""" + test_id = '202701' + aid = '1234' + version_id = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_api_test( + + test_id=test_id, + + aid=aid, + + version_id=version_id, + + _headers=self.te_headers("get_api_test", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_api_test_error_502(self) -> None: + """Integration test for get_api_test error path (HTTP 502)""" + test_id = '202701' + aid = '1234' + version_id = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.get_api_test( + + test_id=test_id, + + aid=aid, + + version_id=version_id, + + _headers=self.te_headers("get_api_test", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_api_tests_happy_path(self) -> None: + """Integration test for get_api_tests success path""" + aid = '1234' + response_body_json = """ + { + "tests" : [ { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "requests" : [ { + "headers" : [ { + "value" : "keep-alive", + "key" : "x-custom-header" + }, { + "value" : "keep-alive", + "key" : "x-custom-header" + } ], + "variables" : [ { + "name" : "myTestName", + "value" : "tests[0].name" + }, { + "name" : "myTestName", + "value" : "tests[0].name" + } ], + "clientId" : "client-id", + "tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token", + "method" : "get", + "verifyCertificate" : false, + "body" : "body", + "url" : "https://api.thousandeyes.com/v7/status", + "password" : "basic_pw123", + "bearerToken" : "abcd-1234-...", + "scope" : "read, write, deploy", + "name" : "Step 1", + "waitTimeMs" : 0, + "clientAuthentication" : "basic-auth-header", + "clientSecret" : "client-secret", + "assertions" : [ { + "name" : "status-code", + "value" : "200", + "operator" : "is" + }, { + "name" : "status-code", + "value" : "200", + "operator" : "is" + } ], + "authType" : "none", + "collectApiResponse" : true, + "username" : "ThousandEyesUserName" + }, { + "headers" : [ { + "value" : "keep-alive", + "key" : "x-custom-header" + }, { + "value" : "keep-alive", + "key" : "x-custom-header" + } ], + "variables" : [ { + "name" : "myTestName", + "value" : "tests[0].name" + }, { + "name" : "myTestName", + "value" : "tests[0].name" + } ], + "clientId" : "client-id", + "tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token", + "method" : "get", + "verifyCertificate" : false, + "body" : "body", + "url" : "https://api.thousandeyes.com/v7/status", + "password" : "basic_pw123", + "bearerToken" : "abcd-1234-...", + "scope" : "read, write, deploy", + "name" : "Step 1", + "waitTimeMs" : 0, + "clientAuthentication" : "basic-auth-header", + "clientSecret" : "client-secret", + "assertions" : [ { + "name" : "status-code", + "value" : "200", + "operator" : "is" + }, { + "name" : "status-code", + "value" : "200", + "operator" : "is" + } ], + "authType" : "none", + "collectApiResponse" : true, + "username" : "ThousandEyesUserName" + } ], + "type" : "api", + "usePublicBgp" : true, + "enabled" : true, + "protocol" : "tcp", + "collectProxyNetworkData" : false, + "followRedirects" : true, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "clientCertDomainsAllowList" : "www.thousandeyes.com", + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "overrideAgentProxy" : false, + "predefinedVariables" : [ { + "name" : "myUsername", + "value" : "ThousandEyesAccountUserName" + }, { + "name" : "myUsername", + "value" : "ThousandEyesAccountUserName" + } ], + "liveShare" : false, + "distributedTracing" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "timeLimit" : 19, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "overrideProxyId" : "281474976710706", + "sslVersionId" : "0", + "targetTime" : 1 + }, { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "requests" : [ { + "headers" : [ { + "value" : "keep-alive", + "key" : "x-custom-header" + }, { + "value" : "keep-alive", + "key" : "x-custom-header" + } ], + "variables" : [ { + "name" : "myTestName", + "value" : "tests[0].name" + }, { + "name" : "myTestName", + "value" : "tests[0].name" + } ], + "clientId" : "client-id", + "tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token", + "method" : "get", + "verifyCertificate" : false, + "body" : "body", + "url" : "https://api.thousandeyes.com/v7/status", + "password" : "basic_pw123", + "bearerToken" : "abcd-1234-...", + "scope" : "read, write, deploy", + "name" : "Step 1", + "waitTimeMs" : 0, + "clientAuthentication" : "basic-auth-header", + "clientSecret" : "client-secret", + "assertions" : [ { + "name" : "status-code", + "value" : "200", + "operator" : "is" + }, { + "name" : "status-code", + "value" : "200", + "operator" : "is" + } ], + "authType" : "none", + "collectApiResponse" : true, + "username" : "ThousandEyesUserName" + }, { + "headers" : [ { + "value" : "keep-alive", + "key" : "x-custom-header" + }, { + "value" : "keep-alive", + "key" : "x-custom-header" + } ], + "variables" : [ { + "name" : "myTestName", + "value" : "tests[0].name" + }, { + "name" : "myTestName", + "value" : "tests[0].name" + } ], + "clientId" : "client-id", + "tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token", + "method" : "get", + "verifyCertificate" : false, + "body" : "body", + "url" : "https://api.thousandeyes.com/v7/status", + "password" : "basic_pw123", + "bearerToken" : "abcd-1234-...", + "scope" : "read, write, deploy", + "name" : "Step 1", + "waitTimeMs" : 0, + "clientAuthentication" : "basic-auth-header", + "clientSecret" : "client-secret", + "assertions" : [ { + "name" : "status-code", + "value" : "200", + "operator" : "is" + }, { + "name" : "status-code", + "value" : "200", + "operator" : "is" + } ], + "authType" : "none", + "collectApiResponse" : true, + "username" : "ThousandEyesUserName" + } ], + "type" : "api", + "usePublicBgp" : true, + "enabled" : true, + "protocol" : "tcp", + "collectProxyNetworkData" : false, + "followRedirects" : true, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "clientCertDomainsAllowList" : "www.thousandeyes.com", + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "overrideAgentProxy" : false, + "predefinedVariables" : [ { + "name" : "myUsername", + "value" : "ThousandEyesAccountUserName" + }, { + "name" : "myUsername", + "value" : "ThousandEyesAccountUserName" + } ], + "liveShare" : false, + "distributedTracing" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "timeLimit" : 19, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "overrideProxyId" : "281474976710706", + "sslVersionId" : "0", + "targetTime" : 1 + } ], + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_api_tests( + + aid=aid, + + _headers=self.te_headers("get_api_tests"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_api_tests_error_401(self) -> None: + """Integration test for get_api_tests error path (HTTP 401)""" + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_api_tests( + + aid=aid, + + _headers=self.te_headers("get_api_tests", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_api_tests_error_403(self) -> None: + """Integration test for get_api_tests error path (HTTP 403)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_api_tests( + + aid=aid, + + _headers=self.te_headers("get_api_tests", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_api_tests_error_404(self) -> None: + """Integration test for get_api_tests error path (HTTP 404)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_api_tests( + + aid=aid, + + _headers=self.te_headers("get_api_tests", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_api_tests_error_429(self) -> None: + """Integration test for get_api_tests error path (HTTP 429)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_api_tests( + + aid=aid, + + _headers=self.te_headers("get_api_tests", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_api_tests_error_500(self) -> None: + """Integration test for get_api_tests error path (HTTP 500)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_api_tests( + + aid=aid, + + _headers=self.te_headers("get_api_tests", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_api_tests_error_502(self) -> None: + """Integration test for get_api_tests error path (HTTP 502)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.get_api_tests( + + aid=aid, + + _headers=self.te_headers("get_api_tests", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_update_api_test_happy_path(self) -> None: + """Integration test for update_api_test success path""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "credentials" : [ "3247", "1051" ], + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "requests" : [ { + "headers" : [ { + "value" : "keep-alive", + "key" : "x-custom-header" + }, { + "value" : "keep-alive", + "key" : "x-custom-header" + } ], + "variables" : [ { + "name" : "myTestName", + "value" : "tests[0].name" + }, { + "name" : "myTestName", + "value" : "tests[0].name" + } ], + "clientId" : "client-id", + "tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token", + "method" : "get", + "verifyCertificate" : false, + "body" : "body", + "url" : "https://api.thousandeyes.com/v7/status", + "password" : "basic_pw123", + "bearerToken" : "abcd-1234-...", + "scope" : "read, write, deploy", + "name" : "Step 1", + "waitTimeMs" : 0, + "clientAuthentication" : "basic-auth-header", + "clientSecret" : "client-secret", + "assertions" : [ { + "name" : "status-code", + "value" : "200", + "operator" : "is" + }, { + "name" : "status-code", + "value" : "200", + "operator" : "is" + } ], + "authType" : "none", + "collectApiResponse" : true, + "username" : "ThousandEyesUserName" + }, { + "headers" : [ { + "value" : "keep-alive", + "key" : "x-custom-header" + }, { + "value" : "keep-alive", + "key" : "x-custom-header" + } ], + "variables" : [ { + "name" : "myTestName", + "value" : "tests[0].name" + }, { + "name" : "myTestName", + "value" : "tests[0].name" + } ], + "clientId" : "client-id", + "tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token", + "method" : "get", + "verifyCertificate" : false, + "body" : "body", + "url" : "https://api.thousandeyes.com/v7/status", + "password" : "basic_pw123", + "bearerToken" : "abcd-1234-...", + "scope" : "read, write, deploy", + "name" : "Step 1", + "waitTimeMs" : 0, + "clientAuthentication" : "basic-auth-header", + "clientSecret" : "client-secret", + "assertions" : [ { + "name" : "status-code", + "value" : "200", + "operator" : "is" + }, { + "name" : "status-code", + "value" : "200", + "operator" : "is" + } ], + "authType" : "none", + "collectApiResponse" : true, + "username" : "ThousandEyesUserName" + } ], + "type" : "api", + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "protocol" : "tcp", + "collectProxyNetworkData" : false, + "followRedirects" : true, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "clientCertDomainsAllowList" : "www.thousandeyes.com", + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "overrideAgentProxy" : false, + "predefinedVariables" : [ { + "name" : "myUsername", + "value" : "ThousandEyesAccountUserName" + }, { + "name" : "myUsername", + "value" : "ThousandEyesAccountUserName" + } ], + "liveShare" : false, + "distributedTracing" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "timeLimit" : 19, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "sslVersionId" : "0", + "targetTime" : 1, + "monitors" : [ "17410", "5" ] + } + + """ + api_test_request = thousandeyes_sdk.tests.models.ApiTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + response_body_json = """ + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "credentials" : [ "3247", "1051" ], + "alertRules" : [ { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + }, { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + } ], + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "requests" : [ { + "headers" : [ { + "value" : "keep-alive", + "key" : "x-custom-header" + }, { + "value" : "keep-alive", + "key" : "x-custom-header" + } ], + "variables" : [ { + "name" : "myTestName", + "value" : "tests[0].name" + }, { + "name" : "myTestName", + "value" : "tests[0].name" + } ], + "clientId" : "client-id", + "tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token", + "method" : "get", + "verifyCertificate" : false, + "body" : "body", + "url" : "https://api.thousandeyes.com/v7/status", + "password" : "basic_pw123", + "bearerToken" : "abcd-1234-...", + "scope" : "read, write, deploy", + "name" : "Step 1", + "waitTimeMs" : 0, + "clientAuthentication" : "basic-auth-header", + "clientSecret" : "client-secret", + "assertions" : [ { + "name" : "status-code", + "value" : "200", + "operator" : "is" + }, { + "name" : "status-code", + "value" : "200", + "operator" : "is" + } ], + "authType" : "none", + "collectApiResponse" : true, + "username" : "ThousandEyesUserName" + }, { + "headers" : [ { + "value" : "keep-alive", + "key" : "x-custom-header" + }, { + "value" : "keep-alive", + "key" : "x-custom-header" + } ], + "variables" : [ { + "name" : "myTestName", + "value" : "tests[0].name" + }, { + "name" : "myTestName", + "value" : "tests[0].name" + } ], + "clientId" : "client-id", + "tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token", + "method" : "get", + "verifyCertificate" : false, + "body" : "body", + "url" : "https://api.thousandeyes.com/v7/status", + "password" : "basic_pw123", + "bearerToken" : "abcd-1234-...", + "scope" : "read, write, deploy", + "name" : "Step 1", + "waitTimeMs" : 0, + "clientAuthentication" : "basic-auth-header", + "clientSecret" : "client-secret", + "assertions" : [ { + "name" : "status-code", + "value" : "200", + "operator" : "is" + }, { + "name" : "status-code", + "value" : "200", + "operator" : "is" + } ], + "authType" : "none", + "collectApiResponse" : true, + "username" : "ThousandEyesUserName" + } ], + "type" : "api", + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "protocol" : "tcp", + "collectProxyNetworkData" : false, + "followRedirects" : true, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "clientCertDomainsAllowList" : "www.thousandeyes.com", + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "overrideAgentProxy" : false, + "predefinedVariables" : [ { + "name" : "myUsername", + "value" : "ThousandEyesAccountUserName" + }, { + "name" : "myUsername", + "value" : "ThousandEyesAccountUserName" + } ], + "liveShare" : false, + "distributedTracing" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "timeLimit" : 19, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "overrideProxyId" : "281474976710706", + "sslVersionId" : "0", + "targetTime" : 1, + "monitors" : [ { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + }, { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + } ] + } + """ + expected_response = json.loads(response_body_json) + response = self.api.update_api_test( + + test_id=test_id, + + api_test_request=api_test_request, + + aid=aid, + + _headers=self.te_headers("update_api_test"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_update_api_test_error_400(self) -> None: + """Integration test for update_api_test error path (HTTP 400)""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "credentials" : [ "3247", "1051" ], + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "requests" : [ { + "headers" : [ { + "value" : "keep-alive", + "key" : "x-custom-header" + }, { + "value" : "keep-alive", + "key" : "x-custom-header" + } ], + "variables" : [ { + "name" : "myTestName", + "value" : "tests[0].name" + }, { + "name" : "myTestName", + "value" : "tests[0].name" + } ], + "clientId" : "client-id", + "tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token", + "method" : "get", + "verifyCertificate" : false, + "body" : "body", + "url" : "https://api.thousandeyes.com/v7/status", + "password" : "basic_pw123", + "bearerToken" : "abcd-1234-...", + "scope" : "read, write, deploy", + "name" : "Step 1", + "waitTimeMs" : 0, + "clientAuthentication" : "basic-auth-header", + "clientSecret" : "client-secret", + "assertions" : [ { + "name" : "status-code", + "value" : "200", + "operator" : "is" + }, { + "name" : "status-code", + "value" : "200", + "operator" : "is" + } ], + "authType" : "none", + "collectApiResponse" : true, + "username" : "ThousandEyesUserName" + }, { + "headers" : [ { + "value" : "keep-alive", + "key" : "x-custom-header" + }, { + "value" : "keep-alive", + "key" : "x-custom-header" + } ], + "variables" : [ { + "name" : "myTestName", + "value" : "tests[0].name" + }, { + "name" : "myTestName", + "value" : "tests[0].name" + } ], + "clientId" : "client-id", + "tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token", + "method" : "get", + "verifyCertificate" : false, + "body" : "body", + "url" : "https://api.thousandeyes.com/v7/status", + "password" : "basic_pw123", + "bearerToken" : "abcd-1234-...", + "scope" : "read, write, deploy", + "name" : "Step 1", + "waitTimeMs" : 0, + "clientAuthentication" : "basic-auth-header", + "clientSecret" : "client-secret", + "assertions" : [ { + "name" : "status-code", + "value" : "200", + "operator" : "is" + }, { + "name" : "status-code", + "value" : "200", + "operator" : "is" + } ], + "authType" : "none", + "collectApiResponse" : true, + "username" : "ThousandEyesUserName" + } ], + "type" : "api", + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "protocol" : "tcp", + "collectProxyNetworkData" : false, + "followRedirects" : true, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "clientCertDomainsAllowList" : "www.thousandeyes.com", + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "overrideAgentProxy" : false, + "predefinedVariables" : [ { + "name" : "myUsername", + "value" : "ThousandEyesAccountUserName" + }, { + "name" : "myUsername", + "value" : "ThousandEyesAccountUserName" + } ], + "liveShare" : false, + "distributedTracing" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "timeLimit" : 19, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "sslVersionId" : "0", + "targetTime" : 1, + "monitors" : [ "17410", "5" ] + } + + """ + api_test_request = thousandeyes_sdk.tests.models.ApiTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.update_api_test( + + test_id=test_id, + + api_test_request=api_test_request, + + aid=aid, + + _headers=self.te_headers("update_api_test", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_api_test_error_401(self) -> None: + """Integration test for update_api_test error path (HTTP 401)""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "credentials" : [ "3247", "1051" ], + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "requests" : [ { + "headers" : [ { + "value" : "keep-alive", + "key" : "x-custom-header" + }, { + "value" : "keep-alive", + "key" : "x-custom-header" + } ], + "variables" : [ { + "name" : "myTestName", + "value" : "tests[0].name" + }, { + "name" : "myTestName", + "value" : "tests[0].name" + } ], + "clientId" : "client-id", + "tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token", + "method" : "get", + "verifyCertificate" : false, + "body" : "body", + "url" : "https://api.thousandeyes.com/v7/status", + "password" : "basic_pw123", + "bearerToken" : "abcd-1234-...", + "scope" : "read, write, deploy", + "name" : "Step 1", + "waitTimeMs" : 0, + "clientAuthentication" : "basic-auth-header", + "clientSecret" : "client-secret", + "assertions" : [ { + "name" : "status-code", + "value" : "200", + "operator" : "is" + }, { + "name" : "status-code", + "value" : "200", + "operator" : "is" + } ], + "authType" : "none", + "collectApiResponse" : true, + "username" : "ThousandEyesUserName" + }, { + "headers" : [ { + "value" : "keep-alive", + "key" : "x-custom-header" + }, { + "value" : "keep-alive", + "key" : "x-custom-header" + } ], + "variables" : [ { + "name" : "myTestName", + "value" : "tests[0].name" + }, { + "name" : "myTestName", + "value" : "tests[0].name" + } ], + "clientId" : "client-id", + "tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token", + "method" : "get", + "verifyCertificate" : false, + "body" : "body", + "url" : "https://api.thousandeyes.com/v7/status", + "password" : "basic_pw123", + "bearerToken" : "abcd-1234-...", + "scope" : "read, write, deploy", + "name" : "Step 1", + "waitTimeMs" : 0, + "clientAuthentication" : "basic-auth-header", + "clientSecret" : "client-secret", + "assertions" : [ { + "name" : "status-code", + "value" : "200", + "operator" : "is" + }, { + "name" : "status-code", + "value" : "200", + "operator" : "is" + } ], + "authType" : "none", + "collectApiResponse" : true, + "username" : "ThousandEyesUserName" + } ], + "type" : "api", + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "protocol" : "tcp", + "collectProxyNetworkData" : false, + "followRedirects" : true, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "clientCertDomainsAllowList" : "www.thousandeyes.com", + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "overrideAgentProxy" : false, + "predefinedVariables" : [ { + "name" : "myUsername", + "value" : "ThousandEyesAccountUserName" + }, { + "name" : "myUsername", + "value" : "ThousandEyesAccountUserName" + } ], + "liveShare" : false, + "distributedTracing" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "timeLimit" : 19, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "sslVersionId" : "0", + "targetTime" : 1, + "monitors" : [ "17410", "5" ] + } + + """ + api_test_request = thousandeyes_sdk.tests.models.ApiTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.update_api_test( + + test_id=test_id, + + api_test_request=api_test_request, + + aid=aid, + + _headers=self.te_headers("update_api_test", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_api_test_error_403(self) -> None: + """Integration test for update_api_test error path (HTTP 403)""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "credentials" : [ "3247", "1051" ], + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "requests" : [ { + "headers" : [ { + "value" : "keep-alive", + "key" : "x-custom-header" + }, { + "value" : "keep-alive", + "key" : "x-custom-header" + } ], + "variables" : [ { + "name" : "myTestName", + "value" : "tests[0].name" + }, { + "name" : "myTestName", + "value" : "tests[0].name" + } ], + "clientId" : "client-id", + "tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token", + "method" : "get", + "verifyCertificate" : false, + "body" : "body", + "url" : "https://api.thousandeyes.com/v7/status", + "password" : "basic_pw123", + "bearerToken" : "abcd-1234-...", + "scope" : "read, write, deploy", + "name" : "Step 1", + "waitTimeMs" : 0, + "clientAuthentication" : "basic-auth-header", + "clientSecret" : "client-secret", + "assertions" : [ { + "name" : "status-code", + "value" : "200", + "operator" : "is" + }, { + "name" : "status-code", + "value" : "200", + "operator" : "is" + } ], + "authType" : "none", + "collectApiResponse" : true, + "username" : "ThousandEyesUserName" + }, { + "headers" : [ { + "value" : "keep-alive", + "key" : "x-custom-header" + }, { + "value" : "keep-alive", + "key" : "x-custom-header" + } ], + "variables" : [ { + "name" : "myTestName", + "value" : "tests[0].name" + }, { + "name" : "myTestName", + "value" : "tests[0].name" + } ], + "clientId" : "client-id", + "tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token", + "method" : "get", + "verifyCertificate" : false, + "body" : "body", + "url" : "https://api.thousandeyes.com/v7/status", + "password" : "basic_pw123", + "bearerToken" : "abcd-1234-...", + "scope" : "read, write, deploy", + "name" : "Step 1", + "waitTimeMs" : 0, + "clientAuthentication" : "basic-auth-header", + "clientSecret" : "client-secret", + "assertions" : [ { + "name" : "status-code", + "value" : "200", + "operator" : "is" + }, { + "name" : "status-code", + "value" : "200", + "operator" : "is" + } ], + "authType" : "none", + "collectApiResponse" : true, + "username" : "ThousandEyesUserName" + } ], + "type" : "api", + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "protocol" : "tcp", + "collectProxyNetworkData" : false, + "followRedirects" : true, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "clientCertDomainsAllowList" : "www.thousandeyes.com", + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "overrideAgentProxy" : false, + "predefinedVariables" : [ { + "name" : "myUsername", + "value" : "ThousandEyesAccountUserName" + }, { + "name" : "myUsername", + "value" : "ThousandEyesAccountUserName" + } ], + "liveShare" : false, + "distributedTracing" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "timeLimit" : 19, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "sslVersionId" : "0", + "targetTime" : 1, + "monitors" : [ "17410", "5" ] + } + + """ + api_test_request = thousandeyes_sdk.tests.models.ApiTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.update_api_test( + + test_id=test_id, + + api_test_request=api_test_request, + + aid=aid, + + _headers=self.te_headers("update_api_test", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_api_test_error_404(self) -> None: + """Integration test for update_api_test error path (HTTP 404)""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "credentials" : [ "3247", "1051" ], + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "requests" : [ { + "headers" : [ { + "value" : "keep-alive", + "key" : "x-custom-header" + }, { + "value" : "keep-alive", + "key" : "x-custom-header" + } ], + "variables" : [ { + "name" : "myTestName", + "value" : "tests[0].name" + }, { + "name" : "myTestName", + "value" : "tests[0].name" + } ], + "clientId" : "client-id", + "tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token", + "method" : "get", + "verifyCertificate" : false, + "body" : "body", + "url" : "https://api.thousandeyes.com/v7/status", + "password" : "basic_pw123", + "bearerToken" : "abcd-1234-...", + "scope" : "read, write, deploy", + "name" : "Step 1", + "waitTimeMs" : 0, + "clientAuthentication" : "basic-auth-header", + "clientSecret" : "client-secret", + "assertions" : [ { + "name" : "status-code", + "value" : "200", + "operator" : "is" + }, { + "name" : "status-code", + "value" : "200", + "operator" : "is" + } ], + "authType" : "none", + "collectApiResponse" : true, + "username" : "ThousandEyesUserName" + }, { + "headers" : [ { + "value" : "keep-alive", + "key" : "x-custom-header" + }, { + "value" : "keep-alive", + "key" : "x-custom-header" + } ], + "variables" : [ { + "name" : "myTestName", + "value" : "tests[0].name" + }, { + "name" : "myTestName", + "value" : "tests[0].name" + } ], + "clientId" : "client-id", + "tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token", + "method" : "get", + "verifyCertificate" : false, + "body" : "body", + "url" : "https://api.thousandeyes.com/v7/status", + "password" : "basic_pw123", + "bearerToken" : "abcd-1234-...", + "scope" : "read, write, deploy", + "name" : "Step 1", + "waitTimeMs" : 0, + "clientAuthentication" : "basic-auth-header", + "clientSecret" : "client-secret", + "assertions" : [ { + "name" : "status-code", + "value" : "200", + "operator" : "is" + }, { + "name" : "status-code", + "value" : "200", + "operator" : "is" + } ], + "authType" : "none", + "collectApiResponse" : true, + "username" : "ThousandEyesUserName" + } ], + "type" : "api", + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "protocol" : "tcp", + "collectProxyNetworkData" : false, + "followRedirects" : true, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "clientCertDomainsAllowList" : "www.thousandeyes.com", + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "overrideAgentProxy" : false, + "predefinedVariables" : [ { + "name" : "myUsername", + "value" : "ThousandEyesAccountUserName" + }, { + "name" : "myUsername", + "value" : "ThousandEyesAccountUserName" + } ], + "liveShare" : false, + "distributedTracing" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "timeLimit" : 19, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "sslVersionId" : "0", + "targetTime" : 1, + "monitors" : [ "17410", "5" ] + } + + """ + api_test_request = thousandeyes_sdk.tests.models.ApiTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.update_api_test( + + test_id=test_id, + + api_test_request=api_test_request, + + aid=aid, + + _headers=self.te_headers("update_api_test", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_api_test_error_429(self) -> None: + """Integration test for update_api_test error path (HTTP 429)""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "credentials" : [ "3247", "1051" ], + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "requests" : [ { + "headers" : [ { + "value" : "keep-alive", + "key" : "x-custom-header" + }, { + "value" : "keep-alive", + "key" : "x-custom-header" + } ], + "variables" : [ { + "name" : "myTestName", + "value" : "tests[0].name" + }, { + "name" : "myTestName", + "value" : "tests[0].name" + } ], + "clientId" : "client-id", + "tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token", + "method" : "get", + "verifyCertificate" : false, + "body" : "body", + "url" : "https://api.thousandeyes.com/v7/status", + "password" : "basic_pw123", + "bearerToken" : "abcd-1234-...", + "scope" : "read, write, deploy", + "name" : "Step 1", + "waitTimeMs" : 0, + "clientAuthentication" : "basic-auth-header", + "clientSecret" : "client-secret", + "assertions" : [ { + "name" : "status-code", + "value" : "200", + "operator" : "is" + }, { + "name" : "status-code", + "value" : "200", + "operator" : "is" + } ], + "authType" : "none", + "collectApiResponse" : true, + "username" : "ThousandEyesUserName" + }, { + "headers" : [ { + "value" : "keep-alive", + "key" : "x-custom-header" + }, { + "value" : "keep-alive", + "key" : "x-custom-header" + } ], + "variables" : [ { + "name" : "myTestName", + "value" : "tests[0].name" + }, { + "name" : "myTestName", + "value" : "tests[0].name" + } ], + "clientId" : "client-id", + "tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token", + "method" : "get", + "verifyCertificate" : false, + "body" : "body", + "url" : "https://api.thousandeyes.com/v7/status", + "password" : "basic_pw123", + "bearerToken" : "abcd-1234-...", + "scope" : "read, write, deploy", + "name" : "Step 1", + "waitTimeMs" : 0, + "clientAuthentication" : "basic-auth-header", + "clientSecret" : "client-secret", + "assertions" : [ { + "name" : "status-code", + "value" : "200", + "operator" : "is" + }, { + "name" : "status-code", + "value" : "200", + "operator" : "is" + } ], + "authType" : "none", + "collectApiResponse" : true, + "username" : "ThousandEyesUserName" + } ], + "type" : "api", + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "protocol" : "tcp", + "collectProxyNetworkData" : false, + "followRedirects" : true, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "clientCertDomainsAllowList" : "www.thousandeyes.com", + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "overrideAgentProxy" : false, + "predefinedVariables" : [ { + "name" : "myUsername", + "value" : "ThousandEyesAccountUserName" + }, { + "name" : "myUsername", + "value" : "ThousandEyesAccountUserName" + } ], + "liveShare" : false, + "distributedTracing" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "timeLimit" : 19, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "sslVersionId" : "0", + "targetTime" : 1, + "monitors" : [ "17410", "5" ] + } + + """ + api_test_request = thousandeyes_sdk.tests.models.ApiTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.update_api_test( + + test_id=test_id, + + api_test_request=api_test_request, + + aid=aid, + + _headers=self.te_headers("update_api_test", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_api_test_error_500(self) -> None: + """Integration test for update_api_test error path (HTTP 500)""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "credentials" : [ "3247", "1051" ], + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "requests" : [ { + "headers" : [ { + "value" : "keep-alive", + "key" : "x-custom-header" + }, { + "value" : "keep-alive", + "key" : "x-custom-header" + } ], + "variables" : [ { + "name" : "myTestName", + "value" : "tests[0].name" + }, { + "name" : "myTestName", + "value" : "tests[0].name" + } ], + "clientId" : "client-id", + "tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token", + "method" : "get", + "verifyCertificate" : false, + "body" : "body", + "url" : "https://api.thousandeyes.com/v7/status", + "password" : "basic_pw123", + "bearerToken" : "abcd-1234-...", + "scope" : "read, write, deploy", + "name" : "Step 1", + "waitTimeMs" : 0, + "clientAuthentication" : "basic-auth-header", + "clientSecret" : "client-secret", + "assertions" : [ { + "name" : "status-code", + "value" : "200", + "operator" : "is" + }, { + "name" : "status-code", + "value" : "200", + "operator" : "is" + } ], + "authType" : "none", + "collectApiResponse" : true, + "username" : "ThousandEyesUserName" + }, { + "headers" : [ { + "value" : "keep-alive", + "key" : "x-custom-header" + }, { + "value" : "keep-alive", + "key" : "x-custom-header" + } ], + "variables" : [ { + "name" : "myTestName", + "value" : "tests[0].name" + }, { + "name" : "myTestName", + "value" : "tests[0].name" + } ], + "clientId" : "client-id", + "tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token", + "method" : "get", + "verifyCertificate" : false, + "body" : "body", + "url" : "https://api.thousandeyes.com/v7/status", + "password" : "basic_pw123", + "bearerToken" : "abcd-1234-...", + "scope" : "read, write, deploy", + "name" : "Step 1", + "waitTimeMs" : 0, + "clientAuthentication" : "basic-auth-header", + "clientSecret" : "client-secret", + "assertions" : [ { + "name" : "status-code", + "value" : "200", + "operator" : "is" + }, { + "name" : "status-code", + "value" : "200", + "operator" : "is" + } ], + "authType" : "none", + "collectApiResponse" : true, + "username" : "ThousandEyesUserName" + } ], + "type" : "api", + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "protocol" : "tcp", + "collectProxyNetworkData" : false, + "followRedirects" : true, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "clientCertDomainsAllowList" : "www.thousandeyes.com", + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "overrideAgentProxy" : false, + "predefinedVariables" : [ { + "name" : "myUsername", + "value" : "ThousandEyesAccountUserName" + }, { + "name" : "myUsername", + "value" : "ThousandEyesAccountUserName" + } ], + "liveShare" : false, + "distributedTracing" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "timeLimit" : 19, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "sslVersionId" : "0", + "targetTime" : 1, + "monitors" : [ "17410", "5" ] + } + + """ + api_test_request = thousandeyes_sdk.tests.models.ApiTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.update_api_test( + + test_id=test_id, + + api_test_request=api_test_request, + + aid=aid, + + _headers=self.te_headers("update_api_test", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_api_test_error_502(self) -> None: + """Integration test for update_api_test error path (HTTP 502)""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "credentials" : [ "3247", "1051" ], + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "requests" : [ { + "headers" : [ { + "value" : "keep-alive", + "key" : "x-custom-header" + }, { + "value" : "keep-alive", + "key" : "x-custom-header" + } ], + "variables" : [ { + "name" : "myTestName", + "value" : "tests[0].name" + }, { + "name" : "myTestName", + "value" : "tests[0].name" + } ], + "clientId" : "client-id", + "tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token", + "method" : "get", + "verifyCertificate" : false, + "body" : "body", + "url" : "https://api.thousandeyes.com/v7/status", + "password" : "basic_pw123", + "bearerToken" : "abcd-1234-...", + "scope" : "read, write, deploy", + "name" : "Step 1", + "waitTimeMs" : 0, + "clientAuthentication" : "basic-auth-header", + "clientSecret" : "client-secret", + "assertions" : [ { + "name" : "status-code", + "value" : "200", + "operator" : "is" + }, { + "name" : "status-code", + "value" : "200", + "operator" : "is" + } ], + "authType" : "none", + "collectApiResponse" : true, + "username" : "ThousandEyesUserName" + }, { + "headers" : [ { + "value" : "keep-alive", + "key" : "x-custom-header" + }, { + "value" : "keep-alive", + "key" : "x-custom-header" + } ], + "variables" : [ { + "name" : "myTestName", + "value" : "tests[0].name" + }, { + "name" : "myTestName", + "value" : "tests[0].name" + } ], + "clientId" : "client-id", + "tokenUrl" : "https://id.cisco.com/oauth2/default/v1/token", + "method" : "get", + "verifyCertificate" : false, + "body" : "body", + "url" : "https://api.thousandeyes.com/v7/status", + "password" : "basic_pw123", + "bearerToken" : "abcd-1234-...", + "scope" : "read, write, deploy", + "name" : "Step 1", + "waitTimeMs" : 0, + "clientAuthentication" : "basic-auth-header", + "clientSecret" : "client-secret", + "assertions" : [ { + "name" : "status-code", + "value" : "200", + "operator" : "is" + }, { + "name" : "status-code", + "value" : "200", + "operator" : "is" + } ], + "authType" : "none", + "collectApiResponse" : true, + "username" : "ThousandEyesUserName" + } ], + "type" : "api", + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "protocol" : "tcp", + "collectProxyNetworkData" : false, + "followRedirects" : true, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "clientCertDomainsAllowList" : "www.thousandeyes.com", + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "overrideAgentProxy" : false, + "predefinedVariables" : [ { + "name" : "myUsername", + "value" : "ThousandEyesAccountUserName" + }, { + "name" : "myUsername", + "value" : "ThousandEyesAccountUserName" + } ], + "liveShare" : false, + "distributedTracing" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "timeLimit" : 19, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "sslVersionId" : "0", + "targetTime" : 1, + "monitors" : [ "17410", "5" ] + } + + """ + api_test_request = thousandeyes_sdk.tests.models.ApiTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.update_api_test( + + test_id=test_id, + + api_test_request=api_test_request, + + aid=aid, + + _headers=self.te_headers("update_api_test", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-tests/test/test_bgp_tests_api_integration.py b/thousandeyes-sdk-tests/test/test_bgp_tests_api_integration.py new file mode 100644 index 00000000..a77fddd4 --- /dev/null +++ b/thousandeyes-sdk-tests/test/test_bgp_tests_api_integration.py @@ -0,0 +1,2105 @@ +# coding: utf-8 + +""" + Tests API + + **Note:** The Page Load Tests, API Tests, and Web Transaction Tests APIs are not available for ThousandEyes for Government instance. This API allows you to list, create, edit, and delete Network and Application Synthetics tests. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.tests.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.tests.api.bgp_tests_api import BGPTestsApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestBGPTestsApiIntegration(IntegrationTestBase): + """BGPTestsApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = BGPTestsApi(self.api_client) + + + def test_create_bgp_test_happy_path(self) -> None: + """Integration test for create_bgp_test success path""" + request_body_json = """ + + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "prefix" : "prefix", + "savedEvent" : true, + "includeCoveredPrefixes" : true, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "type" : "bgp", + "usePublicBgp" : true, + "enabled" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "monitors" : [ "17410", "5" ] + } + + """ + bgp_test_request = thousandeyes_sdk.tests.models.BgpTestRequest.from_json(request_body_json) + aid = '1234' + response_body_json = """ + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "prefix" : "prefix", + "savedEvent" : true, + "includeCoveredPrefixes" : true, + "alertRules" : [ { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + }, { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + } ], + "description" : "ThousandEyes Test", + "type" : "bgp", + "usePublicBgp" : true, + "enabled" : true, + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "monitors" : [ { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + }, { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + } ] + } + """ + expected_response = json.loads(response_body_json) + response = self.api.create_bgp_test( + + bgp_test_request=bgp_test_request, + + aid=aid, + + _headers=self.te_headers("create_bgp_test"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_create_bgp_test_error_400(self) -> None: + """Integration test for create_bgp_test error path (HTTP 400)""" + request_body_json = """ + + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "prefix" : "prefix", + "savedEvent" : true, + "includeCoveredPrefixes" : true, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "type" : "bgp", + "usePublicBgp" : true, + "enabled" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "monitors" : [ "17410", "5" ] + } + + """ + bgp_test_request = thousandeyes_sdk.tests.models.BgpTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.create_bgp_test( + + bgp_test_request=bgp_test_request, + + aid=aid, + + _headers=self.te_headers("create_bgp_test", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_bgp_test_error_401(self) -> None: + """Integration test for create_bgp_test error path (HTTP 401)""" + request_body_json = """ + + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "prefix" : "prefix", + "savedEvent" : true, + "includeCoveredPrefixes" : true, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "type" : "bgp", + "usePublicBgp" : true, + "enabled" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "monitors" : [ "17410", "5" ] + } + + """ + bgp_test_request = thousandeyes_sdk.tests.models.BgpTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.create_bgp_test( + + bgp_test_request=bgp_test_request, + + aid=aid, + + _headers=self.te_headers("create_bgp_test", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_bgp_test_error_403(self) -> None: + """Integration test for create_bgp_test error path (HTTP 403)""" + request_body_json = """ + + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "prefix" : "prefix", + "savedEvent" : true, + "includeCoveredPrefixes" : true, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "type" : "bgp", + "usePublicBgp" : true, + "enabled" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "monitors" : [ "17410", "5" ] + } + + """ + bgp_test_request = thousandeyes_sdk.tests.models.BgpTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.create_bgp_test( + + bgp_test_request=bgp_test_request, + + aid=aid, + + _headers=self.te_headers("create_bgp_test", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_bgp_test_error_404(self) -> None: + """Integration test for create_bgp_test error path (HTTP 404)""" + request_body_json = """ + + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "prefix" : "prefix", + "savedEvent" : true, + "includeCoveredPrefixes" : true, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "type" : "bgp", + "usePublicBgp" : true, + "enabled" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "monitors" : [ "17410", "5" ] + } + + """ + bgp_test_request = thousandeyes_sdk.tests.models.BgpTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.create_bgp_test( + + bgp_test_request=bgp_test_request, + + aid=aid, + + _headers=self.te_headers("create_bgp_test", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_bgp_test_error_429(self) -> None: + """Integration test for create_bgp_test error path (HTTP 429)""" + request_body_json = """ + + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "prefix" : "prefix", + "savedEvent" : true, + "includeCoveredPrefixes" : true, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "type" : "bgp", + "usePublicBgp" : true, + "enabled" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "monitors" : [ "17410", "5" ] + } + + """ + bgp_test_request = thousandeyes_sdk.tests.models.BgpTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.create_bgp_test( + + bgp_test_request=bgp_test_request, + + aid=aid, + + _headers=self.te_headers("create_bgp_test", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_bgp_test_error_500(self) -> None: + """Integration test for create_bgp_test error path (HTTP 500)""" + request_body_json = """ + + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "prefix" : "prefix", + "savedEvent" : true, + "includeCoveredPrefixes" : true, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "type" : "bgp", + "usePublicBgp" : true, + "enabled" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "monitors" : [ "17410", "5" ] + } + + """ + bgp_test_request = thousandeyes_sdk.tests.models.BgpTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.create_bgp_test( + + bgp_test_request=bgp_test_request, + + aid=aid, + + _headers=self.te_headers("create_bgp_test", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_bgp_test_error_502(self) -> None: + """Integration test for create_bgp_test error path (HTTP 502)""" + request_body_json = """ + + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "prefix" : "prefix", + "savedEvent" : true, + "includeCoveredPrefixes" : true, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "type" : "bgp", + "usePublicBgp" : true, + "enabled" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "monitors" : [ "17410", "5" ] + } + + """ + bgp_test_request = thousandeyes_sdk.tests.models.BgpTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.create_bgp_test( + + bgp_test_request=bgp_test_request, + + aid=aid, + + _headers=self.te_headers("create_bgp_test", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_delete_bgp_test_happy_path(self) -> None: + """Integration test for delete_bgp_test success path""" + test_id = '202701' + aid = '1234' + response = self.api.delete_bgp_test_with_http_info( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_bgp_test"), + ) + self.assertEqual(204, response.status_code) + self.assertIsNone(response.data) + + + def test_delete_bgp_test_error_401(self) -> None: + """Integration test for delete_bgp_test error path (HTTP 401)""" + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.delete_bgp_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_bgp_test", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_bgp_test_error_403(self) -> None: + """Integration test for delete_bgp_test error path (HTTP 403)""" + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.delete_bgp_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_bgp_test", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_bgp_test_error_404(self) -> None: + """Integration test for delete_bgp_test error path (HTTP 404)""" + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.delete_bgp_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_bgp_test", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_bgp_test_error_429(self) -> None: + """Integration test for delete_bgp_test error path (HTTP 429)""" + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.delete_bgp_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_bgp_test", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_bgp_test_error_500(self) -> None: + """Integration test for delete_bgp_test error path (HTTP 500)""" + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.delete_bgp_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_bgp_test", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_bgp_test_error_502(self) -> None: + """Integration test for delete_bgp_test error path (HTTP 502)""" + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.delete_bgp_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_bgp_test", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_bgp_test_happy_path(self) -> None: + """Integration test for get_bgp_test success path""" + test_id = '202701' + aid = '1234' + response_body_json = """ + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "prefix" : "prefix", + "savedEvent" : true, + "includeCoveredPrefixes" : true, + "alertRules" : [ { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + }, { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + } ], + "description" : "ThousandEyes Test", + "type" : "bgp", + "usePublicBgp" : true, + "enabled" : true, + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "monitors" : [ { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + }, { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + } ] + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_bgp_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("get_bgp_test"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_bgp_test_error_401(self) -> None: + """Integration test for get_bgp_test error path (HTTP 401)""" + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_bgp_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("get_bgp_test", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_bgp_test_error_403(self) -> None: + """Integration test for get_bgp_test error path (HTTP 403)""" + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_bgp_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("get_bgp_test", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_bgp_test_error_404(self) -> None: + """Integration test for get_bgp_test error path (HTTP 404)""" + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_bgp_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("get_bgp_test", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_bgp_test_error_429(self) -> None: + """Integration test for get_bgp_test error path (HTTP 429)""" + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_bgp_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("get_bgp_test", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_bgp_test_error_500(self) -> None: + """Integration test for get_bgp_test error path (HTTP 500)""" + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_bgp_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("get_bgp_test", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_bgp_test_error_502(self) -> None: + """Integration test for get_bgp_test error path (HTTP 502)""" + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.get_bgp_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("get_bgp_test", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_bgp_tests_happy_path(self) -> None: + """Integration test for get_bgp_tests success path""" + aid = '1234' + response_body_json = """ + { + "tests" : [ { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "prefix" : "prefix", + "savedEvent" : true, + "includeCoveredPrefixes" : true, + "description" : "ThousandEyes Test", + "type" : "bgp", + "usePublicBgp" : true, + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + }, { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "prefix" : "prefix", + "savedEvent" : true, + "includeCoveredPrefixes" : true, + "description" : "ThousandEyes Test", + "type" : "bgp", + "usePublicBgp" : true, + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + } ], + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_bgp_tests( + + aid=aid, + + _headers=self.te_headers("get_bgp_tests"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_bgp_tests_error_401(self) -> None: + """Integration test for get_bgp_tests error path (HTTP 401)""" + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_bgp_tests( + + aid=aid, + + _headers=self.te_headers("get_bgp_tests", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_bgp_tests_error_403(self) -> None: + """Integration test for get_bgp_tests error path (HTTP 403)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_bgp_tests( + + aid=aid, + + _headers=self.te_headers("get_bgp_tests", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_bgp_tests_error_404(self) -> None: + """Integration test for get_bgp_tests error path (HTTP 404)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_bgp_tests( + + aid=aid, + + _headers=self.te_headers("get_bgp_tests", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_bgp_tests_error_429(self) -> None: + """Integration test for get_bgp_tests error path (HTTP 429)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_bgp_tests( + + aid=aid, + + _headers=self.te_headers("get_bgp_tests", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_bgp_tests_error_500(self) -> None: + """Integration test for get_bgp_tests error path (HTTP 500)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_bgp_tests( + + aid=aid, + + _headers=self.te_headers("get_bgp_tests", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_bgp_tests_error_502(self) -> None: + """Integration test for get_bgp_tests error path (HTTP 502)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.get_bgp_tests( + + aid=aid, + + _headers=self.te_headers("get_bgp_tests", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_update_bgp_test_happy_path(self) -> None: + """Integration test for update_bgp_test success path""" + request_body_json = """ + + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "includeCoveredPrefixes" : true, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "type" : "bgp", + "usePublicBgp" : true, + "enabled" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "monitors" : [ "17410", "5" ] + } + + """ + update_bgp_test_request = thousandeyes_sdk.tests.models.UpdateBgpTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + response_body_json = """ + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "prefix" : "prefix", + "savedEvent" : true, + "includeCoveredPrefixes" : true, + "alertRules" : [ { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + }, { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + } ], + "description" : "ThousandEyes Test", + "type" : "bgp", + "usePublicBgp" : true, + "enabled" : true, + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "monitors" : [ { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + }, { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + } ] + } + """ + expected_response = json.loads(response_body_json) + response = self.api.update_bgp_test( + + test_id=test_id, + + update_bgp_test_request=update_bgp_test_request, + + aid=aid, + + _headers=self.te_headers("update_bgp_test"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_update_bgp_test_error_400(self) -> None: + """Integration test for update_bgp_test error path (HTTP 400)""" + request_body_json = """ + + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "includeCoveredPrefixes" : true, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "type" : "bgp", + "usePublicBgp" : true, + "enabled" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "monitors" : [ "17410", "5" ] + } + + """ + update_bgp_test_request = thousandeyes_sdk.tests.models.UpdateBgpTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.update_bgp_test( + + test_id=test_id, + + update_bgp_test_request=update_bgp_test_request, + + aid=aid, + + _headers=self.te_headers("update_bgp_test", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_bgp_test_error_401(self) -> None: + """Integration test for update_bgp_test error path (HTTP 401)""" + request_body_json = """ + + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "includeCoveredPrefixes" : true, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "type" : "bgp", + "usePublicBgp" : true, + "enabled" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "monitors" : [ "17410", "5" ] + } + + """ + update_bgp_test_request = thousandeyes_sdk.tests.models.UpdateBgpTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.update_bgp_test( + + test_id=test_id, + + update_bgp_test_request=update_bgp_test_request, + + aid=aid, + + _headers=self.te_headers("update_bgp_test", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_bgp_test_error_403(self) -> None: + """Integration test for update_bgp_test error path (HTTP 403)""" + request_body_json = """ + + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "includeCoveredPrefixes" : true, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "type" : "bgp", + "usePublicBgp" : true, + "enabled" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "monitors" : [ "17410", "5" ] + } + + """ + update_bgp_test_request = thousandeyes_sdk.tests.models.UpdateBgpTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.update_bgp_test( + + test_id=test_id, + + update_bgp_test_request=update_bgp_test_request, + + aid=aid, + + _headers=self.te_headers("update_bgp_test", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_bgp_test_error_404(self) -> None: + """Integration test for update_bgp_test error path (HTTP 404)""" + request_body_json = """ + + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "includeCoveredPrefixes" : true, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "type" : "bgp", + "usePublicBgp" : true, + "enabled" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "monitors" : [ "17410", "5" ] + } + + """ + update_bgp_test_request = thousandeyes_sdk.tests.models.UpdateBgpTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.update_bgp_test( + + test_id=test_id, + + update_bgp_test_request=update_bgp_test_request, + + aid=aid, + + _headers=self.te_headers("update_bgp_test", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_bgp_test_error_429(self) -> None: + """Integration test for update_bgp_test error path (HTTP 429)""" + request_body_json = """ + + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "includeCoveredPrefixes" : true, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "type" : "bgp", + "usePublicBgp" : true, + "enabled" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "monitors" : [ "17410", "5" ] + } + + """ + update_bgp_test_request = thousandeyes_sdk.tests.models.UpdateBgpTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.update_bgp_test( + + test_id=test_id, + + update_bgp_test_request=update_bgp_test_request, + + aid=aid, + + _headers=self.te_headers("update_bgp_test", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_bgp_test_error_500(self) -> None: + """Integration test for update_bgp_test error path (HTTP 500)""" + request_body_json = """ + + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "includeCoveredPrefixes" : true, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "type" : "bgp", + "usePublicBgp" : true, + "enabled" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "monitors" : [ "17410", "5" ] + } + + """ + update_bgp_test_request = thousandeyes_sdk.tests.models.UpdateBgpTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.update_bgp_test( + + test_id=test_id, + + update_bgp_test_request=update_bgp_test_request, + + aid=aid, + + _headers=self.te_headers("update_bgp_test", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_bgp_test_error_502(self) -> None: + """Integration test for update_bgp_test error path (HTTP 502)""" + request_body_json = """ + + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "includeCoveredPrefixes" : true, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "type" : "bgp", + "usePublicBgp" : true, + "enabled" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "monitors" : [ "17410", "5" ] + } + + """ + update_bgp_test_request = thousandeyes_sdk.tests.models.UpdateBgpTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.update_bgp_test( + + test_id=test_id, + + update_bgp_test_request=update_bgp_test_request, + + aid=aid, + + _headers=self.te_headers("update_bgp_test", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-tests/test/test_dns_server_tests_api_integration.py b/thousandeyes-sdk-tests/test/test_dns_server_tests_api_integration.py new file mode 100644 index 00000000..78862b4e --- /dev/null +++ b/thousandeyes-sdk-tests/test/test_dns_server_tests_api_integration.py @@ -0,0 +1,2720 @@ +# coding: utf-8 + +""" + Tests API + + **Note:** The Page Load Tests, API Tests, and Web Transaction Tests APIs are not available for ThousandEyes for Government instance. This API allows you to list, create, edit, and delete Network and Application Synthetics tests. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.tests.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.tests.api.dns_server_tests_api import DNSServerTestsApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestDNSServerTestsApiIntegration(IntegrationTestBase): + """DNSServerTestsApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = DNSServerTestsApi(self.api_client) + + + def test_create_dns_server_test_happy_path(self) -> None: + """Integration test for create_dns_server_test success path""" + request_body_json = """ + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ "344753", "212697" ], + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "dnsTransportProtocol" : "udp", + "probeMode" : "auto", + "type" : "dns-server", + "usePublicBgp" : true, + "enabled" : true, + "protocol" : "tcp", + "fixedPacketRate" : 50, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "dnsServers" : [ "dns-example.net", "8.8.8.8" ], + "alertsEnabled" : true, + "recursiveQueries" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "dnsQueryClass" : "in", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "monitors" : [ "17410", "5" ] + } + + """ + dns_server_test_request = thousandeyes_sdk.tests.models.DnsServerTestRequest.from_json(request_body_json) + aid = '1234' + response_body_json = """ + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + }, { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + } ], + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "dnsTransportProtocol" : "udp", + "probeMode" : "auto", + "type" : "dns-server", + "usePublicBgp" : true, + "enabled" : true, + "protocol" : "tcp", + "fixedPacketRate" : 50, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "dnsServers" : [ { + "serverName" : "dns-example.net", + "serverId" : "1447" + }, { + "serverName" : "dns-example.net", + "serverId" : "1447" + } ], + "alertsEnabled" : true, + "recursiveQueries" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "dnsQueryClass" : "in", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "monitors" : [ { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + }, { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + } ] + } + """ + expected_response = json.loads(response_body_json) + response = self.api.create_dns_server_test( + + dns_server_test_request=dns_server_test_request, + + aid=aid, + + _headers=self.te_headers("create_dns_server_test"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_create_dns_server_test_error_400(self) -> None: + """Integration test for create_dns_server_test error path (HTTP 400)""" + request_body_json = """ + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ "344753", "212697" ], + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "dnsTransportProtocol" : "udp", + "probeMode" : "auto", + "type" : "dns-server", + "usePublicBgp" : true, + "enabled" : true, + "protocol" : "tcp", + "fixedPacketRate" : 50, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "dnsServers" : [ "dns-example.net", "8.8.8.8" ], + "alertsEnabled" : true, + "recursiveQueries" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "dnsQueryClass" : "in", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "monitors" : [ "17410", "5" ] + } + + """ + dns_server_test_request = thousandeyes_sdk.tests.models.DnsServerTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.create_dns_server_test( + + dns_server_test_request=dns_server_test_request, + + aid=aid, + + _headers=self.te_headers("create_dns_server_test", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_dns_server_test_error_401(self) -> None: + """Integration test for create_dns_server_test error path (HTTP 401)""" + request_body_json = """ + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ "344753", "212697" ], + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "dnsTransportProtocol" : "udp", + "probeMode" : "auto", + "type" : "dns-server", + "usePublicBgp" : true, + "enabled" : true, + "protocol" : "tcp", + "fixedPacketRate" : 50, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "dnsServers" : [ "dns-example.net", "8.8.8.8" ], + "alertsEnabled" : true, + "recursiveQueries" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "dnsQueryClass" : "in", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "monitors" : [ "17410", "5" ] + } + + """ + dns_server_test_request = thousandeyes_sdk.tests.models.DnsServerTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.create_dns_server_test( + + dns_server_test_request=dns_server_test_request, + + aid=aid, + + _headers=self.te_headers("create_dns_server_test", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_dns_server_test_error_403(self) -> None: + """Integration test for create_dns_server_test error path (HTTP 403)""" + request_body_json = """ + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ "344753", "212697" ], + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "dnsTransportProtocol" : "udp", + "probeMode" : "auto", + "type" : "dns-server", + "usePublicBgp" : true, + "enabled" : true, + "protocol" : "tcp", + "fixedPacketRate" : 50, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "dnsServers" : [ "dns-example.net", "8.8.8.8" ], + "alertsEnabled" : true, + "recursiveQueries" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "dnsQueryClass" : "in", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "monitors" : [ "17410", "5" ] + } + + """ + dns_server_test_request = thousandeyes_sdk.tests.models.DnsServerTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.create_dns_server_test( + + dns_server_test_request=dns_server_test_request, + + aid=aid, + + _headers=self.te_headers("create_dns_server_test", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_dns_server_test_error_404(self) -> None: + """Integration test for create_dns_server_test error path (HTTP 404)""" + request_body_json = """ + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ "344753", "212697" ], + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "dnsTransportProtocol" : "udp", + "probeMode" : "auto", + "type" : "dns-server", + "usePublicBgp" : true, + "enabled" : true, + "protocol" : "tcp", + "fixedPacketRate" : 50, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "dnsServers" : [ "dns-example.net", "8.8.8.8" ], + "alertsEnabled" : true, + "recursiveQueries" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "dnsQueryClass" : "in", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "monitors" : [ "17410", "5" ] + } + + """ + dns_server_test_request = thousandeyes_sdk.tests.models.DnsServerTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.create_dns_server_test( + + dns_server_test_request=dns_server_test_request, + + aid=aid, + + _headers=self.te_headers("create_dns_server_test", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_dns_server_test_error_429(self) -> None: + """Integration test for create_dns_server_test error path (HTTP 429)""" + request_body_json = """ + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ "344753", "212697" ], + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "dnsTransportProtocol" : "udp", + "probeMode" : "auto", + "type" : "dns-server", + "usePublicBgp" : true, + "enabled" : true, + "protocol" : "tcp", + "fixedPacketRate" : 50, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "dnsServers" : [ "dns-example.net", "8.8.8.8" ], + "alertsEnabled" : true, + "recursiveQueries" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "dnsQueryClass" : "in", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "monitors" : [ "17410", "5" ] + } + + """ + dns_server_test_request = thousandeyes_sdk.tests.models.DnsServerTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.create_dns_server_test( + + dns_server_test_request=dns_server_test_request, + + aid=aid, + + _headers=self.te_headers("create_dns_server_test", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_dns_server_test_error_500(self) -> None: + """Integration test for create_dns_server_test error path (HTTP 500)""" + request_body_json = """ + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ "344753", "212697" ], + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "dnsTransportProtocol" : "udp", + "probeMode" : "auto", + "type" : "dns-server", + "usePublicBgp" : true, + "enabled" : true, + "protocol" : "tcp", + "fixedPacketRate" : 50, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "dnsServers" : [ "dns-example.net", "8.8.8.8" ], + "alertsEnabled" : true, + "recursiveQueries" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "dnsQueryClass" : "in", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "monitors" : [ "17410", "5" ] + } + + """ + dns_server_test_request = thousandeyes_sdk.tests.models.DnsServerTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.create_dns_server_test( + + dns_server_test_request=dns_server_test_request, + + aid=aid, + + _headers=self.te_headers("create_dns_server_test", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_dns_server_test_error_502(self) -> None: + """Integration test for create_dns_server_test error path (HTTP 502)""" + request_body_json = """ + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ "344753", "212697" ], + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "dnsTransportProtocol" : "udp", + "probeMode" : "auto", + "type" : "dns-server", + "usePublicBgp" : true, + "enabled" : true, + "protocol" : "tcp", + "fixedPacketRate" : 50, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "dnsServers" : [ "dns-example.net", "8.8.8.8" ], + "alertsEnabled" : true, + "recursiveQueries" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "dnsQueryClass" : "in", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "monitors" : [ "17410", "5" ] + } + + """ + dns_server_test_request = thousandeyes_sdk.tests.models.DnsServerTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.create_dns_server_test( + + dns_server_test_request=dns_server_test_request, + + aid=aid, + + _headers=self.te_headers("create_dns_server_test", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_delete_dns_server_test_happy_path(self) -> None: + """Integration test for delete_dns_server_test success path""" + test_id = '202701' + aid = '1234' + response = self.api.delete_dns_server_test_with_http_info( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_dns_server_test"), + ) + self.assertEqual(204, response.status_code) + self.assertIsNone(response.data) + + + def test_delete_dns_server_test_error_401(self) -> None: + """Integration test for delete_dns_server_test error path (HTTP 401)""" + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.delete_dns_server_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_dns_server_test", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_dns_server_test_error_403(self) -> None: + """Integration test for delete_dns_server_test error path (HTTP 403)""" + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.delete_dns_server_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_dns_server_test", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_dns_server_test_error_404(self) -> None: + """Integration test for delete_dns_server_test error path (HTTP 404)""" + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.delete_dns_server_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_dns_server_test", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_dns_server_test_error_429(self) -> None: + """Integration test for delete_dns_server_test error path (HTTP 429)""" + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.delete_dns_server_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_dns_server_test", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_dns_server_test_error_500(self) -> None: + """Integration test for delete_dns_server_test error path (HTTP 500)""" + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.delete_dns_server_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_dns_server_test", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_dns_server_test_error_502(self) -> None: + """Integration test for delete_dns_server_test error path (HTTP 502)""" + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.delete_dns_server_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_dns_server_test", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_dns_server_test_happy_path(self) -> None: + """Integration test for get_dns_server_test success path""" + test_id = '202701' + aid = '1234' + version_id = '1234' + response_body_json = """ + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + }, { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + } ], + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "dnsTransportProtocol" : "udp", + "probeMode" : "auto", + "type" : "dns-server", + "usePublicBgp" : true, + "enabled" : true, + "protocol" : "tcp", + "fixedPacketRate" : 50, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "dnsServers" : [ { + "serverName" : "dns-example.net", + "serverId" : "1447" + }, { + "serverName" : "dns-example.net", + "serverId" : "1447" + } ], + "alertsEnabled" : true, + "recursiveQueries" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "dnsQueryClass" : "in", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "monitors" : [ { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + }, { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + } ] + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_dns_server_test( + + test_id=test_id, + + aid=aid, + + version_id=version_id, + + _headers=self.te_headers("get_dns_server_test"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_dns_server_test_error_401(self) -> None: + """Integration test for get_dns_server_test error path (HTTP 401)""" + test_id = '202701' + aid = '1234' + version_id = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_dns_server_test( + + test_id=test_id, + + aid=aid, + + version_id=version_id, + + _headers=self.te_headers("get_dns_server_test", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_dns_server_test_error_403(self) -> None: + """Integration test for get_dns_server_test error path (HTTP 403)""" + test_id = '202701' + aid = '1234' + version_id = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_dns_server_test( + + test_id=test_id, + + aid=aid, + + version_id=version_id, + + _headers=self.te_headers("get_dns_server_test", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_dns_server_test_error_404(self) -> None: + """Integration test for get_dns_server_test error path (HTTP 404)""" + test_id = '202701' + aid = '1234' + version_id = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_dns_server_test( + + test_id=test_id, + + aid=aid, + + version_id=version_id, + + _headers=self.te_headers("get_dns_server_test", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_dns_server_test_error_429(self) -> None: + """Integration test for get_dns_server_test error path (HTTP 429)""" + test_id = '202701' + aid = '1234' + version_id = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_dns_server_test( + + test_id=test_id, + + aid=aid, + + version_id=version_id, + + _headers=self.te_headers("get_dns_server_test", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_dns_server_test_error_500(self) -> None: + """Integration test for get_dns_server_test error path (HTTP 500)""" + test_id = '202701' + aid = '1234' + version_id = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_dns_server_test( + + test_id=test_id, + + aid=aid, + + version_id=version_id, + + _headers=self.te_headers("get_dns_server_test", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_dns_server_test_error_502(self) -> None: + """Integration test for get_dns_server_test error path (HTTP 502)""" + test_id = '202701' + aid = '1234' + version_id = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.get_dns_server_test( + + test_id=test_id, + + aid=aid, + + version_id=version_id, + + _headers=self.te_headers("get_dns_server_test", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_dns_server_tests_happy_path(self) -> None: + """Integration test for get_dns_server_tests success path""" + aid = '1234' + response_body_json = """ + { + "tests" : [ { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "dnsTransportProtocol" : "udp", + "probeMode" : "auto", + "type" : "dns-server", + "usePublicBgp" : true, + "enabled" : true, + "protocol" : "tcp", + "fixedPacketRate" : 50, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "dnsServers" : [ { + "serverName" : "dns-example.net", + "serverId" : "1447" + }, { + "serverName" : "dns-example.net", + "serverId" : "1447" + } ], + "alertsEnabled" : true, + "recursiveQueries" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "dnsQueryClass" : "in", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706" + }, { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "dnsTransportProtocol" : "udp", + "probeMode" : "auto", + "type" : "dns-server", + "usePublicBgp" : true, + "enabled" : true, + "protocol" : "tcp", + "fixedPacketRate" : 50, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "dnsServers" : [ { + "serverName" : "dns-example.net", + "serverId" : "1447" + }, { + "serverName" : "dns-example.net", + "serverId" : "1447" + } ], + "alertsEnabled" : true, + "recursiveQueries" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "dnsQueryClass" : "in", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706" + } ], + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_dns_server_tests( + + aid=aid, + + _headers=self.te_headers("get_dns_server_tests"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_dns_server_tests_error_401(self) -> None: + """Integration test for get_dns_server_tests error path (HTTP 401)""" + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_dns_server_tests( + + aid=aid, + + _headers=self.te_headers("get_dns_server_tests", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_dns_server_tests_error_403(self) -> None: + """Integration test for get_dns_server_tests error path (HTTP 403)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_dns_server_tests( + + aid=aid, + + _headers=self.te_headers("get_dns_server_tests", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_dns_server_tests_error_404(self) -> None: + """Integration test for get_dns_server_tests error path (HTTP 404)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_dns_server_tests( + + aid=aid, + + _headers=self.te_headers("get_dns_server_tests", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_dns_server_tests_error_429(self) -> None: + """Integration test for get_dns_server_tests error path (HTTP 429)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_dns_server_tests( + + aid=aid, + + _headers=self.te_headers("get_dns_server_tests", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_dns_server_tests_error_500(self) -> None: + """Integration test for get_dns_server_tests error path (HTTP 500)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_dns_server_tests( + + aid=aid, + + _headers=self.te_headers("get_dns_server_tests", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_dns_server_tests_error_502(self) -> None: + """Integration test for get_dns_server_tests error path (HTTP 502)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.get_dns_server_tests( + + aid=aid, + + _headers=self.te_headers("get_dns_server_tests", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_update_dns_server_test_happy_path(self) -> None: + """Integration test for update_dns_server_test success path""" + request_body_json = """ + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ "344753", "212697" ], + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "dnsTransportProtocol" : "udp", + "probeMode" : "auto", + "type" : "dns-server", + "usePublicBgp" : true, + "enabled" : true, + "protocol" : "tcp", + "fixedPacketRate" : 50, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "dnsServers" : [ "dns-example.net", "8.8.8.8" ], + "alertsEnabled" : true, + "recursiveQueries" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "dnsQueryClass" : "in", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "monitors" : [ "17410", "5" ] + } + + """ + dns_server_test_request = thousandeyes_sdk.tests.models.DnsServerTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + response_body_json = """ + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + }, { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + } ], + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "dnsTransportProtocol" : "udp", + "probeMode" : "auto", + "type" : "dns-server", + "usePublicBgp" : true, + "enabled" : true, + "protocol" : "tcp", + "fixedPacketRate" : 50, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "dnsServers" : [ { + "serverName" : "dns-example.net", + "serverId" : "1447" + }, { + "serverName" : "dns-example.net", + "serverId" : "1447" + } ], + "alertsEnabled" : true, + "recursiveQueries" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "dnsQueryClass" : "in", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "monitors" : [ { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + }, { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + } ] + } + """ + expected_response = json.loads(response_body_json) + response = self.api.update_dns_server_test( + + test_id=test_id, + + dns_server_test_request=dns_server_test_request, + + aid=aid, + + _headers=self.te_headers("update_dns_server_test"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_update_dns_server_test_error_400(self) -> None: + """Integration test for update_dns_server_test error path (HTTP 400)""" + request_body_json = """ + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ "344753", "212697" ], + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "dnsTransportProtocol" : "udp", + "probeMode" : "auto", + "type" : "dns-server", + "usePublicBgp" : true, + "enabled" : true, + "protocol" : "tcp", + "fixedPacketRate" : 50, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "dnsServers" : [ "dns-example.net", "8.8.8.8" ], + "alertsEnabled" : true, + "recursiveQueries" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "dnsQueryClass" : "in", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "monitors" : [ "17410", "5" ] + } + + """ + dns_server_test_request = thousandeyes_sdk.tests.models.DnsServerTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.update_dns_server_test( + + test_id=test_id, + + dns_server_test_request=dns_server_test_request, + + aid=aid, + + _headers=self.te_headers("update_dns_server_test", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_dns_server_test_error_401(self) -> None: + """Integration test for update_dns_server_test error path (HTTP 401)""" + request_body_json = """ + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ "344753", "212697" ], + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "dnsTransportProtocol" : "udp", + "probeMode" : "auto", + "type" : "dns-server", + "usePublicBgp" : true, + "enabled" : true, + "protocol" : "tcp", + "fixedPacketRate" : 50, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "dnsServers" : [ "dns-example.net", "8.8.8.8" ], + "alertsEnabled" : true, + "recursiveQueries" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "dnsQueryClass" : "in", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "monitors" : [ "17410", "5" ] + } + + """ + dns_server_test_request = thousandeyes_sdk.tests.models.DnsServerTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.update_dns_server_test( + + test_id=test_id, + + dns_server_test_request=dns_server_test_request, + + aid=aid, + + _headers=self.te_headers("update_dns_server_test", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_dns_server_test_error_403(self) -> None: + """Integration test for update_dns_server_test error path (HTTP 403)""" + request_body_json = """ + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ "344753", "212697" ], + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "dnsTransportProtocol" : "udp", + "probeMode" : "auto", + "type" : "dns-server", + "usePublicBgp" : true, + "enabled" : true, + "protocol" : "tcp", + "fixedPacketRate" : 50, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "dnsServers" : [ "dns-example.net", "8.8.8.8" ], + "alertsEnabled" : true, + "recursiveQueries" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "dnsQueryClass" : "in", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "monitors" : [ "17410", "5" ] + } + + """ + dns_server_test_request = thousandeyes_sdk.tests.models.DnsServerTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.update_dns_server_test( + + test_id=test_id, + + dns_server_test_request=dns_server_test_request, + + aid=aid, + + _headers=self.te_headers("update_dns_server_test", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_dns_server_test_error_404(self) -> None: + """Integration test for update_dns_server_test error path (HTTP 404)""" + request_body_json = """ + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ "344753", "212697" ], + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "dnsTransportProtocol" : "udp", + "probeMode" : "auto", + "type" : "dns-server", + "usePublicBgp" : true, + "enabled" : true, + "protocol" : "tcp", + "fixedPacketRate" : 50, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "dnsServers" : [ "dns-example.net", "8.8.8.8" ], + "alertsEnabled" : true, + "recursiveQueries" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "dnsQueryClass" : "in", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "monitors" : [ "17410", "5" ] + } + + """ + dns_server_test_request = thousandeyes_sdk.tests.models.DnsServerTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.update_dns_server_test( + + test_id=test_id, + + dns_server_test_request=dns_server_test_request, + + aid=aid, + + _headers=self.te_headers("update_dns_server_test", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_dns_server_test_error_429(self) -> None: + """Integration test for update_dns_server_test error path (HTTP 429)""" + request_body_json = """ + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ "344753", "212697" ], + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "dnsTransportProtocol" : "udp", + "probeMode" : "auto", + "type" : "dns-server", + "usePublicBgp" : true, + "enabled" : true, + "protocol" : "tcp", + "fixedPacketRate" : 50, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "dnsServers" : [ "dns-example.net", "8.8.8.8" ], + "alertsEnabled" : true, + "recursiveQueries" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "dnsQueryClass" : "in", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "monitors" : [ "17410", "5" ] + } + + """ + dns_server_test_request = thousandeyes_sdk.tests.models.DnsServerTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.update_dns_server_test( + + test_id=test_id, + + dns_server_test_request=dns_server_test_request, + + aid=aid, + + _headers=self.te_headers("update_dns_server_test", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_dns_server_test_error_500(self) -> None: + """Integration test for update_dns_server_test error path (HTTP 500)""" + request_body_json = """ + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ "344753", "212697" ], + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "dnsTransportProtocol" : "udp", + "probeMode" : "auto", + "type" : "dns-server", + "usePublicBgp" : true, + "enabled" : true, + "protocol" : "tcp", + "fixedPacketRate" : 50, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "dnsServers" : [ "dns-example.net", "8.8.8.8" ], + "alertsEnabled" : true, + "recursiveQueries" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "dnsQueryClass" : "in", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "monitors" : [ "17410", "5" ] + } + + """ + dns_server_test_request = thousandeyes_sdk.tests.models.DnsServerTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.update_dns_server_test( + + test_id=test_id, + + dns_server_test_request=dns_server_test_request, + + aid=aid, + + _headers=self.te_headers("update_dns_server_test", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_dns_server_test_error_502(self) -> None: + """Integration test for update_dns_server_test error path (HTTP 502)""" + request_body_json = """ + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ "344753", "212697" ], + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "dnsTransportProtocol" : "udp", + "probeMode" : "auto", + "type" : "dns-server", + "usePublicBgp" : true, + "enabled" : true, + "protocol" : "tcp", + "fixedPacketRate" : 50, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "dnsServers" : [ "dns-example.net", "8.8.8.8" ], + "alertsEnabled" : true, + "recursiveQueries" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "dnsQueryClass" : "in", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "monitors" : [ "17410", "5" ] + } + + """ + dns_server_test_request = thousandeyes_sdk.tests.models.DnsServerTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.update_dns_server_test( + + test_id=test_id, + + dns_server_test_request=dns_server_test_request, + + aid=aid, + + _headers=self.te_headers("update_dns_server_test", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-tests/test/test_dns_trace_tests_api_integration.py b/thousandeyes-sdk-tests/test/test_dns_trace_tests_api_integration.py new file mode 100644 index 00000000..6640de03 --- /dev/null +++ b/thousandeyes-sdk-tests/test/test_dns_trace_tests_api_integration.py @@ -0,0 +1,2356 @@ +# coding: utf-8 + +""" + Tests API + + **Note:** The Page Load Tests, API Tests, and Web Transaction Tests APIs are not available for ThousandEyes for Government instance. This API allows you to list, create, edit, and delete Network and Application Synthetics tests. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.tests.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.tests.api.dns_trace_tests_api import DNSTraceTestsApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestDNSTraceTestsApiIntegration(IntegrationTestBase): + """DNSTraceTestsApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = DNSTraceTestsApi(self.api_client) + + + def test_create_dns_trace_test_happy_path(self) -> None: + """Integration test for create_dns_trace_test success path""" + request_body_json = """ + + { + "dnsQueryClass" : "in", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "dnsTransportProtocol" : "udp", + "type" : "dns-trace", + "enabled" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + } + + """ + dns_trace_test_request = thousandeyes_sdk.tests.models.DnsTraceTestRequest.from_json(request_body_json) + aid = '1234' + response_body_json = """ + { + "dnsQueryClass" : "in", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "alertRules" : [ { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + }, { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + } ], + "savedEvent" : true, + "description" : "ThousandEyes Test", + "dnsTransportProtocol" : "udp", + "type" : "dns-trace", + "enabled" : true, + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.create_dns_trace_test( + + dns_trace_test_request=dns_trace_test_request, + + aid=aid, + + _headers=self.te_headers("create_dns_trace_test"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_create_dns_trace_test_error_400(self) -> None: + """Integration test for create_dns_trace_test error path (HTTP 400)""" + request_body_json = """ + + { + "dnsQueryClass" : "in", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "dnsTransportProtocol" : "udp", + "type" : "dns-trace", + "enabled" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + } + + """ + dns_trace_test_request = thousandeyes_sdk.tests.models.DnsTraceTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.create_dns_trace_test( + + dns_trace_test_request=dns_trace_test_request, + + aid=aid, + + _headers=self.te_headers("create_dns_trace_test", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_dns_trace_test_error_401(self) -> None: + """Integration test for create_dns_trace_test error path (HTTP 401)""" + request_body_json = """ + + { + "dnsQueryClass" : "in", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "dnsTransportProtocol" : "udp", + "type" : "dns-trace", + "enabled" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + } + + """ + dns_trace_test_request = thousandeyes_sdk.tests.models.DnsTraceTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.create_dns_trace_test( + + dns_trace_test_request=dns_trace_test_request, + + aid=aid, + + _headers=self.te_headers("create_dns_trace_test", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_dns_trace_test_error_403(self) -> None: + """Integration test for create_dns_trace_test error path (HTTP 403)""" + request_body_json = """ + + { + "dnsQueryClass" : "in", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "dnsTransportProtocol" : "udp", + "type" : "dns-trace", + "enabled" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + } + + """ + dns_trace_test_request = thousandeyes_sdk.tests.models.DnsTraceTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.create_dns_trace_test( + + dns_trace_test_request=dns_trace_test_request, + + aid=aid, + + _headers=self.te_headers("create_dns_trace_test", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_dns_trace_test_error_404(self) -> None: + """Integration test for create_dns_trace_test error path (HTTP 404)""" + request_body_json = """ + + { + "dnsQueryClass" : "in", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "dnsTransportProtocol" : "udp", + "type" : "dns-trace", + "enabled" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + } + + """ + dns_trace_test_request = thousandeyes_sdk.tests.models.DnsTraceTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.create_dns_trace_test( + + dns_trace_test_request=dns_trace_test_request, + + aid=aid, + + _headers=self.te_headers("create_dns_trace_test", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_dns_trace_test_error_429(self) -> None: + """Integration test for create_dns_trace_test error path (HTTP 429)""" + request_body_json = """ + + { + "dnsQueryClass" : "in", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "dnsTransportProtocol" : "udp", + "type" : "dns-trace", + "enabled" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + } + + """ + dns_trace_test_request = thousandeyes_sdk.tests.models.DnsTraceTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.create_dns_trace_test( + + dns_trace_test_request=dns_trace_test_request, + + aid=aid, + + _headers=self.te_headers("create_dns_trace_test", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_dns_trace_test_error_500(self) -> None: + """Integration test for create_dns_trace_test error path (HTTP 500)""" + request_body_json = """ + + { + "dnsQueryClass" : "in", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "dnsTransportProtocol" : "udp", + "type" : "dns-trace", + "enabled" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + } + + """ + dns_trace_test_request = thousandeyes_sdk.tests.models.DnsTraceTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.create_dns_trace_test( + + dns_trace_test_request=dns_trace_test_request, + + aid=aid, + + _headers=self.te_headers("create_dns_trace_test", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_dns_trace_test_error_502(self) -> None: + """Integration test for create_dns_trace_test error path (HTTP 502)""" + request_body_json = """ + + { + "dnsQueryClass" : "in", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "dnsTransportProtocol" : "udp", + "type" : "dns-trace", + "enabled" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + } + + """ + dns_trace_test_request = thousandeyes_sdk.tests.models.DnsTraceTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.create_dns_trace_test( + + dns_trace_test_request=dns_trace_test_request, + + aid=aid, + + _headers=self.te_headers("create_dns_trace_test", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_delete_dns_trace_test_happy_path(self) -> None: + """Integration test for delete_dns_trace_test success path""" + test_id = '202701' + aid = '1234' + response = self.api.delete_dns_trace_test_with_http_info( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_dns_trace_test"), + ) + self.assertEqual(204, response.status_code) + self.assertIsNone(response.data) + + + def test_delete_dns_trace_test_error_401(self) -> None: + """Integration test for delete_dns_trace_test error path (HTTP 401)""" + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.delete_dns_trace_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_dns_trace_test", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_dns_trace_test_error_403(self) -> None: + """Integration test for delete_dns_trace_test error path (HTTP 403)""" + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.delete_dns_trace_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_dns_trace_test", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_dns_trace_test_error_404(self) -> None: + """Integration test for delete_dns_trace_test error path (HTTP 404)""" + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.delete_dns_trace_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_dns_trace_test", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_dns_trace_test_error_429(self) -> None: + """Integration test for delete_dns_trace_test error path (HTTP 429)""" + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.delete_dns_trace_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_dns_trace_test", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_dns_trace_test_error_500(self) -> None: + """Integration test for delete_dns_trace_test error path (HTTP 500)""" + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.delete_dns_trace_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_dns_trace_test", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_dns_trace_test_error_502(self) -> None: + """Integration test for delete_dns_trace_test error path (HTTP 502)""" + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.delete_dns_trace_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_dns_trace_test", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_dns_trace_test_happy_path(self) -> None: + """Integration test for get_dns_trace_test success path""" + test_id = '202701' + aid = '1234' + version_id = '1234' + response_body_json = """ + { + "dnsQueryClass" : "in", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "alertRules" : [ { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + }, { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + } ], + "savedEvent" : true, + "description" : "ThousandEyes Test", + "dnsTransportProtocol" : "udp", + "type" : "dns-trace", + "enabled" : true, + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_dns_trace_test( + + test_id=test_id, + + aid=aid, + + version_id=version_id, + + _headers=self.te_headers("get_dns_trace_test"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_dns_trace_test_error_401(self) -> None: + """Integration test for get_dns_trace_test error path (HTTP 401)""" + test_id = '202701' + aid = '1234' + version_id = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_dns_trace_test( + + test_id=test_id, + + aid=aid, + + version_id=version_id, + + _headers=self.te_headers("get_dns_trace_test", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_dns_trace_test_error_403(self) -> None: + """Integration test for get_dns_trace_test error path (HTTP 403)""" + test_id = '202701' + aid = '1234' + version_id = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_dns_trace_test( + + test_id=test_id, + + aid=aid, + + version_id=version_id, + + _headers=self.te_headers("get_dns_trace_test", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_dns_trace_test_error_404(self) -> None: + """Integration test for get_dns_trace_test error path (HTTP 404)""" + test_id = '202701' + aid = '1234' + version_id = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_dns_trace_test( + + test_id=test_id, + + aid=aid, + + version_id=version_id, + + _headers=self.te_headers("get_dns_trace_test", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_dns_trace_test_error_429(self) -> None: + """Integration test for get_dns_trace_test error path (HTTP 429)""" + test_id = '202701' + aid = '1234' + version_id = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_dns_trace_test( + + test_id=test_id, + + aid=aid, + + version_id=version_id, + + _headers=self.te_headers("get_dns_trace_test", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_dns_trace_test_error_500(self) -> None: + """Integration test for get_dns_trace_test error path (HTTP 500)""" + test_id = '202701' + aid = '1234' + version_id = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_dns_trace_test( + + test_id=test_id, + + aid=aid, + + version_id=version_id, + + _headers=self.te_headers("get_dns_trace_test", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_dns_trace_test_error_502(self) -> None: + """Integration test for get_dns_trace_test error path (HTTP 502)""" + test_id = '202701' + aid = '1234' + version_id = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.get_dns_trace_test( + + test_id=test_id, + + aid=aid, + + version_id=version_id, + + _headers=self.te_headers("get_dns_trace_test", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_dns_trace_tests_happy_path(self) -> None: + """Integration test for get_dns_trace_tests success path""" + aid = '1234' + response_body_json = """ + { + "tests" : [ { + "dnsQueryClass" : "in", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "dnsTransportProtocol" : "udp", + "type" : "dns-trace", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + }, { + "dnsQueryClass" : "in", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "dnsTransportProtocol" : "udp", + "type" : "dns-trace", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + } ], + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_dns_trace_tests( + + aid=aid, + + _headers=self.te_headers("get_dns_trace_tests"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_dns_trace_tests_error_401(self) -> None: + """Integration test for get_dns_trace_tests error path (HTTP 401)""" + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_dns_trace_tests( + + aid=aid, + + _headers=self.te_headers("get_dns_trace_tests", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_dns_trace_tests_error_403(self) -> None: + """Integration test for get_dns_trace_tests error path (HTTP 403)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_dns_trace_tests( + + aid=aid, + + _headers=self.te_headers("get_dns_trace_tests", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_dns_trace_tests_error_404(self) -> None: + """Integration test for get_dns_trace_tests error path (HTTP 404)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_dns_trace_tests( + + aid=aid, + + _headers=self.te_headers("get_dns_trace_tests", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_dns_trace_tests_error_429(self) -> None: + """Integration test for get_dns_trace_tests error path (HTTP 429)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_dns_trace_tests( + + aid=aid, + + _headers=self.te_headers("get_dns_trace_tests", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_dns_trace_tests_error_500(self) -> None: + """Integration test for get_dns_trace_tests error path (HTTP 500)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_dns_trace_tests( + + aid=aid, + + _headers=self.te_headers("get_dns_trace_tests", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_dns_trace_tests_error_502(self) -> None: + """Integration test for get_dns_trace_tests error path (HTTP 502)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.get_dns_trace_tests( + + aid=aid, + + _headers=self.te_headers("get_dns_trace_tests", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_update_dns_trace_test_happy_path(self) -> None: + """Integration test for update_dns_trace_test success path""" + request_body_json = """ + + { + "dnsQueryClass" : "in", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "dnsTransportProtocol" : "udp", + "type" : "dns-trace", + "enabled" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + } + + """ + dns_trace_test_request = thousandeyes_sdk.tests.models.DnsTraceTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + response_body_json = """ + { + "dnsQueryClass" : "in", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "alertRules" : [ { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + }, { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + } ], + "savedEvent" : true, + "description" : "ThousandEyes Test", + "dnsTransportProtocol" : "udp", + "type" : "dns-trace", + "enabled" : true, + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.update_dns_trace_test( + + test_id=test_id, + + dns_trace_test_request=dns_trace_test_request, + + aid=aid, + + _headers=self.te_headers("update_dns_trace_test"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_update_dns_trace_test_error_400(self) -> None: + """Integration test for update_dns_trace_test error path (HTTP 400)""" + request_body_json = """ + + { + "dnsQueryClass" : "in", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "dnsTransportProtocol" : "udp", + "type" : "dns-trace", + "enabled" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + } + + """ + dns_trace_test_request = thousandeyes_sdk.tests.models.DnsTraceTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.update_dns_trace_test( + + test_id=test_id, + + dns_trace_test_request=dns_trace_test_request, + + aid=aid, + + _headers=self.te_headers("update_dns_trace_test", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_dns_trace_test_error_401(self) -> None: + """Integration test for update_dns_trace_test error path (HTTP 401)""" + request_body_json = """ + + { + "dnsQueryClass" : "in", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "dnsTransportProtocol" : "udp", + "type" : "dns-trace", + "enabled" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + } + + """ + dns_trace_test_request = thousandeyes_sdk.tests.models.DnsTraceTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.update_dns_trace_test( + + test_id=test_id, + + dns_trace_test_request=dns_trace_test_request, + + aid=aid, + + _headers=self.te_headers("update_dns_trace_test", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_dns_trace_test_error_403(self) -> None: + """Integration test for update_dns_trace_test error path (HTTP 403)""" + request_body_json = """ + + { + "dnsQueryClass" : "in", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "dnsTransportProtocol" : "udp", + "type" : "dns-trace", + "enabled" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + } + + """ + dns_trace_test_request = thousandeyes_sdk.tests.models.DnsTraceTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.update_dns_trace_test( + + test_id=test_id, + + dns_trace_test_request=dns_trace_test_request, + + aid=aid, + + _headers=self.te_headers("update_dns_trace_test", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_dns_trace_test_error_404(self) -> None: + """Integration test for update_dns_trace_test error path (HTTP 404)""" + request_body_json = """ + + { + "dnsQueryClass" : "in", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "dnsTransportProtocol" : "udp", + "type" : "dns-trace", + "enabled" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + } + + """ + dns_trace_test_request = thousandeyes_sdk.tests.models.DnsTraceTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.update_dns_trace_test( + + test_id=test_id, + + dns_trace_test_request=dns_trace_test_request, + + aid=aid, + + _headers=self.te_headers("update_dns_trace_test", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_dns_trace_test_error_429(self) -> None: + """Integration test for update_dns_trace_test error path (HTTP 429)""" + request_body_json = """ + + { + "dnsQueryClass" : "in", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "dnsTransportProtocol" : "udp", + "type" : "dns-trace", + "enabled" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + } + + """ + dns_trace_test_request = thousandeyes_sdk.tests.models.DnsTraceTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.update_dns_trace_test( + + test_id=test_id, + + dns_trace_test_request=dns_trace_test_request, + + aid=aid, + + _headers=self.te_headers("update_dns_trace_test", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_dns_trace_test_error_500(self) -> None: + """Integration test for update_dns_trace_test error path (HTTP 500)""" + request_body_json = """ + + { + "dnsQueryClass" : "in", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "dnsTransportProtocol" : "udp", + "type" : "dns-trace", + "enabled" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + } + + """ + dns_trace_test_request = thousandeyes_sdk.tests.models.DnsTraceTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.update_dns_trace_test( + + test_id=test_id, + + dns_trace_test_request=dns_trace_test_request, + + aid=aid, + + _headers=self.te_headers("update_dns_trace_test", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_dns_trace_test_error_502(self) -> None: + """Integration test for update_dns_trace_test error path (HTTP 502)""" + request_body_json = """ + + { + "dnsQueryClass" : "in", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "dnsTransportProtocol" : "udp", + "type" : "dns-trace", + "enabled" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + } + + """ + dns_trace_test_request = thousandeyes_sdk.tests.models.DnsTraceTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.update_dns_trace_test( + + test_id=test_id, + + dns_trace_test_request=dns_trace_test_request, + + aid=aid, + + _headers=self.te_headers("update_dns_trace_test", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-tests/test/test_dnssec_tests_api_integration.py b/thousandeyes-sdk-tests/test/test_dnssec_tests_api_integration.py new file mode 100644 index 00000000..814db727 --- /dev/null +++ b/thousandeyes-sdk-tests/test/test_dnssec_tests_api_integration.py @@ -0,0 +1,2335 @@ +# coding: utf-8 + +""" + Tests API + + **Note:** The Page Load Tests, API Tests, and Web Transaction Tests APIs are not available for ThousandEyes for Government instance. This API allows you to list, create, edit, and delete Network and Application Synthetics tests. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.tests.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.tests.api.dnssec_tests_api import DNSSECTestsApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestDNSSECTestsApiIntegration(IntegrationTestBase): + """DNSSECTestsApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = DNSSECTestsApi(self.api_client) + + + def test_create_dns_sec_test_happy_path(self) -> None: + """Integration test for create_dns_sec_test success path""" + request_body_json = """ + + { + "dnsQueryClass" : "in", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "type" : "dnssec", + "enabled" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + } + + """ + dns_sec_test_request = thousandeyes_sdk.tests.models.DnsSecTestRequest.from_json(request_body_json) + aid = '1234' + response_body_json = """ + { + "dnsQueryClass" : "in", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "alertRules" : [ { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + }, { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + } ], + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "dnssec", + "enabled" : true, + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.create_dns_sec_test( + + dns_sec_test_request=dns_sec_test_request, + + aid=aid, + + _headers=self.te_headers("create_dns_sec_test"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_create_dns_sec_test_error_400(self) -> None: + """Integration test for create_dns_sec_test error path (HTTP 400)""" + request_body_json = """ + + { + "dnsQueryClass" : "in", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "type" : "dnssec", + "enabled" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + } + + """ + dns_sec_test_request = thousandeyes_sdk.tests.models.DnsSecTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.create_dns_sec_test( + + dns_sec_test_request=dns_sec_test_request, + + aid=aid, + + _headers=self.te_headers("create_dns_sec_test", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_dns_sec_test_error_401(self) -> None: + """Integration test for create_dns_sec_test error path (HTTP 401)""" + request_body_json = """ + + { + "dnsQueryClass" : "in", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "type" : "dnssec", + "enabled" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + } + + """ + dns_sec_test_request = thousandeyes_sdk.tests.models.DnsSecTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.create_dns_sec_test( + + dns_sec_test_request=dns_sec_test_request, + + aid=aid, + + _headers=self.te_headers("create_dns_sec_test", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_dns_sec_test_error_403(self) -> None: + """Integration test for create_dns_sec_test error path (HTTP 403)""" + request_body_json = """ + + { + "dnsQueryClass" : "in", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "type" : "dnssec", + "enabled" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + } + + """ + dns_sec_test_request = thousandeyes_sdk.tests.models.DnsSecTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.create_dns_sec_test( + + dns_sec_test_request=dns_sec_test_request, + + aid=aid, + + _headers=self.te_headers("create_dns_sec_test", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_dns_sec_test_error_404(self) -> None: + """Integration test for create_dns_sec_test error path (HTTP 404)""" + request_body_json = """ + + { + "dnsQueryClass" : "in", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "type" : "dnssec", + "enabled" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + } + + """ + dns_sec_test_request = thousandeyes_sdk.tests.models.DnsSecTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.create_dns_sec_test( + + dns_sec_test_request=dns_sec_test_request, + + aid=aid, + + _headers=self.te_headers("create_dns_sec_test", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_dns_sec_test_error_429(self) -> None: + """Integration test for create_dns_sec_test error path (HTTP 429)""" + request_body_json = """ + + { + "dnsQueryClass" : "in", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "type" : "dnssec", + "enabled" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + } + + """ + dns_sec_test_request = thousandeyes_sdk.tests.models.DnsSecTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.create_dns_sec_test( + + dns_sec_test_request=dns_sec_test_request, + + aid=aid, + + _headers=self.te_headers("create_dns_sec_test", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_dns_sec_test_error_500(self) -> None: + """Integration test for create_dns_sec_test error path (HTTP 500)""" + request_body_json = """ + + { + "dnsQueryClass" : "in", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "type" : "dnssec", + "enabled" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + } + + """ + dns_sec_test_request = thousandeyes_sdk.tests.models.DnsSecTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.create_dns_sec_test( + + dns_sec_test_request=dns_sec_test_request, + + aid=aid, + + _headers=self.te_headers("create_dns_sec_test", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_dns_sec_test_error_502(self) -> None: + """Integration test for create_dns_sec_test error path (HTTP 502)""" + request_body_json = """ + + { + "dnsQueryClass" : "in", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "type" : "dnssec", + "enabled" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + } + + """ + dns_sec_test_request = thousandeyes_sdk.tests.models.DnsSecTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.create_dns_sec_test( + + dns_sec_test_request=dns_sec_test_request, + + aid=aid, + + _headers=self.te_headers("create_dns_sec_test", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_delete_dns_sec_test_happy_path(self) -> None: + """Integration test for delete_dns_sec_test success path""" + test_id = '202701' + aid = '1234' + response = self.api.delete_dns_sec_test_with_http_info( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_dns_sec_test"), + ) + self.assertEqual(204, response.status_code) + self.assertIsNone(response.data) + + + def test_delete_dns_sec_test_error_401(self) -> None: + """Integration test for delete_dns_sec_test error path (HTTP 401)""" + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.delete_dns_sec_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_dns_sec_test", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_dns_sec_test_error_403(self) -> None: + """Integration test for delete_dns_sec_test error path (HTTP 403)""" + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.delete_dns_sec_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_dns_sec_test", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_dns_sec_test_error_404(self) -> None: + """Integration test for delete_dns_sec_test error path (HTTP 404)""" + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.delete_dns_sec_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_dns_sec_test", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_dns_sec_test_error_429(self) -> None: + """Integration test for delete_dns_sec_test error path (HTTP 429)""" + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.delete_dns_sec_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_dns_sec_test", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_dns_sec_test_error_500(self) -> None: + """Integration test for delete_dns_sec_test error path (HTTP 500)""" + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.delete_dns_sec_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_dns_sec_test", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_dns_sec_test_error_502(self) -> None: + """Integration test for delete_dns_sec_test error path (HTTP 502)""" + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.delete_dns_sec_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_dns_sec_test", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_dns_sec_test_happy_path(self) -> None: + """Integration test for get_dns_sec_test success path""" + test_id = '202701' + aid = '1234' + version_id = '1234' + response_body_json = """ + { + "dnsQueryClass" : "in", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "alertRules" : [ { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + }, { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + } ], + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "dnssec", + "enabled" : true, + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_dns_sec_test( + + test_id=test_id, + + aid=aid, + + version_id=version_id, + + _headers=self.te_headers("get_dns_sec_test"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_dns_sec_test_error_401(self) -> None: + """Integration test for get_dns_sec_test error path (HTTP 401)""" + test_id = '202701' + aid = '1234' + version_id = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_dns_sec_test( + + test_id=test_id, + + aid=aid, + + version_id=version_id, + + _headers=self.te_headers("get_dns_sec_test", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_dns_sec_test_error_403(self) -> None: + """Integration test for get_dns_sec_test error path (HTTP 403)""" + test_id = '202701' + aid = '1234' + version_id = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_dns_sec_test( + + test_id=test_id, + + aid=aid, + + version_id=version_id, + + _headers=self.te_headers("get_dns_sec_test", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_dns_sec_test_error_404(self) -> None: + """Integration test for get_dns_sec_test error path (HTTP 404)""" + test_id = '202701' + aid = '1234' + version_id = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_dns_sec_test( + + test_id=test_id, + + aid=aid, + + version_id=version_id, + + _headers=self.te_headers("get_dns_sec_test", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_dns_sec_test_error_429(self) -> None: + """Integration test for get_dns_sec_test error path (HTTP 429)""" + test_id = '202701' + aid = '1234' + version_id = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_dns_sec_test( + + test_id=test_id, + + aid=aid, + + version_id=version_id, + + _headers=self.te_headers("get_dns_sec_test", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_dns_sec_test_error_500(self) -> None: + """Integration test for get_dns_sec_test error path (HTTP 500)""" + test_id = '202701' + aid = '1234' + version_id = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_dns_sec_test( + + test_id=test_id, + + aid=aid, + + version_id=version_id, + + _headers=self.te_headers("get_dns_sec_test", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_dns_sec_test_error_502(self) -> None: + """Integration test for get_dns_sec_test error path (HTTP 502)""" + test_id = '202701' + aid = '1234' + version_id = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.get_dns_sec_test( + + test_id=test_id, + + aid=aid, + + version_id=version_id, + + _headers=self.te_headers("get_dns_sec_test", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_dns_sec_tests_happy_path(self) -> None: + """Integration test for get_dns_sec_tests success path""" + aid = '1234' + response_body_json = """ + { + "tests" : [ { + "dnsQueryClass" : "in", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "dnssec", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + }, { + "dnsQueryClass" : "in", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "dnssec", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + } ], + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_dns_sec_tests( + + aid=aid, + + _headers=self.te_headers("get_dns_sec_tests"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_dns_sec_tests_error_401(self) -> None: + """Integration test for get_dns_sec_tests error path (HTTP 401)""" + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_dns_sec_tests( + + aid=aid, + + _headers=self.te_headers("get_dns_sec_tests", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_dns_sec_tests_error_403(self) -> None: + """Integration test for get_dns_sec_tests error path (HTTP 403)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_dns_sec_tests( + + aid=aid, + + _headers=self.te_headers("get_dns_sec_tests", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_dns_sec_tests_error_404(self) -> None: + """Integration test for get_dns_sec_tests error path (HTTP 404)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_dns_sec_tests( + + aid=aid, + + _headers=self.te_headers("get_dns_sec_tests", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_dns_sec_tests_error_429(self) -> None: + """Integration test for get_dns_sec_tests error path (HTTP 429)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_dns_sec_tests( + + aid=aid, + + _headers=self.te_headers("get_dns_sec_tests", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_dns_sec_tests_error_500(self) -> None: + """Integration test for get_dns_sec_tests error path (HTTP 500)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_dns_sec_tests( + + aid=aid, + + _headers=self.te_headers("get_dns_sec_tests", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_dns_sec_tests_error_502(self) -> None: + """Integration test for get_dns_sec_tests error path (HTTP 502)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.get_dns_sec_tests( + + aid=aid, + + _headers=self.te_headers("get_dns_sec_tests", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_update_dns_sec_test_happy_path(self) -> None: + """Integration test for update_dns_sec_test success path""" + request_body_json = """ + + { + "dnsQueryClass" : "in", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "type" : "dnssec", + "enabled" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + } + + """ + dns_sec_test_request = thousandeyes_sdk.tests.models.DnsSecTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + response_body_json = """ + { + "dnsQueryClass" : "in", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "alertRules" : [ { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + }, { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + } ], + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "dnssec", + "enabled" : true, + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.update_dns_sec_test( + + test_id=test_id, + + dns_sec_test_request=dns_sec_test_request, + + aid=aid, + + _headers=self.te_headers("update_dns_sec_test"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_update_dns_sec_test_error_400(self) -> None: + """Integration test for update_dns_sec_test error path (HTTP 400)""" + request_body_json = """ + + { + "dnsQueryClass" : "in", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "type" : "dnssec", + "enabled" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + } + + """ + dns_sec_test_request = thousandeyes_sdk.tests.models.DnsSecTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.update_dns_sec_test( + + test_id=test_id, + + dns_sec_test_request=dns_sec_test_request, + + aid=aid, + + _headers=self.te_headers("update_dns_sec_test", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_dns_sec_test_error_401(self) -> None: + """Integration test for update_dns_sec_test error path (HTTP 401)""" + request_body_json = """ + + { + "dnsQueryClass" : "in", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "type" : "dnssec", + "enabled" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + } + + """ + dns_sec_test_request = thousandeyes_sdk.tests.models.DnsSecTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.update_dns_sec_test( + + test_id=test_id, + + dns_sec_test_request=dns_sec_test_request, + + aid=aid, + + _headers=self.te_headers("update_dns_sec_test", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_dns_sec_test_error_403(self) -> None: + """Integration test for update_dns_sec_test error path (HTTP 403)""" + request_body_json = """ + + { + "dnsQueryClass" : "in", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "type" : "dnssec", + "enabled" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + } + + """ + dns_sec_test_request = thousandeyes_sdk.tests.models.DnsSecTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.update_dns_sec_test( + + test_id=test_id, + + dns_sec_test_request=dns_sec_test_request, + + aid=aid, + + _headers=self.te_headers("update_dns_sec_test", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_dns_sec_test_error_404(self) -> None: + """Integration test for update_dns_sec_test error path (HTTP 404)""" + request_body_json = """ + + { + "dnsQueryClass" : "in", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "type" : "dnssec", + "enabled" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + } + + """ + dns_sec_test_request = thousandeyes_sdk.tests.models.DnsSecTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.update_dns_sec_test( + + test_id=test_id, + + dns_sec_test_request=dns_sec_test_request, + + aid=aid, + + _headers=self.te_headers("update_dns_sec_test", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_dns_sec_test_error_429(self) -> None: + """Integration test for update_dns_sec_test error path (HTTP 429)""" + request_body_json = """ + + { + "dnsQueryClass" : "in", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "type" : "dnssec", + "enabled" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + } + + """ + dns_sec_test_request = thousandeyes_sdk.tests.models.DnsSecTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.update_dns_sec_test( + + test_id=test_id, + + dns_sec_test_request=dns_sec_test_request, + + aid=aid, + + _headers=self.te_headers("update_dns_sec_test", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_dns_sec_test_error_500(self) -> None: + """Integration test for update_dns_sec_test error path (HTTP 500)""" + request_body_json = """ + + { + "dnsQueryClass" : "in", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "type" : "dnssec", + "enabled" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + } + + """ + dns_sec_test_request = thousandeyes_sdk.tests.models.DnsSecTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.update_dns_sec_test( + + test_id=test_id, + + dns_sec_test_request=dns_sec_test_request, + + aid=aid, + + _headers=self.te_headers("update_dns_sec_test", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_dns_sec_test_error_502(self) -> None: + """Integration test for update_dns_sec_test error path (HTTP 502)""" + request_body_json = """ + + { + "dnsQueryClass" : "in", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "type" : "dnssec", + "enabled" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "domain" : "www.thousandeyes.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + } + + """ + dns_sec_test_request = thousandeyes_sdk.tests.models.DnsSecTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.update_dns_sec_test( + + test_id=test_id, + + dns_sec_test_request=dns_sec_test_request, + + aid=aid, + + _headers=self.te_headers("update_dns_sec_test", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-tests/test/test_ftp_server_tests_api_integration.py b/thousandeyes-sdk-tests/test/test_ftp_server_tests_api_integration.py new file mode 100644 index 00000000..d9f18b08 --- /dev/null +++ b/thousandeyes-sdk-tests/test/test_ftp_server_tests_api_integration.py @@ -0,0 +1,2746 @@ +# coding: utf-8 + +""" + Tests API + + **Note:** The Page Load Tests, API Tests, and Web Transaction Tests APIs are not available for ThousandEyes for Government instance. This API allows you to list, create, edit, and delete Network and Application Synthetics tests. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.tests.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.tests.api.ftp_server_tests_api import FTPServerTestsApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestFTPServerTestsApiIntegration(IntegrationTestBase): + """FTPServerTestsApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = FTPServerTestsApi(self.api_client) + + + def test_create_ftp_server_test_happy_path(self) -> None: + """Integration test for create_ftp_server_test success path""" + request_body_json = """ + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "downloadLimit" : 1048576, + "alertRules" : [ "344753", "212697" ], + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "useExplicitFtps" : false, + "probeMode" : "auto", + "type" : "ftp-server", + "usePublicBgp" : true, + "enabled" : true, + "password" : "password", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "ftpTargetTime" : 1400, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "requestType" : "download", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "ftpTimeLimit" : 10, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "useActiveFtp" : false, + "username" : "username", + "monitors" : [ "17410", "5" ] + } + + """ + ftp_server_test_request = thousandeyes_sdk.tests.models.FtpServerTestRequest.from_json(request_body_json) + aid = '1234' + response_body_json = """ + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "downloadLimit" : 1048576, + "alertRules" : [ { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + }, { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + } ], + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "useExplicitFtps" : false, + "probeMode" : "auto", + "type" : "ftp-server", + "usePublicBgp" : true, + "enabled" : true, + "password" : "password", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "ftpTargetTime" : 1400, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "requestType" : "download", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "ftpTimeLimit" : 10, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "useActiveFtp" : false, + "username" : "username", + "monitors" : [ { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + }, { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + } ] + } + """ + expected_response = json.loads(response_body_json) + response = self.api.create_ftp_server_test( + + ftp_server_test_request=ftp_server_test_request, + + aid=aid, + + _headers=self.te_headers("create_ftp_server_test"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_create_ftp_server_test_error_400(self) -> None: + """Integration test for create_ftp_server_test error path (HTTP 400)""" + request_body_json = """ + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "downloadLimit" : 1048576, + "alertRules" : [ "344753", "212697" ], + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "useExplicitFtps" : false, + "probeMode" : "auto", + "type" : "ftp-server", + "usePublicBgp" : true, + "enabled" : true, + "password" : "password", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "ftpTargetTime" : 1400, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "requestType" : "download", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "ftpTimeLimit" : 10, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "useActiveFtp" : false, + "username" : "username", + "monitors" : [ "17410", "5" ] + } + + """ + ftp_server_test_request = thousandeyes_sdk.tests.models.FtpServerTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.create_ftp_server_test( + + ftp_server_test_request=ftp_server_test_request, + + aid=aid, + + _headers=self.te_headers("create_ftp_server_test", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_ftp_server_test_error_401(self) -> None: + """Integration test for create_ftp_server_test error path (HTTP 401)""" + request_body_json = """ + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "downloadLimit" : 1048576, + "alertRules" : [ "344753", "212697" ], + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "useExplicitFtps" : false, + "probeMode" : "auto", + "type" : "ftp-server", + "usePublicBgp" : true, + "enabled" : true, + "password" : "password", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "ftpTargetTime" : 1400, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "requestType" : "download", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "ftpTimeLimit" : 10, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "useActiveFtp" : false, + "username" : "username", + "monitors" : [ "17410", "5" ] + } + + """ + ftp_server_test_request = thousandeyes_sdk.tests.models.FtpServerTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.create_ftp_server_test( + + ftp_server_test_request=ftp_server_test_request, + + aid=aid, + + _headers=self.te_headers("create_ftp_server_test", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_ftp_server_test_error_403(self) -> None: + """Integration test for create_ftp_server_test error path (HTTP 403)""" + request_body_json = """ + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "downloadLimit" : 1048576, + "alertRules" : [ "344753", "212697" ], + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "useExplicitFtps" : false, + "probeMode" : "auto", + "type" : "ftp-server", + "usePublicBgp" : true, + "enabled" : true, + "password" : "password", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "ftpTargetTime" : 1400, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "requestType" : "download", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "ftpTimeLimit" : 10, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "useActiveFtp" : false, + "username" : "username", + "monitors" : [ "17410", "5" ] + } + + """ + ftp_server_test_request = thousandeyes_sdk.tests.models.FtpServerTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.create_ftp_server_test( + + ftp_server_test_request=ftp_server_test_request, + + aid=aid, + + _headers=self.te_headers("create_ftp_server_test", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_ftp_server_test_error_404(self) -> None: + """Integration test for create_ftp_server_test error path (HTTP 404)""" + request_body_json = """ + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "downloadLimit" : 1048576, + "alertRules" : [ "344753", "212697" ], + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "useExplicitFtps" : false, + "probeMode" : "auto", + "type" : "ftp-server", + "usePublicBgp" : true, + "enabled" : true, + "password" : "password", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "ftpTargetTime" : 1400, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "requestType" : "download", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "ftpTimeLimit" : 10, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "useActiveFtp" : false, + "username" : "username", + "monitors" : [ "17410", "5" ] + } + + """ + ftp_server_test_request = thousandeyes_sdk.tests.models.FtpServerTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.create_ftp_server_test( + + ftp_server_test_request=ftp_server_test_request, + + aid=aid, + + _headers=self.te_headers("create_ftp_server_test", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_ftp_server_test_error_429(self) -> None: + """Integration test for create_ftp_server_test error path (HTTP 429)""" + request_body_json = """ + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "downloadLimit" : 1048576, + "alertRules" : [ "344753", "212697" ], + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "useExplicitFtps" : false, + "probeMode" : "auto", + "type" : "ftp-server", + "usePublicBgp" : true, + "enabled" : true, + "password" : "password", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "ftpTargetTime" : 1400, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "requestType" : "download", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "ftpTimeLimit" : 10, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "useActiveFtp" : false, + "username" : "username", + "monitors" : [ "17410", "5" ] + } + + """ + ftp_server_test_request = thousandeyes_sdk.tests.models.FtpServerTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.create_ftp_server_test( + + ftp_server_test_request=ftp_server_test_request, + + aid=aid, + + _headers=self.te_headers("create_ftp_server_test", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_ftp_server_test_error_500(self) -> None: + """Integration test for create_ftp_server_test error path (HTTP 500)""" + request_body_json = """ + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "downloadLimit" : 1048576, + "alertRules" : [ "344753", "212697" ], + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "useExplicitFtps" : false, + "probeMode" : "auto", + "type" : "ftp-server", + "usePublicBgp" : true, + "enabled" : true, + "password" : "password", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "ftpTargetTime" : 1400, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "requestType" : "download", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "ftpTimeLimit" : 10, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "useActiveFtp" : false, + "username" : "username", + "monitors" : [ "17410", "5" ] + } + + """ + ftp_server_test_request = thousandeyes_sdk.tests.models.FtpServerTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.create_ftp_server_test( + + ftp_server_test_request=ftp_server_test_request, + + aid=aid, + + _headers=self.te_headers("create_ftp_server_test", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_ftp_server_test_error_502(self) -> None: + """Integration test for create_ftp_server_test error path (HTTP 502)""" + request_body_json = """ + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "downloadLimit" : 1048576, + "alertRules" : [ "344753", "212697" ], + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "useExplicitFtps" : false, + "probeMode" : "auto", + "type" : "ftp-server", + "usePublicBgp" : true, + "enabled" : true, + "password" : "password", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "ftpTargetTime" : 1400, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "requestType" : "download", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "ftpTimeLimit" : 10, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "useActiveFtp" : false, + "username" : "username", + "monitors" : [ "17410", "5" ] + } + + """ + ftp_server_test_request = thousandeyes_sdk.tests.models.FtpServerTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.create_ftp_server_test( + + ftp_server_test_request=ftp_server_test_request, + + aid=aid, + + _headers=self.te_headers("create_ftp_server_test", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_delete_ftp_server_test_happy_path(self) -> None: + """Integration test for delete_ftp_server_test success path""" + test_id = '202701' + aid = '1234' + response = self.api.delete_ftp_server_test_with_http_info( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_ftp_server_test"), + ) + self.assertEqual(204, response.status_code) + self.assertIsNone(response.data) + + + def test_delete_ftp_server_test_error_401(self) -> None: + """Integration test for delete_ftp_server_test error path (HTTP 401)""" + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.delete_ftp_server_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_ftp_server_test", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_ftp_server_test_error_403(self) -> None: + """Integration test for delete_ftp_server_test error path (HTTP 403)""" + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.delete_ftp_server_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_ftp_server_test", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_ftp_server_test_error_404(self) -> None: + """Integration test for delete_ftp_server_test error path (HTTP 404)""" + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.delete_ftp_server_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_ftp_server_test", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_ftp_server_test_error_429(self) -> None: + """Integration test for delete_ftp_server_test error path (HTTP 429)""" + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.delete_ftp_server_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_ftp_server_test", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_ftp_server_test_error_500(self) -> None: + """Integration test for delete_ftp_server_test error path (HTTP 500)""" + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.delete_ftp_server_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_ftp_server_test", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_ftp_server_test_happy_path(self) -> None: + """Integration test for get_ftp_server_test success path""" + test_id = '202701' + aid = '1234' + version_id = '1234' + response_body_json = """ + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "downloadLimit" : 1048576, + "alertRules" : [ { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + }, { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + } ], + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "useExplicitFtps" : false, + "probeMode" : "auto", + "type" : "ftp-server", + "usePublicBgp" : true, + "enabled" : true, + "password" : "password", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "ftpTargetTime" : 1400, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "requestType" : "download", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "ftpTimeLimit" : 10, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "useActiveFtp" : false, + "username" : "username", + "monitors" : [ { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + }, { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + } ] + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_ftp_server_test( + + test_id=test_id, + + aid=aid, + + version_id=version_id, + + _headers=self.te_headers("get_ftp_server_test"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_ftp_server_test_error_401(self) -> None: + """Integration test for get_ftp_server_test error path (HTTP 401)""" + test_id = '202701' + aid = '1234' + version_id = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_ftp_server_test( + + test_id=test_id, + + aid=aid, + + version_id=version_id, + + _headers=self.te_headers("get_ftp_server_test", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_ftp_server_test_error_403(self) -> None: + """Integration test for get_ftp_server_test error path (HTTP 403)""" + test_id = '202701' + aid = '1234' + version_id = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_ftp_server_test( + + test_id=test_id, + + aid=aid, + + version_id=version_id, + + _headers=self.te_headers("get_ftp_server_test", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_ftp_server_test_error_404(self) -> None: + """Integration test for get_ftp_server_test error path (HTTP 404)""" + test_id = '202701' + aid = '1234' + version_id = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_ftp_server_test( + + test_id=test_id, + + aid=aid, + + version_id=version_id, + + _headers=self.te_headers("get_ftp_server_test", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_ftp_server_test_error_429(self) -> None: + """Integration test for get_ftp_server_test error path (HTTP 429)""" + test_id = '202701' + aid = '1234' + version_id = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_ftp_server_test( + + test_id=test_id, + + aid=aid, + + version_id=version_id, + + _headers=self.te_headers("get_ftp_server_test", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_ftp_server_test_error_500(self) -> None: + """Integration test for get_ftp_server_test error path (HTTP 500)""" + test_id = '202701' + aid = '1234' + version_id = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_ftp_server_test( + + test_id=test_id, + + aid=aid, + + version_id=version_id, + + _headers=self.te_headers("get_ftp_server_test", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_ftp_server_test_error_502(self) -> None: + """Integration test for get_ftp_server_test error path (HTTP 502)""" + test_id = '202701' + aid = '1234' + version_id = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.get_ftp_server_test( + + test_id=test_id, + + aid=aid, + + version_id=version_id, + + _headers=self.te_headers("get_ftp_server_test", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_ftp_server_tests_happy_path(self) -> None: + """Integration test for get_ftp_server_tests success path""" + aid = '1234' + response_body_json = """ + { + "tests" : [ { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "downloadLimit" : 1048576, + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "useExplicitFtps" : false, + "probeMode" : "auto", + "type" : "ftp-server", + "usePublicBgp" : true, + "enabled" : true, + "password" : "password", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "ftpTargetTime" : 1400, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "requestType" : "download", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "ftpTimeLimit" : 10, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "useActiveFtp" : false, + "username" : "username" + }, { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "downloadLimit" : 1048576, + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "useExplicitFtps" : false, + "probeMode" : "auto", + "type" : "ftp-server", + "usePublicBgp" : true, + "enabled" : true, + "password" : "password", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "ftpTargetTime" : 1400, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "requestType" : "download", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "ftpTimeLimit" : 10, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "useActiveFtp" : false, + "username" : "username" + } ], + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_ftp_server_tests( + + aid=aid, + + _headers=self.te_headers("get_ftp_server_tests"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_ftp_server_tests_error_401(self) -> None: + """Integration test for get_ftp_server_tests error path (HTTP 401)""" + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_ftp_server_tests( + + aid=aid, + + _headers=self.te_headers("get_ftp_server_tests", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_ftp_server_tests_error_403(self) -> None: + """Integration test for get_ftp_server_tests error path (HTTP 403)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_ftp_server_tests( + + aid=aid, + + _headers=self.te_headers("get_ftp_server_tests", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_ftp_server_tests_error_404(self) -> None: + """Integration test for get_ftp_server_tests error path (HTTP 404)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_ftp_server_tests( + + aid=aid, + + _headers=self.te_headers("get_ftp_server_tests", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_ftp_server_tests_error_429(self) -> None: + """Integration test for get_ftp_server_tests error path (HTTP 429)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_ftp_server_tests( + + aid=aid, + + _headers=self.te_headers("get_ftp_server_tests", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_ftp_server_tests_error_500(self) -> None: + """Integration test for get_ftp_server_tests error path (HTTP 500)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_ftp_server_tests( + + aid=aid, + + _headers=self.te_headers("get_ftp_server_tests", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_ftp_server_tests_error_502(self) -> None: + """Integration test for get_ftp_server_tests error path (HTTP 502)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.get_ftp_server_tests( + + aid=aid, + + _headers=self.te_headers("get_ftp_server_tests", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_update_ftp_server_test_happy_path(self) -> None: + """Integration test for update_ftp_server_test success path""" + request_body_json = """ + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "downloadLimit" : 1048576, + "alertRules" : [ "344753", "212697" ], + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "useExplicitFtps" : false, + "probeMode" : "auto", + "type" : "ftp-server", + "usePublicBgp" : true, + "enabled" : true, + "password" : "password", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "ftpTargetTime" : 1400, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "requestType" : "download", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "ftpTimeLimit" : 10, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "useActiveFtp" : false, + "username" : "username", + "monitors" : [ "17410", "5" ] + } + + """ + ftp_server_test_request = thousandeyes_sdk.tests.models.FtpServerTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + response_body_json = """ + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "downloadLimit" : 1048576, + "alertRules" : [ { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + }, { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + } ], + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "useExplicitFtps" : false, + "probeMode" : "auto", + "type" : "ftp-server", + "usePublicBgp" : true, + "enabled" : true, + "password" : "password", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "ftpTargetTime" : 1400, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "requestType" : "download", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "ftpTimeLimit" : 10, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "useActiveFtp" : false, + "username" : "username", + "monitors" : [ { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + }, { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + } ] + } + """ + expected_response = json.loads(response_body_json) + response = self.api.update_ftp_server_test( + + test_id=test_id, + + ftp_server_test_request=ftp_server_test_request, + + aid=aid, + + _headers=self.te_headers("update_ftp_server_test"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_update_ftp_server_test_error_400(self) -> None: + """Integration test for update_ftp_server_test error path (HTTP 400)""" + request_body_json = """ + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "downloadLimit" : 1048576, + "alertRules" : [ "344753", "212697" ], + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "useExplicitFtps" : false, + "probeMode" : "auto", + "type" : "ftp-server", + "usePublicBgp" : true, + "enabled" : true, + "password" : "password", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "ftpTargetTime" : 1400, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "requestType" : "download", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "ftpTimeLimit" : 10, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "useActiveFtp" : false, + "username" : "username", + "monitors" : [ "17410", "5" ] + } + + """ + ftp_server_test_request = thousandeyes_sdk.tests.models.FtpServerTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.update_ftp_server_test( + + test_id=test_id, + + ftp_server_test_request=ftp_server_test_request, + + aid=aid, + + _headers=self.te_headers("update_ftp_server_test", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_ftp_server_test_error_401(self) -> None: + """Integration test for update_ftp_server_test error path (HTTP 401)""" + request_body_json = """ + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "downloadLimit" : 1048576, + "alertRules" : [ "344753", "212697" ], + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "useExplicitFtps" : false, + "probeMode" : "auto", + "type" : "ftp-server", + "usePublicBgp" : true, + "enabled" : true, + "password" : "password", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "ftpTargetTime" : 1400, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "requestType" : "download", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "ftpTimeLimit" : 10, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "useActiveFtp" : false, + "username" : "username", + "monitors" : [ "17410", "5" ] + } + + """ + ftp_server_test_request = thousandeyes_sdk.tests.models.FtpServerTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.update_ftp_server_test( + + test_id=test_id, + + ftp_server_test_request=ftp_server_test_request, + + aid=aid, + + _headers=self.te_headers("update_ftp_server_test", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_ftp_server_test_error_403(self) -> None: + """Integration test for update_ftp_server_test error path (HTTP 403)""" + request_body_json = """ + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "downloadLimit" : 1048576, + "alertRules" : [ "344753", "212697" ], + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "useExplicitFtps" : false, + "probeMode" : "auto", + "type" : "ftp-server", + "usePublicBgp" : true, + "enabled" : true, + "password" : "password", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "ftpTargetTime" : 1400, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "requestType" : "download", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "ftpTimeLimit" : 10, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "useActiveFtp" : false, + "username" : "username", + "monitors" : [ "17410", "5" ] + } + + """ + ftp_server_test_request = thousandeyes_sdk.tests.models.FtpServerTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.update_ftp_server_test( + + test_id=test_id, + + ftp_server_test_request=ftp_server_test_request, + + aid=aid, + + _headers=self.te_headers("update_ftp_server_test", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_ftp_server_test_error_404(self) -> None: + """Integration test for update_ftp_server_test error path (HTTP 404)""" + request_body_json = """ + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "downloadLimit" : 1048576, + "alertRules" : [ "344753", "212697" ], + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "useExplicitFtps" : false, + "probeMode" : "auto", + "type" : "ftp-server", + "usePublicBgp" : true, + "enabled" : true, + "password" : "password", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "ftpTargetTime" : 1400, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "requestType" : "download", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "ftpTimeLimit" : 10, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "useActiveFtp" : false, + "username" : "username", + "monitors" : [ "17410", "5" ] + } + + """ + ftp_server_test_request = thousandeyes_sdk.tests.models.FtpServerTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.update_ftp_server_test( + + test_id=test_id, + + ftp_server_test_request=ftp_server_test_request, + + aid=aid, + + _headers=self.te_headers("update_ftp_server_test", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_ftp_server_test_error_429(self) -> None: + """Integration test for update_ftp_server_test error path (HTTP 429)""" + request_body_json = """ + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "downloadLimit" : 1048576, + "alertRules" : [ "344753", "212697" ], + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "useExplicitFtps" : false, + "probeMode" : "auto", + "type" : "ftp-server", + "usePublicBgp" : true, + "enabled" : true, + "password" : "password", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "ftpTargetTime" : 1400, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "requestType" : "download", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "ftpTimeLimit" : 10, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "useActiveFtp" : false, + "username" : "username", + "monitors" : [ "17410", "5" ] + } + + """ + ftp_server_test_request = thousandeyes_sdk.tests.models.FtpServerTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.update_ftp_server_test( + + test_id=test_id, + + ftp_server_test_request=ftp_server_test_request, + + aid=aid, + + _headers=self.te_headers("update_ftp_server_test", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_ftp_server_test_error_500(self) -> None: + """Integration test for update_ftp_server_test error path (HTTP 500)""" + request_body_json = """ + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "downloadLimit" : 1048576, + "alertRules" : [ "344753", "212697" ], + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "useExplicitFtps" : false, + "probeMode" : "auto", + "type" : "ftp-server", + "usePublicBgp" : true, + "enabled" : true, + "password" : "password", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "ftpTargetTime" : 1400, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "requestType" : "download", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "ftpTimeLimit" : 10, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "useActiveFtp" : false, + "username" : "username", + "monitors" : [ "17410", "5" ] + } + + """ + ftp_server_test_request = thousandeyes_sdk.tests.models.FtpServerTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.update_ftp_server_test( + + test_id=test_id, + + ftp_server_test_request=ftp_server_test_request, + + aid=aid, + + _headers=self.te_headers("update_ftp_server_test", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_ftp_server_test_error_502(self) -> None: + """Integration test for update_ftp_server_test error path (HTTP 502)""" + request_body_json = """ + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "downloadLimit" : 1048576, + "alertRules" : [ "344753", "212697" ], + "bandwidthMeasurements" : true, + "description" : "ThousandEyes Test", + "useExplicitFtps" : false, + "probeMode" : "auto", + "type" : "ftp-server", + "usePublicBgp" : true, + "enabled" : true, + "password" : "password", + "protocol" : "tcp", + "fixedPacketRate" : 50, + "ftpTargetTime" : 1400, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "requestType" : "download", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "ftpTimeLimit" : 10, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "useActiveFtp" : false, + "username" : "username", + "monitors" : [ "17410", "5" ] + } + + """ + ftp_server_test_request = thousandeyes_sdk.tests.models.FtpServerTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.update_ftp_server_test( + + test_id=test_id, + + ftp_server_test_request=ftp_server_test_request, + + aid=aid, + + _headers=self.te_headers("update_ftp_server_test", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-tests/test/test_http_server_tests_api_integration.py b/thousandeyes-sdk-tests/test/test_http_server_tests_api_integration.py new file mode 100644 index 00000000..ea6d9e2a --- /dev/null +++ b/thousandeyes-sdk-tests/test/test_http_server_tests_api_integration.py @@ -0,0 +1,3845 @@ +# coding: utf-8 + +""" + Tests API + + **Note:** The Page Load Tests, API Tests, and Web Transaction Tests APIs are not available for ThousandEyes for Government instance. This API allows you to list, create, edit, and delete Network and Application Synthetics tests. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.tests.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.tests.api.http_server_tests_api import HTTPServerTestsApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestHTTPServerTestsApiIntegration(IntegrationTestBase): + """HTTPServerTestsApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = HTTPServerTestsApi(self.api_client) + + + def test_create_http_server_test_happy_path(self) -> None: + """Integration test for create_http_server_test success path""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "http-server", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "contentRegex" : "(regex)+", + "testName" : "ThousandEyes Test", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "monitors" : [ "17410", "5" ], + "sslVersion" : "Auto", + "useNtlm" : false, + "ipv6Policy" : "use-agent-policy", + "downloadLimit" : 2048, + "requestMethod" : "get", + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "alertsEnabled" : true, + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "headers" : [ "header1: value1", "header2: value2" ], + "numPathTraces" : 3, + "bgpMeasurements" : true, + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "postBody" : "{ \\"example\\" : \\"value\\"}", + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username" + } + + """ + http_server_test_request = thousandeyes_sdk.tests.models.HttpServerTestRequest.from_json(request_body_json) + aid = '1234' + response_body_json = """ + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "http-server", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "contentRegex" : "(regex)+", + "testName" : "ThousandEyes Test", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "overrideProxyId" : "281474976710706", + "monitors" : [ { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + }, { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + } ], + "sslVersion" : "Auto", + "useNtlm" : false, + "ipv6Policy" : "use-agent-policy", + "downloadLimit" : 2048, + "alertRules" : [ { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + }, { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + } ], + "requestMethod" : "get", + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "alertsEnabled" : true, + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "headers" : [ "header1: value1", "header2: value2" ], + "numPathTraces" : 3, + "bgpMeasurements" : true, + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "postBody" : "{ \\"example\\" : \\"value\\"}", + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.create_http_server_test( + + http_server_test_request=http_server_test_request, + + aid=aid, + + _headers=self.te_headers("create_http_server_test"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_create_http_server_test_error_400(self) -> None: + """Integration test for create_http_server_test error path (HTTP 400)""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "http-server", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "contentRegex" : "(regex)+", + "testName" : "ThousandEyes Test", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "monitors" : [ "17410", "5" ], + "sslVersion" : "Auto", + "useNtlm" : false, + "ipv6Policy" : "use-agent-policy", + "downloadLimit" : 2048, + "requestMethod" : "get", + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "alertsEnabled" : true, + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "headers" : [ "header1: value1", "header2: value2" ], + "numPathTraces" : 3, + "bgpMeasurements" : true, + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "postBody" : "{ \\"example\\" : \\"value\\"}", + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username" + } + + """ + http_server_test_request = thousandeyes_sdk.tests.models.HttpServerTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.create_http_server_test( + + http_server_test_request=http_server_test_request, + + aid=aid, + + _headers=self.te_headers("create_http_server_test", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_http_server_test_error_401(self) -> None: + """Integration test for create_http_server_test error path (HTTP 401)""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "http-server", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "contentRegex" : "(regex)+", + "testName" : "ThousandEyes Test", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "monitors" : [ "17410", "5" ], + "sslVersion" : "Auto", + "useNtlm" : false, + "ipv6Policy" : "use-agent-policy", + "downloadLimit" : 2048, + "requestMethod" : "get", + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "alertsEnabled" : true, + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "headers" : [ "header1: value1", "header2: value2" ], + "numPathTraces" : 3, + "bgpMeasurements" : true, + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "postBody" : "{ \\"example\\" : \\"value\\"}", + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username" + } + + """ + http_server_test_request = thousandeyes_sdk.tests.models.HttpServerTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.create_http_server_test( + + http_server_test_request=http_server_test_request, + + aid=aid, + + _headers=self.te_headers("create_http_server_test", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_http_server_test_error_403(self) -> None: + """Integration test for create_http_server_test error path (HTTP 403)""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "http-server", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "contentRegex" : "(regex)+", + "testName" : "ThousandEyes Test", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "monitors" : [ "17410", "5" ], + "sslVersion" : "Auto", + "useNtlm" : false, + "ipv6Policy" : "use-agent-policy", + "downloadLimit" : 2048, + "requestMethod" : "get", + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "alertsEnabled" : true, + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "headers" : [ "header1: value1", "header2: value2" ], + "numPathTraces" : 3, + "bgpMeasurements" : true, + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "postBody" : "{ \\"example\\" : \\"value\\"}", + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username" + } + + """ + http_server_test_request = thousandeyes_sdk.tests.models.HttpServerTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.create_http_server_test( + + http_server_test_request=http_server_test_request, + + aid=aid, + + _headers=self.te_headers("create_http_server_test", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_http_server_test_error_404(self) -> None: + """Integration test for create_http_server_test error path (HTTP 404)""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "http-server", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "contentRegex" : "(regex)+", + "testName" : "ThousandEyes Test", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "monitors" : [ "17410", "5" ], + "sslVersion" : "Auto", + "useNtlm" : false, + "ipv6Policy" : "use-agent-policy", + "downloadLimit" : 2048, + "requestMethod" : "get", + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "alertsEnabled" : true, + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "headers" : [ "header1: value1", "header2: value2" ], + "numPathTraces" : 3, + "bgpMeasurements" : true, + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "postBody" : "{ \\"example\\" : \\"value\\"}", + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username" + } + + """ + http_server_test_request = thousandeyes_sdk.tests.models.HttpServerTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.create_http_server_test( + + http_server_test_request=http_server_test_request, + + aid=aid, + + _headers=self.te_headers("create_http_server_test", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_http_server_test_error_429(self) -> None: + """Integration test for create_http_server_test error path (HTTP 429)""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "http-server", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "contentRegex" : "(regex)+", + "testName" : "ThousandEyes Test", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "monitors" : [ "17410", "5" ], + "sslVersion" : "Auto", + "useNtlm" : false, + "ipv6Policy" : "use-agent-policy", + "downloadLimit" : 2048, + "requestMethod" : "get", + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "alertsEnabled" : true, + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "headers" : [ "header1: value1", "header2: value2" ], + "numPathTraces" : 3, + "bgpMeasurements" : true, + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "postBody" : "{ \\"example\\" : \\"value\\"}", + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username" + } + + """ + http_server_test_request = thousandeyes_sdk.tests.models.HttpServerTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.create_http_server_test( + + http_server_test_request=http_server_test_request, + + aid=aid, + + _headers=self.te_headers("create_http_server_test", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_http_server_test_error_500(self) -> None: + """Integration test for create_http_server_test error path (HTTP 500)""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "http-server", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "contentRegex" : "(regex)+", + "testName" : "ThousandEyes Test", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "monitors" : [ "17410", "5" ], + "sslVersion" : "Auto", + "useNtlm" : false, + "ipv6Policy" : "use-agent-policy", + "downloadLimit" : 2048, + "requestMethod" : "get", + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "alertsEnabled" : true, + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "headers" : [ "header1: value1", "header2: value2" ], + "numPathTraces" : 3, + "bgpMeasurements" : true, + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "postBody" : "{ \\"example\\" : \\"value\\"}", + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username" + } + + """ + http_server_test_request = thousandeyes_sdk.tests.models.HttpServerTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.create_http_server_test( + + http_server_test_request=http_server_test_request, + + aid=aid, + + _headers=self.te_headers("create_http_server_test", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_http_server_test_error_502(self) -> None: + """Integration test for create_http_server_test error path (HTTP 502)""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "http-server", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "contentRegex" : "(regex)+", + "testName" : "ThousandEyes Test", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "monitors" : [ "17410", "5" ], + "sslVersion" : "Auto", + "useNtlm" : false, + "ipv6Policy" : "use-agent-policy", + "downloadLimit" : 2048, + "requestMethod" : "get", + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "alertsEnabled" : true, + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "headers" : [ "header1: value1", "header2: value2" ], + "numPathTraces" : 3, + "bgpMeasurements" : true, + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "postBody" : "{ \\"example\\" : \\"value\\"}", + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username" + } + + """ + http_server_test_request = thousandeyes_sdk.tests.models.HttpServerTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.create_http_server_test( + + http_server_test_request=http_server_test_request, + + aid=aid, + + _headers=self.te_headers("create_http_server_test", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_delete_http_server_test_happy_path(self) -> None: + """Integration test for delete_http_server_test success path""" + test_id = '202701' + aid = '1234' + response = self.api.delete_http_server_test_with_http_info( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_http_server_test"), + ) + self.assertEqual(204, response.status_code) + self.assertIsNone(response.data) + + + def test_delete_http_server_test_error_401(self) -> None: + """Integration test for delete_http_server_test error path (HTTP 401)""" + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.delete_http_server_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_http_server_test", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_http_server_test_error_403(self) -> None: + """Integration test for delete_http_server_test error path (HTTP 403)""" + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.delete_http_server_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_http_server_test", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_http_server_test_error_404(self) -> None: + """Integration test for delete_http_server_test error path (HTTP 404)""" + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.delete_http_server_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_http_server_test", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_http_server_test_error_429(self) -> None: + """Integration test for delete_http_server_test error path (HTTP 429)""" + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.delete_http_server_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_http_server_test", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_http_server_test_error_500(self) -> None: + """Integration test for delete_http_server_test error path (HTTP 500)""" + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.delete_http_server_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_http_server_test", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_http_server_test_error_502(self) -> None: + """Integration test for delete_http_server_test error path (HTTP 502)""" + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.delete_http_server_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_http_server_test", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_http_server_test_happy_path(self) -> None: + """Integration test for get_http_server_test success path""" + test_id = '202701' + aid = '1234' + version_id = '1234' + response_body_json = """ + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "http-server", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "contentRegex" : "(regex)+", + "testName" : "ThousandEyes Test", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "overrideProxyId" : "281474976710706", + "monitors" : [ { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + }, { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + } ], + "sslVersion" : "Auto", + "useNtlm" : false, + "ipv6Policy" : "use-agent-policy", + "downloadLimit" : 2048, + "alertRules" : [ { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + }, { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + } ], + "requestMethod" : "get", + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "alertsEnabled" : true, + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "headers" : [ "header1: value1", "header2: value2" ], + "numPathTraces" : 3, + "bgpMeasurements" : true, + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "postBody" : "{ \\"example\\" : \\"value\\"}", + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_http_server_test( + + test_id=test_id, + + aid=aid, + + version_id=version_id, + + _headers=self.te_headers("get_http_server_test"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_http_server_test_error_401(self) -> None: + """Integration test for get_http_server_test error path (HTTP 401)""" + test_id = '202701' + aid = '1234' + version_id = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_http_server_test( + + test_id=test_id, + + aid=aid, + + version_id=version_id, + + _headers=self.te_headers("get_http_server_test", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_http_server_test_error_403(self) -> None: + """Integration test for get_http_server_test error path (HTTP 403)""" + test_id = '202701' + aid = '1234' + version_id = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_http_server_test( + + test_id=test_id, + + aid=aid, + + version_id=version_id, + + _headers=self.te_headers("get_http_server_test", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_http_server_test_error_404(self) -> None: + """Integration test for get_http_server_test error path (HTTP 404)""" + test_id = '202701' + aid = '1234' + version_id = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_http_server_test( + + test_id=test_id, + + aid=aid, + + version_id=version_id, + + _headers=self.te_headers("get_http_server_test", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_http_server_test_error_429(self) -> None: + """Integration test for get_http_server_test error path (HTTP 429)""" + test_id = '202701' + aid = '1234' + version_id = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_http_server_test( + + test_id=test_id, + + aid=aid, + + version_id=version_id, + + _headers=self.te_headers("get_http_server_test", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_http_server_test_error_500(self) -> None: + """Integration test for get_http_server_test error path (HTTP 500)""" + test_id = '202701' + aid = '1234' + version_id = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_http_server_test( + + test_id=test_id, + + aid=aid, + + version_id=version_id, + + _headers=self.te_headers("get_http_server_test", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_http_server_test_error_502(self) -> None: + """Integration test for get_http_server_test error path (HTTP 502)""" + test_id = '202701' + aid = '1234' + version_id = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.get_http_server_test( + + test_id=test_id, + + aid=aid, + + version_id=version_id, + + _headers=self.te_headers("get_http_server_test", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_http_server_tests_happy_path(self) -> None: + """Integration test for get_http_server_tests success path""" + aid = '1234' + response_body_json = """ + { + "tests" : [ { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "http-server", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "contentRegex" : "(regex)+", + "testName" : "ThousandEyes Test", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "overrideProxyId" : "281474976710706", + "sslVersion" : "Auto", + "useNtlm" : false, + "ipv6Policy" : "use-agent-policy", + "downloadLimit" : 2048, + "requestMethod" : "get", + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "alertsEnabled" : true, + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "headers" : [ "header1: value1", "header2: value2" ], + "numPathTraces" : 3, + "bgpMeasurements" : true, + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "createdDate" : "2022-07-17T22:00:54Z", + "postBody" : "{ \\"example\\" : \\"value\\"}", + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username" + }, { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "http-server", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "contentRegex" : "(regex)+", + "testName" : "ThousandEyes Test", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "overrideProxyId" : "281474976710706", + "sslVersion" : "Auto", + "useNtlm" : false, + "ipv6Policy" : "use-agent-policy", + "downloadLimit" : 2048, + "requestMethod" : "get", + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "alertsEnabled" : true, + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "headers" : [ "header1: value1", "header2: value2" ], + "numPathTraces" : 3, + "bgpMeasurements" : true, + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "createdDate" : "2022-07-17T22:00:54Z", + "postBody" : "{ \\"example\\" : \\"value\\"}", + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username" + } ], + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_http_server_tests( + + aid=aid, + + _headers=self.te_headers("get_http_server_tests"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_http_server_tests_error_401(self) -> None: + """Integration test for get_http_server_tests error path (HTTP 401)""" + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_http_server_tests( + + aid=aid, + + _headers=self.te_headers("get_http_server_tests", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_http_server_tests_error_403(self) -> None: + """Integration test for get_http_server_tests error path (HTTP 403)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_http_server_tests( + + aid=aid, + + _headers=self.te_headers("get_http_server_tests", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_http_server_tests_error_404(self) -> None: + """Integration test for get_http_server_tests error path (HTTP 404)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_http_server_tests( + + aid=aid, + + _headers=self.te_headers("get_http_server_tests", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_http_server_tests_error_429(self) -> None: + """Integration test for get_http_server_tests error path (HTTP 429)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_http_server_tests( + + aid=aid, + + _headers=self.te_headers("get_http_server_tests", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_http_server_tests_error_500(self) -> None: + """Integration test for get_http_server_tests error path (HTTP 500)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_http_server_tests( + + aid=aid, + + _headers=self.te_headers("get_http_server_tests", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_http_server_tests_error_502(self) -> None: + """Integration test for get_http_server_tests error path (HTTP 502)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.get_http_server_tests( + + aid=aid, + + _headers=self.te_headers("get_http_server_tests", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_update_http_server_test_happy_path(self) -> None: + """Integration test for update_http_server_test success path""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "http-server", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "contentRegex" : "(regex)+", + "testName" : "ThousandEyes Test", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "monitors" : [ "17410", "5" ], + "sslVersion" : "Auto", + "useNtlm" : false, + "ipv6Policy" : "use-agent-policy", + "downloadLimit" : 2048, + "requestMethod" : "get", + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "alertsEnabled" : true, + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "headers" : [ "header1: value1", "header2: value2" ], + "numPathTraces" : 3, + "bgpMeasurements" : true, + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "postBody" : "{ \\"example\\" : \\"value\\"}", + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username" + } + + """ + http_server_test_request = thousandeyes_sdk.tests.models.HttpServerTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + response_body_json = """ + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "http-server", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "contentRegex" : "(regex)+", + "testName" : "ThousandEyes Test", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "overrideProxyId" : "281474976710706", + "monitors" : [ { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + }, { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + } ], + "sslVersion" : "Auto", + "useNtlm" : false, + "ipv6Policy" : "use-agent-policy", + "downloadLimit" : 2048, + "alertRules" : [ { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + }, { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + } ], + "requestMethod" : "get", + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "alertsEnabled" : true, + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "headers" : [ "header1: value1", "header2: value2" ], + "numPathTraces" : 3, + "bgpMeasurements" : true, + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "postBody" : "{ \\"example\\" : \\"value\\"}", + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.update_http_server_test( + + test_id=test_id, + + http_server_test_request=http_server_test_request, + + aid=aid, + + _headers=self.te_headers("update_http_server_test"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_update_http_server_test_error_400(self) -> None: + """Integration test for update_http_server_test error path (HTTP 400)""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "http-server", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "contentRegex" : "(regex)+", + "testName" : "ThousandEyes Test", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "monitors" : [ "17410", "5" ], + "sslVersion" : "Auto", + "useNtlm" : false, + "ipv6Policy" : "use-agent-policy", + "downloadLimit" : 2048, + "requestMethod" : "get", + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "alertsEnabled" : true, + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "headers" : [ "header1: value1", "header2: value2" ], + "numPathTraces" : 3, + "bgpMeasurements" : true, + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "postBody" : "{ \\"example\\" : \\"value\\"}", + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username" + } + + """ + http_server_test_request = thousandeyes_sdk.tests.models.HttpServerTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.update_http_server_test( + + test_id=test_id, + + http_server_test_request=http_server_test_request, + + aid=aid, + + _headers=self.te_headers("update_http_server_test", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_http_server_test_error_401(self) -> None: + """Integration test for update_http_server_test error path (HTTP 401)""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "http-server", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "contentRegex" : "(regex)+", + "testName" : "ThousandEyes Test", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "monitors" : [ "17410", "5" ], + "sslVersion" : "Auto", + "useNtlm" : false, + "ipv6Policy" : "use-agent-policy", + "downloadLimit" : 2048, + "requestMethod" : "get", + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "alertsEnabled" : true, + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "headers" : [ "header1: value1", "header2: value2" ], + "numPathTraces" : 3, + "bgpMeasurements" : true, + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "postBody" : "{ \\"example\\" : \\"value\\"}", + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username" + } + + """ + http_server_test_request = thousandeyes_sdk.tests.models.HttpServerTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.update_http_server_test( + + test_id=test_id, + + http_server_test_request=http_server_test_request, + + aid=aid, + + _headers=self.te_headers("update_http_server_test", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_http_server_test_error_403(self) -> None: + """Integration test for update_http_server_test error path (HTTP 403)""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "http-server", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "contentRegex" : "(regex)+", + "testName" : "ThousandEyes Test", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "monitors" : [ "17410", "5" ], + "sslVersion" : "Auto", + "useNtlm" : false, + "ipv6Policy" : "use-agent-policy", + "downloadLimit" : 2048, + "requestMethod" : "get", + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "alertsEnabled" : true, + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "headers" : [ "header1: value1", "header2: value2" ], + "numPathTraces" : 3, + "bgpMeasurements" : true, + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "postBody" : "{ \\"example\\" : \\"value\\"}", + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username" + } + + """ + http_server_test_request = thousandeyes_sdk.tests.models.HttpServerTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.update_http_server_test( + + test_id=test_id, + + http_server_test_request=http_server_test_request, + + aid=aid, + + _headers=self.te_headers("update_http_server_test", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_http_server_test_error_404(self) -> None: + """Integration test for update_http_server_test error path (HTTP 404)""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "http-server", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "contentRegex" : "(regex)+", + "testName" : "ThousandEyes Test", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "monitors" : [ "17410", "5" ], + "sslVersion" : "Auto", + "useNtlm" : false, + "ipv6Policy" : "use-agent-policy", + "downloadLimit" : 2048, + "requestMethod" : "get", + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "alertsEnabled" : true, + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "headers" : [ "header1: value1", "header2: value2" ], + "numPathTraces" : 3, + "bgpMeasurements" : true, + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "postBody" : "{ \\"example\\" : \\"value\\"}", + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username" + } + + """ + http_server_test_request = thousandeyes_sdk.tests.models.HttpServerTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.update_http_server_test( + + test_id=test_id, + + http_server_test_request=http_server_test_request, + + aid=aid, + + _headers=self.te_headers("update_http_server_test", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_http_server_test_error_429(self) -> None: + """Integration test for update_http_server_test error path (HTTP 429)""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "http-server", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "contentRegex" : "(regex)+", + "testName" : "ThousandEyes Test", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "monitors" : [ "17410", "5" ], + "sslVersion" : "Auto", + "useNtlm" : false, + "ipv6Policy" : "use-agent-policy", + "downloadLimit" : 2048, + "requestMethod" : "get", + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "alertsEnabled" : true, + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "headers" : [ "header1: value1", "header2: value2" ], + "numPathTraces" : 3, + "bgpMeasurements" : true, + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "postBody" : "{ \\"example\\" : \\"value\\"}", + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username" + } + + """ + http_server_test_request = thousandeyes_sdk.tests.models.HttpServerTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.update_http_server_test( + + test_id=test_id, + + http_server_test_request=http_server_test_request, + + aid=aid, + + _headers=self.te_headers("update_http_server_test", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_http_server_test_error_500(self) -> None: + """Integration test for update_http_server_test error path (HTTP 500)""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "http-server", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "contentRegex" : "(regex)+", + "testName" : "ThousandEyes Test", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "monitors" : [ "17410", "5" ], + "sslVersion" : "Auto", + "useNtlm" : false, + "ipv6Policy" : "use-agent-policy", + "downloadLimit" : 2048, + "requestMethod" : "get", + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "alertsEnabled" : true, + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "headers" : [ "header1: value1", "header2: value2" ], + "numPathTraces" : 3, + "bgpMeasurements" : true, + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "postBody" : "{ \\"example\\" : \\"value\\"}", + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username" + } + + """ + http_server_test_request = thousandeyes_sdk.tests.models.HttpServerTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.update_http_server_test( + + test_id=test_id, + + http_server_test_request=http_server_test_request, + + aid=aid, + + _headers=self.te_headers("update_http_server_test", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_http_server_test_error_502(self) -> None: + """Integration test for update_http_server_test error path (HTTP 502)""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "http-server", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "contentRegex" : "(regex)+", + "testName" : "ThousandEyes Test", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "monitors" : [ "17410", "5" ], + "sslVersion" : "Auto", + "useNtlm" : false, + "ipv6Policy" : "use-agent-policy", + "downloadLimit" : 2048, + "requestMethod" : "get", + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "alertsEnabled" : true, + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "headers" : [ "header1: value1", "header2: value2" ], + "numPathTraces" : 3, + "bgpMeasurements" : true, + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "postBody" : "{ \\"example\\" : \\"value\\"}", + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username" + } + + """ + http_server_test_request = thousandeyes_sdk.tests.models.HttpServerTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.update_http_server_test( + + test_id=test_id, + + http_server_test_request=http_server_test_request, + + aid=aid, + + _headers=self.te_headers("update_http_server_test", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-tests/test/test_page_load_tests_api_integration.py b/thousandeyes-sdk-tests/test/test_page_load_tests_api_integration.py new file mode 100644 index 00000000..b8d56e61 --- /dev/null +++ b/thousandeyes-sdk-tests/test/test_page_load_tests_api_integration.py @@ -0,0 +1,4055 @@ +# coding: utf-8 + +""" + Tests API + + **Note:** The Page Load Tests, API Tests, and Web Transaction Tests APIs are not available for ThousandEyes for Government instance. This API allows you to list, create, edit, and delete Network and Application Synthetics tests. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.tests.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.tests.api.page_load_tests_api import PageLoadTestsApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestPageLoadTestsApiIntegration(IntegrationTestBase): + """PageLoadTestsApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = PageLoadTestsApi(self.api_client) + + + def test_create_page_load_test_happy_path(self) -> None: + """Integration test for create_page_load_test success path""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "page-load", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "chromePolicies" : "{\\"ProxyMode\\":\\"direct\\"}", + "contentRegex" : "(regex)+", + "pageLoadingStrategy" : "normal", + "testName" : "ThousandEyes Test", + "allowMicAndCamera" : false, + "browserLanguage" : "en-US", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "httpInterval" : 120, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "emulatedDeviceId" : "2", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "monitors" : [ "17410", "5" ], + "sslVersion" : "Auto", + "useNtlm" : false, + "downloadLimit" : 2048, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "blockDomains" : "domain.com/", + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowGeolocation" : false, + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "alertsEnabled" : true, + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "pageLoadTargetTime" : 10, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "pageLoadTimeLimit" : 10, + "identifyAgentTrafficWithUserAgent" : false, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "disableScreenshot" : false, + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "subinterval" : 60, + "chromeOptions" : "--disable-gpu", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username" + } + + """ + page_load_test_request = thousandeyes_sdk.tests.models.PageLoadTestRequest.from_json(request_body_json) + aid = '1234' + response_body_json = """ + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "page-load", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "chromePolicies" : "{\\"ProxyMode\\":\\"direct\\"}", + "contentRegex" : "(regex)+", + "pageLoadingStrategy" : "normal", + "testName" : "ThousandEyes Test", + "allowMicAndCamera" : false, + "browserLanguage" : "en-US", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "httpInterval" : 120, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "emulatedDeviceId" : "2", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "overrideProxyId" : "281474976710706", + "monitors" : [ { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + }, { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + } ], + "sslVersion" : "Auto", + "useNtlm" : false, + "downloadLimit" : 2048, + "alertRules" : [ { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + }, { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + } ], + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "blockDomains" : "domain.com/", + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowGeolocation" : false, + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "alertsEnabled" : true, + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "pageLoadTargetTime" : 10, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "pageLoadTimeLimit" : 10, + "identifyAgentTrafficWithUserAgent" : false, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "disableScreenshot" : false, + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "subinterval" : 60, + "chromeOptions" : "--disable-gpu", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.create_page_load_test( + + page_load_test_request=page_load_test_request, + + aid=aid, + + _headers=self.te_headers("create_page_load_test"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_create_page_load_test_error_400(self) -> None: + """Integration test for create_page_load_test error path (HTTP 400)""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "page-load", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "chromePolicies" : "{\\"ProxyMode\\":\\"direct\\"}", + "contentRegex" : "(regex)+", + "pageLoadingStrategy" : "normal", + "testName" : "ThousandEyes Test", + "allowMicAndCamera" : false, + "browserLanguage" : "en-US", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "httpInterval" : 120, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "emulatedDeviceId" : "2", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "monitors" : [ "17410", "5" ], + "sslVersion" : "Auto", + "useNtlm" : false, + "downloadLimit" : 2048, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "blockDomains" : "domain.com/", + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowGeolocation" : false, + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "alertsEnabled" : true, + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "pageLoadTargetTime" : 10, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "pageLoadTimeLimit" : 10, + "identifyAgentTrafficWithUserAgent" : false, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "disableScreenshot" : false, + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "subinterval" : 60, + "chromeOptions" : "--disable-gpu", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username" + } + + """ + page_load_test_request = thousandeyes_sdk.tests.models.PageLoadTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.create_page_load_test( + + page_load_test_request=page_load_test_request, + + aid=aid, + + _headers=self.te_headers("create_page_load_test", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_page_load_test_error_401(self) -> None: + """Integration test for create_page_load_test error path (HTTP 401)""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "page-load", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "chromePolicies" : "{\\"ProxyMode\\":\\"direct\\"}", + "contentRegex" : "(regex)+", + "pageLoadingStrategy" : "normal", + "testName" : "ThousandEyes Test", + "allowMicAndCamera" : false, + "browserLanguage" : "en-US", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "httpInterval" : 120, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "emulatedDeviceId" : "2", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "monitors" : [ "17410", "5" ], + "sslVersion" : "Auto", + "useNtlm" : false, + "downloadLimit" : 2048, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "blockDomains" : "domain.com/", + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowGeolocation" : false, + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "alertsEnabled" : true, + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "pageLoadTargetTime" : 10, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "pageLoadTimeLimit" : 10, + "identifyAgentTrafficWithUserAgent" : false, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "disableScreenshot" : false, + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "subinterval" : 60, + "chromeOptions" : "--disable-gpu", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username" + } + + """ + page_load_test_request = thousandeyes_sdk.tests.models.PageLoadTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.create_page_load_test( + + page_load_test_request=page_load_test_request, + + aid=aid, + + _headers=self.te_headers("create_page_load_test", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_page_load_test_error_403(self) -> None: + """Integration test for create_page_load_test error path (HTTP 403)""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "page-load", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "chromePolicies" : "{\\"ProxyMode\\":\\"direct\\"}", + "contentRegex" : "(regex)+", + "pageLoadingStrategy" : "normal", + "testName" : "ThousandEyes Test", + "allowMicAndCamera" : false, + "browserLanguage" : "en-US", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "httpInterval" : 120, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "emulatedDeviceId" : "2", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "monitors" : [ "17410", "5" ], + "sslVersion" : "Auto", + "useNtlm" : false, + "downloadLimit" : 2048, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "blockDomains" : "domain.com/", + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowGeolocation" : false, + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "alertsEnabled" : true, + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "pageLoadTargetTime" : 10, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "pageLoadTimeLimit" : 10, + "identifyAgentTrafficWithUserAgent" : false, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "disableScreenshot" : false, + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "subinterval" : 60, + "chromeOptions" : "--disable-gpu", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username" + } + + """ + page_load_test_request = thousandeyes_sdk.tests.models.PageLoadTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.create_page_load_test( + + page_load_test_request=page_load_test_request, + + aid=aid, + + _headers=self.te_headers("create_page_load_test", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_page_load_test_error_404(self) -> None: + """Integration test for create_page_load_test error path (HTTP 404)""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "page-load", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "chromePolicies" : "{\\"ProxyMode\\":\\"direct\\"}", + "contentRegex" : "(regex)+", + "pageLoadingStrategy" : "normal", + "testName" : "ThousandEyes Test", + "allowMicAndCamera" : false, + "browserLanguage" : "en-US", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "httpInterval" : 120, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "emulatedDeviceId" : "2", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "monitors" : [ "17410", "5" ], + "sslVersion" : "Auto", + "useNtlm" : false, + "downloadLimit" : 2048, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "blockDomains" : "domain.com/", + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowGeolocation" : false, + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "alertsEnabled" : true, + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "pageLoadTargetTime" : 10, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "pageLoadTimeLimit" : 10, + "identifyAgentTrafficWithUserAgent" : false, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "disableScreenshot" : false, + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "subinterval" : 60, + "chromeOptions" : "--disable-gpu", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username" + } + + """ + page_load_test_request = thousandeyes_sdk.tests.models.PageLoadTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.create_page_load_test( + + page_load_test_request=page_load_test_request, + + aid=aid, + + _headers=self.te_headers("create_page_load_test", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_page_load_test_error_429(self) -> None: + """Integration test for create_page_load_test error path (HTTP 429)""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "page-load", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "chromePolicies" : "{\\"ProxyMode\\":\\"direct\\"}", + "contentRegex" : "(regex)+", + "pageLoadingStrategy" : "normal", + "testName" : "ThousandEyes Test", + "allowMicAndCamera" : false, + "browserLanguage" : "en-US", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "httpInterval" : 120, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "emulatedDeviceId" : "2", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "monitors" : [ "17410", "5" ], + "sslVersion" : "Auto", + "useNtlm" : false, + "downloadLimit" : 2048, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "blockDomains" : "domain.com/", + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowGeolocation" : false, + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "alertsEnabled" : true, + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "pageLoadTargetTime" : 10, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "pageLoadTimeLimit" : 10, + "identifyAgentTrafficWithUserAgent" : false, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "disableScreenshot" : false, + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "subinterval" : 60, + "chromeOptions" : "--disable-gpu", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username" + } + + """ + page_load_test_request = thousandeyes_sdk.tests.models.PageLoadTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.create_page_load_test( + + page_load_test_request=page_load_test_request, + + aid=aid, + + _headers=self.te_headers("create_page_load_test", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_page_load_test_error_500(self) -> None: + """Integration test for create_page_load_test error path (HTTP 500)""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "page-load", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "chromePolicies" : "{\\"ProxyMode\\":\\"direct\\"}", + "contentRegex" : "(regex)+", + "pageLoadingStrategy" : "normal", + "testName" : "ThousandEyes Test", + "allowMicAndCamera" : false, + "browserLanguage" : "en-US", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "httpInterval" : 120, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "emulatedDeviceId" : "2", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "monitors" : [ "17410", "5" ], + "sslVersion" : "Auto", + "useNtlm" : false, + "downloadLimit" : 2048, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "blockDomains" : "domain.com/", + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowGeolocation" : false, + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "alertsEnabled" : true, + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "pageLoadTargetTime" : 10, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "pageLoadTimeLimit" : 10, + "identifyAgentTrafficWithUserAgent" : false, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "disableScreenshot" : false, + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "subinterval" : 60, + "chromeOptions" : "--disable-gpu", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username" + } + + """ + page_load_test_request = thousandeyes_sdk.tests.models.PageLoadTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.create_page_load_test( + + page_load_test_request=page_load_test_request, + + aid=aid, + + _headers=self.te_headers("create_page_load_test", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_page_load_test_error_502(self) -> None: + """Integration test for create_page_load_test error path (HTTP 502)""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "page-load", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "chromePolicies" : "{\\"ProxyMode\\":\\"direct\\"}", + "contentRegex" : "(regex)+", + "pageLoadingStrategy" : "normal", + "testName" : "ThousandEyes Test", + "allowMicAndCamera" : false, + "browserLanguage" : "en-US", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "httpInterval" : 120, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "emulatedDeviceId" : "2", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "monitors" : [ "17410", "5" ], + "sslVersion" : "Auto", + "useNtlm" : false, + "downloadLimit" : 2048, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "blockDomains" : "domain.com/", + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowGeolocation" : false, + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "alertsEnabled" : true, + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "pageLoadTargetTime" : 10, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "pageLoadTimeLimit" : 10, + "identifyAgentTrafficWithUserAgent" : false, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "disableScreenshot" : false, + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "subinterval" : 60, + "chromeOptions" : "--disable-gpu", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username" + } + + """ + page_load_test_request = thousandeyes_sdk.tests.models.PageLoadTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.create_page_load_test( + + page_load_test_request=page_load_test_request, + + aid=aid, + + _headers=self.te_headers("create_page_load_test", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_delete_page_load_test_happy_path(self) -> None: + """Integration test for delete_page_load_test success path""" + test_id = '202701' + aid = '1234' + response = self.api.delete_page_load_test_with_http_info( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_page_load_test"), + ) + self.assertEqual(204, response.status_code) + self.assertIsNone(response.data) + + + def test_delete_page_load_test_error_401(self) -> None: + """Integration test for delete_page_load_test error path (HTTP 401)""" + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.delete_page_load_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_page_load_test", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_page_load_test_error_403(self) -> None: + """Integration test for delete_page_load_test error path (HTTP 403)""" + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.delete_page_load_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_page_load_test", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_page_load_test_error_404(self) -> None: + """Integration test for delete_page_load_test error path (HTTP 404)""" + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.delete_page_load_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_page_load_test", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_page_load_test_error_429(self) -> None: + """Integration test for delete_page_load_test error path (HTTP 429)""" + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.delete_page_load_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_page_load_test", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_page_load_test_error_500(self) -> None: + """Integration test for delete_page_load_test error path (HTTP 500)""" + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.delete_page_load_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_page_load_test", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_page_load_test_error_502(self) -> None: + """Integration test for delete_page_load_test error path (HTTP 502)""" + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.delete_page_load_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_page_load_test", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_page_load_test_happy_path(self) -> None: + """Integration test for get_page_load_test success path""" + test_id = '202701' + aid = '1234' + version_id = '1234' + response_body_json = """ + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "page-load", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "chromePolicies" : "{\\"ProxyMode\\":\\"direct\\"}", + "contentRegex" : "(regex)+", + "pageLoadingStrategy" : "normal", + "testName" : "ThousandEyes Test", + "allowMicAndCamera" : false, + "browserLanguage" : "en-US", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "httpInterval" : 120, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "emulatedDeviceId" : "2", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "overrideProxyId" : "281474976710706", + "monitors" : [ { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + }, { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + } ], + "sslVersion" : "Auto", + "useNtlm" : false, + "downloadLimit" : 2048, + "alertRules" : [ { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + }, { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + } ], + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "blockDomains" : "domain.com/", + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowGeolocation" : false, + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "alertsEnabled" : true, + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "pageLoadTargetTime" : 10, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "pageLoadTimeLimit" : 10, + "identifyAgentTrafficWithUserAgent" : false, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "disableScreenshot" : false, + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "subinterval" : 60, + "chromeOptions" : "--disable-gpu", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_page_load_test( + + test_id=test_id, + + aid=aid, + + version_id=version_id, + + _headers=self.te_headers("get_page_load_test"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_page_load_test_error_401(self) -> None: + """Integration test for get_page_load_test error path (HTTP 401)""" + test_id = '202701' + aid = '1234' + version_id = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_page_load_test( + + test_id=test_id, + + aid=aid, + + version_id=version_id, + + _headers=self.te_headers("get_page_load_test", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_page_load_test_error_403(self) -> None: + """Integration test for get_page_load_test error path (HTTP 403)""" + test_id = '202701' + aid = '1234' + version_id = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_page_load_test( + + test_id=test_id, + + aid=aid, + + version_id=version_id, + + _headers=self.te_headers("get_page_load_test", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_page_load_test_error_404(self) -> None: + """Integration test for get_page_load_test error path (HTTP 404)""" + test_id = '202701' + aid = '1234' + version_id = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_page_load_test( + + test_id=test_id, + + aid=aid, + + version_id=version_id, + + _headers=self.te_headers("get_page_load_test", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_page_load_test_error_429(self) -> None: + """Integration test for get_page_load_test error path (HTTP 429)""" + test_id = '202701' + aid = '1234' + version_id = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_page_load_test( + + test_id=test_id, + + aid=aid, + + version_id=version_id, + + _headers=self.te_headers("get_page_load_test", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_page_load_test_error_500(self) -> None: + """Integration test for get_page_load_test error path (HTTP 500)""" + test_id = '202701' + aid = '1234' + version_id = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_page_load_test( + + test_id=test_id, + + aid=aid, + + version_id=version_id, + + _headers=self.te_headers("get_page_load_test", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_page_load_test_error_502(self) -> None: + """Integration test for get_page_load_test error path (HTTP 502)""" + test_id = '202701' + aid = '1234' + version_id = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.get_page_load_test( + + test_id=test_id, + + aid=aid, + + version_id=version_id, + + _headers=self.te_headers("get_page_load_test", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_page_load_tests_happy_path(self) -> None: + """Integration test for get_page_load_tests success path""" + aid = '1234' + response_body_json = """ + { + "tests" : [ { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "page-load", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "chromePolicies" : "{\\"ProxyMode\\":\\"direct\\"}", + "contentRegex" : "(regex)+", + "pageLoadingStrategy" : "normal", + "testName" : "ThousandEyes Test", + "allowMicAndCamera" : false, + "browserLanguage" : "en-US", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "httpInterval" : 120, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "emulatedDeviceId" : "2", + "overrideProxyId" : "281474976710706", + "sslVersion" : "Auto", + "useNtlm" : false, + "downloadLimit" : 2048, + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "blockDomains" : "domain.com/", + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowGeolocation" : false, + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "alertsEnabled" : true, + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "pageLoadTargetTime" : 10, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "pageLoadTimeLimit" : 10, + "identifyAgentTrafficWithUserAgent" : false, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "createdDate" : "2022-07-17T22:00:54Z", + "disableScreenshot" : false, + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "subinterval" : 60, + "chromeOptions" : "--disable-gpu", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username" + }, { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "page-load", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "chromePolicies" : "{\\"ProxyMode\\":\\"direct\\"}", + "contentRegex" : "(regex)+", + "pageLoadingStrategy" : "normal", + "testName" : "ThousandEyes Test", + "allowMicAndCamera" : false, + "browserLanguage" : "en-US", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "httpInterval" : 120, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "emulatedDeviceId" : "2", + "overrideProxyId" : "281474976710706", + "sslVersion" : "Auto", + "useNtlm" : false, + "downloadLimit" : 2048, + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "blockDomains" : "domain.com/", + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowGeolocation" : false, + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "alertsEnabled" : true, + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "pageLoadTargetTime" : 10, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "pageLoadTimeLimit" : 10, + "identifyAgentTrafficWithUserAgent" : false, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "createdDate" : "2022-07-17T22:00:54Z", + "disableScreenshot" : false, + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "subinterval" : 60, + "chromeOptions" : "--disable-gpu", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username" + } ], + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_page_load_tests( + + aid=aid, + + _headers=self.te_headers("get_page_load_tests"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_page_load_tests_error_401(self) -> None: + """Integration test for get_page_load_tests error path (HTTP 401)""" + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_page_load_tests( + + aid=aid, + + _headers=self.te_headers("get_page_load_tests", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_page_load_tests_error_403(self) -> None: + """Integration test for get_page_load_tests error path (HTTP 403)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_page_load_tests( + + aid=aid, + + _headers=self.te_headers("get_page_load_tests", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_page_load_tests_error_404(self) -> None: + """Integration test for get_page_load_tests error path (HTTP 404)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_page_load_tests( + + aid=aid, + + _headers=self.te_headers("get_page_load_tests", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_page_load_tests_error_429(self) -> None: + """Integration test for get_page_load_tests error path (HTTP 429)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_page_load_tests( + + aid=aid, + + _headers=self.te_headers("get_page_load_tests", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_page_load_tests_error_500(self) -> None: + """Integration test for get_page_load_tests error path (HTTP 500)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_page_load_tests( + + aid=aid, + + _headers=self.te_headers("get_page_load_tests", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_page_load_tests_error_502(self) -> None: + """Integration test for get_page_load_tests error path (HTTP 502)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.get_page_load_tests( + + aid=aid, + + _headers=self.te_headers("get_page_load_tests", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_update_page_load_test_happy_path(self) -> None: + """Integration test for update_page_load_test success path""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "page-load", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "chromePolicies" : "{\\"ProxyMode\\":\\"direct\\"}", + "contentRegex" : "(regex)+", + "pageLoadingStrategy" : "normal", + "testName" : "ThousandEyes Test", + "allowMicAndCamera" : false, + "browserLanguage" : "en-US", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "httpInterval" : 120, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "emulatedDeviceId" : "2", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "monitors" : [ "17410", "5" ], + "sslVersion" : "Auto", + "useNtlm" : false, + "downloadLimit" : 2048, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "blockDomains" : "domain.com/", + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowGeolocation" : false, + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "alertsEnabled" : true, + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "pageLoadTargetTime" : 10, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "pageLoadTimeLimit" : 10, + "identifyAgentTrafficWithUserAgent" : false, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "disableScreenshot" : false, + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "subinterval" : 60, + "chromeOptions" : "--disable-gpu", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username" + } + + """ + page_load_test_request = thousandeyes_sdk.tests.models.PageLoadTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + response_body_json = """ + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "page-load", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "chromePolicies" : "{\\"ProxyMode\\":\\"direct\\"}", + "contentRegex" : "(regex)+", + "pageLoadingStrategy" : "normal", + "testName" : "ThousandEyes Test", + "allowMicAndCamera" : false, + "browserLanguage" : "en-US", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "httpInterval" : 120, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "emulatedDeviceId" : "2", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "overrideProxyId" : "281474976710706", + "monitors" : [ { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + }, { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + } ], + "sslVersion" : "Auto", + "useNtlm" : false, + "downloadLimit" : 2048, + "alertRules" : [ { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + }, { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + } ], + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "blockDomains" : "domain.com/", + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowGeolocation" : false, + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "alertsEnabled" : true, + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "pageLoadTargetTime" : 10, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "pageLoadTimeLimit" : 10, + "identifyAgentTrafficWithUserAgent" : false, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "disableScreenshot" : false, + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "subinterval" : 60, + "chromeOptions" : "--disable-gpu", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.update_page_load_test( + + test_id=test_id, + + page_load_test_request=page_load_test_request, + + aid=aid, + + _headers=self.te_headers("update_page_load_test"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_update_page_load_test_error_400(self) -> None: + """Integration test for update_page_load_test error path (HTTP 400)""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "page-load", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "chromePolicies" : "{\\"ProxyMode\\":\\"direct\\"}", + "contentRegex" : "(regex)+", + "pageLoadingStrategy" : "normal", + "testName" : "ThousandEyes Test", + "allowMicAndCamera" : false, + "browserLanguage" : "en-US", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "httpInterval" : 120, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "emulatedDeviceId" : "2", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "monitors" : [ "17410", "5" ], + "sslVersion" : "Auto", + "useNtlm" : false, + "downloadLimit" : 2048, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "blockDomains" : "domain.com/", + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowGeolocation" : false, + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "alertsEnabled" : true, + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "pageLoadTargetTime" : 10, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "pageLoadTimeLimit" : 10, + "identifyAgentTrafficWithUserAgent" : false, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "disableScreenshot" : false, + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "subinterval" : 60, + "chromeOptions" : "--disable-gpu", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username" + } + + """ + page_load_test_request = thousandeyes_sdk.tests.models.PageLoadTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.update_page_load_test( + + test_id=test_id, + + page_load_test_request=page_load_test_request, + + aid=aid, + + _headers=self.te_headers("update_page_load_test", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_page_load_test_error_401(self) -> None: + """Integration test for update_page_load_test error path (HTTP 401)""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "page-load", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "chromePolicies" : "{\\"ProxyMode\\":\\"direct\\"}", + "contentRegex" : "(regex)+", + "pageLoadingStrategy" : "normal", + "testName" : "ThousandEyes Test", + "allowMicAndCamera" : false, + "browserLanguage" : "en-US", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "httpInterval" : 120, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "emulatedDeviceId" : "2", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "monitors" : [ "17410", "5" ], + "sslVersion" : "Auto", + "useNtlm" : false, + "downloadLimit" : 2048, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "blockDomains" : "domain.com/", + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowGeolocation" : false, + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "alertsEnabled" : true, + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "pageLoadTargetTime" : 10, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "pageLoadTimeLimit" : 10, + "identifyAgentTrafficWithUserAgent" : false, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "disableScreenshot" : false, + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "subinterval" : 60, + "chromeOptions" : "--disable-gpu", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username" + } + + """ + page_load_test_request = thousandeyes_sdk.tests.models.PageLoadTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.update_page_load_test( + + test_id=test_id, + + page_load_test_request=page_load_test_request, + + aid=aid, + + _headers=self.te_headers("update_page_load_test", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_page_load_test_error_403(self) -> None: + """Integration test for update_page_load_test error path (HTTP 403)""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "page-load", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "chromePolicies" : "{\\"ProxyMode\\":\\"direct\\"}", + "contentRegex" : "(regex)+", + "pageLoadingStrategy" : "normal", + "testName" : "ThousandEyes Test", + "allowMicAndCamera" : false, + "browserLanguage" : "en-US", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "httpInterval" : 120, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "emulatedDeviceId" : "2", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "monitors" : [ "17410", "5" ], + "sslVersion" : "Auto", + "useNtlm" : false, + "downloadLimit" : 2048, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "blockDomains" : "domain.com/", + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowGeolocation" : false, + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "alertsEnabled" : true, + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "pageLoadTargetTime" : 10, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "pageLoadTimeLimit" : 10, + "identifyAgentTrafficWithUserAgent" : false, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "disableScreenshot" : false, + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "subinterval" : 60, + "chromeOptions" : "--disable-gpu", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username" + } + + """ + page_load_test_request = thousandeyes_sdk.tests.models.PageLoadTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.update_page_load_test( + + test_id=test_id, + + page_load_test_request=page_load_test_request, + + aid=aid, + + _headers=self.te_headers("update_page_load_test", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_page_load_test_error_404(self) -> None: + """Integration test for update_page_load_test error path (HTTP 404)""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "page-load", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "chromePolicies" : "{\\"ProxyMode\\":\\"direct\\"}", + "contentRegex" : "(regex)+", + "pageLoadingStrategy" : "normal", + "testName" : "ThousandEyes Test", + "allowMicAndCamera" : false, + "browserLanguage" : "en-US", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "httpInterval" : 120, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "emulatedDeviceId" : "2", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "monitors" : [ "17410", "5" ], + "sslVersion" : "Auto", + "useNtlm" : false, + "downloadLimit" : 2048, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "blockDomains" : "domain.com/", + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowGeolocation" : false, + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "alertsEnabled" : true, + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "pageLoadTargetTime" : 10, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "pageLoadTimeLimit" : 10, + "identifyAgentTrafficWithUserAgent" : false, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "disableScreenshot" : false, + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "subinterval" : 60, + "chromeOptions" : "--disable-gpu", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username" + } + + """ + page_load_test_request = thousandeyes_sdk.tests.models.PageLoadTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.update_page_load_test( + + test_id=test_id, + + page_load_test_request=page_load_test_request, + + aid=aid, + + _headers=self.te_headers("update_page_load_test", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_page_load_test_error_429(self) -> None: + """Integration test for update_page_load_test error path (HTTP 429)""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "page-load", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "chromePolicies" : "{\\"ProxyMode\\":\\"direct\\"}", + "contentRegex" : "(regex)+", + "pageLoadingStrategy" : "normal", + "testName" : "ThousandEyes Test", + "allowMicAndCamera" : false, + "browserLanguage" : "en-US", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "httpInterval" : 120, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "emulatedDeviceId" : "2", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "monitors" : [ "17410", "5" ], + "sslVersion" : "Auto", + "useNtlm" : false, + "downloadLimit" : 2048, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "blockDomains" : "domain.com/", + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowGeolocation" : false, + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "alertsEnabled" : true, + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "pageLoadTargetTime" : 10, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "pageLoadTimeLimit" : 10, + "identifyAgentTrafficWithUserAgent" : false, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "disableScreenshot" : false, + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "subinterval" : 60, + "chromeOptions" : "--disable-gpu", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username" + } + + """ + page_load_test_request = thousandeyes_sdk.tests.models.PageLoadTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.update_page_load_test( + + test_id=test_id, + + page_load_test_request=page_load_test_request, + + aid=aid, + + _headers=self.te_headers("update_page_load_test", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_page_load_test_error_500(self) -> None: + """Integration test for update_page_load_test error path (HTTP 500)""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "page-load", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "chromePolicies" : "{\\"ProxyMode\\":\\"direct\\"}", + "contentRegex" : "(regex)+", + "pageLoadingStrategy" : "normal", + "testName" : "ThousandEyes Test", + "allowMicAndCamera" : false, + "browserLanguage" : "en-US", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "httpInterval" : 120, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "emulatedDeviceId" : "2", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "monitors" : [ "17410", "5" ], + "sslVersion" : "Auto", + "useNtlm" : false, + "downloadLimit" : 2048, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "blockDomains" : "domain.com/", + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowGeolocation" : false, + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "alertsEnabled" : true, + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "pageLoadTargetTime" : 10, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "pageLoadTimeLimit" : 10, + "identifyAgentTrafficWithUserAgent" : false, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "disableScreenshot" : false, + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "subinterval" : 60, + "chromeOptions" : "--disable-gpu", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username" + } + + """ + page_load_test_request = thousandeyes_sdk.tests.models.PageLoadTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.update_page_load_test( + + test_id=test_id, + + page_load_test_request=page_load_test_request, + + aid=aid, + + _headers=self.te_headers("update_page_load_test", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_page_load_test_error_502(self) -> None: + """Integration test for update_page_load_test error path (HTTP 502)""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "page-load", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "chromePolicies" : "{\\"ProxyMode\\":\\"direct\\"}", + "contentRegex" : "(regex)+", + "pageLoadingStrategy" : "normal", + "testName" : "ThousandEyes Test", + "allowMicAndCamera" : false, + "browserLanguage" : "en-US", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "httpInterval" : 120, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "emulatedDeviceId" : "2", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "monitors" : [ "17410", "5" ], + "sslVersion" : "Auto", + "useNtlm" : false, + "downloadLimit" : 2048, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "blockDomains" : "domain.com/", + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowGeolocation" : false, + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "alertsEnabled" : true, + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "pageLoadTargetTime" : 10, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "pageLoadTimeLimit" : 10, + "identifyAgentTrafficWithUserAgent" : false, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "disableScreenshot" : false, + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "subinterval" : 60, + "chromeOptions" : "--disable-gpu", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username" + } + + """ + page_load_test_request = thousandeyes_sdk.tests.models.PageLoadTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.update_page_load_test( + + test_id=test_id, + + page_load_test_request=page_load_test_request, + + aid=aid, + + _headers=self.te_headers("update_page_load_test", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-tests/test/test_path_visualization_interface_groups_api_integration.py b/thousandeyes-sdk-tests/test/test_path_visualization_interface_groups_api_integration.py new file mode 100644 index 00000000..71f3d786 --- /dev/null +++ b/thousandeyes-sdk-tests/test/test_path_visualization_interface_groups_api_integration.py @@ -0,0 +1,1067 @@ +# coding: utf-8 + +""" + Tests API + + **Note:** The Page Load Tests, API Tests, and Web Transaction Tests APIs are not available for ThousandEyes for Government instance. This API allows you to list, create, edit, and delete Network and Application Synthetics tests. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.tests.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.tests.api.path_visualization_interface_groups_api import PathVisualizationInterfaceGroupsApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestPathVisualizationInterfaceGroupsApiIntegration(IntegrationTestBase): + """PathVisualizationInterfaceGroupsApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = PathVisualizationInterfaceGroupsApi(self.api_client) + + + def test_create_path_vis_interface_groups_happy_path(self) -> None: + """Integration test for create_path_vis_interface_groups success path""" + request_body_json = """ + + { + "groupName" : "PathVis Interface Group", + "rdnsRegexes" : [ "aggr403b-1.iad3.rackspace.net", "aggr403c-1.iad3.rackspace.net" ], + "groupId" : "281474976710706", + "ipAddresses" : [ "1.1.1.1", "8.8.8.8" ], + "aid" : "1234" + } + + """ + interface_group = thousandeyes_sdk.tests.models.InterfaceGroup.from_json(request_body_json) + aid = '1234' + response_body_json = """ + { + "groupName" : "PathVis Interface Group", + "rdnsRegexes" : [ "aggr403b-1.iad3.rackspace.net", "aggr403c-1.iad3.rackspace.net" ], + "groupId" : "281474976710706", + "ipAddresses" : [ "1.1.1.1", "8.8.8.8" ], + "aid" : "1234" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.create_path_vis_interface_groups( + + interface_group=interface_group, + + aid=aid, + + _headers=self.te_headers("create_path_vis_interface_groups"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_create_path_vis_interface_groups_error_400(self) -> None: + """Integration test for create_path_vis_interface_groups error path (HTTP 400)""" + request_body_json = """ + + { + "groupName" : "PathVis Interface Group", + "rdnsRegexes" : [ "aggr403b-1.iad3.rackspace.net", "aggr403c-1.iad3.rackspace.net" ], + "groupId" : "281474976710706", + "ipAddresses" : [ "1.1.1.1", "8.8.8.8" ], + "aid" : "1234" + } + + """ + interface_group = thousandeyes_sdk.tests.models.InterfaceGroup.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.create_path_vis_interface_groups( + + interface_group=interface_group, + + aid=aid, + + _headers=self.te_headers("create_path_vis_interface_groups", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_path_vis_interface_groups_error_401(self) -> None: + """Integration test for create_path_vis_interface_groups error path (HTTP 401)""" + request_body_json = """ + + { + "groupName" : "PathVis Interface Group", + "rdnsRegexes" : [ "aggr403b-1.iad3.rackspace.net", "aggr403c-1.iad3.rackspace.net" ], + "groupId" : "281474976710706", + "ipAddresses" : [ "1.1.1.1", "8.8.8.8" ], + "aid" : "1234" + } + + """ + interface_group = thousandeyes_sdk.tests.models.InterfaceGroup.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.create_path_vis_interface_groups( + + interface_group=interface_group, + + aid=aid, + + _headers=self.te_headers("create_path_vis_interface_groups", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_path_vis_interface_groups_error_403(self) -> None: + """Integration test for create_path_vis_interface_groups error path (HTTP 403)""" + request_body_json = """ + + { + "groupName" : "PathVis Interface Group", + "rdnsRegexes" : [ "aggr403b-1.iad3.rackspace.net", "aggr403c-1.iad3.rackspace.net" ], + "groupId" : "281474976710706", + "ipAddresses" : [ "1.1.1.1", "8.8.8.8" ], + "aid" : "1234" + } + + """ + interface_group = thousandeyes_sdk.tests.models.InterfaceGroup.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.create_path_vis_interface_groups( + + interface_group=interface_group, + + aid=aid, + + _headers=self.te_headers("create_path_vis_interface_groups", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_path_vis_interface_groups_error_404(self) -> None: + """Integration test for create_path_vis_interface_groups error path (HTTP 404)""" + request_body_json = """ + + { + "groupName" : "PathVis Interface Group", + "rdnsRegexes" : [ "aggr403b-1.iad3.rackspace.net", "aggr403c-1.iad3.rackspace.net" ], + "groupId" : "281474976710706", + "ipAddresses" : [ "1.1.1.1", "8.8.8.8" ], + "aid" : "1234" + } + + """ + interface_group = thousandeyes_sdk.tests.models.InterfaceGroup.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.create_path_vis_interface_groups( + + interface_group=interface_group, + + aid=aid, + + _headers=self.te_headers("create_path_vis_interface_groups", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_path_vis_interface_groups_error_429(self) -> None: + """Integration test for create_path_vis_interface_groups error path (HTTP 429)""" + request_body_json = """ + + { + "groupName" : "PathVis Interface Group", + "rdnsRegexes" : [ "aggr403b-1.iad3.rackspace.net", "aggr403c-1.iad3.rackspace.net" ], + "groupId" : "281474976710706", + "ipAddresses" : [ "1.1.1.1", "8.8.8.8" ], + "aid" : "1234" + } + + """ + interface_group = thousandeyes_sdk.tests.models.InterfaceGroup.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.create_path_vis_interface_groups( + + interface_group=interface_group, + + aid=aid, + + _headers=self.te_headers("create_path_vis_interface_groups", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_path_vis_interface_groups_error_500(self) -> None: + """Integration test for create_path_vis_interface_groups error path (HTTP 500)""" + request_body_json = """ + + { + "groupName" : "PathVis Interface Group", + "rdnsRegexes" : [ "aggr403b-1.iad3.rackspace.net", "aggr403c-1.iad3.rackspace.net" ], + "groupId" : "281474976710706", + "ipAddresses" : [ "1.1.1.1", "8.8.8.8" ], + "aid" : "1234" + } + + """ + interface_group = thousandeyes_sdk.tests.models.InterfaceGroup.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.create_path_vis_interface_groups( + + interface_group=interface_group, + + aid=aid, + + _headers=self.te_headers("create_path_vis_interface_groups", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_path_vis_interface_groups_error_502(self) -> None: + """Integration test for create_path_vis_interface_groups error path (HTTP 502)""" + request_body_json = """ + + { + "groupName" : "PathVis Interface Group", + "rdnsRegexes" : [ "aggr403b-1.iad3.rackspace.net", "aggr403c-1.iad3.rackspace.net" ], + "groupId" : "281474976710706", + "ipAddresses" : [ "1.1.1.1", "8.8.8.8" ], + "aid" : "1234" + } + + """ + interface_group = thousandeyes_sdk.tests.models.InterfaceGroup.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.create_path_vis_interface_groups( + + interface_group=interface_group, + + aid=aid, + + _headers=self.te_headers("create_path_vis_interface_groups", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_delete_path_vis_interface_group_happy_path(self) -> None: + """Integration test for delete_path_vis_interface_group success path""" + interface_group_id = '281474976710706' + aid = '1234' + response = self.api.delete_path_vis_interface_group_with_http_info( + + interface_group_id=interface_group_id, + + aid=aid, + + _headers=self.te_headers("delete_path_vis_interface_group"), + ) + self.assertEqual(204, response.status_code) + self.assertIsNone(response.data) + + + def test_delete_path_vis_interface_group_error_401(self) -> None: + """Integration test for delete_path_vis_interface_group error path (HTTP 401)""" + interface_group_id = '281474976710706' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.delete_path_vis_interface_group( + + interface_group_id=interface_group_id, + + aid=aid, + + _headers=self.te_headers("delete_path_vis_interface_group", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_path_vis_interface_group_error_403(self) -> None: + """Integration test for delete_path_vis_interface_group error path (HTTP 403)""" + interface_group_id = '281474976710706' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.delete_path_vis_interface_group( + + interface_group_id=interface_group_id, + + aid=aid, + + _headers=self.te_headers("delete_path_vis_interface_group", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_path_vis_interface_group_error_404(self) -> None: + """Integration test for delete_path_vis_interface_group error path (HTTP 404)""" + interface_group_id = '281474976710706' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.delete_path_vis_interface_group( + + interface_group_id=interface_group_id, + + aid=aid, + + _headers=self.te_headers("delete_path_vis_interface_group", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_path_vis_interface_group_error_429(self) -> None: + """Integration test for delete_path_vis_interface_group error path (HTTP 429)""" + interface_group_id = '281474976710706' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.delete_path_vis_interface_group( + + interface_group_id=interface_group_id, + + aid=aid, + + _headers=self.te_headers("delete_path_vis_interface_group", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_path_vis_interface_group_error_500(self) -> None: + """Integration test for delete_path_vis_interface_group error path (HTTP 500)""" + interface_group_id = '281474976710706' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.delete_path_vis_interface_group( + + interface_group_id=interface_group_id, + + aid=aid, + + _headers=self.te_headers("delete_path_vis_interface_group", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_path_vis_interface_group_error_502(self) -> None: + """Integration test for delete_path_vis_interface_group error path (HTTP 502)""" + interface_group_id = '281474976710706' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.delete_path_vis_interface_group( + + interface_group_id=interface_group_id, + + aid=aid, + + _headers=self.te_headers("delete_path_vis_interface_group", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_path_vis_interface_groups_happy_path(self) -> None: + """Integration test for get_path_vis_interface_groups success path""" + aid = '1234' + response_body_json = """ + { + "pathVisInterfaceGroups" : [ { + "groupName" : "PathVis Interface Group", + "rdnsRegexes" : [ "aggr403b-1.iad3.rackspace.net", "aggr403c-1.iad3.rackspace.net" ], + "groupId" : "281474976710706", + "ipAddresses" : [ "1.1.1.1", "8.8.8.8" ], + "aid" : "1234" + }, { + "groupName" : "PathVis Interface Group", + "rdnsRegexes" : [ "aggr403b-1.iad3.rackspace.net", "aggr403c-1.iad3.rackspace.net" ], + "groupId" : "281474976710706", + "ipAddresses" : [ "1.1.1.1", "8.8.8.8" ], + "aid" : "1234" + } ], + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_path_vis_interface_groups( + + aid=aid, + + _headers=self.te_headers("get_path_vis_interface_groups"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_path_vis_interface_groups_error_401(self) -> None: + """Integration test for get_path_vis_interface_groups error path (HTTP 401)""" + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_path_vis_interface_groups( + + aid=aid, + + _headers=self.te_headers("get_path_vis_interface_groups", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_path_vis_interface_groups_error_403(self) -> None: + """Integration test for get_path_vis_interface_groups error path (HTTP 403)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_path_vis_interface_groups( + + aid=aid, + + _headers=self.te_headers("get_path_vis_interface_groups", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_path_vis_interface_groups_error_404(self) -> None: + """Integration test for get_path_vis_interface_groups error path (HTTP 404)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_path_vis_interface_groups( + + aid=aid, + + _headers=self.te_headers("get_path_vis_interface_groups", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_path_vis_interface_groups_error_429(self) -> None: + """Integration test for get_path_vis_interface_groups error path (HTTP 429)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_path_vis_interface_groups( + + aid=aid, + + _headers=self.te_headers("get_path_vis_interface_groups", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_path_vis_interface_groups_error_500(self) -> None: + """Integration test for get_path_vis_interface_groups error path (HTTP 500)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_path_vis_interface_groups( + + aid=aid, + + _headers=self.te_headers("get_path_vis_interface_groups", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_path_vis_interface_groups_error_502(self) -> None: + """Integration test for get_path_vis_interface_groups error path (HTTP 502)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.get_path_vis_interface_groups( + + aid=aid, + + _headers=self.te_headers("get_path_vis_interface_groups", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_update_path_vis_interface_group_happy_path(self) -> None: + """Integration test for update_path_vis_interface_group success path""" + request_body_json = """ + + { + "groupName" : "PathVis Interface Group", + "rdnsRegexes" : [ "aggr403b-1.iad3.rackspace.net", "aggr403c-1.iad3.rackspace.net" ], + "groupId" : "281474976710706", + "ipAddresses" : [ "1.1.1.1", "8.8.8.8" ], + "aid" : "1234" + } + + """ + interface_group = thousandeyes_sdk.tests.models.InterfaceGroup.from_json(request_body_json) + interface_group_id = '281474976710706' + aid = '1234' + response_body_json = """ + { + "groupName" : "PathVis Interface Group", + "rdnsRegexes" : [ "aggr403b-1.iad3.rackspace.net", "aggr403c-1.iad3.rackspace.net" ], + "groupId" : "281474976710706", + "ipAddresses" : [ "1.1.1.1", "8.8.8.8" ], + "aid" : "1234" + } + """ + expected_response = json.loads(response_body_json) + response = self.api.update_path_vis_interface_group( + + interface_group_id=interface_group_id, + + interface_group=interface_group, + + aid=aid, + + _headers=self.te_headers("update_path_vis_interface_group"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_update_path_vis_interface_group_error_400(self) -> None: + """Integration test for update_path_vis_interface_group error path (HTTP 400)""" + request_body_json = """ + + { + "groupName" : "PathVis Interface Group", + "rdnsRegexes" : [ "aggr403b-1.iad3.rackspace.net", "aggr403c-1.iad3.rackspace.net" ], + "groupId" : "281474976710706", + "ipAddresses" : [ "1.1.1.1", "8.8.8.8" ], + "aid" : "1234" + } + + """ + interface_group = thousandeyes_sdk.tests.models.InterfaceGroup.from_json(request_body_json) + interface_group_id = '281474976710706' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.update_path_vis_interface_group( + + interface_group_id=interface_group_id, + + interface_group=interface_group, + + aid=aid, + + _headers=self.te_headers("update_path_vis_interface_group", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_path_vis_interface_group_error_401(self) -> None: + """Integration test for update_path_vis_interface_group error path (HTTP 401)""" + request_body_json = """ + + { + "groupName" : "PathVis Interface Group", + "rdnsRegexes" : [ "aggr403b-1.iad3.rackspace.net", "aggr403c-1.iad3.rackspace.net" ], + "groupId" : "281474976710706", + "ipAddresses" : [ "1.1.1.1", "8.8.8.8" ], + "aid" : "1234" + } + + """ + interface_group = thousandeyes_sdk.tests.models.InterfaceGroup.from_json(request_body_json) + interface_group_id = '281474976710706' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.update_path_vis_interface_group( + + interface_group_id=interface_group_id, + + interface_group=interface_group, + + aid=aid, + + _headers=self.te_headers("update_path_vis_interface_group", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_path_vis_interface_group_error_403(self) -> None: + """Integration test for update_path_vis_interface_group error path (HTTP 403)""" + request_body_json = """ + + { + "groupName" : "PathVis Interface Group", + "rdnsRegexes" : [ "aggr403b-1.iad3.rackspace.net", "aggr403c-1.iad3.rackspace.net" ], + "groupId" : "281474976710706", + "ipAddresses" : [ "1.1.1.1", "8.8.8.8" ], + "aid" : "1234" + } + + """ + interface_group = thousandeyes_sdk.tests.models.InterfaceGroup.from_json(request_body_json) + interface_group_id = '281474976710706' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.update_path_vis_interface_group( + + interface_group_id=interface_group_id, + + interface_group=interface_group, + + aid=aid, + + _headers=self.te_headers("update_path_vis_interface_group", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_path_vis_interface_group_error_404(self) -> None: + """Integration test for update_path_vis_interface_group error path (HTTP 404)""" + request_body_json = """ + + { + "groupName" : "PathVis Interface Group", + "rdnsRegexes" : [ "aggr403b-1.iad3.rackspace.net", "aggr403c-1.iad3.rackspace.net" ], + "groupId" : "281474976710706", + "ipAddresses" : [ "1.1.1.1", "8.8.8.8" ], + "aid" : "1234" + } + + """ + interface_group = thousandeyes_sdk.tests.models.InterfaceGroup.from_json(request_body_json) + interface_group_id = '281474976710706' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.update_path_vis_interface_group( + + interface_group_id=interface_group_id, + + interface_group=interface_group, + + aid=aid, + + _headers=self.te_headers("update_path_vis_interface_group", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_path_vis_interface_group_error_429(self) -> None: + """Integration test for update_path_vis_interface_group error path (HTTP 429)""" + request_body_json = """ + + { + "groupName" : "PathVis Interface Group", + "rdnsRegexes" : [ "aggr403b-1.iad3.rackspace.net", "aggr403c-1.iad3.rackspace.net" ], + "groupId" : "281474976710706", + "ipAddresses" : [ "1.1.1.1", "8.8.8.8" ], + "aid" : "1234" + } + + """ + interface_group = thousandeyes_sdk.tests.models.InterfaceGroup.from_json(request_body_json) + interface_group_id = '281474976710706' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.update_path_vis_interface_group( + + interface_group_id=interface_group_id, + + interface_group=interface_group, + + aid=aid, + + _headers=self.te_headers("update_path_vis_interface_group", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_path_vis_interface_group_error_500(self) -> None: + """Integration test for update_path_vis_interface_group error path (HTTP 500)""" + request_body_json = """ + + { + "groupName" : "PathVis Interface Group", + "rdnsRegexes" : [ "aggr403b-1.iad3.rackspace.net", "aggr403c-1.iad3.rackspace.net" ], + "groupId" : "281474976710706", + "ipAddresses" : [ "1.1.1.1", "8.8.8.8" ], + "aid" : "1234" + } + + """ + interface_group = thousandeyes_sdk.tests.models.InterfaceGroup.from_json(request_body_json) + interface_group_id = '281474976710706' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.update_path_vis_interface_group( + + interface_group_id=interface_group_id, + + interface_group=interface_group, + + aid=aid, + + _headers=self.te_headers("update_path_vis_interface_group", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_path_vis_interface_group_error_502(self) -> None: + """Integration test for update_path_vis_interface_group error path (HTTP 502)""" + request_body_json = """ + + { + "groupName" : "PathVis Interface Group", + "rdnsRegexes" : [ "aggr403b-1.iad3.rackspace.net", "aggr403c-1.iad3.rackspace.net" ], + "groupId" : "281474976710706", + "ipAddresses" : [ "1.1.1.1", "8.8.8.8" ], + "aid" : "1234" + } + + """ + interface_group = thousandeyes_sdk.tests.models.InterfaceGroup.from_json(request_body_json) + interface_group_id = '281474976710706' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.update_path_vis_interface_group( + + interface_group_id=interface_group_id, + + interface_group=interface_group, + + aid=aid, + + _headers=self.te_headers("update_path_vis_interface_group", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-tests/test/test_sip_server_tests_api_integration.py b/thousandeyes-sdk-tests/test/test_sip_server_tests_api_integration.py new file mode 100644 index 00000000..37366e48 --- /dev/null +++ b/thousandeyes-sdk-tests/test/test_sip_server_tests_api_integration.py @@ -0,0 +1,2757 @@ +# coding: utf-8 + +""" + Tests API + + **Note:** The Page Load Tests, API Tests, and Web Transaction Tests APIs are not available for ThousandEyes for Government instance. This API allows you to list, create, edit, and delete Network and Application Synthetics tests. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.tests.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.tests.api.sip_server_tests_api import SIPServerTestsApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestSIPServerTestsApiIntegration(IntegrationTestBase): + """SIPServerTestsApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = SIPServerTestsApi(self.api_client) + + + def test_create_sip_server_test_happy_path(self) -> None: + """Integration test for create_sip_server_test success path""" + request_body_json = """ + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "registerEnabled" : false, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "type" : "sip-server", + "usePublicBgp" : true, + "enabled" : true, + "fixedPacketRate" : 50, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "targetSipCredentials" : { + "password" : "password", + "protocol" : "tcp", + "port" : 49153, + "sipRegistrar" : "voice.thousandeyes.com", + "authUser" : "username", + "user" : "username" + }, + "testName" : "ThousandEyes Test", + "sipTargetTime" : 1000, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "optionsRegex" : "[\\"a-z\\"]", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "sipTimeLimit" : 5, + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "monitors" : [ "17410", "5" ] + } + + """ + sip_server_test_request = thousandeyes_sdk.tests.models.SipServerTestRequest.from_json(request_body_json) + aid = '1234' + response_body_json = """ + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "registerEnabled" : false, + "alertRules" : [ { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + }, { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + } ], + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "type" : "sip-server", + "authUser" : "username", + "usePublicBgp" : true, + "enabled" : true, + "fixedPacketRate" : 50, + "password" : "password", + "protocol" : "tcp", + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "sipTargetTime" : 1000, + "bgpMeasurements" : true, + "numPathTraces" : 3, + "optionsRegex" : "[\\"a-z\\"]", + "liveShare" : false, + "savedEvent" : true, + "sipRegistrar" : "voice.thousandeyes.com", + "networkMeasurements" : true, + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "port" : 49153, + "modifiedDate" : "2022-07-17T22:00:54Z", + "sipTimeLimit" : 5, + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "user" : "username", + "monitors" : [ { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + }, { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + } ] + } + """ + expected_response = json.loads(response_body_json) + response = self.api.create_sip_server_test( + + sip_server_test_request=sip_server_test_request, + + aid=aid, + + _headers=self.te_headers("create_sip_server_test"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_create_sip_server_test_error_400(self) -> None: + """Integration test for create_sip_server_test error path (HTTP 400)""" + request_body_json = """ + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "registerEnabled" : false, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "type" : "sip-server", + "usePublicBgp" : true, + "enabled" : true, + "fixedPacketRate" : 50, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "targetSipCredentials" : { + "password" : "password", + "protocol" : "tcp", + "port" : 49153, + "sipRegistrar" : "voice.thousandeyes.com", + "authUser" : "username", + "user" : "username" + }, + "testName" : "ThousandEyes Test", + "sipTargetTime" : 1000, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "optionsRegex" : "[\\"a-z\\"]", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "sipTimeLimit" : 5, + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "monitors" : [ "17410", "5" ] + } + + """ + sip_server_test_request = thousandeyes_sdk.tests.models.SipServerTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.create_sip_server_test( + + sip_server_test_request=sip_server_test_request, + + aid=aid, + + _headers=self.te_headers("create_sip_server_test", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_sip_server_test_error_401(self) -> None: + """Integration test for create_sip_server_test error path (HTTP 401)""" + request_body_json = """ + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "registerEnabled" : false, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "type" : "sip-server", + "usePublicBgp" : true, + "enabled" : true, + "fixedPacketRate" : 50, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "targetSipCredentials" : { + "password" : "password", + "protocol" : "tcp", + "port" : 49153, + "sipRegistrar" : "voice.thousandeyes.com", + "authUser" : "username", + "user" : "username" + }, + "testName" : "ThousandEyes Test", + "sipTargetTime" : 1000, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "optionsRegex" : "[\\"a-z\\"]", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "sipTimeLimit" : 5, + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "monitors" : [ "17410", "5" ] + } + + """ + sip_server_test_request = thousandeyes_sdk.tests.models.SipServerTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.create_sip_server_test( + + sip_server_test_request=sip_server_test_request, + + aid=aid, + + _headers=self.te_headers("create_sip_server_test", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_sip_server_test_error_403(self) -> None: + """Integration test for create_sip_server_test error path (HTTP 403)""" + request_body_json = """ + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "registerEnabled" : false, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "type" : "sip-server", + "usePublicBgp" : true, + "enabled" : true, + "fixedPacketRate" : 50, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "targetSipCredentials" : { + "password" : "password", + "protocol" : "tcp", + "port" : 49153, + "sipRegistrar" : "voice.thousandeyes.com", + "authUser" : "username", + "user" : "username" + }, + "testName" : "ThousandEyes Test", + "sipTargetTime" : 1000, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "optionsRegex" : "[\\"a-z\\"]", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "sipTimeLimit" : 5, + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "monitors" : [ "17410", "5" ] + } + + """ + sip_server_test_request = thousandeyes_sdk.tests.models.SipServerTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.create_sip_server_test( + + sip_server_test_request=sip_server_test_request, + + aid=aid, + + _headers=self.te_headers("create_sip_server_test", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_sip_server_test_error_404(self) -> None: + """Integration test for create_sip_server_test error path (HTTP 404)""" + request_body_json = """ + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "registerEnabled" : false, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "type" : "sip-server", + "usePublicBgp" : true, + "enabled" : true, + "fixedPacketRate" : 50, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "targetSipCredentials" : { + "password" : "password", + "protocol" : "tcp", + "port" : 49153, + "sipRegistrar" : "voice.thousandeyes.com", + "authUser" : "username", + "user" : "username" + }, + "testName" : "ThousandEyes Test", + "sipTargetTime" : 1000, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "optionsRegex" : "[\\"a-z\\"]", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "sipTimeLimit" : 5, + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "monitors" : [ "17410", "5" ] + } + + """ + sip_server_test_request = thousandeyes_sdk.tests.models.SipServerTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.create_sip_server_test( + + sip_server_test_request=sip_server_test_request, + + aid=aid, + + _headers=self.te_headers("create_sip_server_test", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_sip_server_test_error_429(self) -> None: + """Integration test for create_sip_server_test error path (HTTP 429)""" + request_body_json = """ + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "registerEnabled" : false, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "type" : "sip-server", + "usePublicBgp" : true, + "enabled" : true, + "fixedPacketRate" : 50, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "targetSipCredentials" : { + "password" : "password", + "protocol" : "tcp", + "port" : 49153, + "sipRegistrar" : "voice.thousandeyes.com", + "authUser" : "username", + "user" : "username" + }, + "testName" : "ThousandEyes Test", + "sipTargetTime" : 1000, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "optionsRegex" : "[\\"a-z\\"]", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "sipTimeLimit" : 5, + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "monitors" : [ "17410", "5" ] + } + + """ + sip_server_test_request = thousandeyes_sdk.tests.models.SipServerTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.create_sip_server_test( + + sip_server_test_request=sip_server_test_request, + + aid=aid, + + _headers=self.te_headers("create_sip_server_test", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_sip_server_test_error_500(self) -> None: + """Integration test for create_sip_server_test error path (HTTP 500)""" + request_body_json = """ + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "registerEnabled" : false, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "type" : "sip-server", + "usePublicBgp" : true, + "enabled" : true, + "fixedPacketRate" : 50, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "targetSipCredentials" : { + "password" : "password", + "protocol" : "tcp", + "port" : 49153, + "sipRegistrar" : "voice.thousandeyes.com", + "authUser" : "username", + "user" : "username" + }, + "testName" : "ThousandEyes Test", + "sipTargetTime" : 1000, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "optionsRegex" : "[\\"a-z\\"]", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "sipTimeLimit" : 5, + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "monitors" : [ "17410", "5" ] + } + + """ + sip_server_test_request = thousandeyes_sdk.tests.models.SipServerTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.create_sip_server_test( + + sip_server_test_request=sip_server_test_request, + + aid=aid, + + _headers=self.te_headers("create_sip_server_test", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_sip_server_test_error_502(self) -> None: + """Integration test for create_sip_server_test error path (HTTP 502)""" + request_body_json = """ + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "registerEnabled" : false, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "type" : "sip-server", + "usePublicBgp" : true, + "enabled" : true, + "fixedPacketRate" : 50, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "targetSipCredentials" : { + "password" : "password", + "protocol" : "tcp", + "port" : 49153, + "sipRegistrar" : "voice.thousandeyes.com", + "authUser" : "username", + "user" : "username" + }, + "testName" : "ThousandEyes Test", + "sipTargetTime" : 1000, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "optionsRegex" : "[\\"a-z\\"]", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "sipTimeLimit" : 5, + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "monitors" : [ "17410", "5" ] + } + + """ + sip_server_test_request = thousandeyes_sdk.tests.models.SipServerTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.create_sip_server_test( + + sip_server_test_request=sip_server_test_request, + + aid=aid, + + _headers=self.te_headers("create_sip_server_test", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_delete_sip_server_test_happy_path(self) -> None: + """Integration test for delete_sip_server_test success path""" + test_id = '202701' + aid = '1234' + response = self.api.delete_sip_server_test_with_http_info( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_sip_server_test"), + ) + self.assertEqual(204, response.status_code) + self.assertIsNone(response.data) + + + def test_delete_sip_server_test_error_401(self) -> None: + """Integration test for delete_sip_server_test error path (HTTP 401)""" + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.delete_sip_server_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_sip_server_test", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_sip_server_test_error_403(self) -> None: + """Integration test for delete_sip_server_test error path (HTTP 403)""" + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.delete_sip_server_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_sip_server_test", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_sip_server_test_error_404(self) -> None: + """Integration test for delete_sip_server_test error path (HTTP 404)""" + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.delete_sip_server_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_sip_server_test", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_sip_server_test_error_429(self) -> None: + """Integration test for delete_sip_server_test error path (HTTP 429)""" + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.delete_sip_server_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_sip_server_test", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_sip_server_test_error_500(self) -> None: + """Integration test for delete_sip_server_test error path (HTTP 500)""" + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.delete_sip_server_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_sip_server_test", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_sip_server_test_happy_path(self) -> None: + """Integration test for get_sip_server_test success path""" + test_id = '202701' + aid = '1234' + version_id = '1234' + response_body_json = """ + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "registerEnabled" : false, + "alertRules" : [ { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + }, { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + } ], + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "type" : "sip-server", + "authUser" : "username", + "usePublicBgp" : true, + "enabled" : true, + "fixedPacketRate" : 50, + "password" : "password", + "protocol" : "tcp", + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "sipTargetTime" : 1000, + "bgpMeasurements" : true, + "numPathTraces" : 3, + "optionsRegex" : "[\\"a-z\\"]", + "liveShare" : false, + "savedEvent" : true, + "sipRegistrar" : "voice.thousandeyes.com", + "networkMeasurements" : true, + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "port" : 49153, + "modifiedDate" : "2022-07-17T22:00:54Z", + "sipTimeLimit" : 5, + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "user" : "username", + "monitors" : [ { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + }, { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + } ] + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_sip_server_test( + + test_id=test_id, + + aid=aid, + + version_id=version_id, + + _headers=self.te_headers("get_sip_server_test"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_sip_server_test_error_401(self) -> None: + """Integration test for get_sip_server_test error path (HTTP 401)""" + test_id = '202701' + aid = '1234' + version_id = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_sip_server_test( + + test_id=test_id, + + aid=aid, + + version_id=version_id, + + _headers=self.te_headers("get_sip_server_test", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_sip_server_test_error_403(self) -> None: + """Integration test for get_sip_server_test error path (HTTP 403)""" + test_id = '202701' + aid = '1234' + version_id = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_sip_server_test( + + test_id=test_id, + + aid=aid, + + version_id=version_id, + + _headers=self.te_headers("get_sip_server_test", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_sip_server_test_error_404(self) -> None: + """Integration test for get_sip_server_test error path (HTTP 404)""" + test_id = '202701' + aid = '1234' + version_id = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_sip_server_test( + + test_id=test_id, + + aid=aid, + + version_id=version_id, + + _headers=self.te_headers("get_sip_server_test", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_sip_server_test_error_429(self) -> None: + """Integration test for get_sip_server_test error path (HTTP 429)""" + test_id = '202701' + aid = '1234' + version_id = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_sip_server_test( + + test_id=test_id, + + aid=aid, + + version_id=version_id, + + _headers=self.te_headers("get_sip_server_test", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_sip_server_test_error_500(self) -> None: + """Integration test for get_sip_server_test error path (HTTP 500)""" + test_id = '202701' + aid = '1234' + version_id = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_sip_server_test( + + test_id=test_id, + + aid=aid, + + version_id=version_id, + + _headers=self.te_headers("get_sip_server_test", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_sip_server_test_error_502(self) -> None: + """Integration test for get_sip_server_test error path (HTTP 502)""" + test_id = '202701' + aid = '1234' + version_id = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.get_sip_server_test( + + test_id=test_id, + + aid=aid, + + version_id=version_id, + + _headers=self.te_headers("get_sip_server_test", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_sip_server_tests_happy_path(self) -> None: + """Integration test for get_sip_server_tests success path""" + aid = '1234' + response_body_json = """ + { + "tests" : [ { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "registerEnabled" : false, + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "type" : "sip-server", + "authUser" : "username", + "usePublicBgp" : true, + "enabled" : true, + "fixedPacketRate" : 50, + "password" : "password", + "protocol" : "tcp", + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "sipTargetTime" : 1000, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "optionsRegex" : "[\\"a-z\\"]", + "liveShare" : false, + "savedEvent" : true, + "sipRegistrar" : "voice.thousandeyes.com", + "networkMeasurements" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "port" : 49153, + "modifiedDate" : "2022-07-17T22:00:54Z", + "sipTimeLimit" : 5, + "interval" : 60, + "testId" : "281474976710706", + "user" : "username" + }, { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "registerEnabled" : false, + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "type" : "sip-server", + "authUser" : "username", + "usePublicBgp" : true, + "enabled" : true, + "fixedPacketRate" : 50, + "password" : "password", + "protocol" : "tcp", + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "sipTargetTime" : 1000, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "optionsRegex" : "[\\"a-z\\"]", + "liveShare" : false, + "savedEvent" : true, + "sipRegistrar" : "voice.thousandeyes.com", + "networkMeasurements" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "port" : 49153, + "modifiedDate" : "2022-07-17T22:00:54Z", + "sipTimeLimit" : 5, + "interval" : 60, + "testId" : "281474976710706", + "user" : "username" + } ], + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_sip_server_tests( + + aid=aid, + + _headers=self.te_headers("get_sip_server_tests"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_sip_server_tests_error_401(self) -> None: + """Integration test for get_sip_server_tests error path (HTTP 401)""" + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_sip_server_tests( + + aid=aid, + + _headers=self.te_headers("get_sip_server_tests", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_sip_server_tests_error_403(self) -> None: + """Integration test for get_sip_server_tests error path (HTTP 403)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_sip_server_tests( + + aid=aid, + + _headers=self.te_headers("get_sip_server_tests", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_sip_server_tests_error_404(self) -> None: + """Integration test for get_sip_server_tests error path (HTTP 404)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_sip_server_tests( + + aid=aid, + + _headers=self.te_headers("get_sip_server_tests", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_sip_server_tests_error_429(self) -> None: + """Integration test for get_sip_server_tests error path (HTTP 429)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_sip_server_tests( + + aid=aid, + + _headers=self.te_headers("get_sip_server_tests", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_sip_server_tests_error_500(self) -> None: + """Integration test for get_sip_server_tests error path (HTTP 500)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_sip_server_tests( + + aid=aid, + + _headers=self.te_headers("get_sip_server_tests", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_sip_server_tests_error_502(self) -> None: + """Integration test for get_sip_server_tests error path (HTTP 502)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.get_sip_server_tests( + + aid=aid, + + _headers=self.te_headers("get_sip_server_tests", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_update_sip_server_test_happy_path(self) -> None: + """Integration test for update_sip_server_test success path""" + request_body_json = """ + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "registerEnabled" : false, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "type" : "sip-server", + "usePublicBgp" : true, + "enabled" : true, + "fixedPacketRate" : 50, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "targetSipCredentials" : { + "password" : "password", + "protocol" : "tcp", + "port" : 49153, + "sipRegistrar" : "voice.thousandeyes.com", + "authUser" : "username", + "user" : "username" + }, + "testName" : "ThousandEyes Test", + "sipTargetTime" : 1000, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "optionsRegex" : "[\\"a-z\\"]", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "sipTimeLimit" : 5, + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "monitors" : [ "17410", "5" ] + } + + """ + sip_server_test_request = thousandeyes_sdk.tests.models.SipServerTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + response_body_json = """ + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "registerEnabled" : false, + "alertRules" : [ { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + }, { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + } ], + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "type" : "sip-server", + "authUser" : "username", + "usePublicBgp" : true, + "enabled" : true, + "fixedPacketRate" : 50, + "password" : "password", + "protocol" : "tcp", + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "sipTargetTime" : 1000, + "bgpMeasurements" : true, + "numPathTraces" : 3, + "optionsRegex" : "[\\"a-z\\"]", + "liveShare" : false, + "savedEvent" : true, + "sipRegistrar" : "voice.thousandeyes.com", + "networkMeasurements" : true, + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "port" : 49153, + "modifiedDate" : "2022-07-17T22:00:54Z", + "sipTimeLimit" : 5, + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "user" : "username", + "monitors" : [ { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + }, { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + } ] + } + """ + expected_response = json.loads(response_body_json) + response = self.api.update_sip_server_test( + + test_id=test_id, + + sip_server_test_request=sip_server_test_request, + + aid=aid, + + _headers=self.te_headers("update_sip_server_test"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_update_sip_server_test_error_400(self) -> None: + """Integration test for update_sip_server_test error path (HTTP 400)""" + request_body_json = """ + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "registerEnabled" : false, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "type" : "sip-server", + "usePublicBgp" : true, + "enabled" : true, + "fixedPacketRate" : 50, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "targetSipCredentials" : { + "password" : "password", + "protocol" : "tcp", + "port" : 49153, + "sipRegistrar" : "voice.thousandeyes.com", + "authUser" : "username", + "user" : "username" + }, + "testName" : "ThousandEyes Test", + "sipTargetTime" : 1000, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "optionsRegex" : "[\\"a-z\\"]", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "sipTimeLimit" : 5, + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "monitors" : [ "17410", "5" ] + } + + """ + sip_server_test_request = thousandeyes_sdk.tests.models.SipServerTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.update_sip_server_test( + + test_id=test_id, + + sip_server_test_request=sip_server_test_request, + + aid=aid, + + _headers=self.te_headers("update_sip_server_test", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_sip_server_test_error_401(self) -> None: + """Integration test for update_sip_server_test error path (HTTP 401)""" + request_body_json = """ + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "registerEnabled" : false, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "type" : "sip-server", + "usePublicBgp" : true, + "enabled" : true, + "fixedPacketRate" : 50, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "targetSipCredentials" : { + "password" : "password", + "protocol" : "tcp", + "port" : 49153, + "sipRegistrar" : "voice.thousandeyes.com", + "authUser" : "username", + "user" : "username" + }, + "testName" : "ThousandEyes Test", + "sipTargetTime" : 1000, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "optionsRegex" : "[\\"a-z\\"]", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "sipTimeLimit" : 5, + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "monitors" : [ "17410", "5" ] + } + + """ + sip_server_test_request = thousandeyes_sdk.tests.models.SipServerTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.update_sip_server_test( + + test_id=test_id, + + sip_server_test_request=sip_server_test_request, + + aid=aid, + + _headers=self.te_headers("update_sip_server_test", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_sip_server_test_error_403(self) -> None: + """Integration test for update_sip_server_test error path (HTTP 403)""" + request_body_json = """ + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "registerEnabled" : false, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "type" : "sip-server", + "usePublicBgp" : true, + "enabled" : true, + "fixedPacketRate" : 50, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "targetSipCredentials" : { + "password" : "password", + "protocol" : "tcp", + "port" : 49153, + "sipRegistrar" : "voice.thousandeyes.com", + "authUser" : "username", + "user" : "username" + }, + "testName" : "ThousandEyes Test", + "sipTargetTime" : 1000, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "optionsRegex" : "[\\"a-z\\"]", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "sipTimeLimit" : 5, + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "monitors" : [ "17410", "5" ] + } + + """ + sip_server_test_request = thousandeyes_sdk.tests.models.SipServerTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.update_sip_server_test( + + test_id=test_id, + + sip_server_test_request=sip_server_test_request, + + aid=aid, + + _headers=self.te_headers("update_sip_server_test", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_sip_server_test_error_404(self) -> None: + """Integration test for update_sip_server_test error path (HTTP 404)""" + request_body_json = """ + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "registerEnabled" : false, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "type" : "sip-server", + "usePublicBgp" : true, + "enabled" : true, + "fixedPacketRate" : 50, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "targetSipCredentials" : { + "password" : "password", + "protocol" : "tcp", + "port" : 49153, + "sipRegistrar" : "voice.thousandeyes.com", + "authUser" : "username", + "user" : "username" + }, + "testName" : "ThousandEyes Test", + "sipTargetTime" : 1000, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "optionsRegex" : "[\\"a-z\\"]", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "sipTimeLimit" : 5, + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "monitors" : [ "17410", "5" ] + } + + """ + sip_server_test_request = thousandeyes_sdk.tests.models.SipServerTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.update_sip_server_test( + + test_id=test_id, + + sip_server_test_request=sip_server_test_request, + + aid=aid, + + _headers=self.te_headers("update_sip_server_test", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_sip_server_test_error_429(self) -> None: + """Integration test for update_sip_server_test error path (HTTP 429)""" + request_body_json = """ + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "registerEnabled" : false, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "type" : "sip-server", + "usePublicBgp" : true, + "enabled" : true, + "fixedPacketRate" : 50, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "targetSipCredentials" : { + "password" : "password", + "protocol" : "tcp", + "port" : 49153, + "sipRegistrar" : "voice.thousandeyes.com", + "authUser" : "username", + "user" : "username" + }, + "testName" : "ThousandEyes Test", + "sipTargetTime" : 1000, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "optionsRegex" : "[\\"a-z\\"]", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "sipTimeLimit" : 5, + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "monitors" : [ "17410", "5" ] + } + + """ + sip_server_test_request = thousandeyes_sdk.tests.models.SipServerTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.update_sip_server_test( + + test_id=test_id, + + sip_server_test_request=sip_server_test_request, + + aid=aid, + + _headers=self.te_headers("update_sip_server_test", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_sip_server_test_error_500(self) -> None: + """Integration test for update_sip_server_test error path (HTTP 500)""" + request_body_json = """ + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "registerEnabled" : false, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "type" : "sip-server", + "usePublicBgp" : true, + "enabled" : true, + "fixedPacketRate" : 50, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "targetSipCredentials" : { + "password" : "password", + "protocol" : "tcp", + "port" : 49153, + "sipRegistrar" : "voice.thousandeyes.com", + "authUser" : "username", + "user" : "username" + }, + "testName" : "ThousandEyes Test", + "sipTargetTime" : 1000, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "optionsRegex" : "[\\"a-z\\"]", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "sipTimeLimit" : 5, + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "monitors" : [ "17410", "5" ] + } + + """ + sip_server_test_request = thousandeyes_sdk.tests.models.SipServerTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.update_sip_server_test( + + test_id=test_id, + + sip_server_test_request=sip_server_test_request, + + aid=aid, + + _headers=self.te_headers("update_sip_server_test", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_sip_server_test_error_502(self) -> None: + """Integration test for update_sip_server_test error path (HTTP 502)""" + request_body_json = """ + + { + "mtuMeasurements" : false, + "ipv6Policy" : "use-agent-policy", + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "registerEnabled" : false, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "probeMode" : "auto", + "type" : "sip-server", + "usePublicBgp" : true, + "enabled" : true, + "fixedPacketRate" : 50, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "targetSipCredentials" : { + "password" : "password", + "protocol" : "tcp", + "port" : 49153, + "sipRegistrar" : "voice.thousandeyes.com", + "authUser" : "username", + "user" : "username" + }, + "testName" : "ThousandEyes Test", + "sipTargetTime" : 1000, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "optionsRegex" : "[\\"a-z\\"]", + "liveShare" : false, + "savedEvent" : true, + "networkMeasurements" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "sipTimeLimit" : 5, + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "monitors" : [ "17410", "5" ] + } + + """ + sip_server_test_request = thousandeyes_sdk.tests.models.SipServerTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.update_sip_server_test( + + test_id=test_id, + + sip_server_test_request=sip_server_test_request, + + aid=aid, + + _headers=self.te_headers("update_sip_server_test", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-tests/test/test_tests_api_integration.py b/thousandeyes-sdk-tests/test/test_tests_api_integration.py new file mode 100644 index 00000000..c06af4e5 --- /dev/null +++ b/thousandeyes-sdk-tests/test/test_tests_api_integration.py @@ -0,0 +1,445 @@ +# coding: utf-8 + +""" + Tests API + + **Note:** The Page Load Tests, API Tests, and Web Transaction Tests APIs are not available for ThousandEyes for Government instance. This API allows you to list, create, edit, and delete Network and Application Synthetics tests. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.tests.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.tests.api.tests_api import TestsApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestTestsApiIntegration(IntegrationTestBase): + """TestsApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = TestsApi(self.api_client) + + + def test_get_test_version_history_happy_path(self) -> None: + """Integration test for get_test_version_history success path""" + test_id = '202701' + aid = '1234' + limit = 50 + response_body_json = """ + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "testVersionHistory" : [ { + "versionId" : "1234", + "versionTimestamp" : "2022-07-17T22:00:54Z", + "createdBy" : "user (user@user.com)", + "testId" : "474276" + }, { + "versionId" : "1234", + "versionTimestamp" : "2022-07-17T22:00:54Z", + "createdBy" : "user (user@user.com)", + "testId" : "474276" + } ] + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_test_version_history( + + test_id=test_id, + + aid=aid, + + limit=limit, + + _headers=self.te_headers("get_test_version_history"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_test_version_history_error_401(self) -> None: + """Integration test for get_test_version_history error path (HTTP 401)""" + test_id = '202701' + aid = '1234' + limit = 50 + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_test_version_history( + + test_id=test_id, + + aid=aid, + + limit=limit, + + _headers=self.te_headers("get_test_version_history", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_version_history_error_403(self) -> None: + """Integration test for get_test_version_history error path (HTTP 403)""" + test_id = '202701' + aid = '1234' + limit = 50 + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_test_version_history( + + test_id=test_id, + + aid=aid, + + limit=limit, + + _headers=self.te_headers("get_test_version_history", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_version_history_error_404(self) -> None: + """Integration test for get_test_version_history error path (HTTP 404)""" + test_id = '202701' + aid = '1234' + limit = 50 + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_test_version_history( + + test_id=test_id, + + aid=aid, + + limit=limit, + + _headers=self.te_headers("get_test_version_history", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_test_version_history_error_500(self) -> None: + """Integration test for get_test_version_history error path (HTTP 500)""" + test_id = '202701' + aid = '1234' + limit = 50 + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_test_version_history( + + test_id=test_id, + + aid=aid, + + limit=limit, + + _headers=self.te_headers("get_test_version_history", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_tests_happy_path(self) -> None: + """Integration test for get_tests success path""" + aid = '1234' + response_body_json = """ + { + "tests" : [ { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + }, { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "liveShare" : false, + "savedEvent" : true, + "description" : "ThousandEyes Test", + "type" : "agent-to-server", + "enabled" : true, + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "modifiedBy" : "user@user.com", + "testId" : "281474976710706", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test" + } ], + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_tests( + + aid=aid, + + _headers=self.te_headers("get_tests"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_tests_error_401(self) -> None: + """Integration test for get_tests error path (HTTP 401)""" + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_tests( + + aid=aid, + + _headers=self.te_headers("get_tests", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_tests_error_403(self) -> None: + """Integration test for get_tests error path (HTTP 403)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_tests( + + aid=aid, + + _headers=self.te_headers("get_tests", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_tests_error_404(self) -> None: + """Integration test for get_tests error path (HTTP 404)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_tests( + + aid=aid, + + _headers=self.te_headers("get_tests", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_tests_error_429(self) -> None: + """Integration test for get_tests error path (HTTP 429)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_tests( + + aid=aid, + + _headers=self.te_headers("get_tests", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_tests_error_500(self) -> None: + """Integration test for get_tests error path (HTTP 500)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_tests( + + aid=aid, + + _headers=self.te_headers("get_tests", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_tests_error_502(self) -> None: + """Integration test for get_tests error path (HTTP 502)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.get_tests( + + aid=aid, + + _headers=self.te_headers("get_tests", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-tests/test/test_utils.py b/thousandeyes-sdk-tests/test/test_utils.py index 930528d9..37913f62 100644 --- a/thousandeyes-sdk-tests/test/test_utils.py +++ b/thousandeyes-sdk-tests/test/test_utils.py @@ -2,15 +2,36 @@ import json import unittest +from typing import Any from pydantic import BaseModel +def _project_onto_constructed(expected: Any, constructed: Any) -> Any: + """Keep only example fields that appear in the constructed model output.""" + if isinstance(constructed, dict): + if not isinstance(expected, dict): + return expected + return { + key: _project_onto_constructed(expected.get(key), value) + for key, value in constructed.items() + } + if isinstance(constructed, list): + if not isinstance(expected, list): + return expected + return [ + _project_onto_constructed(expected[index], value) + for index, value in enumerate(constructed) + ] + return expected + + def assert_constructed_model_matches_example_json(model: BaseModel, loaded_json: dict): test_case = unittest.TestCase() test_case.maxDiff = None test_case.assertIsNotNone(model) constructed_json = json.loads(model.to_json()) - sorted_loaded_json = json.dumps(loaded_json, sort_keys=True) + projected_loaded_json = _project_onto_constructed(loaded_json, constructed_json) + sorted_loaded_json = json.dumps(projected_loaded_json, sort_keys=True) sorted_constructed_json = json.dumps(constructed_json, sort_keys=True) test_case.assertEqual(sorted_loaded_json, sorted_constructed_json) diff --git a/thousandeyes-sdk-tests/test/test_voice_tests_api_integration.py b/thousandeyes-sdk-tests/test/test_voice_tests_api_integration.py new file mode 100644 index 00000000..1642afbc --- /dev/null +++ b/thousandeyes-sdk-tests/test/test_voice_tests_api_integration.py @@ -0,0 +1,2585 @@ +# coding: utf-8 + +""" + Tests API + + **Note:** The Page Load Tests, API Tests, and Web Transaction Tests APIs are not available for ThousandEyes for Government instance. This API allows you to list, create, edit, and delete Network and Application Synthetics tests. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.tests.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.tests.api.voice_tests_api import VoiceTestsApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestVoiceTestsApiIntegration(IntegrationTestBase): + """VoiceTestsApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = VoiceTestsApi(self.api_client) + + + def test_create_voice_test_happy_path(self) -> None: + """Integration test for create_voice_test success path""" + request_body_json = """ + + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "type" : "voice", + "usePublicBgp" : true, + "enabled" : true, + "jitterBuffer" : 40, + "dscpId" : "0", + "duration" : 5, + "dscp" : "Best Effort (DSCP 0)", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "liveShare" : false, + "savedEvent" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "codec" : "G.711 @ 64 Kbps", + "codecId" : "0", + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "port" : 1024, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "targetAgentId" : "281474976710706", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "monitors" : [ "17410", "5" ] + } + + """ + voice_test_request = thousandeyes_sdk.tests.models.VoiceTestRequest.from_json(request_body_json) + aid = '1234' + response_body_json = """ + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + }, { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + } ], + "description" : "ThousandEyes Test", + "type" : "voice", + "usePublicBgp" : true, + "enabled" : true, + "jitterBuffer" : 40, + "dscpId" : "0", + "duration" : 5, + "dscp" : "Best Effort (DSCP 0)", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "liveShare" : false, + "savedEvent" : true, + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "codec" : "G.711 @ 64 Kbps", + "codecId" : "0", + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "port" : 1024, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "targetAgentId" : "281474976710706", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "monitors" : [ { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + }, { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + } ] + } + """ + expected_response = json.loads(response_body_json) + response = self.api.create_voice_test( + + voice_test_request=voice_test_request, + + aid=aid, + + _headers=self.te_headers("create_voice_test"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_create_voice_test_error_400(self) -> None: + """Integration test for create_voice_test error path (HTTP 400)""" + request_body_json = """ + + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "type" : "voice", + "usePublicBgp" : true, + "enabled" : true, + "jitterBuffer" : 40, + "dscpId" : "0", + "duration" : 5, + "dscp" : "Best Effort (DSCP 0)", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "liveShare" : false, + "savedEvent" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "codec" : "G.711 @ 64 Kbps", + "codecId" : "0", + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "port" : 1024, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "targetAgentId" : "281474976710706", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "monitors" : [ "17410", "5" ] + } + + """ + voice_test_request = thousandeyes_sdk.tests.models.VoiceTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.create_voice_test( + + voice_test_request=voice_test_request, + + aid=aid, + + _headers=self.te_headers("create_voice_test", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_voice_test_error_401(self) -> None: + """Integration test for create_voice_test error path (HTTP 401)""" + request_body_json = """ + + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "type" : "voice", + "usePublicBgp" : true, + "enabled" : true, + "jitterBuffer" : 40, + "dscpId" : "0", + "duration" : 5, + "dscp" : "Best Effort (DSCP 0)", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "liveShare" : false, + "savedEvent" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "codec" : "G.711 @ 64 Kbps", + "codecId" : "0", + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "port" : 1024, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "targetAgentId" : "281474976710706", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "monitors" : [ "17410", "5" ] + } + + """ + voice_test_request = thousandeyes_sdk.tests.models.VoiceTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.create_voice_test( + + voice_test_request=voice_test_request, + + aid=aid, + + _headers=self.te_headers("create_voice_test", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_voice_test_error_403(self) -> None: + """Integration test for create_voice_test error path (HTTP 403)""" + request_body_json = """ + + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "type" : "voice", + "usePublicBgp" : true, + "enabled" : true, + "jitterBuffer" : 40, + "dscpId" : "0", + "duration" : 5, + "dscp" : "Best Effort (DSCP 0)", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "liveShare" : false, + "savedEvent" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "codec" : "G.711 @ 64 Kbps", + "codecId" : "0", + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "port" : 1024, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "targetAgentId" : "281474976710706", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "monitors" : [ "17410", "5" ] + } + + """ + voice_test_request = thousandeyes_sdk.tests.models.VoiceTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.create_voice_test( + + voice_test_request=voice_test_request, + + aid=aid, + + _headers=self.te_headers("create_voice_test", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_voice_test_error_404(self) -> None: + """Integration test for create_voice_test error path (HTTP 404)""" + request_body_json = """ + + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "type" : "voice", + "usePublicBgp" : true, + "enabled" : true, + "jitterBuffer" : 40, + "dscpId" : "0", + "duration" : 5, + "dscp" : "Best Effort (DSCP 0)", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "liveShare" : false, + "savedEvent" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "codec" : "G.711 @ 64 Kbps", + "codecId" : "0", + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "port" : 1024, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "targetAgentId" : "281474976710706", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "monitors" : [ "17410", "5" ] + } + + """ + voice_test_request = thousandeyes_sdk.tests.models.VoiceTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.create_voice_test( + + voice_test_request=voice_test_request, + + aid=aid, + + _headers=self.te_headers("create_voice_test", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_voice_test_error_429(self) -> None: + """Integration test for create_voice_test error path (HTTP 429)""" + request_body_json = """ + + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "type" : "voice", + "usePublicBgp" : true, + "enabled" : true, + "jitterBuffer" : 40, + "dscpId" : "0", + "duration" : 5, + "dscp" : "Best Effort (DSCP 0)", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "liveShare" : false, + "savedEvent" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "codec" : "G.711 @ 64 Kbps", + "codecId" : "0", + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "port" : 1024, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "targetAgentId" : "281474976710706", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "monitors" : [ "17410", "5" ] + } + + """ + voice_test_request = thousandeyes_sdk.tests.models.VoiceTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.create_voice_test( + + voice_test_request=voice_test_request, + + aid=aid, + + _headers=self.te_headers("create_voice_test", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_voice_test_error_500(self) -> None: + """Integration test for create_voice_test error path (HTTP 500)""" + request_body_json = """ + + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "type" : "voice", + "usePublicBgp" : true, + "enabled" : true, + "jitterBuffer" : 40, + "dscpId" : "0", + "duration" : 5, + "dscp" : "Best Effort (DSCP 0)", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "liveShare" : false, + "savedEvent" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "codec" : "G.711 @ 64 Kbps", + "codecId" : "0", + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "port" : 1024, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "targetAgentId" : "281474976710706", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "monitors" : [ "17410", "5" ] + } + + """ + voice_test_request = thousandeyes_sdk.tests.models.VoiceTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.create_voice_test( + + voice_test_request=voice_test_request, + + aid=aid, + + _headers=self.te_headers("create_voice_test", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_voice_test_error_502(self) -> None: + """Integration test for create_voice_test error path (HTTP 502)""" + request_body_json = """ + + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "type" : "voice", + "usePublicBgp" : true, + "enabled" : true, + "jitterBuffer" : 40, + "dscpId" : "0", + "duration" : 5, + "dscp" : "Best Effort (DSCP 0)", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "liveShare" : false, + "savedEvent" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "codec" : "G.711 @ 64 Kbps", + "codecId" : "0", + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "port" : 1024, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "targetAgentId" : "281474976710706", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "monitors" : [ "17410", "5" ] + } + + """ + voice_test_request = thousandeyes_sdk.tests.models.VoiceTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.create_voice_test( + + voice_test_request=voice_test_request, + + aid=aid, + + _headers=self.te_headers("create_voice_test", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_delete_voice_test_happy_path(self) -> None: + """Integration test for delete_voice_test success path""" + test_id = '202701' + aid = '1234' + response = self.api.delete_voice_test_with_http_info( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_voice_test"), + ) + self.assertEqual(204, response.status_code) + self.assertIsNone(response.data) + + + def test_delete_voice_test_error_401(self) -> None: + """Integration test for delete_voice_test error path (HTTP 401)""" + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.delete_voice_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_voice_test", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_voice_test_error_403(self) -> None: + """Integration test for delete_voice_test error path (HTTP 403)""" + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.delete_voice_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_voice_test", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_voice_test_error_404(self) -> None: + """Integration test for delete_voice_test error path (HTTP 404)""" + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.delete_voice_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_voice_test", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_voice_test_error_429(self) -> None: + """Integration test for delete_voice_test error path (HTTP 429)""" + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.delete_voice_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_voice_test", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_voice_test_error_500(self) -> None: + """Integration test for delete_voice_test error path (HTTP 500)""" + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.delete_voice_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_voice_test", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_voice_test_error_502(self) -> None: + """Integration test for delete_voice_test error path (HTTP 502)""" + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.delete_voice_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_voice_test", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_voice_test_happy_path(self) -> None: + """Integration test for get_voice_test success path""" + test_id = '202701' + aid = '1234' + version_id = '1234' + response_body_json = """ + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + }, { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + } ], + "description" : "ThousandEyes Test", + "type" : "voice", + "usePublicBgp" : true, + "enabled" : true, + "jitterBuffer" : 40, + "dscpId" : "0", + "duration" : 5, + "dscp" : "Best Effort (DSCP 0)", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "liveShare" : false, + "savedEvent" : true, + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "codec" : "G.711 @ 64 Kbps", + "codecId" : "0", + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "port" : 1024, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "targetAgentId" : "281474976710706", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "monitors" : [ { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + }, { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + } ] + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_voice_test( + + test_id=test_id, + + aid=aid, + + version_id=version_id, + + _headers=self.te_headers("get_voice_test"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_voice_test_error_401(self) -> None: + """Integration test for get_voice_test error path (HTTP 401)""" + test_id = '202701' + aid = '1234' + version_id = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_voice_test( + + test_id=test_id, + + aid=aid, + + version_id=version_id, + + _headers=self.te_headers("get_voice_test", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_voice_test_error_403(self) -> None: + """Integration test for get_voice_test error path (HTTP 403)""" + test_id = '202701' + aid = '1234' + version_id = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_voice_test( + + test_id=test_id, + + aid=aid, + + version_id=version_id, + + _headers=self.te_headers("get_voice_test", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_voice_test_error_404(self) -> None: + """Integration test for get_voice_test error path (HTTP 404)""" + test_id = '202701' + aid = '1234' + version_id = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_voice_test( + + test_id=test_id, + + aid=aid, + + version_id=version_id, + + _headers=self.te_headers("get_voice_test", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_voice_test_error_429(self) -> None: + """Integration test for get_voice_test error path (HTTP 429)""" + test_id = '202701' + aid = '1234' + version_id = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_voice_test( + + test_id=test_id, + + aid=aid, + + version_id=version_id, + + _headers=self.te_headers("get_voice_test", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_voice_test_error_500(self) -> None: + """Integration test for get_voice_test error path (HTTP 500)""" + test_id = '202701' + aid = '1234' + version_id = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_voice_test( + + test_id=test_id, + + aid=aid, + + version_id=version_id, + + _headers=self.te_headers("get_voice_test", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_voice_test_error_502(self) -> None: + """Integration test for get_voice_test error path (HTTP 502)""" + test_id = '202701' + aid = '1234' + version_id = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.get_voice_test( + + test_id=test_id, + + aid=aid, + + version_id=version_id, + + _headers=self.te_headers("get_voice_test", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_voice_tests_happy_path(self) -> None: + """Integration test for get_voice_tests success path""" + aid = '1234' + response_body_json = """ + { + "tests" : [ { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "description" : "ThousandEyes Test", + "type" : "voice", + "usePublicBgp" : true, + "enabled" : true, + "jitterBuffer" : 40, + "dscpId" : "0", + "duration" : 5, + "dscp" : "Best Effort (DSCP 0)", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "liveShare" : false, + "savedEvent" : true, + "codec" : "G.711 @ 64 Kbps", + "codecId" : "0", + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "port" : 1024, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "targetAgentId" : "281474976710706", + "interval" : 60, + "testId" : "281474976710706" + }, { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "description" : "ThousandEyes Test", + "type" : "voice", + "usePublicBgp" : true, + "enabled" : true, + "jitterBuffer" : 40, + "dscpId" : "0", + "duration" : 5, + "dscp" : "Best Effort (DSCP 0)", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "liveShare" : false, + "savedEvent" : true, + "codec" : "G.711 @ 64 Kbps", + "codecId" : "0", + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "port" : 1024, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "targetAgentId" : "281474976710706", + "interval" : 60, + "testId" : "281474976710706" + } ], + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_voice_tests( + + aid=aid, + + _headers=self.te_headers("get_voice_tests"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_voice_tests_error_401(self) -> None: + """Integration test for get_voice_tests error path (HTTP 401)""" + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_voice_tests( + + aid=aid, + + _headers=self.te_headers("get_voice_tests", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_voice_tests_error_403(self) -> None: + """Integration test for get_voice_tests error path (HTTP 403)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_voice_tests( + + aid=aid, + + _headers=self.te_headers("get_voice_tests", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_voice_tests_error_404(self) -> None: + """Integration test for get_voice_tests error path (HTTP 404)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_voice_tests( + + aid=aid, + + _headers=self.te_headers("get_voice_tests", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_voice_tests_error_429(self) -> None: + """Integration test for get_voice_tests error path (HTTP 429)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_voice_tests( + + aid=aid, + + _headers=self.te_headers("get_voice_tests", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_voice_tests_error_500(self) -> None: + """Integration test for get_voice_tests error path (HTTP 500)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_voice_tests( + + aid=aid, + + _headers=self.te_headers("get_voice_tests", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_voice_tests_error_502(self) -> None: + """Integration test for get_voice_tests error path (HTTP 502)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.get_voice_tests( + + aid=aid, + + _headers=self.te_headers("get_voice_tests", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_update_voice_test_happy_path(self) -> None: + """Integration test for update_voice_test success path""" + request_body_json = """ + + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "type" : "voice", + "usePublicBgp" : true, + "enabled" : true, + "jitterBuffer" : 40, + "dscpId" : "0", + "duration" : 5, + "dscp" : "Best Effort (DSCP 0)", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "liveShare" : false, + "savedEvent" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "codec" : "G.711 @ 64 Kbps", + "codecId" : "0", + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "port" : 1024, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "targetAgentId" : "281474976710706", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "monitors" : [ "17410", "5" ] + } + + """ + voice_test_request = thousandeyes_sdk.tests.models.VoiceTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + response_body_json = """ + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + }, { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + } ], + "description" : "ThousandEyes Test", + "type" : "voice", + "usePublicBgp" : true, + "enabled" : true, + "jitterBuffer" : 40, + "dscpId" : "0", + "duration" : 5, + "dscp" : "Best Effort (DSCP 0)", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "liveShare" : false, + "savedEvent" : true, + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "codec" : "G.711 @ 64 Kbps", + "codecId" : "0", + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "port" : 1024, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "targetAgentId" : "281474976710706", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "monitors" : [ { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + }, { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + } ] + } + """ + expected_response = json.loads(response_body_json) + response = self.api.update_voice_test( + + test_id=test_id, + + voice_test_request=voice_test_request, + + aid=aid, + + _headers=self.te_headers("update_voice_test"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_update_voice_test_error_400(self) -> None: + """Integration test for update_voice_test error path (HTTP 400)""" + request_body_json = """ + + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "type" : "voice", + "usePublicBgp" : true, + "enabled" : true, + "jitterBuffer" : 40, + "dscpId" : "0", + "duration" : 5, + "dscp" : "Best Effort (DSCP 0)", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "liveShare" : false, + "savedEvent" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "codec" : "G.711 @ 64 Kbps", + "codecId" : "0", + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "port" : 1024, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "targetAgentId" : "281474976710706", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "monitors" : [ "17410", "5" ] + } + + """ + voice_test_request = thousandeyes_sdk.tests.models.VoiceTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.update_voice_test( + + test_id=test_id, + + voice_test_request=voice_test_request, + + aid=aid, + + _headers=self.te_headers("update_voice_test", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_voice_test_error_401(self) -> None: + """Integration test for update_voice_test error path (HTTP 401)""" + request_body_json = """ + + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "type" : "voice", + "usePublicBgp" : true, + "enabled" : true, + "jitterBuffer" : 40, + "dscpId" : "0", + "duration" : 5, + "dscp" : "Best Effort (DSCP 0)", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "liveShare" : false, + "savedEvent" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "codec" : "G.711 @ 64 Kbps", + "codecId" : "0", + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "port" : 1024, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "targetAgentId" : "281474976710706", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "monitors" : [ "17410", "5" ] + } + + """ + voice_test_request = thousandeyes_sdk.tests.models.VoiceTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.update_voice_test( + + test_id=test_id, + + voice_test_request=voice_test_request, + + aid=aid, + + _headers=self.te_headers("update_voice_test", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_voice_test_error_403(self) -> None: + """Integration test for update_voice_test error path (HTTP 403)""" + request_body_json = """ + + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "type" : "voice", + "usePublicBgp" : true, + "enabled" : true, + "jitterBuffer" : 40, + "dscpId" : "0", + "duration" : 5, + "dscp" : "Best Effort (DSCP 0)", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "liveShare" : false, + "savedEvent" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "codec" : "G.711 @ 64 Kbps", + "codecId" : "0", + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "port" : 1024, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "targetAgentId" : "281474976710706", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "monitors" : [ "17410", "5" ] + } + + """ + voice_test_request = thousandeyes_sdk.tests.models.VoiceTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.update_voice_test( + + test_id=test_id, + + voice_test_request=voice_test_request, + + aid=aid, + + _headers=self.te_headers("update_voice_test", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_voice_test_error_404(self) -> None: + """Integration test for update_voice_test error path (HTTP 404)""" + request_body_json = """ + + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "type" : "voice", + "usePublicBgp" : true, + "enabled" : true, + "jitterBuffer" : 40, + "dscpId" : "0", + "duration" : 5, + "dscp" : "Best Effort (DSCP 0)", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "liveShare" : false, + "savedEvent" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "codec" : "G.711 @ 64 Kbps", + "codecId" : "0", + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "port" : 1024, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "targetAgentId" : "281474976710706", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "monitors" : [ "17410", "5" ] + } + + """ + voice_test_request = thousandeyes_sdk.tests.models.VoiceTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.update_voice_test( + + test_id=test_id, + + voice_test_request=voice_test_request, + + aid=aid, + + _headers=self.te_headers("update_voice_test", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_voice_test_error_429(self) -> None: + """Integration test for update_voice_test error path (HTTP 429)""" + request_body_json = """ + + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "type" : "voice", + "usePublicBgp" : true, + "enabled" : true, + "jitterBuffer" : 40, + "dscpId" : "0", + "duration" : 5, + "dscp" : "Best Effort (DSCP 0)", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "liveShare" : false, + "savedEvent" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "codec" : "G.711 @ 64 Kbps", + "codecId" : "0", + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "port" : 1024, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "targetAgentId" : "281474976710706", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "monitors" : [ "17410", "5" ] + } + + """ + voice_test_request = thousandeyes_sdk.tests.models.VoiceTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.update_voice_test( + + test_id=test_id, + + voice_test_request=voice_test_request, + + aid=aid, + + _headers=self.te_headers("update_voice_test", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_voice_test_error_500(self) -> None: + """Integration test for update_voice_test error path (HTTP 500)""" + request_body_json = """ + + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "type" : "voice", + "usePublicBgp" : true, + "enabled" : true, + "jitterBuffer" : 40, + "dscpId" : "0", + "duration" : 5, + "dscp" : "Best Effort (DSCP 0)", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "liveShare" : false, + "savedEvent" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "codec" : "G.711 @ 64 Kbps", + "codecId" : "0", + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "port" : 1024, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "targetAgentId" : "281474976710706", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "monitors" : [ "17410", "5" ] + } + + """ + voice_test_request = thousandeyes_sdk.tests.models.VoiceTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.update_voice_test( + + test_id=test_id, + + voice_test_request=voice_test_request, + + aid=aid, + + _headers=self.te_headers("update_voice_test", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_voice_test_error_502(self) -> None: + """Integration test for update_voice_test error path (HTTP 502)""" + request_body_json = """ + + { + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "type" : "voice", + "usePublicBgp" : true, + "enabled" : true, + "jitterBuffer" : 40, + "dscpId" : "0", + "duration" : 5, + "dscp" : "Best Effort (DSCP 0)", + "modifiedBy" : "user@user.com", + "alertsEnabled" : true, + "testName" : "ThousandEyes Test", + "numPathTraces" : 3, + "bgpMeasurements" : true, + "liveShare" : false, + "savedEvent" : true, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "codec" : "G.711 @ 64 Kbps", + "codecId" : "0", + "createdDate" : "2022-07-17T22:00:54Z", + "createdBy" : "user@user.com", + "port" : 1024, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "targetAgentId" : "281474976710706", + "interval" : 60, + "testId" : "281474976710706", + "sharedWithAccounts" : [ "1234", "12345" ], + "monitors" : [ "17410", "5" ] + } + + """ + voice_test_request = thousandeyes_sdk.tests.models.VoiceTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.update_voice_test( + + test_id=test_id, + + voice_test_request=voice_test_request, + + aid=aid, + + _headers=self.te_headers("update_voice_test", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-tests/test/test_web_transaction_tests_api_integration.py b/thousandeyes-sdk-tests/test/test_web_transaction_tests_api_integration.py new file mode 100644 index 00000000..d6ec8962 --- /dev/null +++ b/thousandeyes-sdk-tests/test/test_web_transaction_tests_api_integration.py @@ -0,0 +1,4074 @@ +# coding: utf-8 + +""" + Tests API + + **Note:** The Page Load Tests, API Tests, and Web Transaction Tests APIs are not available for ThousandEyes for Government instance. This API allows you to list, create, edit, and delete Network and Application Synthetics tests. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.tests.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.tests.api.web_transaction_tests_api import WebTransactionTestsApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestWebTransactionTestsApiIntegration(IntegrationTestBase): + """WebTransactionTestsApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = WebTransactionTestsApi(self.api_client) + + + def test_create_web_transactions_test_happy_path(self) -> None: + """Integration test for create_web_transactions_test success path""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "web-transactions", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "chromePolicies" : "{\\"ProxyMode\\":\\"direct\\"}", + "contentRegex" : "(regex)+", + "pageLoadingStrategy" : "normal", + "testName" : "ThousandEyes Test", + "allowMicAndCamera" : false, + "browserLanguage" : "en-US", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "emulatedDeviceId" : "2", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "monitors" : [ "17410", "5" ], + "sslVersion" : "Auto", + "useNtlm" : false, + "credentials" : [ "3247", "1051" ], + "downloadLimit" : 2048, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "blockDomains" : "domain.com/", + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowGeolocation" : false, + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "alertsEnabled" : true, + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "transactionScript" : "if (true) { return true; }", + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "identifyAgentTrafficWithUserAgent" : false, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "timeLimit" : 30, + "createdDate" : "2022-07-17T22:00:54Z", + "disableScreenshot" : false, + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "subinterval" : 60, + "chromeOptions" : "--disable-gpu", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username", + "targetTime" : 1 + } + + """ + web_transaction_test_request = thousandeyes_sdk.tests.models.WebTransactionTestRequest.from_json(request_body_json) + aid = '1234' + response_body_json = """ + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "web-transactions", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "chromePolicies" : "{\\"ProxyMode\\":\\"direct\\"}", + "contentRegex" : "(regex)+", + "pageLoadingStrategy" : "normal", + "testName" : "ThousandEyes Test", + "allowMicAndCamera" : false, + "browserLanguage" : "en-US", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "emulatedDeviceId" : "2", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "overrideProxyId" : "281474976710706", + "monitors" : [ { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + }, { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + } ], + "sslVersion" : "Auto", + "useNtlm" : false, + "credentials" : [ "3247", "1051" ], + "downloadLimit" : 2048, + "alertRules" : [ { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + }, { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + } ], + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "blockDomains" : "domain.com/", + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowGeolocation" : false, + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "alertsEnabled" : true, + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "transactionScript" : "if (true) { return true; }", + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "identifyAgentTrafficWithUserAgent" : false, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "timeLimit" : 30, + "createdDate" : "2022-07-17T22:00:54Z", + "disableScreenshot" : false, + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "subinterval" : 60, + "chromeOptions" : "--disable-gpu", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username", + "targetTime" : 1 + } + """ + expected_response = json.loads(response_body_json) + response = self.api.create_web_transactions_test( + + web_transaction_test_request=web_transaction_test_request, + + aid=aid, + + _headers=self.te_headers("create_web_transactions_test"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_create_web_transactions_test_error_400(self) -> None: + """Integration test for create_web_transactions_test error path (HTTP 400)""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "web-transactions", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "chromePolicies" : "{\\"ProxyMode\\":\\"direct\\"}", + "contentRegex" : "(regex)+", + "pageLoadingStrategy" : "normal", + "testName" : "ThousandEyes Test", + "allowMicAndCamera" : false, + "browserLanguage" : "en-US", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "emulatedDeviceId" : "2", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "monitors" : [ "17410", "5" ], + "sslVersion" : "Auto", + "useNtlm" : false, + "credentials" : [ "3247", "1051" ], + "downloadLimit" : 2048, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "blockDomains" : "domain.com/", + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowGeolocation" : false, + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "alertsEnabled" : true, + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "transactionScript" : "if (true) { return true; }", + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "identifyAgentTrafficWithUserAgent" : false, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "timeLimit" : 30, + "createdDate" : "2022-07-17T22:00:54Z", + "disableScreenshot" : false, + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "subinterval" : 60, + "chromeOptions" : "--disable-gpu", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username", + "targetTime" : 1 + } + + """ + web_transaction_test_request = thousandeyes_sdk.tests.models.WebTransactionTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.create_web_transactions_test( + + web_transaction_test_request=web_transaction_test_request, + + aid=aid, + + _headers=self.te_headers("create_web_transactions_test", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_web_transactions_test_error_401(self) -> None: + """Integration test for create_web_transactions_test error path (HTTP 401)""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "web-transactions", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "chromePolicies" : "{\\"ProxyMode\\":\\"direct\\"}", + "contentRegex" : "(regex)+", + "pageLoadingStrategy" : "normal", + "testName" : "ThousandEyes Test", + "allowMicAndCamera" : false, + "browserLanguage" : "en-US", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "emulatedDeviceId" : "2", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "monitors" : [ "17410", "5" ], + "sslVersion" : "Auto", + "useNtlm" : false, + "credentials" : [ "3247", "1051" ], + "downloadLimit" : 2048, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "blockDomains" : "domain.com/", + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowGeolocation" : false, + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "alertsEnabled" : true, + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "transactionScript" : "if (true) { return true; }", + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "identifyAgentTrafficWithUserAgent" : false, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "timeLimit" : 30, + "createdDate" : "2022-07-17T22:00:54Z", + "disableScreenshot" : false, + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "subinterval" : 60, + "chromeOptions" : "--disable-gpu", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username", + "targetTime" : 1 + } + + """ + web_transaction_test_request = thousandeyes_sdk.tests.models.WebTransactionTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.create_web_transactions_test( + + web_transaction_test_request=web_transaction_test_request, + + aid=aid, + + _headers=self.te_headers("create_web_transactions_test", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_web_transactions_test_error_403(self) -> None: + """Integration test for create_web_transactions_test error path (HTTP 403)""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "web-transactions", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "chromePolicies" : "{\\"ProxyMode\\":\\"direct\\"}", + "contentRegex" : "(regex)+", + "pageLoadingStrategy" : "normal", + "testName" : "ThousandEyes Test", + "allowMicAndCamera" : false, + "browserLanguage" : "en-US", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "emulatedDeviceId" : "2", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "monitors" : [ "17410", "5" ], + "sslVersion" : "Auto", + "useNtlm" : false, + "credentials" : [ "3247", "1051" ], + "downloadLimit" : 2048, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "blockDomains" : "domain.com/", + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowGeolocation" : false, + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "alertsEnabled" : true, + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "transactionScript" : "if (true) { return true; }", + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "identifyAgentTrafficWithUserAgent" : false, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "timeLimit" : 30, + "createdDate" : "2022-07-17T22:00:54Z", + "disableScreenshot" : false, + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "subinterval" : 60, + "chromeOptions" : "--disable-gpu", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username", + "targetTime" : 1 + } + + """ + web_transaction_test_request = thousandeyes_sdk.tests.models.WebTransactionTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.create_web_transactions_test( + + web_transaction_test_request=web_transaction_test_request, + + aid=aid, + + _headers=self.te_headers("create_web_transactions_test", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_web_transactions_test_error_404(self) -> None: + """Integration test for create_web_transactions_test error path (HTTP 404)""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "web-transactions", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "chromePolicies" : "{\\"ProxyMode\\":\\"direct\\"}", + "contentRegex" : "(regex)+", + "pageLoadingStrategy" : "normal", + "testName" : "ThousandEyes Test", + "allowMicAndCamera" : false, + "browserLanguage" : "en-US", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "emulatedDeviceId" : "2", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "monitors" : [ "17410", "5" ], + "sslVersion" : "Auto", + "useNtlm" : false, + "credentials" : [ "3247", "1051" ], + "downloadLimit" : 2048, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "blockDomains" : "domain.com/", + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowGeolocation" : false, + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "alertsEnabled" : true, + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "transactionScript" : "if (true) { return true; }", + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "identifyAgentTrafficWithUserAgent" : false, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "timeLimit" : 30, + "createdDate" : "2022-07-17T22:00:54Z", + "disableScreenshot" : false, + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "subinterval" : 60, + "chromeOptions" : "--disable-gpu", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username", + "targetTime" : 1 + } + + """ + web_transaction_test_request = thousandeyes_sdk.tests.models.WebTransactionTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.create_web_transactions_test( + + web_transaction_test_request=web_transaction_test_request, + + aid=aid, + + _headers=self.te_headers("create_web_transactions_test", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_web_transactions_test_error_429(self) -> None: + """Integration test for create_web_transactions_test error path (HTTP 429)""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "web-transactions", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "chromePolicies" : "{\\"ProxyMode\\":\\"direct\\"}", + "contentRegex" : "(regex)+", + "pageLoadingStrategy" : "normal", + "testName" : "ThousandEyes Test", + "allowMicAndCamera" : false, + "browserLanguage" : "en-US", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "emulatedDeviceId" : "2", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "monitors" : [ "17410", "5" ], + "sslVersion" : "Auto", + "useNtlm" : false, + "credentials" : [ "3247", "1051" ], + "downloadLimit" : 2048, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "blockDomains" : "domain.com/", + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowGeolocation" : false, + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "alertsEnabled" : true, + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "transactionScript" : "if (true) { return true; }", + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "identifyAgentTrafficWithUserAgent" : false, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "timeLimit" : 30, + "createdDate" : "2022-07-17T22:00:54Z", + "disableScreenshot" : false, + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "subinterval" : 60, + "chromeOptions" : "--disable-gpu", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username", + "targetTime" : 1 + } + + """ + web_transaction_test_request = thousandeyes_sdk.tests.models.WebTransactionTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.create_web_transactions_test( + + web_transaction_test_request=web_transaction_test_request, + + aid=aid, + + _headers=self.te_headers("create_web_transactions_test", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_web_transactions_test_error_500(self) -> None: + """Integration test for create_web_transactions_test error path (HTTP 500)""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "web-transactions", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "chromePolicies" : "{\\"ProxyMode\\":\\"direct\\"}", + "contentRegex" : "(regex)+", + "pageLoadingStrategy" : "normal", + "testName" : "ThousandEyes Test", + "allowMicAndCamera" : false, + "browserLanguage" : "en-US", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "emulatedDeviceId" : "2", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "monitors" : [ "17410", "5" ], + "sslVersion" : "Auto", + "useNtlm" : false, + "credentials" : [ "3247", "1051" ], + "downloadLimit" : 2048, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "blockDomains" : "domain.com/", + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowGeolocation" : false, + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "alertsEnabled" : true, + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "transactionScript" : "if (true) { return true; }", + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "identifyAgentTrafficWithUserAgent" : false, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "timeLimit" : 30, + "createdDate" : "2022-07-17T22:00:54Z", + "disableScreenshot" : false, + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "subinterval" : 60, + "chromeOptions" : "--disable-gpu", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username", + "targetTime" : 1 + } + + """ + web_transaction_test_request = thousandeyes_sdk.tests.models.WebTransactionTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.create_web_transactions_test( + + web_transaction_test_request=web_transaction_test_request, + + aid=aid, + + _headers=self.te_headers("create_web_transactions_test", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_create_web_transactions_test_error_502(self) -> None: + """Integration test for create_web_transactions_test error path (HTTP 502)""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "web-transactions", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "chromePolicies" : "{\\"ProxyMode\\":\\"direct\\"}", + "contentRegex" : "(regex)+", + "pageLoadingStrategy" : "normal", + "testName" : "ThousandEyes Test", + "allowMicAndCamera" : false, + "browserLanguage" : "en-US", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "emulatedDeviceId" : "2", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "monitors" : [ "17410", "5" ], + "sslVersion" : "Auto", + "useNtlm" : false, + "credentials" : [ "3247", "1051" ], + "downloadLimit" : 2048, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "blockDomains" : "domain.com/", + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowGeolocation" : false, + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "alertsEnabled" : true, + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "transactionScript" : "if (true) { return true; }", + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "identifyAgentTrafficWithUserAgent" : false, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "timeLimit" : 30, + "createdDate" : "2022-07-17T22:00:54Z", + "disableScreenshot" : false, + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "subinterval" : 60, + "chromeOptions" : "--disable-gpu", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username", + "targetTime" : 1 + } + + """ + web_transaction_test_request = thousandeyes_sdk.tests.models.WebTransactionTestRequest.from_json(request_body_json) + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.create_web_transactions_test( + + web_transaction_test_request=web_transaction_test_request, + + aid=aid, + + _headers=self.te_headers("create_web_transactions_test", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_delete_web_transactions_test_happy_path(self) -> None: + """Integration test for delete_web_transactions_test success path""" + test_id = '202701' + aid = '1234' + response = self.api.delete_web_transactions_test_with_http_info( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_web_transactions_test"), + ) + self.assertEqual(204, response.status_code) + self.assertIsNone(response.data) + + + def test_delete_web_transactions_test_error_401(self) -> None: + """Integration test for delete_web_transactions_test error path (HTTP 401)""" + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.delete_web_transactions_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_web_transactions_test", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_web_transactions_test_error_403(self) -> None: + """Integration test for delete_web_transactions_test error path (HTTP 403)""" + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.delete_web_transactions_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_web_transactions_test", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_web_transactions_test_error_404(self) -> None: + """Integration test for delete_web_transactions_test error path (HTTP 404)""" + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.delete_web_transactions_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_web_transactions_test", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_web_transactions_test_error_429(self) -> None: + """Integration test for delete_web_transactions_test error path (HTTP 429)""" + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.delete_web_transactions_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_web_transactions_test", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_web_transactions_test_error_500(self) -> None: + """Integration test for delete_web_transactions_test error path (HTTP 500)""" + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.delete_web_transactions_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_web_transactions_test", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_delete_web_transactions_test_error_502(self) -> None: + """Integration test for delete_web_transactions_test error path (HTTP 502)""" + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.delete_web_transactions_test( + + test_id=test_id, + + aid=aid, + + _headers=self.te_headers("delete_web_transactions_test", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_web_transactions_test_happy_path(self) -> None: + """Integration test for get_web_transactions_test success path""" + test_id = '202701' + aid = '1234' + version_id = '1234' + response_body_json = """ + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "web-transactions", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "chromePolicies" : "{\\"ProxyMode\\":\\"direct\\"}", + "contentRegex" : "(regex)+", + "pageLoadingStrategy" : "normal", + "testName" : "ThousandEyes Test", + "allowMicAndCamera" : false, + "browserLanguage" : "en-US", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "emulatedDeviceId" : "2", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "overrideProxyId" : "281474976710706", + "monitors" : [ { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + }, { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + } ], + "sslVersion" : "Auto", + "useNtlm" : false, + "credentials" : [ "3247", "1051" ], + "downloadLimit" : 2048, + "alertRules" : [ { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + }, { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + } ], + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "blockDomains" : "domain.com/", + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowGeolocation" : false, + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "alertsEnabled" : true, + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "transactionScript" : "if (true) { return true; }", + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "identifyAgentTrafficWithUserAgent" : false, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "timeLimit" : 30, + "createdDate" : "2022-07-17T22:00:54Z", + "disableScreenshot" : false, + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "subinterval" : 60, + "chromeOptions" : "--disable-gpu", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username", + "targetTime" : 1 + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_web_transactions_test( + + test_id=test_id, + + aid=aid, + + version_id=version_id, + + _headers=self.te_headers("get_web_transactions_test"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_web_transactions_test_error_401(self) -> None: + """Integration test for get_web_transactions_test error path (HTTP 401)""" + test_id = '202701' + aid = '1234' + version_id = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_web_transactions_test( + + test_id=test_id, + + aid=aid, + + version_id=version_id, + + _headers=self.te_headers("get_web_transactions_test", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_web_transactions_test_error_403(self) -> None: + """Integration test for get_web_transactions_test error path (HTTP 403)""" + test_id = '202701' + aid = '1234' + version_id = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_web_transactions_test( + + test_id=test_id, + + aid=aid, + + version_id=version_id, + + _headers=self.te_headers("get_web_transactions_test", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_web_transactions_test_error_404(self) -> None: + """Integration test for get_web_transactions_test error path (HTTP 404)""" + test_id = '202701' + aid = '1234' + version_id = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_web_transactions_test( + + test_id=test_id, + + aid=aid, + + version_id=version_id, + + _headers=self.te_headers("get_web_transactions_test", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_web_transactions_test_error_429(self) -> None: + """Integration test for get_web_transactions_test error path (HTTP 429)""" + test_id = '202701' + aid = '1234' + version_id = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_web_transactions_test( + + test_id=test_id, + + aid=aid, + + version_id=version_id, + + _headers=self.te_headers("get_web_transactions_test", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_web_transactions_test_error_500(self) -> None: + """Integration test for get_web_transactions_test error path (HTTP 500)""" + test_id = '202701' + aid = '1234' + version_id = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_web_transactions_test( + + test_id=test_id, + + aid=aid, + + version_id=version_id, + + _headers=self.te_headers("get_web_transactions_test", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_web_transactions_test_error_502(self) -> None: + """Integration test for get_web_transactions_test error path (HTTP 502)""" + test_id = '202701' + aid = '1234' + version_id = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.get_web_transactions_test( + + test_id=test_id, + + aid=aid, + + version_id=version_id, + + _headers=self.te_headers("get_web_transactions_test", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_web_transactions_tests_happy_path(self) -> None: + """Integration test for get_web_transactions_tests success path""" + aid = '1234' + response_body_json = """ + { + "tests" : [ { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "web-transactions", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "chromePolicies" : "{\\"ProxyMode\\":\\"direct\\"}", + "contentRegex" : "(regex)+", + "pageLoadingStrategy" : "normal", + "testName" : "ThousandEyes Test", + "allowMicAndCamera" : false, + "browserLanguage" : "en-US", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "emulatedDeviceId" : "2", + "overrideProxyId" : "281474976710706", + "sslVersion" : "Auto", + "useNtlm" : false, + "downloadLimit" : 2048, + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "blockDomains" : "domain.com/", + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowGeolocation" : false, + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "alertsEnabled" : true, + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "transactionScript" : "if (true) { return true; }", + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "identifyAgentTrafficWithUserAgent" : false, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "timeLimit" : 30, + "createdDate" : "2022-07-17T22:00:54Z", + "disableScreenshot" : false, + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "subinterval" : 60, + "chromeOptions" : "--disable-gpu", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username", + "targetTime" : 1 + }, { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "web-transactions", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "chromePolicies" : "{\\"ProxyMode\\":\\"direct\\"}", + "contentRegex" : "(regex)+", + "pageLoadingStrategy" : "normal", + "testName" : "ThousandEyes Test", + "allowMicAndCamera" : false, + "browserLanguage" : "en-US", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "emulatedDeviceId" : "2", + "overrideProxyId" : "281474976710706", + "sslVersion" : "Auto", + "useNtlm" : false, + "downloadLimit" : 2048, + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "blockDomains" : "domain.com/", + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowGeolocation" : false, + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "alertsEnabled" : true, + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "transactionScript" : "if (true) { return true; }", + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "identifyAgentTrafficWithUserAgent" : false, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "timeLimit" : 30, + "createdDate" : "2022-07-17T22:00:54Z", + "disableScreenshot" : false, + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "subinterval" : 60, + "chromeOptions" : "--disable-gpu", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username", + "targetTime" : 1 + } ], + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_web_transactions_tests( + + aid=aid, + + _headers=self.te_headers("get_web_transactions_tests"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_web_transactions_tests_error_401(self) -> None: + """Integration test for get_web_transactions_tests error path (HTTP 401)""" + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_web_transactions_tests( + + aid=aid, + + _headers=self.te_headers("get_web_transactions_tests", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_web_transactions_tests_error_403(self) -> None: + """Integration test for get_web_transactions_tests error path (HTTP 403)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_web_transactions_tests( + + aid=aid, + + _headers=self.te_headers("get_web_transactions_tests", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_web_transactions_tests_error_404(self) -> None: + """Integration test for get_web_transactions_tests error path (HTTP 404)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_web_transactions_tests( + + aid=aid, + + _headers=self.te_headers("get_web_transactions_tests", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_web_transactions_tests_error_429(self) -> None: + """Integration test for get_web_transactions_tests error path (HTTP 429)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_web_transactions_tests( + + aid=aid, + + _headers=self.te_headers("get_web_transactions_tests", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_web_transactions_tests_error_500(self) -> None: + """Integration test for get_web_transactions_tests error path (HTTP 500)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_web_transactions_tests( + + aid=aid, + + _headers=self.te_headers("get_web_transactions_tests", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_web_transactions_tests_error_502(self) -> None: + """Integration test for get_web_transactions_tests error path (HTTP 502)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.get_web_transactions_tests( + + aid=aid, + + _headers=self.te_headers("get_web_transactions_tests", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_update_web_transactions_test_happy_path(self) -> None: + """Integration test for update_web_transactions_test success path""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "web-transactions", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "chromePolicies" : "{\\"ProxyMode\\":\\"direct\\"}", + "contentRegex" : "(regex)+", + "pageLoadingStrategy" : "normal", + "testName" : "ThousandEyes Test", + "allowMicAndCamera" : false, + "browserLanguage" : "en-US", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "emulatedDeviceId" : "2", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "monitors" : [ "17410", "5" ], + "sslVersion" : "Auto", + "useNtlm" : false, + "credentials" : [ "3247", "1051" ], + "downloadLimit" : 2048, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "blockDomains" : "domain.com/", + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowGeolocation" : false, + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "alertsEnabled" : true, + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "transactionScript" : "if (true) { return true; }", + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "identifyAgentTrafficWithUserAgent" : false, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "timeLimit" : 30, + "createdDate" : "2022-07-17T22:00:54Z", + "disableScreenshot" : false, + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "subinterval" : 60, + "chromeOptions" : "--disable-gpu", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username", + "targetTime" : 1 + } + + """ + web_transaction_test_request = thousandeyes_sdk.tests.models.WebTransactionTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + response_body_json = """ + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "web-transactions", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "chromePolicies" : "{\\"ProxyMode\\":\\"direct\\"}", + "contentRegex" : "(regex)+", + "pageLoadingStrategy" : "normal", + "testName" : "ThousandEyes Test", + "allowMicAndCamera" : false, + "browserLanguage" : "en-US", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + }, { + "labelId" : "961", + "name" : "Artem label", + "isBuiltin" : false + } ], + "tags" : [ { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + }, { + "id" : "5aeab5d5-0d34-4d44-a7ac-fb440185295c", + "value" : "San Francisco", + "key" : "Location" + } ], + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "emulatedDeviceId" : "2", + "sharedWithAccounts" : [ { + "name" : "Account name", + "aid" : "1234" + }, { + "name" : "Account name", + "aid" : "1234" + } ], + "overrideProxyId" : "281474976710706", + "monitors" : [ { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + }, { + "monitorType" : "public", + "monitorId" : "1234", + "monitorName" : "Seattle, WA", + "ipAddress" : "4.69.184.193", + "countryId" : "GB", + "network" : "Level 3 Communications, Inc. (AS 3356)" + } ], + "sslVersion" : "Auto", + "useNtlm" : false, + "credentials" : [ "3247", "1051" ], + "downloadLimit" : 2048, + "alertRules" : [ { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + }, { + "severity" : "major", + "expression" : "((hops((hopDelay >= 100 ms))))", + "alertType" : "http-server", + "roundsViolatingMode" : "exact", + "sensitivityLevel" : "medium", + "roundsViolatingOutOf" : 5, + "roundsViolatingRequired" : 2, + "isDefault" : true, + "minimumSourcesPct" : 99, + "ruleName" : "The End of the Internet", + "minimumSources" : 10, + "ruleId" : "127094", + "direction" : "to-target" + } ], + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "blockDomains" : "domain.com/", + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowGeolocation" : false, + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "alertsEnabled" : true, + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "transactionScript" : "if (true) { return true; }", + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "identifyAgentTrafficWithUserAgent" : false, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + }, { + "agentId" : "281474976710706", + "agentType" : "enterprise-cluster", + "prefix" : "99.128.0.0/11", + "coordinates" : { + "latitude" : 37.77493, + "longitude" : -122.41942 + }, + "agentName" : "thousandeyes-stg-va-254", + "networkProviderInfo" : { + "asn" : 7018, + "name" : "AT&T Services, Inc.", + "type" : "isp" + }, + "countryId" : "US", + "enabled" : true, + "network" : "AT&T Services, Inc. (AS 7018)", + "publicIpAddresses" : [ "192.168.1.78", "f9b2:3a21:f25c:d300:03f4:586d:f8d6:4e1c" ], + "ipAddresses" : [ "99.139.65.220", "9bbd:8a0a:a257:5876:288b:6cb2:3f36:64ce" ], + "location" : "San Francisco Bay Area", + "verifySslCertificates" : true + } ], + "timeLimit" : 30, + "createdDate" : "2022-07-17T22:00:54Z", + "disableScreenshot" : false, + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "subinterval" : 60, + "chromeOptions" : "--disable-gpu", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username", + "targetTime" : 1 + } + """ + expected_response = json.loads(response_body_json) + response = self.api.update_web_transactions_test( + + test_id=test_id, + + web_transaction_test_request=web_transaction_test_request, + + aid=aid, + + _headers=self.te_headers("update_web_transactions_test"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_update_web_transactions_test_error_400(self) -> None: + """Integration test for update_web_transactions_test error path (HTTP 400)""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "web-transactions", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "chromePolicies" : "{\\"ProxyMode\\":\\"direct\\"}", + "contentRegex" : "(regex)+", + "pageLoadingStrategy" : "normal", + "testName" : "ThousandEyes Test", + "allowMicAndCamera" : false, + "browserLanguage" : "en-US", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "emulatedDeviceId" : "2", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "monitors" : [ "17410", "5" ], + "sslVersion" : "Auto", + "useNtlm" : false, + "credentials" : [ "3247", "1051" ], + "downloadLimit" : 2048, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "blockDomains" : "domain.com/", + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowGeolocation" : false, + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "alertsEnabled" : true, + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "transactionScript" : "if (true) { return true; }", + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "identifyAgentTrafficWithUserAgent" : false, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "timeLimit" : 30, + "createdDate" : "2022-07-17T22:00:54Z", + "disableScreenshot" : false, + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "subinterval" : 60, + "chromeOptions" : "--disable-gpu", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username", + "targetTime" : 1 + } + + """ + web_transaction_test_request = thousandeyes_sdk.tests.models.WebTransactionTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.update_web_transactions_test( + + test_id=test_id, + + web_transaction_test_request=web_transaction_test_request, + + aid=aid, + + _headers=self.te_headers("update_web_transactions_test", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_web_transactions_test_error_401(self) -> None: + """Integration test for update_web_transactions_test error path (HTTP 401)""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "web-transactions", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "chromePolicies" : "{\\"ProxyMode\\":\\"direct\\"}", + "contentRegex" : "(regex)+", + "pageLoadingStrategy" : "normal", + "testName" : "ThousandEyes Test", + "allowMicAndCamera" : false, + "browserLanguage" : "en-US", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "emulatedDeviceId" : "2", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "monitors" : [ "17410", "5" ], + "sslVersion" : "Auto", + "useNtlm" : false, + "credentials" : [ "3247", "1051" ], + "downloadLimit" : 2048, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "blockDomains" : "domain.com/", + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowGeolocation" : false, + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "alertsEnabled" : true, + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "transactionScript" : "if (true) { return true; }", + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "identifyAgentTrafficWithUserAgent" : false, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "timeLimit" : 30, + "createdDate" : "2022-07-17T22:00:54Z", + "disableScreenshot" : false, + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "subinterval" : 60, + "chromeOptions" : "--disable-gpu", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username", + "targetTime" : 1 + } + + """ + web_transaction_test_request = thousandeyes_sdk.tests.models.WebTransactionTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.update_web_transactions_test( + + test_id=test_id, + + web_transaction_test_request=web_transaction_test_request, + + aid=aid, + + _headers=self.te_headers("update_web_transactions_test", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_web_transactions_test_error_403(self) -> None: + """Integration test for update_web_transactions_test error path (HTTP 403)""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "web-transactions", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "chromePolicies" : "{\\"ProxyMode\\":\\"direct\\"}", + "contentRegex" : "(regex)+", + "pageLoadingStrategy" : "normal", + "testName" : "ThousandEyes Test", + "allowMicAndCamera" : false, + "browserLanguage" : "en-US", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "emulatedDeviceId" : "2", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "monitors" : [ "17410", "5" ], + "sslVersion" : "Auto", + "useNtlm" : false, + "credentials" : [ "3247", "1051" ], + "downloadLimit" : 2048, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "blockDomains" : "domain.com/", + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowGeolocation" : false, + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "alertsEnabled" : true, + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "transactionScript" : "if (true) { return true; }", + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "identifyAgentTrafficWithUserAgent" : false, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "timeLimit" : 30, + "createdDate" : "2022-07-17T22:00:54Z", + "disableScreenshot" : false, + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "subinterval" : 60, + "chromeOptions" : "--disable-gpu", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username", + "targetTime" : 1 + } + + """ + web_transaction_test_request = thousandeyes_sdk.tests.models.WebTransactionTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.update_web_transactions_test( + + test_id=test_id, + + web_transaction_test_request=web_transaction_test_request, + + aid=aid, + + _headers=self.te_headers("update_web_transactions_test", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_web_transactions_test_error_404(self) -> None: + """Integration test for update_web_transactions_test error path (HTTP 404)""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "web-transactions", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "chromePolicies" : "{\\"ProxyMode\\":\\"direct\\"}", + "contentRegex" : "(regex)+", + "pageLoadingStrategy" : "normal", + "testName" : "ThousandEyes Test", + "allowMicAndCamera" : false, + "browserLanguage" : "en-US", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "emulatedDeviceId" : "2", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "monitors" : [ "17410", "5" ], + "sslVersion" : "Auto", + "useNtlm" : false, + "credentials" : [ "3247", "1051" ], + "downloadLimit" : 2048, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "blockDomains" : "domain.com/", + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowGeolocation" : false, + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "alertsEnabled" : true, + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "transactionScript" : "if (true) { return true; }", + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "identifyAgentTrafficWithUserAgent" : false, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "timeLimit" : 30, + "createdDate" : "2022-07-17T22:00:54Z", + "disableScreenshot" : false, + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "subinterval" : 60, + "chromeOptions" : "--disable-gpu", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username", + "targetTime" : 1 + } + + """ + web_transaction_test_request = thousandeyes_sdk.tests.models.WebTransactionTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.update_web_transactions_test( + + test_id=test_id, + + web_transaction_test_request=web_transaction_test_request, + + aid=aid, + + _headers=self.te_headers("update_web_transactions_test", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_web_transactions_test_error_429(self) -> None: + """Integration test for update_web_transactions_test error path (HTTP 429)""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "web-transactions", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "chromePolicies" : "{\\"ProxyMode\\":\\"direct\\"}", + "contentRegex" : "(regex)+", + "pageLoadingStrategy" : "normal", + "testName" : "ThousandEyes Test", + "allowMicAndCamera" : false, + "browserLanguage" : "en-US", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "emulatedDeviceId" : "2", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "monitors" : [ "17410", "5" ], + "sslVersion" : "Auto", + "useNtlm" : false, + "credentials" : [ "3247", "1051" ], + "downloadLimit" : 2048, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "blockDomains" : "domain.com/", + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowGeolocation" : false, + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "alertsEnabled" : true, + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "transactionScript" : "if (true) { return true; }", + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "identifyAgentTrafficWithUserAgent" : false, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "timeLimit" : 30, + "createdDate" : "2022-07-17T22:00:54Z", + "disableScreenshot" : false, + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "subinterval" : 60, + "chromeOptions" : "--disable-gpu", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username", + "targetTime" : 1 + } + + """ + web_transaction_test_request = thousandeyes_sdk.tests.models.WebTransactionTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.update_web_transactions_test( + + test_id=test_id, + + web_transaction_test_request=web_transaction_test_request, + + aid=aid, + + _headers=self.te_headers("update_web_transactions_test", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_web_transactions_test_error_500(self) -> None: + """Integration test for update_web_transactions_test error path (HTTP 500)""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "web-transactions", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "chromePolicies" : "{\\"ProxyMode\\":\\"direct\\"}", + "contentRegex" : "(regex)+", + "pageLoadingStrategy" : "normal", + "testName" : "ThousandEyes Test", + "allowMicAndCamera" : false, + "browserLanguage" : "en-US", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "emulatedDeviceId" : "2", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "monitors" : [ "17410", "5" ], + "sslVersion" : "Auto", + "useNtlm" : false, + "credentials" : [ "3247", "1051" ], + "downloadLimit" : 2048, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "blockDomains" : "domain.com/", + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowGeolocation" : false, + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "alertsEnabled" : true, + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "transactionScript" : "if (true) { return true; }", + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "identifyAgentTrafficWithUserAgent" : false, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "timeLimit" : 30, + "createdDate" : "2022-07-17T22:00:54Z", + "disableScreenshot" : false, + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "subinterval" : 60, + "chromeOptions" : "--disable-gpu", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username", + "targetTime" : 1 + } + + """ + web_transaction_test_request = thousandeyes_sdk.tests.models.WebTransactionTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.update_web_transactions_test( + + test_id=test_id, + + web_transaction_test_request=web_transaction_test_request, + + aid=aid, + + _headers=self.te_headers("update_web_transactions_test", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_update_web_transactions_test_error_502(self) -> None: + """Integration test for update_web_transactions_test error path (HTTP 502)""" + request_body_json = """ + + { + "clientCertificate" : "-----BEGIN PRIVATE KEY-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END PRIVATE KEY-----\\n-----BEGIN CERTIFICATE-----\\nMIICUTCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADBXMQswCQYDVQQGEwJDTjEL\\n-----END CERTIFICATE-----\\n", + "mtuMeasurements" : false, + "_links" : { + "testResults" : [ { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/network" + }, { + "href" : "https://api.thousandeyes.com/v7/test-results/281474976710706/path-vis" + } ], + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "dnsOverride" : "8.8.8.8", + "bandwidthMeasurements" : true, + "probeMode" : "auto", + "includeHeaders" : true, + "type" : "web-transactions", + "oAuth" : { + "testUrl" : "https://api.thousandeyes.com/v7/status", + "requestMethod" : "post", + "postBody" : "client_id: ************", + "headers" : "Authorization: Basic ************", + "authType" : "none", + "username" : "user123", + "password" : "*******" + }, + "password" : "password", + "protocol" : "tcp", + "followRedirects" : true, + "chromePolicies" : "{\\"ProxyMode\\":\\"direct\\"}", + "contentRegex" : "(regex)+", + "pageLoadingStrategy" : "normal", + "testName" : "ThousandEyes Test", + "allowMicAndCamera" : false, + "browserLanguage" : "en-US", + "verifyCertificate" : false, + "overrideAgentProxy" : false, + "liveShare" : false, + "agentInterfaces" : { + "agentId" : "2954", + "ipAddress" : "192.1.1.0" + }, + "labels" : [ "9842", "1283" ], + "tags" : [ "c6b78e57-81a2-4c5f-a11a-d96c3c664d55", "ec8e64fb-6f11-485c-a5d5-488098ad626a" ], + "randomizedStartTime" : false, + "modifiedDate" : "2022-07-17T22:00:54Z", + "interval" : 60, + "emulatedDeviceId" : "2", + "sharedWithAccounts" : [ "1234", "12345" ], + "overrideProxyId" : "281474976710706", + "monitors" : [ "17410", "5" ], + "sslVersion" : "Auto", + "useNtlm" : false, + "credentials" : [ "3247", "1051" ], + "downloadLimit" : 2048, + "alertRules" : [ "344753", "212697" ], + "description" : "ThousandEyes Test", + "httpTimeLimit" : 5, + "blockDomains" : "domain.com/", + "usePublicBgp" : true, + "enabled" : true, + "vaultCredentials" : [ { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + }, { + "secretId" : "f27e85b2-318b-4145-b5aa-c9dc8d8b0819", + "target" : "username" + } ], + "allowGeolocation" : false, + "allowUnsafeLegacyRenegotiation" : true, + "fixedPacketRate" : 50, + "httpVersion" : 2, + "collectProxyNetworkData" : false, + "pathTraceMode" : "classic", + "modifiedBy" : "user@user.com", + "authType" : "none", + "alertsEnabled" : true, + "customHeaders" : { + "root" : { + "header1" : "value1" + }, + "domains" : { + "domain1.com" : { + "header2" : "value2" + } + }, + "all" : { + "header3" : "value3" + } + }, + "numPathTraces" : 3, + "bgpMeasurements" : true, + "transactionScript" : "if (true) { return true; }", + "distributedTracing" : false, + "savedEvent" : true, + "userAgent" : "curl", + "identifyAgentTrafficWithUserAgent" : false, + "networkMeasurements" : true, + "url" : "www.thousandeyes.com", + "agents" : [ { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + }, { + "agentId" : "125", + "sourceIpAddress" : "1.1.1.1" + } ], + "timeLimit" : 30, + "createdDate" : "2022-07-17T22:00:54Z", + "disableScreenshot" : false, + "createdBy" : "user@user.com", + "testId" : "281474976710706", + "subinterval" : 60, + "chromeOptions" : "--disable-gpu", + "desiredStatusCode" : "200", + "httpTargetTime" : 100, + "sslVersionId" : "0", + "username" : "username", + "targetTime" : 1 + } + + """ + web_transaction_test_request = thousandeyes_sdk.tests.models.WebTransactionTestRequest.from_json(request_body_json) + test_id = '202701' + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(502) + ) as context: + self.api.update_web_transactions_test( + + test_id=test_id, + + web_transaction_test_request=web_transaction_test_request, + + aid=aid, + + _headers=self.te_headers("update_web_transactions_test", error_status="502"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-usage/test/conftest.py b/thousandeyes-sdk-usage/test/conftest.py new file mode 100644 index 00000000..2edba7b3 --- /dev/null +++ b/thousandeyes-sdk-usage/test/conftest.py @@ -0,0 +1,7 @@ +import sys +from pathlib import Path + +_repo_root = Path(__file__).resolve().parents[2] +_core_test_support = _repo_root / "thousandeyes-sdk-core" / "test" +if str(_core_test_support) not in sys.path: + sys.path.insert(0, str(_core_test_support)) diff --git a/thousandeyes-sdk-usage/test/integration_test_utils.py b/thousandeyes-sdk-usage/test/integration_test_utils.py new file mode 100644 index 00000000..21833c98 --- /dev/null +++ b/thousandeyes-sdk-usage/test/integration_test_utils.py @@ -0,0 +1,37 @@ +# coding: utf-8 + +""" + Usage API + + These usage endpoints define the following operations: * **Usage**: Retrieve usage data for the specified time period (default is one month). * Users must have the `View organization usage` permission to access this endpoint. * This operation offers visibility across all account groups within the organization. * Users with `View organization usage` permission in multiple organizations should query the operation with the `aid` query string parameter (see optional parameters) for each organization. * The `agentId` field in enterprise agent unit responses may be omitted when not available. * **Quotas**: Obtain organization and account usage quotas. Additionally, users with the appropriate permissions can create, update, or delete these quotas. * Users must have the necessary permissions to perform quota-related actions. Refer to the Usage API operations for detailed usage instructions and optional parameters. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from thousandeyes_sdk.core.api_client import ApiClient +from thousandeyes_sdk.core.configuration import Configuration +from sdk_test_support.mock_server import ERROR_STATUS_HEADER, OPERATION_ID_HEADER, MockApiServer + +from .mock_manifest import OPERATION_MANIFEST + + +class IntegrationTestBase(unittest.TestCase): + def setUp(self) -> None: + self.server = MockApiServer(OPERATION_MANIFEST) + self.server.start() + configuration = Configuration(host=self.server.base_url, access_token="test-token") + self.api_client = ApiClient(configuration=configuration) + + def tearDown(self) -> None: + self.server.stop() + + def te_headers(self, operation_id: str, error_status=None): + headers = {OPERATION_ID_HEADER: operation_id} + if error_status is not None: + headers[ERROR_STATUS_HEADER] = error_status + return headers diff --git a/thousandeyes-sdk-usage/test/mock_manifest.py b/thousandeyes-sdk-usage/test/mock_manifest.py new file mode 100644 index 00000000..4ce9a01c --- /dev/null +++ b/thousandeyes-sdk-usage/test/mock_manifest.py @@ -0,0 +1,1183 @@ +# coding: utf-8 + +""" + Usage API + + These usage endpoints define the following operations: * **Usage**: Retrieve usage data for the specified time period (default is one month). * Users must have the `View organization usage` permission to access this endpoint. * This operation offers visibility across all account groups within the organization. * Users with `View organization usage` permission in multiple organizations should query the operation with the `aid` query string parameter (see optional parameters) for each organization. * The `agentId` field in enterprise agent unit responses may be omitted when not available. * **Quotas**: Obtain organization and account usage quotas. Additionally, users with the appropriate permissions can create, update, or delete these quotas. * Users must have the necessary permissions to perform quota-related actions. Refer to the Usage API operations for detailed usage instructions and optional parameters. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json + +from sdk_test_support.mock_server_types import ErrorResponseExpectation, OperationExpectation + +OPERATION_MANIFEST = { + + "assign_organizations_account_groups_quotas": OperationExpectation( + operation_id="assign_organizations_account_groups_quotas", + method="POST", + path="/quotas/account-groups/assign", + path_param_examples={ + }, + success_status=200, + success_body=json.loads(""" + + { + "organizations" : [ { + "orgId" : "1234", + "accountGroups" : [ { + "value" : 12000, + "aid" : "1234" + }, { + "value" : 12000, + "aid" : "1234" + } ] + }, { + "orgId" : "1234", + "accountGroups" : [ { + "value" : 12000, + "aid" : "1234" + }, { + "value" : 12000, + "aid" : "1234" + } ] + } ] + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "organizations" : [ { + "orgId" : "1234", + "accountGroups" : [ { + "value" : 12000, + "aid" : "1234" + }, { + "value" : 12000, + "aid" : "1234" + } ] + }, { + "orgId" : "1234", + "accountGroups" : [ { + "value" : 12000, + "aid" : "1234" + }, { + "value" : 12000, + "aid" : "1234" + } ] + } ] + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "assign_organizations_quotas": OperationExpectation( + operation_id="assign_organizations_quotas", + method="POST", + path="/quotas/assign", + path_param_examples={ + }, + success_status=200, + success_body=json.loads(""" + + { + "organizations" : [ { + "orgId" : "1234", + "value" : 12000 + }, { + "orgId" : "12345", + "value" : 10000 + } ] + } + + """), + + success_content_type="application/json", + + request_body_example=json.loads(""" + + { + "organizations" : [ { + "value" : 12000 + }, { + "orgId" : "1234", + "value" : 10000 + } ] + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_quotas": OperationExpectation( + operation_id="get_quotas", + method="GET", + path="/quotas", + path_param_examples={ + }, + success_status=200, + success_body=json.loads(""" + + { + "quotas" : [ { + "accountGroupQuotas" : [ { + "value" : 12000, + "aid" : "1234" + }, { + "value" : 10000, + "aid" : "12345" + } ], + "organizationQuota" : { + "value" : 22500, + "orgId" : "10" + } + }, { + "accountGroupQuotas" : [ { + "value" : 12000, + "aid" : "1234" + }, { + "value" : 10000, + "aid" : "12345" + } ], + "organizationQuota" : { + "value" : 22500, + "orgId" : "10" + } + } ], + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "unassign_organizations_account_groups_quotas": OperationExpectation( + operation_id="unassign_organizations_account_groups_quotas", + method="POST", + path="/quotas/account-groups/unassign", + path_param_examples={ + }, + success_status=204, + success_body=None, + success_content_type="application/json", + request_body_example=json.loads(""" + + { + "organizations" : [ { + "orgId" : "1234", + "accountGroups" : [ "1234", "12345" ] + }, { + "orgId" : "1234", + "accountGroups" : [ "1234", "12345" ] + } ] + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "unassign_organizations_quotas": OperationExpectation( + operation_id="unassign_organizations_quotas", + method="POST", + path="/quotas/unassign", + path_param_examples={ + }, + success_status=204, + success_body=None, + success_content_type="application/json", + request_body_example=json.loads(""" + + { + "organizations" : [ "1234", "12345" ] + } + + """), + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_enterprise_agents_units_usage": OperationExpectation( + operation_id="get_enterprise_agents_units_usage", + method="GET", + path="/usage/units/enterprise-agents", + path_param_examples={ + }, + success_status=200, + success_body=json.loads(""" + + { + "_links" : { + "next" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "previous" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "breakdowns" : [ { + "aid" : "1234", + "agentId" : "123456", + "accountGroupName" : "Support", + "agentName" : "TEVA-test-agent", + "enterpriseUnitsUsed" : 599878, + "enterpriseUnitsProjected" : 597808 + }, { + "aid" : "315", + "agentId" : "789", + "accountGroupName" : "Documentation", + "agentName" : "lab-physical-appliance-1", + "enterpriseUnitsUsed" : 597123, + "enterpriseUnitsProjected" : 597808 + } ] + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_tests_units_usage": OperationExpectation( + operation_id="get_tests_units_usage", + method="GET", + path="/usage/units/tests", + path_param_examples={ + }, + success_status=200, + success_body=json.loads(""" + + { + "_links" : { + "next" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "previous" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "breakdowns" : [ { + "testId" : "1158", + "testName" : "https://app.thousandeyes.com", + "testType" : "Web-Page Load", + "enterpriseUnitsUsed" : 14050, + "enterpriseUnitsProjected" : 340674, + "cloudUnitsUsed" : 10000, + "cloudUnitsProjected" : 12000, + "aid" : "1234", + "accountGroupName" : "Support" + }, { + "testId" : "1221", + "testName" : "https://app.thousandeyes.com", + "testType" : "Web - HTTP Server", + "enterpriseUnitsUsed" : 194051, + "enterpriseUnitsProjected" : 30622, + "cloudUnitsUsed" : 12000, + "cloudUnitsProjected" : 13000, + "aid" : "1234", + "accountGroupName" : "Support" + } ] + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + + "get_usage": OperationExpectation( + operation_id="get_usage", + method="GET", + path="/usage", + path_param_examples={ + }, + success_status=200, + success_body=json.loads(""" + + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "usage" : { + "cloudUnitsProjected" : 20993812, + "connectedDevicesUnitsUsed" : 79640902, + "enterpriseAgentsUsed" : 58, + "endpointAgents" : [ { + "aid" : "1234", + "accountGroupName" : "Support", + "endpointAgentsUsed" : 22 + }, { + "aid" : "12345", + "accountGroupName" : "Documentation", + "endpointAgentsUsed" : 14 + } ], + "cloudUnitsNextBillingPeriod" : 25123456, + "enterpriseUnitsNextBillingPeriod" : 0, + "endpointAgentsUsed" : 42, + "enterpriseUnitsUsed" : 79640902, + "cloudUnitsUsed" : 8500489, + "connectedDevicesUnitsNextBillingPeriod" : 0, + "connectedDevicesUnitsProjected" : 108016317, + "tests" : [ { + "aid" : "1234", + "testId" : "1158", + "accountGroupName" : "Documentation", + "testName" : "https://app.thousandeyes.com", + "testType" : "Web-Page Load", + "cloudUnitsUsed" : 14050, + "cloudUnitsProjected" : 340674 + }, { + "aid" : "12345", + "testId" : "1159", + "accountGroupName" : "Documentation", + "testName" : "https://support.thousandeyes.com", + "testType" : "Web - HTTP Server", + "cloudUnitsUsed" : 64390, + "cloudUnitsProjected" : 164457 + } ], + "endpointAgentsEmbedded" : [ { + "aid" : "1234", + "accountGroupName" : "Support", + "endpointAgentsEmbeddedUsed" : 2 + }, { + "aid" : "12345", + "accountGroupName" : "Documentation", + "endpointAgentsEmbeddedUsed" : 3 + } ], + "allocations" : { + "used" : 1000, + "projected" : 1000, + "allocations" : [ { + "productName" : "Some Product Name", + "allocatedUnits" : 600 + } ] + }, + "endpointAgentsEssentialsUsed" : 5, + "quota" : { + "monthEnd" : "2020-02-05T08:00:00Z", + "endpointAgentsEmbeddedIncluded" : 10, + "enterpriseAgentsIncluded" : 25, + "monthStart" : "2020-01-05T08:00:00Z", + "cloudUnitsIncluded" : 4320000000, + "deviceAgentsIncluded" : 100, + "endpointAgentsIncluded" : 200, + "endpointAgentsEssentialsIncluded" : 10 + }, + "enterpriseUnitsProjected" : 108016317, + "endpointAgentsEmbeddedUsed" : 5, + "enterpriseAgents" : [ { + "aid" : "1234", + "accountGroupName" : "Support", + "enterpriseAgentsUsed" : 7 + }, { + "aid" : "12345", + "accountGroupName" : "Documentation", + "enterpriseAgentsUsed" : 1 + } ], + "enterpriseAgentUnits" : [ { + "aid" : "1234", + "agentId" : "123456", + "accountGroupName" : "Support", + "agentName" : "TEVA-test-agent", + "enterpriseUnitsUsed" : 599878, + "enterpriseUnitsProjected" : 597808 + }, { + "aid" : "315", + "agentId" : "789", + "accountGroupName" : "Documentation", + "agentName" : "lab-physical-appliance-1", + "enterpriseUnitsUsed" : 597123, + "enterpriseUnitsProjected" : 597808 + } ], + "endpointAgentsEssentials" : [ { + "aid" : "1234", + "accountGroupName" : "Support", + "endpointAgentsEssentialsUsed" : 2 + }, { + "aid" : "12345", + "accountGroupName" : "Documentation", + "endpointAgentsEssentialsUsed" : 3 + } ] + } + } + + """), + + success_content_type="application/json", + + request_body_example=None, + error_responses={ + + "400": ErrorResponseExpectation( + status=400, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + }"""), + content_type="application/json", + ), + + "401": ErrorResponseExpectation( + status=401, + body=json.loads(""" + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + }"""), + content_type="application/json", + ), + + "403": ErrorResponseExpectation( + status=403, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "404": ErrorResponseExpectation( + status=404, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "429": ErrorResponseExpectation( + status=429, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + "500": ErrorResponseExpectation( + status=500, + body=json.loads(""" + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + }"""), + content_type="application/json", + ), + + }, + ), + +} diff --git a/thousandeyes-sdk-usage/test/test_quotas_api_integration.py b/thousandeyes-sdk-usage/test/test_quotas_api_integration.py new file mode 100644 index 00000000..49a00ba4 --- /dev/null +++ b/thousandeyes-sdk-usage/test/test_quotas_api_integration.py @@ -0,0 +1,1343 @@ +# coding: utf-8 + +""" + Usage API + + These usage endpoints define the following operations: * **Usage**: Retrieve usage data for the specified time period (default is one month). * Users must have the `View organization usage` permission to access this endpoint. * This operation offers visibility across all account groups within the organization. * Users with `View organization usage` permission in multiple organizations should query the operation with the `aid` query string parameter (see optional parameters) for each organization. * The `agentId` field in enterprise agent unit responses may be omitted when not available. * **Quotas**: Obtain organization and account usage quotas. Additionally, users with the appropriate permissions can create, update, or delete these quotas. * Users must have the necessary permissions to perform quota-related actions. Refer to the Usage API operations for detailed usage instructions and optional parameters. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.usage.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.usage.api.quotas_api import QuotasApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestQuotasApiIntegration(IntegrationTestBase): + """QuotasApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = QuotasApi(self.api_client) + + + def test_assign_organizations_account_groups_quotas_happy_path(self) -> None: + """Integration test for assign_organizations_account_groups_quotas success path""" + request_body_json = """ + + { + "organizations" : [ { + "orgId" : "1234", + "accountGroups" : [ { + "value" : 12000, + "aid" : "1234" + }, { + "value" : 12000, + "aid" : "1234" + } ] + }, { + "orgId" : "1234", + "accountGroups" : [ { + "value" : 12000, + "aid" : "1234" + }, { + "value" : 12000, + "aid" : "1234" + } ] + } ] + } + + """ + organizations_quotas_assign = thousandeyes_sdk.usage.models.OrganizationsQuotasAssign.from_json(request_body_json) + response_body_json = """ + { + "organizations" : [ { + "orgId" : "1234", + "accountGroups" : [ { + "value" : 12000, + "aid" : "1234" + }, { + "value" : 12000, + "aid" : "1234" + } ] + }, { + "orgId" : "1234", + "accountGroups" : [ { + "value" : 12000, + "aid" : "1234" + }, { + "value" : 12000, + "aid" : "1234" + } ] + } ] + } + """ + expected_response = json.loads(response_body_json) + response = self.api.assign_organizations_account_groups_quotas( + + organizations_quotas_assign=organizations_quotas_assign, + + _headers=self.te_headers("assign_organizations_account_groups_quotas"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_assign_organizations_account_groups_quotas_error_400(self) -> None: + """Integration test for assign_organizations_account_groups_quotas error path (HTTP 400)""" + request_body_json = """ + + { + "organizations" : [ { + "orgId" : "1234", + "accountGroups" : [ { + "value" : 12000, + "aid" : "1234" + }, { + "value" : 12000, + "aid" : "1234" + } ] + }, { + "orgId" : "1234", + "accountGroups" : [ { + "value" : 12000, + "aid" : "1234" + }, { + "value" : 12000, + "aid" : "1234" + } ] + } ] + } + + """ + organizations_quotas_assign = thousandeyes_sdk.usage.models.OrganizationsQuotasAssign.from_json(request_body_json) + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.assign_organizations_account_groups_quotas( + + organizations_quotas_assign=organizations_quotas_assign, + + _headers=self.te_headers("assign_organizations_account_groups_quotas", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_assign_organizations_account_groups_quotas_error_401(self) -> None: + """Integration test for assign_organizations_account_groups_quotas error path (HTTP 401)""" + request_body_json = """ + + { + "organizations" : [ { + "orgId" : "1234", + "accountGroups" : [ { + "value" : 12000, + "aid" : "1234" + }, { + "value" : 12000, + "aid" : "1234" + } ] + }, { + "orgId" : "1234", + "accountGroups" : [ { + "value" : 12000, + "aid" : "1234" + }, { + "value" : 12000, + "aid" : "1234" + } ] + } ] + } + + """ + organizations_quotas_assign = thousandeyes_sdk.usage.models.OrganizationsQuotasAssign.from_json(request_body_json) + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.assign_organizations_account_groups_quotas( + + organizations_quotas_assign=organizations_quotas_assign, + + _headers=self.te_headers("assign_organizations_account_groups_quotas", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_assign_organizations_account_groups_quotas_error_403(self) -> None: + """Integration test for assign_organizations_account_groups_quotas error path (HTTP 403)""" + request_body_json = """ + + { + "organizations" : [ { + "orgId" : "1234", + "accountGroups" : [ { + "value" : 12000, + "aid" : "1234" + }, { + "value" : 12000, + "aid" : "1234" + } ] + }, { + "orgId" : "1234", + "accountGroups" : [ { + "value" : 12000, + "aid" : "1234" + }, { + "value" : 12000, + "aid" : "1234" + } ] + } ] + } + + """ + organizations_quotas_assign = thousandeyes_sdk.usage.models.OrganizationsQuotasAssign.from_json(request_body_json) + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.assign_organizations_account_groups_quotas( + + organizations_quotas_assign=organizations_quotas_assign, + + _headers=self.te_headers("assign_organizations_account_groups_quotas", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_assign_organizations_account_groups_quotas_error_404(self) -> None: + """Integration test for assign_organizations_account_groups_quotas error path (HTTP 404)""" + request_body_json = """ + + { + "organizations" : [ { + "orgId" : "1234", + "accountGroups" : [ { + "value" : 12000, + "aid" : "1234" + }, { + "value" : 12000, + "aid" : "1234" + } ] + }, { + "orgId" : "1234", + "accountGroups" : [ { + "value" : 12000, + "aid" : "1234" + }, { + "value" : 12000, + "aid" : "1234" + } ] + } ] + } + + """ + organizations_quotas_assign = thousandeyes_sdk.usage.models.OrganizationsQuotasAssign.from_json(request_body_json) + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.assign_organizations_account_groups_quotas( + + organizations_quotas_assign=organizations_quotas_assign, + + _headers=self.te_headers("assign_organizations_account_groups_quotas", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_assign_organizations_account_groups_quotas_error_429(self) -> None: + """Integration test for assign_organizations_account_groups_quotas error path (HTTP 429)""" + request_body_json = """ + + { + "organizations" : [ { + "orgId" : "1234", + "accountGroups" : [ { + "value" : 12000, + "aid" : "1234" + }, { + "value" : 12000, + "aid" : "1234" + } ] + }, { + "orgId" : "1234", + "accountGroups" : [ { + "value" : 12000, + "aid" : "1234" + }, { + "value" : 12000, + "aid" : "1234" + } ] + } ] + } + + """ + organizations_quotas_assign = thousandeyes_sdk.usage.models.OrganizationsQuotasAssign.from_json(request_body_json) + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.assign_organizations_account_groups_quotas( + + organizations_quotas_assign=organizations_quotas_assign, + + _headers=self.te_headers("assign_organizations_account_groups_quotas", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_assign_organizations_account_groups_quotas_error_500(self) -> None: + """Integration test for assign_organizations_account_groups_quotas error path (HTTP 500)""" + request_body_json = """ + + { + "organizations" : [ { + "orgId" : "1234", + "accountGroups" : [ { + "value" : 12000, + "aid" : "1234" + }, { + "value" : 12000, + "aid" : "1234" + } ] + }, { + "orgId" : "1234", + "accountGroups" : [ { + "value" : 12000, + "aid" : "1234" + }, { + "value" : 12000, + "aid" : "1234" + } ] + } ] + } + + """ + organizations_quotas_assign = thousandeyes_sdk.usage.models.OrganizationsQuotasAssign.from_json(request_body_json) + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.assign_organizations_account_groups_quotas( + + organizations_quotas_assign=organizations_quotas_assign, + + _headers=self.te_headers("assign_organizations_account_groups_quotas", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_assign_organizations_quotas_happy_path(self) -> None: + """Integration test for assign_organizations_quotas success path""" + request_body_json = """ + + { + "organizations" : [ { + "value" : 12000 + }, { + "orgId" : "1234", + "value" : 10000 + } ] + } + + """ + quotas_assign_request = thousandeyes_sdk.usage.models.QuotasAssignRequest.from_json(request_body_json) + response_body_json = """ + { + "organizations" : [ { + "orgId" : "1234", + "value" : 12000 + }, { + "orgId" : "12345", + "value" : 10000 + } ] + } + """ + expected_response = json.loads(response_body_json) + response = self.api.assign_organizations_quotas( + + quotas_assign_request=quotas_assign_request, + + _headers=self.te_headers("assign_organizations_quotas"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_assign_organizations_quotas_error_400(self) -> None: + """Integration test for assign_organizations_quotas error path (HTTP 400)""" + request_body_json = """ + + { + "organizations" : [ { + "value" : 12000 + }, { + "orgId" : "1234", + "value" : 10000 + } ] + } + + """ + quotas_assign_request = thousandeyes_sdk.usage.models.QuotasAssignRequest.from_json(request_body_json) + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.assign_organizations_quotas( + + quotas_assign_request=quotas_assign_request, + + _headers=self.te_headers("assign_organizations_quotas", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_assign_organizations_quotas_error_401(self) -> None: + """Integration test for assign_organizations_quotas error path (HTTP 401)""" + request_body_json = """ + + { + "organizations" : [ { + "value" : 12000 + }, { + "orgId" : "1234", + "value" : 10000 + } ] + } + + """ + quotas_assign_request = thousandeyes_sdk.usage.models.QuotasAssignRequest.from_json(request_body_json) + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.assign_organizations_quotas( + + quotas_assign_request=quotas_assign_request, + + _headers=self.te_headers("assign_organizations_quotas", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_assign_organizations_quotas_error_403(self) -> None: + """Integration test for assign_organizations_quotas error path (HTTP 403)""" + request_body_json = """ + + { + "organizations" : [ { + "value" : 12000 + }, { + "orgId" : "1234", + "value" : 10000 + } ] + } + + """ + quotas_assign_request = thousandeyes_sdk.usage.models.QuotasAssignRequest.from_json(request_body_json) + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.assign_organizations_quotas( + + quotas_assign_request=quotas_assign_request, + + _headers=self.te_headers("assign_organizations_quotas", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_assign_organizations_quotas_error_404(self) -> None: + """Integration test for assign_organizations_quotas error path (HTTP 404)""" + request_body_json = """ + + { + "organizations" : [ { + "value" : 12000 + }, { + "orgId" : "1234", + "value" : 10000 + } ] + } + + """ + quotas_assign_request = thousandeyes_sdk.usage.models.QuotasAssignRequest.from_json(request_body_json) + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.assign_organizations_quotas( + + quotas_assign_request=quotas_assign_request, + + _headers=self.te_headers("assign_organizations_quotas", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_assign_organizations_quotas_error_429(self) -> None: + """Integration test for assign_organizations_quotas error path (HTTP 429)""" + request_body_json = """ + + { + "organizations" : [ { + "value" : 12000 + }, { + "orgId" : "1234", + "value" : 10000 + } ] + } + + """ + quotas_assign_request = thousandeyes_sdk.usage.models.QuotasAssignRequest.from_json(request_body_json) + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.assign_organizations_quotas( + + quotas_assign_request=quotas_assign_request, + + _headers=self.te_headers("assign_organizations_quotas", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_assign_organizations_quotas_error_500(self) -> None: + """Integration test for assign_organizations_quotas error path (HTTP 500)""" + request_body_json = """ + + { + "organizations" : [ { + "value" : 12000 + }, { + "orgId" : "1234", + "value" : 10000 + } ] + } + + """ + quotas_assign_request = thousandeyes_sdk.usage.models.QuotasAssignRequest.from_json(request_body_json) + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.assign_organizations_quotas( + + quotas_assign_request=quotas_assign_request, + + _headers=self.te_headers("assign_organizations_quotas", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_quotas_happy_path(self) -> None: + """Integration test for get_quotas success path""" + response_body_json = """ + { + "quotas" : [ { + "accountGroupQuotas" : [ { + "value" : 12000, + "aid" : "1234" + }, { + "value" : 10000, + "aid" : "12345" + } ], + "organizationQuota" : { + "value" : 22500, + "orgId" : "10" + } + }, { + "accountGroupQuotas" : [ { + "value" : 12000, + "aid" : "1234" + }, { + "value" : 10000, + "aid" : "12345" + } ], + "organizationQuota" : { + "value" : 22500, + "orgId" : "10" + } + } ], + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + } + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_quotas( + + _headers=self.te_headers("get_quotas"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_quotas_error_400(self) -> None: + """Integration test for get_quotas error path (HTTP 400)""" + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.get_quotas( + + _headers=self.te_headers("get_quotas", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_quotas_error_401(self) -> None: + """Integration test for get_quotas error path (HTTP 401)""" + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_quotas( + + _headers=self.te_headers("get_quotas", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_quotas_error_403(self) -> None: + """Integration test for get_quotas error path (HTTP 403)""" + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_quotas( + + _headers=self.te_headers("get_quotas", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_quotas_error_404(self) -> None: + """Integration test for get_quotas error path (HTTP 404)""" + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_quotas( + + _headers=self.te_headers("get_quotas", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_quotas_error_429(self) -> None: + """Integration test for get_quotas error path (HTTP 429)""" + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_quotas( + + _headers=self.te_headers("get_quotas", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_quotas_error_500(self) -> None: + """Integration test for get_quotas error path (HTTP 500)""" + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_quotas( + + _headers=self.te_headers("get_quotas", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_unassign_organizations_account_groups_quotas_happy_path(self) -> None: + """Integration test for unassign_organizations_account_groups_quotas success path""" + request_body_json = """ + + { + "organizations" : [ { + "orgId" : "1234", + "accountGroups" : [ "1234", "12345" ] + }, { + "orgId" : "1234", + "accountGroups" : [ "1234", "12345" ] + } ] + } + + """ + organizations_quotas_unassign = thousandeyes_sdk.usage.models.OrganizationsQuotasUnassign.from_json(request_body_json) + response = self.api.unassign_organizations_account_groups_quotas_with_http_info( + + organizations_quotas_unassign=organizations_quotas_unassign, + + _headers=self.te_headers("unassign_organizations_account_groups_quotas"), + ) + self.assertEqual(204, response.status_code) + self.assertIsNone(response.data) + + + def test_unassign_organizations_account_groups_quotas_error_400(self) -> None: + """Integration test for unassign_organizations_account_groups_quotas error path (HTTP 400)""" + request_body_json = """ + + { + "organizations" : [ { + "orgId" : "1234", + "accountGroups" : [ "1234", "12345" ] + }, { + "orgId" : "1234", + "accountGroups" : [ "1234", "12345" ] + } ] + } + + """ + organizations_quotas_unassign = thousandeyes_sdk.usage.models.OrganizationsQuotasUnassign.from_json(request_body_json) + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.unassign_organizations_account_groups_quotas( + + organizations_quotas_unassign=organizations_quotas_unassign, + + _headers=self.te_headers("unassign_organizations_account_groups_quotas", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_unassign_organizations_account_groups_quotas_error_401(self) -> None: + """Integration test for unassign_organizations_account_groups_quotas error path (HTTP 401)""" + request_body_json = """ + + { + "organizations" : [ { + "orgId" : "1234", + "accountGroups" : [ "1234", "12345" ] + }, { + "orgId" : "1234", + "accountGroups" : [ "1234", "12345" ] + } ] + } + + """ + organizations_quotas_unassign = thousandeyes_sdk.usage.models.OrganizationsQuotasUnassign.from_json(request_body_json) + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.unassign_organizations_account_groups_quotas( + + organizations_quotas_unassign=organizations_quotas_unassign, + + _headers=self.te_headers("unassign_organizations_account_groups_quotas", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_unassign_organizations_account_groups_quotas_error_403(self) -> None: + """Integration test for unassign_organizations_account_groups_quotas error path (HTTP 403)""" + request_body_json = """ + + { + "organizations" : [ { + "orgId" : "1234", + "accountGroups" : [ "1234", "12345" ] + }, { + "orgId" : "1234", + "accountGroups" : [ "1234", "12345" ] + } ] + } + + """ + organizations_quotas_unassign = thousandeyes_sdk.usage.models.OrganizationsQuotasUnassign.from_json(request_body_json) + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.unassign_organizations_account_groups_quotas( + + organizations_quotas_unassign=organizations_quotas_unassign, + + _headers=self.te_headers("unassign_organizations_account_groups_quotas", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_unassign_organizations_account_groups_quotas_error_404(self) -> None: + """Integration test for unassign_organizations_account_groups_quotas error path (HTTP 404)""" + request_body_json = """ + + { + "organizations" : [ { + "orgId" : "1234", + "accountGroups" : [ "1234", "12345" ] + }, { + "orgId" : "1234", + "accountGroups" : [ "1234", "12345" ] + } ] + } + + """ + organizations_quotas_unassign = thousandeyes_sdk.usage.models.OrganizationsQuotasUnassign.from_json(request_body_json) + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.unassign_organizations_account_groups_quotas( + + organizations_quotas_unassign=organizations_quotas_unassign, + + _headers=self.te_headers("unassign_organizations_account_groups_quotas", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_unassign_organizations_account_groups_quotas_error_429(self) -> None: + """Integration test for unassign_organizations_account_groups_quotas error path (HTTP 429)""" + request_body_json = """ + + { + "organizations" : [ { + "orgId" : "1234", + "accountGroups" : [ "1234", "12345" ] + }, { + "orgId" : "1234", + "accountGroups" : [ "1234", "12345" ] + } ] + } + + """ + organizations_quotas_unassign = thousandeyes_sdk.usage.models.OrganizationsQuotasUnassign.from_json(request_body_json) + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.unassign_organizations_account_groups_quotas( + + organizations_quotas_unassign=organizations_quotas_unassign, + + _headers=self.te_headers("unassign_organizations_account_groups_quotas", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_unassign_organizations_account_groups_quotas_error_500(self) -> None: + """Integration test for unassign_organizations_account_groups_quotas error path (HTTP 500)""" + request_body_json = """ + + { + "organizations" : [ { + "orgId" : "1234", + "accountGroups" : [ "1234", "12345" ] + }, { + "orgId" : "1234", + "accountGroups" : [ "1234", "12345" ] + } ] + } + + """ + organizations_quotas_unassign = thousandeyes_sdk.usage.models.OrganizationsQuotasUnassign.from_json(request_body_json) + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.unassign_organizations_account_groups_quotas( + + organizations_quotas_unassign=organizations_quotas_unassign, + + _headers=self.te_headers("unassign_organizations_account_groups_quotas", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_unassign_organizations_quotas_happy_path(self) -> None: + """Integration test for unassign_organizations_quotas success path""" + request_body_json = """ + + { + "organizations" : [ "1234", "12345" ] + } + + """ + quotas_unassign = thousandeyes_sdk.usage.models.QuotasUnassign.from_json(request_body_json) + response = self.api.unassign_organizations_quotas_with_http_info( + + quotas_unassign=quotas_unassign, + + _headers=self.te_headers("unassign_organizations_quotas"), + ) + self.assertEqual(204, response.status_code) + self.assertIsNone(response.data) + + + def test_unassign_organizations_quotas_error_400(self) -> None: + """Integration test for unassign_organizations_quotas error path (HTTP 400)""" + request_body_json = """ + + { + "organizations" : [ "1234", "12345" ] + } + + """ + quotas_unassign = thousandeyes_sdk.usage.models.QuotasUnassign.from_json(request_body_json) + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.unassign_organizations_quotas( + + quotas_unassign=quotas_unassign, + + _headers=self.te_headers("unassign_organizations_quotas", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_unassign_organizations_quotas_error_401(self) -> None: + """Integration test for unassign_organizations_quotas error path (HTTP 401)""" + request_body_json = """ + + { + "organizations" : [ "1234", "12345" ] + } + + """ + quotas_unassign = thousandeyes_sdk.usage.models.QuotasUnassign.from_json(request_body_json) + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.unassign_organizations_quotas( + + quotas_unassign=quotas_unassign, + + _headers=self.te_headers("unassign_organizations_quotas", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_unassign_organizations_quotas_error_403(self) -> None: + """Integration test for unassign_organizations_quotas error path (HTTP 403)""" + request_body_json = """ + + { + "organizations" : [ "1234", "12345" ] + } + + """ + quotas_unassign = thousandeyes_sdk.usage.models.QuotasUnassign.from_json(request_body_json) + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.unassign_organizations_quotas( + + quotas_unassign=quotas_unassign, + + _headers=self.te_headers("unassign_organizations_quotas", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_unassign_organizations_quotas_error_404(self) -> None: + """Integration test for unassign_organizations_quotas error path (HTTP 404)""" + request_body_json = """ + + { + "organizations" : [ "1234", "12345" ] + } + + """ + quotas_unassign = thousandeyes_sdk.usage.models.QuotasUnassign.from_json(request_body_json) + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.unassign_organizations_quotas( + + quotas_unassign=quotas_unassign, + + _headers=self.te_headers("unassign_organizations_quotas", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_unassign_organizations_quotas_error_429(self) -> None: + """Integration test for unassign_organizations_quotas error path (HTTP 429)""" + request_body_json = """ + + { + "organizations" : [ "1234", "12345" ] + } + + """ + quotas_unassign = thousandeyes_sdk.usage.models.QuotasUnassign.from_json(request_body_json) + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.unassign_organizations_quotas( + + quotas_unassign=quotas_unassign, + + _headers=self.te_headers("unassign_organizations_quotas", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_unassign_organizations_quotas_error_500(self) -> None: + """Integration test for unassign_organizations_quotas error path (HTTP 500)""" + request_body_json = """ + + { + "organizations" : [ "1234", "12345" ] + } + + """ + quotas_unassign = thousandeyes_sdk.usage.models.QuotasUnassign.from_json(request_body_json) + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.unassign_organizations_quotas( + + quotas_unassign=quotas_unassign, + + _headers=self.te_headers("unassign_organizations_quotas", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-usage/test/test_usage_api_integration.py b/thousandeyes-sdk-usage/test/test_usage_api_integration.py new file mode 100644 index 00000000..dc835747 --- /dev/null +++ b/thousandeyes-sdk-usage/test/test_usage_api_integration.py @@ -0,0 +1,878 @@ +# coding: utf-8 + +""" + Usage API + + These usage endpoints define the following operations: * **Usage**: Retrieve usage data for the specified time period (default is one month). * Users must have the `View organization usage` permission to access this endpoint. * This operation offers visibility across all account groups within the organization. * Users with `View organization usage` permission in multiple organizations should query the operation with the `aid` query string parameter (see optional parameters) for each organization. * The `agentId` field in enterprise agent unit responses may be omitted when not available. * **Quotas**: Obtain organization and account usage quotas. Additionally, users with the appropriate permissions can create, update, or delete these quotas. * Users must have the necessary permissions to perform quota-related actions. Refer to the Usage API operations for detailed usage instructions and optional parameters. + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import json +import unittest +import thousandeyes_sdk.usage.models + +from thousandeyes_sdk.core.exceptions import ApiException +from thousandeyes_sdk.usage.api.usage_api import UsageApi +from .integration_test_utils import IntegrationTestBase +from .test_utils import assert_constructed_model_matches_example_json + + +class TestUsageApiIntegration(IntegrationTestBase): + """UsageApi integration test stubs""" + + def setUp(self) -> None: + super().setUp() + self.api = UsageApi(self.api_client) + + + def test_get_enterprise_agents_units_usage_happy_path(self) -> None: + """Integration test for get_enterprise_agents_units_usage success path""" + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + response_body_json = """ + { + "_links" : { + "next" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "previous" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "breakdowns" : [ { + "aid" : "1234", + "agentId" : "123456", + "accountGroupName" : "Support", + "agentName" : "TEVA-test-agent", + "enterpriseUnitsUsed" : 599878, + "enterpriseUnitsProjected" : 597808 + }, { + "aid" : "315", + "agentId" : "789", + "accountGroupName" : "Documentation", + "agentName" : "lab-physical-appliance-1", + "enterpriseUnitsUsed" : 597123, + "enterpriseUnitsProjected" : 597808 + } ] + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_enterprise_agents_units_usage( + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_enterprise_agents_units_usage"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_enterprise_agents_units_usage_error_400(self) -> None: + """Integration test for get_enterprise_agents_units_usage error path (HTTP 400)""" + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.get_enterprise_agents_units_usage( + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_enterprise_agents_units_usage", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_enterprise_agents_units_usage_error_401(self) -> None: + """Integration test for get_enterprise_agents_units_usage error path (HTTP 401)""" + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_enterprise_agents_units_usage( + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_enterprise_agents_units_usage", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_enterprise_agents_units_usage_error_403(self) -> None: + """Integration test for get_enterprise_agents_units_usage error path (HTTP 403)""" + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_enterprise_agents_units_usage( + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_enterprise_agents_units_usage", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_enterprise_agents_units_usage_error_404(self) -> None: + """Integration test for get_enterprise_agents_units_usage error path (HTTP 404)""" + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_enterprise_agents_units_usage( + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_enterprise_agents_units_usage", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_enterprise_agents_units_usage_error_429(self) -> None: + """Integration test for get_enterprise_agents_units_usage error path (HTTP 429)""" + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_enterprise_agents_units_usage( + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_enterprise_agents_units_usage", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_enterprise_agents_units_usage_error_500(self) -> None: + """Integration test for get_enterprise_agents_units_usage error path (HTTP 500)""" + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_enterprise_agents_units_usage( + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_enterprise_agents_units_usage", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_tests_units_usage_happy_path(self) -> None: + """Integration test for get_tests_units_usage success path""" + aid = '1234' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + response_body_json = """ + { + "_links" : { + "next" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "previous" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + }, + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "breakdowns" : [ { + "testId" : "1158", + "testName" : "https://app.thousandeyes.com", + "testType" : "Web-Page Load", + "enterpriseUnitsUsed" : 14050, + "enterpriseUnitsProjected" : 340674, + "cloudUnitsUsed" : 10000, + "cloudUnitsProjected" : 12000, + "aid" : "1234", + "accountGroupName" : "Support" + }, { + "testId" : "1221", + "testName" : "https://app.thousandeyes.com", + "testType" : "Web - HTTP Server", + "enterpriseUnitsUsed" : 194051, + "enterpriseUnitsProjected" : 30622, + "cloudUnitsUsed" : 12000, + "cloudUnitsProjected" : 13000, + "aid" : "1234", + "accountGroupName" : "Support" + } ] + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_tests_units_usage( + + aid=aid, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_tests_units_usage"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_tests_units_usage_error_400(self) -> None: + """Integration test for get_tests_units_usage error path (HTTP 400)""" + aid = '1234' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.get_tests_units_usage( + + aid=aid, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_tests_units_usage", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_tests_units_usage_error_401(self) -> None: + """Integration test for get_tests_units_usage error path (HTTP 401)""" + aid = '1234' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_tests_units_usage( + + aid=aid, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_tests_units_usage", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_tests_units_usage_error_403(self) -> None: + """Integration test for get_tests_units_usage error path (HTTP 403)""" + aid = '1234' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_tests_units_usage( + + aid=aid, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_tests_units_usage", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_tests_units_usage_error_404(self) -> None: + """Integration test for get_tests_units_usage error path (HTTP 404)""" + aid = '1234' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_tests_units_usage( + + aid=aid, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_tests_units_usage", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_tests_units_usage_error_429(self) -> None: + """Integration test for get_tests_units_usage error path (HTTP 429)""" + aid = '1234' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_tests_units_usage( + + aid=aid, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_tests_units_usage", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_tests_units_usage_error_500(self) -> None: + """Integration test for get_tests_units_usage error path (HTTP 500)""" + aid = '1234' + start_date = '2022-07-17T22:00:54Z' + end_date = '2022-07-18T22:00:54Z' + cursor = 'cursor_example' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_tests_units_usage( + + aid=aid, + + start_date=start_date, + + end_date=end_date, + + cursor=cursor, + + _headers=self.te_headers("get_tests_units_usage", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + def test_get_usage_happy_path(self) -> None: + """Integration test for get_usage success path""" + aid = '1234' + response_body_json = """ + { + "_links" : { + "self" : { + "hreflang" : "hreflang", + "templated" : true, + "profile" : "profile", + "name" : "name", + "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", + "type" : "type", + "deprecation" : "deprecation", + "title" : "title" + } + }, + "usage" : { + "cloudUnitsProjected" : 20993812, + "connectedDevicesUnitsUsed" : 79640902, + "enterpriseAgentsUsed" : 58, + "endpointAgents" : [ { + "aid" : "1234", + "accountGroupName" : "Support", + "endpointAgentsUsed" : 22 + }, { + "aid" : "12345", + "accountGroupName" : "Documentation", + "endpointAgentsUsed" : 14 + } ], + "cloudUnitsNextBillingPeriod" : 25123456, + "enterpriseUnitsNextBillingPeriod" : 0, + "endpointAgentsUsed" : 42, + "enterpriseUnitsUsed" : 79640902, + "cloudUnitsUsed" : 8500489, + "connectedDevicesUnitsNextBillingPeriod" : 0, + "connectedDevicesUnitsProjected" : 108016317, + "tests" : [ { + "aid" : "1234", + "testId" : "1158", + "accountGroupName" : "Documentation", + "testName" : "https://app.thousandeyes.com", + "testType" : "Web-Page Load", + "cloudUnitsUsed" : 14050, + "cloudUnitsProjected" : 340674 + }, { + "aid" : "12345", + "testId" : "1159", + "accountGroupName" : "Documentation", + "testName" : "https://support.thousandeyes.com", + "testType" : "Web - HTTP Server", + "cloudUnitsUsed" : 64390, + "cloudUnitsProjected" : 164457 + } ], + "endpointAgentsEmbedded" : [ { + "aid" : "1234", + "accountGroupName" : "Support", + "endpointAgentsEmbeddedUsed" : 2 + }, { + "aid" : "12345", + "accountGroupName" : "Documentation", + "endpointAgentsEmbeddedUsed" : 3 + } ], + "allocations" : { + "used" : 1000, + "projected" : 1000, + "allocations" : [ { + "productName" : "Some Product Name", + "allocatedUnits" : 600 + } ] + }, + "endpointAgentsEssentialsUsed" : 5, + "quota" : { + "monthEnd" : "2020-02-05T08:00:00Z", + "endpointAgentsEmbeddedIncluded" : 10, + "enterpriseAgentsIncluded" : 25, + "monthStart" : "2020-01-05T08:00:00Z", + "cloudUnitsIncluded" : 4320000000, + "deviceAgentsIncluded" : 100, + "endpointAgentsIncluded" : 200, + "endpointAgentsEssentialsIncluded" : 10 + }, + "enterpriseUnitsProjected" : 108016317, + "endpointAgentsEmbeddedUsed" : 5, + "enterpriseAgents" : [ { + "aid" : "1234", + "accountGroupName" : "Support", + "enterpriseAgentsUsed" : 7 + }, { + "aid" : "12345", + "accountGroupName" : "Documentation", + "enterpriseAgentsUsed" : 1 + } ], + "enterpriseAgentUnits" : [ { + "aid" : "1234", + "agentId" : "123456", + "accountGroupName" : "Support", + "agentName" : "TEVA-test-agent", + "enterpriseUnitsUsed" : 599878, + "enterpriseUnitsProjected" : 597808 + }, { + "aid" : "315", + "agentId" : "789", + "accountGroupName" : "Documentation", + "agentName" : "lab-physical-appliance-1", + "enterpriseUnitsUsed" : 597123, + "enterpriseUnitsProjected" : 597808 + } ], + "endpointAgentsEssentials" : [ { + "aid" : "1234", + "accountGroupName" : "Support", + "endpointAgentsEssentialsUsed" : 2 + }, { + "aid" : "12345", + "accountGroupName" : "Documentation", + "endpointAgentsEssentialsUsed" : 3 + } ] + } + } + """ + expected_response = json.loads(response_body_json) + response = self.api.get_usage( + + aid=aid, + + _headers=self.te_headers("get_usage"), + ) + assert_constructed_model_matches_example_json(response, expected_response) + + + def test_get_usage_error_400(self) -> None: + """Integration test for get_usage error path (HTTP 400)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "errors" : [ { + "code" : "code", + "field" : "field", + "message" : "message" + }, { + "code" : "code", + "field" : "field", + "message" : "message" + } ], + "status" : 0 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(400) + ) as context: + self.api.get_usage( + + aid=aid, + + _headers=self.te_headers("get_usage", error_status="400"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_usage_error_401(self) -> None: + """Integration test for get_usage error path (HTTP 401)""" + aid = '1234' + error_body_json = """ + { + "error_description" : "Invalid access token", + "error" : "invalid_token" + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(401) + ) as context: + self.api.get_usage( + + aid=aid, + + _headers=self.te_headers("get_usage", error_status="401"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_usage_error_403(self) -> None: + """Integration test for get_usage error path (HTTP 403)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(403) + ) as context: + self.api.get_usage( + + aid=aid, + + _headers=self.te_headers("get_usage", error_status="403"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_usage_error_404(self) -> None: + """Integration test for get_usage error path (HTTP 404)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(404) + ) as context: + self.api.get_usage( + + aid=aid, + + _headers=self.te_headers("get_usage", error_status="404"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_usage_error_429(self) -> None: + """Integration test for get_usage error path (HTTP 429)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(429) + ) as context: + self.api.get_usage( + + aid=aid, + + _headers=self.te_headers("get_usage", error_status="429"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + def test_get_usage_error_500(self) -> None: + """Integration test for get_usage error path (HTTP 500)""" + aid = '1234' + error_body_json = """ + { + "instance" : "instance", + "detail" : "detail", + "type" : "type", + "title" : "title", + "status" : 6 + } + """ + expected_error = json.loads(error_body_json) + with self.assertRaises( + ApiException.exception_class_for_http_status(500) + ) as context: + self.api.get_usage( + + aid=aid, + + _headers=self.te_headers("get_usage", error_status="500"), + ) + assert_constructed_model_matches_example_json(context.exception.data, expected_error) + + + + + + +if __name__ == '__main__': + unittest.main() diff --git a/thousandeyes-sdk-usage/test/test_utils.py b/thousandeyes-sdk-usage/test/test_utils.py index 930528d9..37913f62 100644 --- a/thousandeyes-sdk-usage/test/test_utils.py +++ b/thousandeyes-sdk-usage/test/test_utils.py @@ -2,15 +2,36 @@ import json import unittest +from typing import Any from pydantic import BaseModel +def _project_onto_constructed(expected: Any, constructed: Any) -> Any: + """Keep only example fields that appear in the constructed model output.""" + if isinstance(constructed, dict): + if not isinstance(expected, dict): + return expected + return { + key: _project_onto_constructed(expected.get(key), value) + for key, value in constructed.items() + } + if isinstance(constructed, list): + if not isinstance(expected, list): + return expected + return [ + _project_onto_constructed(expected[index], value) + for index, value in enumerate(constructed) + ] + return expected + + def assert_constructed_model_matches_example_json(model: BaseModel, loaded_json: dict): test_case = unittest.TestCase() test_case.maxDiff = None test_case.assertIsNotNone(model) constructed_json = json.loads(model.to_json()) - sorted_loaded_json = json.dumps(loaded_json, sort_keys=True) + projected_loaded_json = _project_onto_constructed(loaded_json, constructed_json) + sorted_loaded_json = json.dumps(projected_loaded_json, sort_keys=True) sorted_constructed_json = json.dumps(constructed_json, sort_keys=True) test_case.assertEqual(sorted_loaded_json, sorted_constructed_json)