# 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()
