# coding: utf-8 """ Cloud Insights Integrations API **Note:** All Cloud Insights APIs are not available for ThousandEyes for Government instance. The Cloud Insights Integrations API lets you programmatically manage **AWS** and **Azure** monitoring integrations in ThousandEyes. ### What You Can Do - **List** all integrations. - **Get** details for a specific integration. - **Delete** an existing integration. - **Create** integrations for: - **AWS**: inventory monitoring and flow logs monitoring. - **Azure**: inventory monitoring and flow logs monitoring. - **Update** integrations for: - **Azure**: inventory monitoring and flow logs monitoring. - **Fetch AWS IAM policy documents** required to configure AWS inventory and flow-logs integrations. - **Retrieve** the current AWS and Azure integration policy settings to understand which AWS and Azure resource groups, AWS regions, Azure subscription rules are enabled and whether CloudTrail is enabled for Cloud Insights for inventory monitoring. - **Update** policy settings to change the approved AWS resource groups, AWS regions, and Azure subscription rules that ThousandEyes should inventory. ### Scope and Tenancy All operations are scoped to the authenticated account group. Responses include only resources associated with that group. ### Payloads and formats - **Requests:** `application/json` - **Responses:** primarily `application/hal+json` for resource representations and `application/json` for policy documents. - HAL responses include `_links` with a `self` relation for direct navigation. ### Integration Types - **Inventory monitoring** - AWS: reads inventory and network topology via read-only IAM permissions. - Azure: authenticates with a Service Principal to read inventory and network topology. - **Flow logs monitoring** - AWS: reads flow logs from S3 buckets and uses SNS for notifications. - Azure: reads flow logs via **Service Bus Queue** (`serviceBusQueueUrl`). ### Policy Helpers (AWS) Dedicated endpoints return **Trusted Policy**, **Permissions Policy**, and **SNS Topic Access Policy** documents to simplify role setup for inventory and flow logs integrations. ### Notes - All example values in this specification are **fictitious**. For more information about Cloud Insights, see [Cloud Insights](https://docs.thousandeyes.com/product-documentation/cloud-insights). Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. """ # noqa: E501 import json import unittest import thousandeyes_sdk.cloud_insights_integrations.models from .test_utils import assert_constructed_model_matches_example_json from thousandeyes_sdk.cloud_insights_integrations.api.cloud_insights_integration_policy_settings_api import CloudInsightsIntegrationPolicySettingsApi class TestCloudInsightsIntegrationPolicySettingsApi(unittest.TestCase): """CloudInsightsIntegrationPolicySettingsApi unit test stubs""" def setUp(self) -> None: self.api = CloudInsightsIntegrationPolicySettingsApi() def tearDown(self) -> None: pass def test_get_aws_integration_policy_settings_models_validation(self) -> None: """Test case for get_aws_integration_policy_settings request and response models""" response_body_json = """ { "enabledRegions" : [ "us-east-1", "eu-west-1", "ap-southeast-2" ], "enabledResourceGroupTypes" : [ "ec2", "s3-bucket", "global-network" ], "_links" : { "self" : { "hreflang" : "hreflang", "templated" : true, "profile" : "profile", "name" : "name", "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", "type" : "type", "deprecation" : "deprecation", "title" : "title" } }, "enabledCloudtrail" : true }""" response_loaded_json = json.loads(response_body_json) response_from_json = thousandeyes_sdk.cloud_insights_integrations.models.AwsIntegrationPolicySetting.from_json(response_body_json) assert_constructed_model_matches_example_json(response_from_json, response_loaded_json) def test_get_azure_integration_policy_settings_models_validation(self) -> None: """Test case for get_azure_integration_policy_settings request and response models""" response_body_json = """ { "enabledResourceGroupTypes" : [ "networking", "virtual-wan", "traffic-manager" ], "_links" : { "self" : { "hreflang" : "hreflang", "templated" : true, "profile" : "profile", "name" : "name", "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", "type" : "type", "deprecation" : "deprecation", "title" : "title" } }, "subscriptionsPolicy" : { "rules" : [ { "field" : "subscription-name", "pattern" : "^prod-.*$", "action" : "include" }, { "field" : "subscription-id", "pattern" : "3145d332-e1c9-4670-a672-12e17d4f627e", "action" : "exclude" } ], "defaultAction" : "exclude" } }""" response_loaded_json = json.loads(response_body_json) response_from_json = thousandeyes_sdk.cloud_insights_integrations.models.AzureIntegrationPolicySetting.from_json(response_body_json) assert_constructed_model_matches_example_json(response_from_json, response_loaded_json) def test_update_aws_integration_policy_settings_models_validation(self) -> None: """Test case for update_aws_integration_policy_settings request and response models""" request_body_json = """ { "enabledRegions" : [ "us-east-1", "eu-west-1", "ap-southeast-2" ], "enabledResourceGroupTypes" : [ "ec2", "s3-bucket", "global-network" ], "_links" : { "self" : { "hreflang" : "hreflang", "templated" : true, "profile" : "profile", "name" : "name", "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", "type" : "type", "deprecation" : "deprecation", "title" : "title" } }, "enabledCloudtrail" : true } """ request_loaded_json = json.loads(request_body_json) request_from_json = thousandeyes_sdk.cloud_insights_integrations.models.AwsIntegrationPolicySetting.from_json(request_body_json) assert_constructed_model_matches_example_json(request_from_json, request_loaded_json) response_body_json = """ { "enabledRegions" : [ "us-east-1", "eu-west-1", "ap-southeast-2" ], "enabledResourceGroupTypes" : [ "ec2", "s3-bucket", "global-network" ], "_links" : { "self" : { "hreflang" : "hreflang", "templated" : true, "profile" : "profile", "name" : "name", "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", "type" : "type", "deprecation" : "deprecation", "title" : "title" } }, "enabledCloudtrail" : true }""" response_loaded_json = json.loads(response_body_json) response_from_json = thousandeyes_sdk.cloud_insights_integrations.models.AwsIntegrationPolicySetting.from_json(response_body_json) assert_constructed_model_matches_example_json(response_from_json, response_loaded_json) def test_update_azure_integration_policy_settings_models_validation(self) -> None: """Test case for update_azure_integration_policy_settings request and response models""" request_body_json = """ { "enabledResourceGroupTypes" : [ "networking", "virtual-wan", "traffic-manager" ], "_links" : { "self" : { "hreflang" : "hreflang", "templated" : true, "profile" : "profile", "name" : "name", "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", "type" : "type", "deprecation" : "deprecation", "title" : "title" } }, "subscriptionsPolicy" : { "rules" : [ { "field" : "subscription-name", "pattern" : "^prod-.*$", "action" : "include" }, { "field" : "subscription-id", "pattern" : "3145d332-e1c9-4670-a672-12e17d4f627e", "action" : "exclude" } ], "defaultAction" : "exclude" } } """ request_loaded_json = json.loads(request_body_json) request_from_json = thousandeyes_sdk.cloud_insights_integrations.models.AzureIntegrationPolicySetting.from_json(request_body_json) assert_constructed_model_matches_example_json(request_from_json, request_loaded_json) response_body_json = """ { "enabledResourceGroupTypes" : [ "networking", "virtual-wan", "traffic-manager" ], "_links" : { "self" : { "hreflang" : "hreflang", "templated" : true, "profile" : "profile", "name" : "name", "href" : "https://api.thousandeyes.com/v7/link/to/resource/id", "type" : "type", "deprecation" : "deprecation", "title" : "title" } }, "subscriptionsPolicy" : { "rules" : [ { "field" : "subscription-name", "pattern" : "^prod-.*$", "action" : "include" }, { "field" : "subscription-id", "pattern" : "3145d332-e1c9-4670-a672-12e17d4f627e", "action" : "exclude" } ], "defaultAction" : "exclude" } }""" response_loaded_json = json.loads(response_body_json) response_from_json = thousandeyes_sdk.cloud_insights_integrations.models.AzureIntegrationPolicySetting.from_json(response_body_json) assert_constructed_model_matches_example_json(response_from_json, response_loaded_json) if __name__ == '__main__': unittest.main()