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