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