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