thousandeyes-sdk-python/thousandeyes-sdk-dashboards/test/test_dashboards_api_integration.py
Kevin 5441f44f1f CP-2453 Add generated integration tests for all SDK packages
Sync OAS-driven integration test artifacts (mock manifest, test base, conftest, and per-operation integration tests) across 21 packages for CP-2453 full rollout evaluation.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-28 12:07:00 +01:00

4826 lines
209 KiB
Python

# coding: utf-8
"""
Dashboards API
Manage ThousandEyes Dashboards.
Generated by OpenAPI Generator (https://openapi-generator.tech)
Do not edit the class manually.
""" # noqa: E501
import json
import unittest
import thousandeyes_sdk.dashboards.models
from thousandeyes_sdk.core.exceptions import ApiException
from thousandeyes_sdk.dashboards.api.dashboards_api import DashboardsApi
from .integration_test_utils import IntegrationTestBase
from .test_utils import assert_constructed_model_matches_example_json
class TestDashboardsApiIntegration(IntegrationTestBase):
"""DashboardsApi integration test stubs"""
def setUp(self) -> None:
super().setUp()
self.api = DashboardsApi(self.api_client)
def test_create_dashboard_happy_path(self) -> None:
"""Integration test for create_dashboard success path"""
request_body_json = """
{
"isMigratedReport" : false,
"_links" : {
"snapshots" : {
"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"
}
},
"isDefaultForAccount" : false,
"isDefaultForUser" : true,
"description" : "HTTP Server Widgets",
"isPrivate" : true,
"title" : "HTTP Server Widgets",
"isBuiltIn" : true,
"widgets" : [ {
"embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f",
"shouldExcludeAlertSuppressionWindows" : 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"
}
},
"visualMode" : "Full",
"filters" : {
"TEST" : [ 5187, 5227 ],
"ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ]
},
"title" : "Widget Title",
"type" : "Agent Status",
"metricGroup" : "BGP",
"measure" : {
"percentileValue" : 95,
"type" : "MEAN"
},
"apiLink" : "apiLink",
"metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT",
"isEmbedded" : true,
"id" : "1234",
"fixedTimespan" : {
"unit" : "Days",
"value" : 10
},
"dataSource" : "ENDPOINT_AGENTS",
"direction" : "FROM_TARGET"
}, {
"embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f",
"shouldExcludeAlertSuppressionWindows" : 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"
}
},
"visualMode" : "Full",
"filters" : {
"TEST" : [ 5187, 5227 ],
"ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ]
},
"title" : "Widget Title",
"type" : "Agent Status",
"metricGroup" : "BGP",
"measure" : {
"percentileValue" : 95,
"type" : "MEAN"
},
"apiLink" : "apiLink",
"metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT",
"isEmbedded" : true,
"id" : "1234",
"fixedTimespan" : {
"unit" : "Days",
"value" : 10
},
"dataSource" : "ENDPOINT_AGENTS",
"direction" : "FROM_TARGET"
} ],
"defaultTimespan" : {
"duration" : 7200,
"timespanDuration" : 7200,
"start" : "2023-05-16T10:14:28Z",
"end" : "2023-05-16T11:14:28Z",
"timespanStart" : "2023-05-16 10:14:28",
"timespanEnd" : "2023-05-16 11:14:28"
},
"layout" : {
"layoutId" : "grid-layout-1",
"type" : "grid",
"details" : {
"widgetPositioning" : [ {
"x" : 0,
"y" : 0,
"w" : 9,
"h" : 5,
"id" : "widgetId-71lbb"
} ]
}
},
"globalFilterId" : "65babd9bb90bf55b17c96c8d",
"dashboardId" : "5e1f7a99143ae6004fdc3bb4",
"createdBy" : "1",
"modifiedDate" : "2023-05-16T10:14:28Z",
"modifiedBy" : "1",
"isGlobalOverride" : true,
"aid" : "1234"
}
"""
dashboard = thousandeyes_sdk.dashboards.models.Dashboard.from_json(request_body_json)
aid = '1234'
response_body_json = """
{
&quot;isMigratedReport&quot; : false,
&quot;_links&quot; : {
&quot;snapshots&quot; : {
&quot;hreflang&quot; : &quot;hreflang&quot;,
&quot;templated&quot; : true,
&quot;profile&quot; : &quot;profile&quot;,
&quot;name&quot; : &quot;name&quot;,
&quot;href&quot; : &quot;https://api.thousandeyes.com/v7/link/to/resource/id&quot;,
&quot;type&quot; : &quot;type&quot;,
&quot;deprecation&quot; : &quot;deprecation&quot;,
&quot;title&quot; : &quot;title&quot;
},
&quot;self&quot; : {
&quot;hreflang&quot; : &quot;hreflang&quot;,
&quot;templated&quot; : true,
&quot;profile&quot; : &quot;profile&quot;,
&quot;name&quot; : &quot;name&quot;,
&quot;href&quot; : &quot;https://api.thousandeyes.com/v7/link/to/resource/id&quot;,
&quot;type&quot; : &quot;type&quot;,
&quot;deprecation&quot; : &quot;deprecation&quot;,
&quot;title&quot; : &quot;title&quot;
}
},
&quot;isDefaultForAccount&quot; : false,
&quot;isDefaultForUser&quot; : true,
&quot;description&quot; : &quot;HTTP Server Widgets&quot;,
&quot;isPrivate&quot; : true,
&quot;title&quot; : &quot;HTTP Server Widgets&quot;,
&quot;isBuiltIn&quot; : true,
&quot;widgets&quot; : [ {
&quot;embedUrl&quot; : &quot;https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f&quot;,
&quot;shouldExcludeAlertSuppressionWindows&quot; : true,
&quot;_links&quot; : {
&quot;self&quot; : {
&quot;hreflang&quot; : &quot;hreflang&quot;,
&quot;templated&quot; : true,
&quot;profile&quot; : &quot;profile&quot;,
&quot;name&quot; : &quot;name&quot;,
&quot;href&quot; : &quot;https://api.thousandeyes.com/v7/link/to/resource/id&quot;,
&quot;type&quot; : &quot;type&quot;,
&quot;deprecation&quot; : &quot;deprecation&quot;,
&quot;title&quot; : &quot;title&quot;
}
},
&quot;visualMode&quot; : &quot;Full&quot;,
&quot;filters&quot; : {
&quot;TEST&quot; : [ 5187, 5227 ],
&quot;ENDPOINT_MACHINE_ID&quot; : [ &quot;fbd0050c-07f7-43f7-9631-14b32f096962&quot; ]
},
&quot;title&quot; : &quot;Widget Title&quot;,
&quot;type&quot; : &quot;Agent Status&quot;,
&quot;metricGroup&quot; : &quot;BGP&quot;,
&quot;measure&quot; : {
&quot;percentileValue&quot; : 95,
&quot;type&quot; : &quot;MEAN&quot;
},
&quot;apiLink&quot; : &quot;apiLink&quot;,
&quot;metric&quot; : &quot;ENDPOINT_GATEWAY_CPU_LOAD_PERCENT&quot;,
&quot;isEmbedded&quot; : true,
&quot;id&quot; : &quot;1234&quot;,
&quot;fixedTimespan&quot; : {
&quot;unit&quot; : &quot;Days&quot;,
&quot;value&quot; : 10
},
&quot;dataSource&quot; : &quot;ENDPOINT_AGENTS&quot;,
&quot;direction&quot; : &quot;FROM_TARGET&quot;
}, {
&quot;embedUrl&quot; : &quot;https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f&quot;,
&quot;shouldExcludeAlertSuppressionWindows&quot; : true,
&quot;_links&quot; : {
&quot;self&quot; : {
&quot;hreflang&quot; : &quot;hreflang&quot;,
&quot;templated&quot; : true,
&quot;profile&quot; : &quot;profile&quot;,
&quot;name&quot; : &quot;name&quot;,
&quot;href&quot; : &quot;https://api.thousandeyes.com/v7/link/to/resource/id&quot;,
&quot;type&quot; : &quot;type&quot;,
&quot;deprecation&quot; : &quot;deprecation&quot;,
&quot;title&quot; : &quot;title&quot;
}
},
&quot;visualMode&quot; : &quot;Full&quot;,
&quot;filters&quot; : {
&quot;TEST&quot; : [ 5187, 5227 ],
&quot;ENDPOINT_MACHINE_ID&quot; : [ &quot;fbd0050c-07f7-43f7-9631-14b32f096962&quot; ]
},
&quot;title&quot; : &quot;Widget Title&quot;,
&quot;type&quot; : &quot;Agent Status&quot;,
&quot;metricGroup&quot; : &quot;BGP&quot;,
&quot;measure&quot; : {
&quot;percentileValue&quot; : 95,
&quot;type&quot; : &quot;MEAN&quot;
},
&quot;apiLink&quot; : &quot;apiLink&quot;,
&quot;metric&quot; : &quot;ENDPOINT_GATEWAY_CPU_LOAD_PERCENT&quot;,
&quot;isEmbedded&quot; : true,
&quot;id&quot; : &quot;1234&quot;,
&quot;fixedTimespan&quot; : {
&quot;unit&quot; : &quot;Days&quot;,
&quot;value&quot; : 10
},
&quot;dataSource&quot; : &quot;ENDPOINT_AGENTS&quot;,
&quot;direction&quot; : &quot;FROM_TARGET&quot;
} ],
&quot;defaultTimespan&quot; : {
&quot;duration&quot; : 7200,
&quot;timespanDuration&quot; : 7200,
&quot;start&quot; : &quot;2023-05-16T10:14:28Z&quot;,
&quot;end&quot; : &quot;2023-05-16T11:14:28Z&quot;,
&quot;timespanStart&quot; : &quot;2023-05-16 10:14:28&quot;,
&quot;timespanEnd&quot; : &quot;2023-05-16 11:14:28&quot;
},
&quot;layout&quot; : {
&quot;layoutId&quot; : &quot;grid-layout-1&quot;,
&quot;type&quot; : &quot;grid&quot;,
&quot;details&quot; : {
&quot;widgetPositioning&quot; : [ {
&quot;x&quot; : 0,
&quot;y&quot; : 0,
&quot;w&quot; : 9,
&quot;h&quot; : 5,
&quot;id&quot; : &quot;widgetId-71lbb&quot;
} ]
}
},
&quot;globalFilterId&quot; : &quot;65babd9bb90bf55b17c96c8d&quot;,
&quot;dashboardId&quot; : &quot;5e1f7a99143ae6004fdc3bb4&quot;,
&quot;createdBy&quot; : &quot;1&quot;,
&quot;modifiedDate&quot; : &quot;2023-05-16T10:14:28Z&quot;,
&quot;modifiedBy&quot; : &quot;1&quot;,
&quot;isGlobalOverride&quot; : true,
&quot;aid&quot; : &quot;1234&quot;
}
"""
expected_response = json.loads(response_body_json)
response = self.api.create_dashboard(
dashboard=dashboard,
aid=aid,
_headers=self.te_headers("create_dashboard"),
)
assert_constructed_model_matches_example_json(response, expected_response)
def test_create_dashboard_error_400(self) -> None:
"""Integration test for create_dashboard error path (HTTP 400)"""
request_body_json = """
{
"isMigratedReport" : false,
"_links" : {
"snapshots" : {
"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"
}
},
"isDefaultForAccount" : false,
"isDefaultForUser" : true,
"description" : "HTTP Server Widgets",
"isPrivate" : true,
"title" : "HTTP Server Widgets",
"isBuiltIn" : true,
"widgets" : [ {
"embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f",
"shouldExcludeAlertSuppressionWindows" : 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"
}
},
"visualMode" : "Full",
"filters" : {
"TEST" : [ 5187, 5227 ],
"ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ]
},
"title" : "Widget Title",
"type" : "Agent Status",
"metricGroup" : "BGP",
"measure" : {
"percentileValue" : 95,
"type" : "MEAN"
},
"apiLink" : "apiLink",
"metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT",
"isEmbedded" : true,
"id" : "1234",
"fixedTimespan" : {
"unit" : "Days",
"value" : 10
},
"dataSource" : "ENDPOINT_AGENTS",
"direction" : "FROM_TARGET"
}, {
"embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f",
"shouldExcludeAlertSuppressionWindows" : 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"
}
},
"visualMode" : "Full",
"filters" : {
"TEST" : [ 5187, 5227 ],
"ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ]
},
"title" : "Widget Title",
"type" : "Agent Status",
"metricGroup" : "BGP",
"measure" : {
"percentileValue" : 95,
"type" : "MEAN"
},
"apiLink" : "apiLink",
"metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT",
"isEmbedded" : true,
"id" : "1234",
"fixedTimespan" : {
"unit" : "Days",
"value" : 10
},
"dataSource" : "ENDPOINT_AGENTS",
"direction" : "FROM_TARGET"
} ],
"defaultTimespan" : {
"duration" : 7200,
"timespanDuration" : 7200,
"start" : "2023-05-16T10:14:28Z",
"end" : "2023-05-16T11:14:28Z",
"timespanStart" : "2023-05-16 10:14:28",
"timespanEnd" : "2023-05-16 11:14:28"
},
"layout" : {
"layoutId" : "grid-layout-1",
"type" : "grid",
"details" : {
"widgetPositioning" : [ {
"x" : 0,
"y" : 0,
"w" : 9,
"h" : 5,
"id" : "widgetId-71lbb"
} ]
}
},
"globalFilterId" : "65babd9bb90bf55b17c96c8d",
"dashboardId" : "5e1f7a99143ae6004fdc3bb4",
"createdBy" : "1",
"modifiedDate" : "2023-05-16T10:14:28Z",
"modifiedBy" : "1",
"isGlobalOverride" : true,
"aid" : "1234"
}
"""
dashboard = thousandeyes_sdk.dashboards.models.Dashboard.from_json(request_body_json)
aid = '1234'
error_body_json = """
{
"instance" : "instance",
"detail" : "detail",
"type" : "type",
"title" : "title",
"errors" : [ {
"code" : "code",
"field" : "field",
"message" : "message"
}, {
"code" : "code",
"field" : "field",
"message" : "message"
} ],
"status" : 0
}
"""
expected_error = json.loads(error_body_json)
with self.assertRaises(
ApiException.exception_class_for_http_status(400)
) as context:
self.api.create_dashboard(
dashboard=dashboard,
aid=aid,
_headers=self.te_headers("create_dashboard", error_status="400"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_create_dashboard_error_401(self) -> None:
"""Integration test for create_dashboard error path (HTTP 401)"""
request_body_json = """
{
"isMigratedReport" : false,
"_links" : {
"snapshots" : {
"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"
}
},
"isDefaultForAccount" : false,
"isDefaultForUser" : true,
"description" : "HTTP Server Widgets",
"isPrivate" : true,
"title" : "HTTP Server Widgets",
"isBuiltIn" : true,
"widgets" : [ {
"embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f",
"shouldExcludeAlertSuppressionWindows" : 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"
}
},
"visualMode" : "Full",
"filters" : {
"TEST" : [ 5187, 5227 ],
"ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ]
},
"title" : "Widget Title",
"type" : "Agent Status",
"metricGroup" : "BGP",
"measure" : {
"percentileValue" : 95,
"type" : "MEAN"
},
"apiLink" : "apiLink",
"metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT",
"isEmbedded" : true,
"id" : "1234",
"fixedTimespan" : {
"unit" : "Days",
"value" : 10
},
"dataSource" : "ENDPOINT_AGENTS",
"direction" : "FROM_TARGET"
}, {
"embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f",
"shouldExcludeAlertSuppressionWindows" : 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"
}
},
"visualMode" : "Full",
"filters" : {
"TEST" : [ 5187, 5227 ],
"ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ]
},
"title" : "Widget Title",
"type" : "Agent Status",
"metricGroup" : "BGP",
"measure" : {
"percentileValue" : 95,
"type" : "MEAN"
},
"apiLink" : "apiLink",
"metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT",
"isEmbedded" : true,
"id" : "1234",
"fixedTimespan" : {
"unit" : "Days",
"value" : 10
},
"dataSource" : "ENDPOINT_AGENTS",
"direction" : "FROM_TARGET"
} ],
"defaultTimespan" : {
"duration" : 7200,
"timespanDuration" : 7200,
"start" : "2023-05-16T10:14:28Z",
"end" : "2023-05-16T11:14:28Z",
"timespanStart" : "2023-05-16 10:14:28",
"timespanEnd" : "2023-05-16 11:14:28"
},
"layout" : {
"layoutId" : "grid-layout-1",
"type" : "grid",
"details" : {
"widgetPositioning" : [ {
"x" : 0,
"y" : 0,
"w" : 9,
"h" : 5,
"id" : "widgetId-71lbb"
} ]
}
},
"globalFilterId" : "65babd9bb90bf55b17c96c8d",
"dashboardId" : "5e1f7a99143ae6004fdc3bb4",
"createdBy" : "1",
"modifiedDate" : "2023-05-16T10:14:28Z",
"modifiedBy" : "1",
"isGlobalOverride" : true,
"aid" : "1234"
}
"""
dashboard = thousandeyes_sdk.dashboards.models.Dashboard.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_dashboard(
dashboard=dashboard,
aid=aid,
_headers=self.te_headers("create_dashboard", error_status="401"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_create_dashboard_error_403(self) -> None:
"""Integration test for create_dashboard error path (HTTP 403)"""
request_body_json = """
{
"isMigratedReport" : false,
"_links" : {
"snapshots" : {
"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"
}
},
"isDefaultForAccount" : false,
"isDefaultForUser" : true,
"description" : "HTTP Server Widgets",
"isPrivate" : true,
"title" : "HTTP Server Widgets",
"isBuiltIn" : true,
"widgets" : [ {
"embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f",
"shouldExcludeAlertSuppressionWindows" : 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"
}
},
"visualMode" : "Full",
"filters" : {
"TEST" : [ 5187, 5227 ],
"ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ]
},
"title" : "Widget Title",
"type" : "Agent Status",
"metricGroup" : "BGP",
"measure" : {
"percentileValue" : 95,
"type" : "MEAN"
},
"apiLink" : "apiLink",
"metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT",
"isEmbedded" : true,
"id" : "1234",
"fixedTimespan" : {
"unit" : "Days",
"value" : 10
},
"dataSource" : "ENDPOINT_AGENTS",
"direction" : "FROM_TARGET"
}, {
"embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f",
"shouldExcludeAlertSuppressionWindows" : 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"
}
},
"visualMode" : "Full",
"filters" : {
"TEST" : [ 5187, 5227 ],
"ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ]
},
"title" : "Widget Title",
"type" : "Agent Status",
"metricGroup" : "BGP",
"measure" : {
"percentileValue" : 95,
"type" : "MEAN"
},
"apiLink" : "apiLink",
"metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT",
"isEmbedded" : true,
"id" : "1234",
"fixedTimespan" : {
"unit" : "Days",
"value" : 10
},
"dataSource" : "ENDPOINT_AGENTS",
"direction" : "FROM_TARGET"
} ],
"defaultTimespan" : {
"duration" : 7200,
"timespanDuration" : 7200,
"start" : "2023-05-16T10:14:28Z",
"end" : "2023-05-16T11:14:28Z",
"timespanStart" : "2023-05-16 10:14:28",
"timespanEnd" : "2023-05-16 11:14:28"
},
"layout" : {
"layoutId" : "grid-layout-1",
"type" : "grid",
"details" : {
"widgetPositioning" : [ {
"x" : 0,
"y" : 0,
"w" : 9,
"h" : 5,
"id" : "widgetId-71lbb"
} ]
}
},
"globalFilterId" : "65babd9bb90bf55b17c96c8d",
"dashboardId" : "5e1f7a99143ae6004fdc3bb4",
"createdBy" : "1",
"modifiedDate" : "2023-05-16T10:14:28Z",
"modifiedBy" : "1",
"isGlobalOverride" : true,
"aid" : "1234"
}
"""
dashboard = thousandeyes_sdk.dashboards.models.Dashboard.from_json(request_body_json)
aid = '1234'
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.create_dashboard(
dashboard=dashboard,
aid=aid,
_headers=self.te_headers("create_dashboard", error_status="403"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_create_dashboard_error_404(self) -> None:
"""Integration test for create_dashboard error path (HTTP 404)"""
request_body_json = """
{
"isMigratedReport" : false,
"_links" : {
"snapshots" : {
"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"
}
},
"isDefaultForAccount" : false,
"isDefaultForUser" : true,
"description" : "HTTP Server Widgets",
"isPrivate" : true,
"title" : "HTTP Server Widgets",
"isBuiltIn" : true,
"widgets" : [ {
"embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f",
"shouldExcludeAlertSuppressionWindows" : 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"
}
},
"visualMode" : "Full",
"filters" : {
"TEST" : [ 5187, 5227 ],
"ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ]
},
"title" : "Widget Title",
"type" : "Agent Status",
"metricGroup" : "BGP",
"measure" : {
"percentileValue" : 95,
"type" : "MEAN"
},
"apiLink" : "apiLink",
"metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT",
"isEmbedded" : true,
"id" : "1234",
"fixedTimespan" : {
"unit" : "Days",
"value" : 10
},
"dataSource" : "ENDPOINT_AGENTS",
"direction" : "FROM_TARGET"
}, {
"embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f",
"shouldExcludeAlertSuppressionWindows" : 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"
}
},
"visualMode" : "Full",
"filters" : {
"TEST" : [ 5187, 5227 ],
"ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ]
},
"title" : "Widget Title",
"type" : "Agent Status",
"metricGroup" : "BGP",
"measure" : {
"percentileValue" : 95,
"type" : "MEAN"
},
"apiLink" : "apiLink",
"metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT",
"isEmbedded" : true,
"id" : "1234",
"fixedTimespan" : {
"unit" : "Days",
"value" : 10
},
"dataSource" : "ENDPOINT_AGENTS",
"direction" : "FROM_TARGET"
} ],
"defaultTimespan" : {
"duration" : 7200,
"timespanDuration" : 7200,
"start" : "2023-05-16T10:14:28Z",
"end" : "2023-05-16T11:14:28Z",
"timespanStart" : "2023-05-16 10:14:28",
"timespanEnd" : "2023-05-16 11:14:28"
},
"layout" : {
"layoutId" : "grid-layout-1",
"type" : "grid",
"details" : {
"widgetPositioning" : [ {
"x" : 0,
"y" : 0,
"w" : 9,
"h" : 5,
"id" : "widgetId-71lbb"
} ]
}
},
"globalFilterId" : "65babd9bb90bf55b17c96c8d",
"dashboardId" : "5e1f7a99143ae6004fdc3bb4",
"createdBy" : "1",
"modifiedDate" : "2023-05-16T10:14:28Z",
"modifiedBy" : "1",
"isGlobalOverride" : true,
"aid" : "1234"
}
"""
dashboard = thousandeyes_sdk.dashboards.models.Dashboard.from_json(request_body_json)
aid = '1234'
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(404)
) as context:
self.api.create_dashboard(
dashboard=dashboard,
aid=aid,
_headers=self.te_headers("create_dashboard", error_status="404"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_create_dashboard_error_429(self) -> None:
"""Integration test for create_dashboard error path (HTTP 429)"""
request_body_json = """
{
"isMigratedReport" : false,
"_links" : {
"snapshots" : {
"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"
}
},
"isDefaultForAccount" : false,
"isDefaultForUser" : true,
"description" : "HTTP Server Widgets",
"isPrivate" : true,
"title" : "HTTP Server Widgets",
"isBuiltIn" : true,
"widgets" : [ {
"embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f",
"shouldExcludeAlertSuppressionWindows" : 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"
}
},
"visualMode" : "Full",
"filters" : {
"TEST" : [ 5187, 5227 ],
"ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ]
},
"title" : "Widget Title",
"type" : "Agent Status",
"metricGroup" : "BGP",
"measure" : {
"percentileValue" : 95,
"type" : "MEAN"
},
"apiLink" : "apiLink",
"metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT",
"isEmbedded" : true,
"id" : "1234",
"fixedTimespan" : {
"unit" : "Days",
"value" : 10
},
"dataSource" : "ENDPOINT_AGENTS",
"direction" : "FROM_TARGET"
}, {
"embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f",
"shouldExcludeAlertSuppressionWindows" : 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"
}
},
"visualMode" : "Full",
"filters" : {
"TEST" : [ 5187, 5227 ],
"ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ]
},
"title" : "Widget Title",
"type" : "Agent Status",
"metricGroup" : "BGP",
"measure" : {
"percentileValue" : 95,
"type" : "MEAN"
},
"apiLink" : "apiLink",
"metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT",
"isEmbedded" : true,
"id" : "1234",
"fixedTimespan" : {
"unit" : "Days",
"value" : 10
},
"dataSource" : "ENDPOINT_AGENTS",
"direction" : "FROM_TARGET"
} ],
"defaultTimespan" : {
"duration" : 7200,
"timespanDuration" : 7200,
"start" : "2023-05-16T10:14:28Z",
"end" : "2023-05-16T11:14:28Z",
"timespanStart" : "2023-05-16 10:14:28",
"timespanEnd" : "2023-05-16 11:14:28"
},
"layout" : {
"layoutId" : "grid-layout-1",
"type" : "grid",
"details" : {
"widgetPositioning" : [ {
"x" : 0,
"y" : 0,
"w" : 9,
"h" : 5,
"id" : "widgetId-71lbb"
} ]
}
},
"globalFilterId" : "65babd9bb90bf55b17c96c8d",
"dashboardId" : "5e1f7a99143ae6004fdc3bb4",
"createdBy" : "1",
"modifiedDate" : "2023-05-16T10:14:28Z",
"modifiedBy" : "1",
"isGlobalOverride" : true,
"aid" : "1234"
}
"""
dashboard = thousandeyes_sdk.dashboards.models.Dashboard.from_json(request_body_json)
aid = '1234'
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.create_dashboard(
dashboard=dashboard,
aid=aid,
_headers=self.te_headers("create_dashboard", error_status="429"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_create_dashboard_error_500(self) -> None:
"""Integration test for create_dashboard error path (HTTP 500)"""
request_body_json = """
{
"isMigratedReport" : false,
"_links" : {
"snapshots" : {
"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"
}
},
"isDefaultForAccount" : false,
"isDefaultForUser" : true,
"description" : "HTTP Server Widgets",
"isPrivate" : true,
"title" : "HTTP Server Widgets",
"isBuiltIn" : true,
"widgets" : [ {
"embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f",
"shouldExcludeAlertSuppressionWindows" : 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"
}
},
"visualMode" : "Full",
"filters" : {
"TEST" : [ 5187, 5227 ],
"ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ]
},
"title" : "Widget Title",
"type" : "Agent Status",
"metricGroup" : "BGP",
"measure" : {
"percentileValue" : 95,
"type" : "MEAN"
},
"apiLink" : "apiLink",
"metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT",
"isEmbedded" : true,
"id" : "1234",
"fixedTimespan" : {
"unit" : "Days",
"value" : 10
},
"dataSource" : "ENDPOINT_AGENTS",
"direction" : "FROM_TARGET"
}, {
"embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f",
"shouldExcludeAlertSuppressionWindows" : 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"
}
},
"visualMode" : "Full",
"filters" : {
"TEST" : [ 5187, 5227 ],
"ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ]
},
"title" : "Widget Title",
"type" : "Agent Status",
"metricGroup" : "BGP",
"measure" : {
"percentileValue" : 95,
"type" : "MEAN"
},
"apiLink" : "apiLink",
"metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT",
"isEmbedded" : true,
"id" : "1234",
"fixedTimespan" : {
"unit" : "Days",
"value" : 10
},
"dataSource" : "ENDPOINT_AGENTS",
"direction" : "FROM_TARGET"
} ],
"defaultTimespan" : {
"duration" : 7200,
"timespanDuration" : 7200,
"start" : "2023-05-16T10:14:28Z",
"end" : "2023-05-16T11:14:28Z",
"timespanStart" : "2023-05-16 10:14:28",
"timespanEnd" : "2023-05-16 11:14:28"
},
"layout" : {
"layoutId" : "grid-layout-1",
"type" : "grid",
"details" : {
"widgetPositioning" : [ {
"x" : 0,
"y" : 0,
"w" : 9,
"h" : 5,
"id" : "widgetId-71lbb"
} ]
}
},
"globalFilterId" : "65babd9bb90bf55b17c96c8d",
"dashboardId" : "5e1f7a99143ae6004fdc3bb4",
"createdBy" : "1",
"modifiedDate" : "2023-05-16T10:14:28Z",
"modifiedBy" : "1",
"isGlobalOverride" : true,
"aid" : "1234"
}
"""
dashboard = thousandeyes_sdk.dashboards.models.Dashboard.from_json(request_body_json)
aid = '1234'
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.create_dashboard(
dashboard=dashboard,
aid=aid,
_headers=self.te_headers("create_dashboard", error_status="500"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_delete_dashboard_happy_path(self) -> None:
"""Integration test for delete_dashboard success path"""
dashboard_id = '646f4d2ce3c99b0536c3821e'
aid = '1234'
response = self.api.delete_dashboard_with_http_info(
dashboard_id=dashboard_id,
aid=aid,
_headers=self.te_headers("delete_dashboard"),
)
self.assertEqual(204, response.status_code)
self.assertIsNone(response.data)
def test_delete_dashboard_error_400(self) -> None:
"""Integration test for delete_dashboard error path (HTTP 400)"""
dashboard_id = '646f4d2ce3c99b0536c3821e'
aid = '1234'
error_body_json = """
{
"instance" : "instance",
"detail" : "detail",
"type" : "type",
"title" : "title",
"errors" : [ {
"code" : "code",
"field" : "field",
"message" : "message"
}, {
"code" : "code",
"field" : "field",
"message" : "message"
} ],
"status" : 0
}
"""
expected_error = json.loads(error_body_json)
with self.assertRaises(
ApiException.exception_class_for_http_status(400)
) as context:
self.api.delete_dashboard(
dashboard_id=dashboard_id,
aid=aid,
_headers=self.te_headers("delete_dashboard", error_status="400"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_delete_dashboard_error_401(self) -> None:
"""Integration test for delete_dashboard error path (HTTP 401)"""
dashboard_id = '646f4d2ce3c99b0536c3821e'
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_dashboard(
dashboard_id=dashboard_id,
aid=aid,
_headers=self.te_headers("delete_dashboard", error_status="401"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_delete_dashboard_error_403(self) -> None:
"""Integration test for delete_dashboard error path (HTTP 403)"""
dashboard_id = '646f4d2ce3c99b0536c3821e'
aid = '1234'
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.delete_dashboard(
dashboard_id=dashboard_id,
aid=aid,
_headers=self.te_headers("delete_dashboard", error_status="403"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_delete_dashboard_error_404(self) -> None:
"""Integration test for delete_dashboard error path (HTTP 404)"""
dashboard_id = '646f4d2ce3c99b0536c3821e'
aid = '1234'
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(404)
) as context:
self.api.delete_dashboard(
dashboard_id=dashboard_id,
aid=aid,
_headers=self.te_headers("delete_dashboard", error_status="404"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_delete_dashboard_error_429(self) -> None:
"""Integration test for delete_dashboard error path (HTTP 429)"""
dashboard_id = '646f4d2ce3c99b0536c3821e'
aid = '1234'
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.delete_dashboard(
dashboard_id=dashboard_id,
aid=aid,
_headers=self.te_headers("delete_dashboard", error_status="429"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_delete_dashboard_error_500(self) -> None:
"""Integration test for delete_dashboard error path (HTTP 500)"""
dashboard_id = '646f4d2ce3c99b0536c3821e'
aid = '1234'
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.delete_dashboard(
dashboard_id=dashboard_id,
aid=aid,
_headers=self.te_headers("delete_dashboard", error_status="500"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_get_dashboard_happy_path(self) -> None:
"""Integration test for get_dashboard success path"""
dashboard_id = '646f4d2ce3c99b0536c3821e'
aid = '1234'
response_body_json = """
{
&quot;isMigratedReport&quot; : false,
&quot;dashboardCreatedBy&quot; : &quot;1&quot;,
&quot;_links&quot; : {
&quot;snapshots&quot; : {
&quot;hreflang&quot; : &quot;hreflang&quot;,
&quot;templated&quot; : true,
&quot;profile&quot; : &quot;profile&quot;,
&quot;name&quot; : &quot;name&quot;,
&quot;href&quot; : &quot;https://api.thousandeyes.com/v7/link/to/resource/id&quot;,
&quot;type&quot; : &quot;type&quot;,
&quot;deprecation&quot; : &quot;deprecation&quot;,
&quot;title&quot; : &quot;title&quot;
},
&quot;self&quot; : {
&quot;hreflang&quot; : &quot;hreflang&quot;,
&quot;templated&quot; : true,
&quot;profile&quot; : &quot;profile&quot;,
&quot;name&quot; : &quot;name&quot;,
&quot;href&quot; : &quot;https://api.thousandeyes.com/v7/link/to/resource/id&quot;,
&quot;type&quot; : &quot;type&quot;,
&quot;deprecation&quot; : &quot;deprecation&quot;,
&quot;title&quot; : &quot;title&quot;
}
},
&quot;isDefaultForUser&quot; : true,
&quot;description&quot; : &quot;HTTP Server Widgets&quot;,
&quot;isPrivate&quot; : true,
&quot;title&quot; : &quot;HTTP Server Widgets&quot;,
&quot;isBuiltIn&quot; : true,
&quot;widgets&quot; : [ {
&quot;embedUrl&quot; : &quot;https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f&quot;,
&quot;shouldExcludeAlertSuppressionWindows&quot; : true,
&quot;_links&quot; : {
&quot;self&quot; : {
&quot;hreflang&quot; : &quot;hreflang&quot;,
&quot;templated&quot; : true,
&quot;profile&quot; : &quot;profile&quot;,
&quot;name&quot; : &quot;name&quot;,
&quot;href&quot; : &quot;https://api.thousandeyes.com/v7/link/to/resource/id&quot;,
&quot;type&quot; : &quot;type&quot;,
&quot;deprecation&quot; : &quot;deprecation&quot;,
&quot;title&quot; : &quot;title&quot;
}
},
&quot;visualMode&quot; : &quot;Full&quot;,
&quot;filters&quot; : {
&quot;TEST&quot; : [ 5187, 5227 ],
&quot;ENDPOINT_MACHINE_ID&quot; : [ &quot;fbd0050c-07f7-43f7-9631-14b32f096962&quot; ]
},
&quot;title&quot; : &quot;Widget Title&quot;,
&quot;type&quot; : &quot;Agent Status&quot;,
&quot;metricGroup&quot; : &quot;BGP&quot;,
&quot;measure&quot; : {
&quot;percentileValue&quot; : 95,
&quot;type&quot; : &quot;MEAN&quot;
},
&quot;apiLink&quot; : &quot;apiLink&quot;,
&quot;metric&quot; : &quot;ENDPOINT_GATEWAY_CPU_LOAD_PERCENT&quot;,
&quot;isEmbedded&quot; : true,
&quot;id&quot; : &quot;1234&quot;,
&quot;fixedTimespan&quot; : {
&quot;unit&quot; : &quot;Days&quot;,
&quot;value&quot; : 10
},
&quot;dataSource&quot; : &quot;ENDPOINT_AGENTS&quot;,
&quot;direction&quot; : &quot;FROM_TARGET&quot;
}, {
&quot;embedUrl&quot; : &quot;https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f&quot;,
&quot;shouldExcludeAlertSuppressionWindows&quot; : true,
&quot;_links&quot; : {
&quot;self&quot; : {
&quot;hreflang&quot; : &quot;hreflang&quot;,
&quot;templated&quot; : true,
&quot;profile&quot; : &quot;profile&quot;,
&quot;name&quot; : &quot;name&quot;,
&quot;href&quot; : &quot;https://api.thousandeyes.com/v7/link/to/resource/id&quot;,
&quot;type&quot; : &quot;type&quot;,
&quot;deprecation&quot; : &quot;deprecation&quot;,
&quot;title&quot; : &quot;title&quot;
}
},
&quot;visualMode&quot; : &quot;Full&quot;,
&quot;filters&quot; : {
&quot;TEST&quot; : [ 5187, 5227 ],
&quot;ENDPOINT_MACHINE_ID&quot; : [ &quot;fbd0050c-07f7-43f7-9631-14b32f096962&quot; ]
},
&quot;title&quot; : &quot;Widget Title&quot;,
&quot;type&quot; : &quot;Agent Status&quot;,
&quot;metricGroup&quot; : &quot;BGP&quot;,
&quot;measure&quot; : {
&quot;percentileValue&quot; : 95,
&quot;type&quot; : &quot;MEAN&quot;
},
&quot;apiLink&quot; : &quot;apiLink&quot;,
&quot;metric&quot; : &quot;ENDPOINT_GATEWAY_CPU_LOAD_PERCENT&quot;,
&quot;isEmbedded&quot; : true,
&quot;id&quot; : &quot;1234&quot;,
&quot;fixedTimespan&quot; : {
&quot;unit&quot; : &quot;Days&quot;,
&quot;value&quot; : 10
},
&quot;dataSource&quot; : &quot;ENDPOINT_AGENTS&quot;,
&quot;direction&quot; : &quot;FROM_TARGET&quot;
} ],
&quot;globalFilterId&quot; : &quot;65babd9bb90bf55b17c96c8d&quot;,
&quot;modifiedBy&quot; : 1,
&quot;dashboardModifiedBy&quot; : &quot;1&quot;,
&quot;migratedReport&quot; : false,
&quot;isDefaultForAccount&quot; : false,
&quot;defaultTimespan&quot; : {
&quot;duration&quot; : 7200,
&quot;timespanDuration&quot; : 7200,
&quot;start&quot; : &quot;2023-05-16T10:14:28Z&quot;,
&quot;end&quot; : &quot;2023-05-16T11:14:28Z&quot;,
&quot;timespanStart&quot; : &quot;2023-05-16 10:14:28&quot;,
&quot;timespanEnd&quot; : &quot;2023-05-16 11:14:28&quot;
},
&quot;layout&quot; : {
&quot;layoutId&quot; : &quot;grid-layout-1&quot;,
&quot;type&quot; : &quot;grid&quot;,
&quot;details&quot; : {
&quot;widgetPositioning&quot; : [ {
&quot;x&quot; : 0,
&quot;y&quot; : 0,
&quot;w&quot; : 9,
&quot;h&quot; : 5,
&quot;id&quot; : &quot;widgetId-71lbb&quot;
} ]
}
},
&quot;accountId&quot; : 1234,
&quot;apiLink&quot; : [ {
&quot;key&quot; : &quot;&quot;
}, {
&quot;key&quot; : &quot;&quot;
} ],
&quot;dashboardId&quot; : &quot;5e1f7a99143ae6004fdc3bb4&quot;,
&quot;createdBy&quot; : 1,
&quot;globalOverride&quot; : true,
&quot;modifiedDate&quot; : &quot;2023-05-16 10:14:28&quot;,
&quot;isGlobalOverride&quot; : true,
&quot;aid&quot; : &quot;1234&quot;,
&quot;dashboardModifiedDate&quot; : &quot;2023-05-16T10:14:28Z&quot;
}
"""
expected_response = json.loads(response_body_json)
response = self.api.get_dashboard(
dashboard_id=dashboard_id,
aid=aid,
_headers=self.te_headers("get_dashboard"),
)
assert_constructed_model_matches_example_json(response, expected_response)
def test_get_dashboard_error_400(self) -> None:
"""Integration test for get_dashboard error path (HTTP 400)"""
dashboard_id = '646f4d2ce3c99b0536c3821e'
aid = '1234'
error_body_json = """
{
"instance" : "instance",
"detail" : "detail",
"type" : "type",
"title" : "title",
"errors" : [ {
"code" : "code",
"field" : "field",
"message" : "message"
}, {
"code" : "code",
"field" : "field",
"message" : "message"
} ],
"status" : 0
}
"""
expected_error = json.loads(error_body_json)
with self.assertRaises(
ApiException.exception_class_for_http_status(400)
) as context:
self.api.get_dashboard(
dashboard_id=dashboard_id,
aid=aid,
_headers=self.te_headers("get_dashboard", error_status="400"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_get_dashboard_error_401(self) -> None:
"""Integration test for get_dashboard error path (HTTP 401)"""
dashboard_id = '646f4d2ce3c99b0536c3821e'
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_dashboard(
dashboard_id=dashboard_id,
aid=aid,
_headers=self.te_headers("get_dashboard", error_status="401"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_get_dashboard_error_403(self) -> None:
"""Integration test for get_dashboard error path (HTTP 403)"""
dashboard_id = '646f4d2ce3c99b0536c3821e'
aid = '1234'
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_dashboard(
dashboard_id=dashboard_id,
aid=aid,
_headers=self.te_headers("get_dashboard", error_status="403"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_get_dashboard_error_404(self) -> None:
"""Integration test for get_dashboard error path (HTTP 404)"""
dashboard_id = '646f4d2ce3c99b0536c3821e'
aid = '1234'
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(404)
) as context:
self.api.get_dashboard(
dashboard_id=dashboard_id,
aid=aid,
_headers=self.te_headers("get_dashboard", error_status="404"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_get_dashboard_error_429(self) -> None:
"""Integration test for get_dashboard error path (HTTP 429)"""
dashboard_id = '646f4d2ce3c99b0536c3821e'
aid = '1234'
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_dashboard(
dashboard_id=dashboard_id,
aid=aid,
_headers=self.te_headers("get_dashboard", error_status="429"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_get_dashboard_error_500(self) -> None:
"""Integration test for get_dashboard error path (HTTP 500)"""
dashboard_id = '646f4d2ce3c99b0536c3821e'
aid = '1234'
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_dashboard(
dashboard_id=dashboard_id,
aid=aid,
_headers=self.te_headers("get_dashboard", error_status="500"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_get_dashboard_widget_data_happy_path(self) -> None:
"""Integration test for get_dashboard_widget_data success path"""
dashboard_id = '646f4d2ce3c99b0536c3821e'
widget_id = 'unpmg'
aid = '1234'
window = '12h'
start_date = '2022-07-17T22:00:54Z'
end_date = '2022-07-18T22:00:54Z'
max = 10
cursor = 'bGFzdFJvdW5kSWQ9MTY4MTQxMDQ4MA'
sort = 'alertStatus'
order = thousandeyes_sdk.dashboards.DashboardOrder()
response_body_json = """
{
&quot;groupLabels&quot; : [ {
&quot;groupProperty&quot; : &quot;AGENT&quot;,
&quot;groupLabels&quot; : [ {
&quot;groupId&quot; : &quot;2565&quot;,
&quot;groupLabel&quot; : &quot;San Francisco, CA&quot;
}, {
&quot;groupId&quot; : &quot;2565&quot;,
&quot;groupLabel&quot; : &quot;San Francisco, CA&quot;
} ]
}, {
&quot;groupProperty&quot; : &quot;AGENT&quot;,
&quot;groupLabels&quot; : [ {
&quot;groupId&quot; : &quot;2565&quot;,
&quot;groupLabel&quot; : &quot;San Francisco, CA&quot;
}, {
&quot;groupId&quot; : &quot;2565&quot;,
&quot;groupLabel&quot; : &quot;San Francisco, CA&quot;
} ]
} ],
&quot;data&quot; : {
&quot;alerts&quot; : [ {
&quot;alertType&quot; : &quot;network-end-to-end-server&quot;,
&quot;durationInSeconds&quot; : 25,
&quot;alertSource&quot; : &quot;Http Test&quot;,
&quot;active&quot; : true,
&quot;testId&quot; : &quot;56512&quot;,
&quot;startTime&quot; : &quot;2023-06-02T08:54:00Z&quot;,
&quot;alertId&quot; : &quot;2004945&quot;,
&quot;ruleId&quot; : &quot;281724&quot;,
&quot;alertRule&quot; : &quot;Http Test Rule&quot;
}, {
&quot;alertType&quot; : &quot;network-end-to-end-server&quot;,
&quot;durationInSeconds&quot; : 25,
&quot;alertSource&quot; : &quot;Http Test&quot;,
&quot;active&quot; : true,
&quot;testId&quot; : &quot;56512&quot;,
&quot;startTime&quot; : &quot;2023-06-02T08:54:00Z&quot;,
&quot;alertId&quot; : &quot;2004945&quot;,
&quot;ruleId&quot; : &quot;281724&quot;,
&quot;alertRule&quot; : &quot;Http Test Rule&quot;
} ],
&quot;summary&quot; : {
&quot;offline&quot; : 2,
&quot;online&quot; : 10,
&quot;disabled&quot; : 3
},
&quot;totalAlerts&quot; : 500,
&quot;cards&quot; : [ {
&quot;numberOfDataPoints&quot; : 24192,
&quot;cardName&quot; : &quot;Card Name&quot;,
&quot;endDate&quot; : &quot;2023-05-16T10:14:28Z&quot;,
&quot;_links&quot; : {
&quot;self&quot; : {
&quot;hreflang&quot; : &quot;hreflang&quot;,
&quot;templated&quot; : true,
&quot;profile&quot; : &quot;profile&quot;,
&quot;name&quot; : &quot;name&quot;,
&quot;href&quot; : &quot;https://api.thousandeyes.com/v7/link/to/resource/id&quot;,
&quot;type&quot; : &quot;type&quot;,
&quot;deprecation&quot; : &quot;deprecation&quot;,
&quot;title&quot; : &quot;title&quot;
}
},
&quot;cardId&quot; : &quot;lrxxr&quot;,
&quot;alertSuppressionWindows&quot; : [ {
&quot;testIds&quot; : [ &quot;281474976710661&quot; ],
&quot;repeatUnit&quot; : &quot;week&quot;,
&quot;durationInSeconds&quot; : 7200,
&quot;repeat&quot; : &quot;custom&quot;,
&quot;name&quot; : &quot;Test dashboards&quot;,
&quot;repeatEvery&quot; : 5,
&quot;id&quot; : &quot;281474976710662&quot;,
&quot;startTimes&quot; : [ &quot;2023-05-16T10:14:28Z&quot; ]
}, {
&quot;testIds&quot; : [ &quot;281474976710661&quot; ],
&quot;repeatUnit&quot; : &quot;week&quot;,
&quot;durationInSeconds&quot; : 7200,
&quot;repeat&quot; : &quot;custom&quot;,
&quot;name&quot; : &quot;Test dashboards&quot;,
&quot;repeatEvery&quot; : 5,
&quot;id&quot; : &quot;281474976710662&quot;,
&quot;startTimes&quot; : [ &quot;2023-05-16T10:14:28Z&quot; ]
} ],
&quot;binSize&quot; : 3600,
&quot;previousValue&quot; : 500,
&quot;value&quot; : 100,
&quot;startDate&quot; : &quot;2023-05-16T10:14:28Z&quot;,
&quot;timestamp&quot; : 1567620000,
&quot;status&quot; : &quot;No data&quot;
}, {
&quot;numberOfDataPoints&quot; : 24192,
&quot;cardName&quot; : &quot;Card Name&quot;,
&quot;endDate&quot; : &quot;2023-05-16T10:14:28Z&quot;,
&quot;_links&quot; : {
&quot;self&quot; : {
&quot;hreflang&quot; : &quot;hreflang&quot;,
&quot;templated&quot; : true,
&quot;profile&quot; : &quot;profile&quot;,
&quot;name&quot; : &quot;name&quot;,
&quot;href&quot; : &quot;https://api.thousandeyes.com/v7/link/to/resource/id&quot;,
&quot;type&quot; : &quot;type&quot;,
&quot;deprecation&quot; : &quot;deprecation&quot;,
&quot;title&quot; : &quot;title&quot;
}
},
&quot;cardId&quot; : &quot;lrxxr&quot;,
&quot;alertSuppressionWindows&quot; : [ {
&quot;testIds&quot; : [ &quot;281474976710661&quot; ],
&quot;repeatUnit&quot; : &quot;week&quot;,
&quot;durationInSeconds&quot; : 7200,
&quot;repeat&quot; : &quot;custom&quot;,
&quot;name&quot; : &quot;Test dashboards&quot;,
&quot;repeatEvery&quot; : 5,
&quot;id&quot; : &quot;281474976710662&quot;,
&quot;startTimes&quot; : [ &quot;2023-05-16T10:14:28Z&quot; ]
}, {
&quot;testIds&quot; : [ &quot;281474976710661&quot; ],
&quot;repeatUnit&quot; : &quot;week&quot;,
&quot;durationInSeconds&quot; : 7200,
&quot;repeat&quot; : &quot;custom&quot;,
&quot;name&quot; : &quot;Test dashboards&quot;,
&quot;repeatEvery&quot; : 5,
&quot;id&quot; : &quot;281474976710662&quot;,
&quot;startTimes&quot; : [ &quot;2023-05-16T10:14:28Z&quot; ]
} ],
&quot;binSize&quot; : 3600,
&quot;previousValue&quot; : 500,
&quot;value&quot; : 100,
&quot;startDate&quot; : &quot;2023-05-16T10:14:28Z&quot;,
&quot;timestamp&quot; : 1567620000,
&quot;status&quot; : &quot;No data&quot;
} ],
&quot;tests&quot; : [ {
&quot;graphlets&quot; : [ {
&quot;metric&quot; : &quot;Availability&quot;,
&quot;testId&quot; : &quot;68257&quot;,
&quot;points&quot; : [ {
&quot;x&quot; : 1580403900,
&quot;y&quot; : 128.249
}, {
&quot;x&quot; : 1580403900,
&quot;y&quot; : 128.249
} ]
}, {
&quot;metric&quot; : &quot;Availability&quot;,
&quot;testId&quot; : &quot;68257&quot;,
&quot;points&quot; : [ {
&quot;x&quot; : 1580403900,
&quot;y&quot; : 128.249
}, {
&quot;x&quot; : 1580403900,
&quot;y&quot; : 128.249
} ]
} ],
&quot;alertCount&quot; : 398,
&quot;testType&quot; : &quot;Web - HTTP Server&quot;,
&quot;testId&quot; : &quot;68256&quot;,
&quot;isShared&quot; : true,
&quot;testName&quot; : &quot;Http Test Name&quot;,
&quot;target&quot; : &quot;www.google.com&quot;
}, {
&quot;graphlets&quot; : [ {
&quot;metric&quot; : &quot;Availability&quot;,
&quot;testId&quot; : &quot;68257&quot;,
&quot;points&quot; : [ {
&quot;x&quot; : 1580403900,
&quot;y&quot; : 128.249
}, {
&quot;x&quot; : 1580403900,
&quot;y&quot; : 128.249
} ]
}, {
&quot;metric&quot; : &quot;Availability&quot;,
&quot;testId&quot; : &quot;68257&quot;,
&quot;points&quot; : [ {
&quot;x&quot; : 1580403900,
&quot;y&quot; : 128.249
}, {
&quot;x&quot; : 1580403900,
&quot;y&quot; : 128.249
} ]
} ],
&quot;alertCount&quot; : 398,
&quot;testType&quot; : &quot;Web - HTTP Server&quot;,
&quot;testId&quot; : &quot;68256&quot;,
&quot;isShared&quot; : true,
&quot;testName&quot; : &quot;Http Test Name&quot;,
&quot;target&quot; : &quot;www.google.com&quot;
} ],
&quot;columns&quot; : [ {
&quot;_links&quot; : {
&quot;self&quot; : {
&quot;hreflang&quot; : &quot;hreflang&quot;,
&quot;templated&quot; : true,
&quot;profile&quot; : &quot;profile&quot;,
&quot;name&quot; : &quot;name&quot;,
&quot;href&quot; : &quot;https://api.thousandeyes.com/v7/link/to/resource/id&quot;,
&quot;type&quot; : &quot;type&quot;,
&quot;deprecation&quot; : &quot;deprecation&quot;,
&quot;title&quot; : &quot;title&quot;
}
},
&quot;columnId&quot; : &quot;938to&quot;,
&quot;alertSuppressionWindows&quot; : [ {
&quot;testIds&quot; : [ &quot;281474976710661&quot; ],
&quot;repeatUnit&quot; : &quot;week&quot;,
&quot;durationInSeconds&quot; : 7200,
&quot;repeat&quot; : &quot;custom&quot;,
&quot;name&quot; : &quot;Test dashboards&quot;,
&quot;repeatEvery&quot; : 5,
&quot;id&quot; : &quot;281474976710662&quot;,
&quot;startTimes&quot; : [ &quot;2023-05-16T10:14:28Z&quot; ]
}, {
&quot;testIds&quot; : [ &quot;281474976710661&quot; ],
&quot;repeatUnit&quot; : &quot;week&quot;,
&quot;durationInSeconds&quot; : 7200,
&quot;repeat&quot; : &quot;custom&quot;,
&quot;name&quot; : &quot;Test dashboards&quot;,
&quot;repeatEvery&quot; : 5,
&quot;id&quot; : &quot;281474976710662&quot;,
&quot;startTimes&quot; : [ &quot;2023-05-16T10:14:28Z&quot; ]
} ],
&quot;binSize&quot; : 3600,
&quot;points&quot; : [ {
&quot;numberOfDataPoints&quot; : 23304,
&quot;groups&quot; : [ {
&quot;groupProperty&quot; : &quot;COUNTRY&quot;,
&quot;groupValue&quot; : &quot;US&quot;
}, {
&quot;groupProperty&quot; : &quot;COUNTRY&quot;,
&quot;groupValue&quot; : &quot;US&quot;
} ],
&quot;value&quot; : 100,
&quot;timestamp&quot; : 1567620000
}, {
&quot;numberOfDataPoints&quot; : 23304,
&quot;groups&quot; : [ {
&quot;groupProperty&quot; : &quot;COUNTRY&quot;,
&quot;groupValue&quot; : &quot;US&quot;
}, {
&quot;groupProperty&quot; : &quot;COUNTRY&quot;,
&quot;groupValue&quot; : &quot;US&quot;
} ],
&quot;value&quot; : 100,
&quot;timestamp&quot; : 1567620000
} ],
&quot;status&quot; : &quot;No data&quot;
}, {
&quot;_links&quot; : {
&quot;self&quot; : {
&quot;hreflang&quot; : &quot;hreflang&quot;,
&quot;templated&quot; : true,
&quot;profile&quot; : &quot;profile&quot;,
&quot;name&quot; : &quot;name&quot;,
&quot;href&quot; : &quot;https://api.thousandeyes.com/v7/link/to/resource/id&quot;,
&quot;type&quot; : &quot;type&quot;,
&quot;deprecation&quot; : &quot;deprecation&quot;,
&quot;title&quot; : &quot;title&quot;
}
},
&quot;columnId&quot; : &quot;938to&quot;,
&quot;alertSuppressionWindows&quot; : [ {
&quot;testIds&quot; : [ &quot;281474976710661&quot; ],
&quot;repeatUnit&quot; : &quot;week&quot;,
&quot;durationInSeconds&quot; : 7200,
&quot;repeat&quot; : &quot;custom&quot;,
&quot;name&quot; : &quot;Test dashboards&quot;,
&quot;repeatEvery&quot; : 5,
&quot;id&quot; : &quot;281474976710662&quot;,
&quot;startTimes&quot; : [ &quot;2023-05-16T10:14:28Z&quot; ]
}, {
&quot;testIds&quot; : [ &quot;281474976710661&quot; ],
&quot;repeatUnit&quot; : &quot;week&quot;,
&quot;durationInSeconds&quot; : 7200,
&quot;repeat&quot; : &quot;custom&quot;,
&quot;name&quot; : &quot;Test dashboards&quot;,
&quot;repeatEvery&quot; : 5,
&quot;id&quot; : &quot;281474976710662&quot;,
&quot;startTimes&quot; : [ &quot;2023-05-16T10:14:28Z&quot; ]
} ],
&quot;binSize&quot; : 3600,
&quot;points&quot; : [ {
&quot;numberOfDataPoints&quot; : 23304,
&quot;groups&quot; : [ {
&quot;groupProperty&quot; : &quot;COUNTRY&quot;,
&quot;groupValue&quot; : &quot;US&quot;
}, {
&quot;groupProperty&quot; : &quot;COUNTRY&quot;,
&quot;groupValue&quot; : &quot;US&quot;
} ],
&quot;value&quot; : 100,
&quot;timestamp&quot; : 1567620000
}, {
&quot;numberOfDataPoints&quot; : 23304,
&quot;groups&quot; : [ {
&quot;groupProperty&quot; : &quot;COUNTRY&quot;,
&quot;groupValue&quot; : &quot;US&quot;
}, {
&quot;groupProperty&quot; : &quot;COUNTRY&quot;,
&quot;groupValue&quot; : &quot;US&quot;
} ],
&quot;value&quot; : 100,
&quot;timestamp&quot; : 1567620000
} ],
&quot;status&quot; : &quot;No data&quot;
} ],
&quot;alertSuppressionWindows&quot; : [ {
&quot;testIds&quot; : [ &quot;281474976710661&quot; ],
&quot;repeatUnit&quot; : &quot;week&quot;,
&quot;durationInSeconds&quot; : 7200,
&quot;repeat&quot; : &quot;custom&quot;,
&quot;name&quot; : &quot;Test dashboards&quot;,
&quot;repeatEvery&quot; : 5,
&quot;id&quot; : &quot;281474976710662&quot;,
&quot;startTimes&quot; : [ &quot;2023-05-16T10:14:28Z&quot; ]
}, {
&quot;testIds&quot; : [ &quot;281474976710661&quot; ],
&quot;repeatUnit&quot; : &quot;week&quot;,
&quot;durationInSeconds&quot; : 7200,
&quot;repeat&quot; : &quot;custom&quot;,
&quot;name&quot; : &quot;Test dashboards&quot;,
&quot;repeatEvery&quot; : 5,
&quot;id&quot; : &quot;281474976710662&quot;,
&quot;startTimes&quot; : [ &quot;2023-05-16T10:14:28Z&quot; ]
} ],
&quot;activeAlerts&quot; : 483,
&quot;startRound&quot; : 1384309800,
&quot;points&quot; : [ {
&quot;numberOfDataPoints&quot; : 23304,
&quot;groups&quot; : [ {
&quot;groupProperty&quot; : &quot;COUNTRY&quot;,
&quot;groupValue&quot; : &quot;US&quot;
}, {
&quot;groupProperty&quot; : &quot;COUNTRY&quot;,
&quot;groupValue&quot; : &quot;US&quot;
} ],
&quot;value&quot; : 100,
&quot;timestamp&quot; : 1567620000
}, {
&quot;numberOfDataPoints&quot; : 23304,
&quot;groups&quot; : [ {
&quot;groupProperty&quot; : &quot;COUNTRY&quot;,
&quot;groupValue&quot; : &quot;US&quot;
}, {
&quot;groupProperty&quot; : &quot;COUNTRY&quot;,
&quot;groupValue&quot; : &quot;US&quot;
} ],
&quot;value&quot; : 100,
&quot;timestamp&quot; : 1567620000
} ],
&quot;agents&quot; : [ {
&quot;agentId&quot; : &quot;6522&quot;,
&quot;agentName&quot; : &quot;0c3898000117&quot;,
&quot;location&quot; : {
&quot;locationName&quot; : &quot;San Francisco, California, US&quot;,
&quot;latitude&quot; : 37.77493,
&quot;longitude&quot; : -122.41942
},
&quot;ipInfo&quot; : {
&quot;ipv6&quot; : &quot;ipv6&quot;,
&quot;privateIp&quot; : &quot;172.58.92.31&quot;,
&quot;operativeSystemVersion&quot; : &quot;operativeSystemVersion&quot;,
&quot;publicIp&quot; : &quot;172.58.92.31&quot;
},
&quot;status&quot; : &quot;online&quot;
}, {
&quot;agentId&quot; : &quot;6522&quot;,
&quot;agentName&quot; : &quot;0c3898000117&quot;,
&quot;location&quot; : {
&quot;locationName&quot; : &quot;San Francisco, California, US&quot;,
&quot;latitude&quot; : 37.77493,
&quot;longitude&quot; : -122.41942
},
&quot;ipInfo&quot; : {
&quot;ipv6&quot; : &quot;ipv6&quot;,
&quot;privateIp&quot; : &quot;172.58.92.31&quot;,
&quot;operativeSystemVersion&quot; : &quot;operativeSystemVersion&quot;,
&quot;publicIp&quot; : &quot;172.58.92.31&quot;
},
&quot;status&quot; : &quot;online&quot;
} ],
&quot;status&quot; : &quot;No data&quot;
},
&quot;endDate&quot; : &quot;2022-07-18T22:00:54Z&quot;,
&quot;_links&quot; : {
&quot;next&quot; : {
&quot;hreflang&quot; : &quot;hreflang&quot;,
&quot;templated&quot; : true,
&quot;profile&quot; : &quot;profile&quot;,
&quot;name&quot; : &quot;name&quot;,
&quot;href&quot; : &quot;https://api.thousandeyes.com/v7/link/to/resource/id&quot;,
&quot;type&quot; : &quot;type&quot;,
&quot;deprecation&quot; : &quot;deprecation&quot;,
&quot;title&quot; : &quot;title&quot;
},
&quot;previous&quot; : {
&quot;hreflang&quot; : &quot;hreflang&quot;,
&quot;templated&quot; : true,
&quot;profile&quot; : &quot;profile&quot;,
&quot;name&quot; : &quot;name&quot;,
&quot;href&quot; : &quot;https://api.thousandeyes.com/v7/link/to/resource/id&quot;,
&quot;type&quot; : &quot;type&quot;,
&quot;deprecation&quot; : &quot;deprecation&quot;,
&quot;title&quot; : &quot;title&quot;
},
&quot;self&quot; : {
&quot;hreflang&quot; : &quot;hreflang&quot;,
&quot;templated&quot; : true,
&quot;profile&quot; : &quot;profile&quot;,
&quot;name&quot; : &quot;name&quot;,
&quot;href&quot; : &quot;https://api.thousandeyes.com/v7/link/to/resource/id&quot;,
&quot;type&quot; : &quot;type&quot;,
&quot;deprecation&quot; : &quot;deprecation&quot;,
&quot;title&quot; : &quot;title&quot;
}
},
&quot;binSize&quot; : 3600,
&quot;startDate&quot; : &quot;2022-07-17T22:00:54Z&quot;
}
"""
expected_response = json.loads(response_body_json)
response = self.api.get_dashboard_widget_data(
dashboard_id=dashboard_id,
widget_id=widget_id,
aid=aid,
window=window,
start_date=start_date,
end_date=end_date,
max=max,
cursor=cursor,
sort=sort,
order=order,
_headers=self.te_headers("get_dashboard_widget_data"),
)
assert_constructed_model_matches_example_json(response, expected_response)
def test_get_dashboard_widget_data_error_400(self) -> None:
"""Integration test for get_dashboard_widget_data error path (HTTP 400)"""
dashboard_id = '646f4d2ce3c99b0536c3821e'
widget_id = 'unpmg'
aid = '1234'
window = '12h'
start_date = '2022-07-17T22:00:54Z'
end_date = '2022-07-18T22:00:54Z'
max = 10
cursor = 'bGFzdFJvdW5kSWQ9MTY4MTQxMDQ4MA'
sort = 'alertStatus'
order = thousandeyes_sdk.dashboards.DashboardOrder()
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_dashboard_widget_data(
dashboard_id=dashboard_id,
widget_id=widget_id,
aid=aid,
window=window,
start_date=start_date,
end_date=end_date,
max=max,
cursor=cursor,
sort=sort,
order=order,
_headers=self.te_headers("get_dashboard_widget_data", error_status="400"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_get_dashboard_widget_data_error_401(self) -> None:
"""Integration test for get_dashboard_widget_data error path (HTTP 401)"""
dashboard_id = '646f4d2ce3c99b0536c3821e'
widget_id = 'unpmg'
aid = '1234'
window = '12h'
start_date = '2022-07-17T22:00:54Z'
end_date = '2022-07-18T22:00:54Z'
max = 10
cursor = 'bGFzdFJvdW5kSWQ9MTY4MTQxMDQ4MA'
sort = 'alertStatus'
order = thousandeyes_sdk.dashboards.DashboardOrder()
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_dashboard_widget_data(
dashboard_id=dashboard_id,
widget_id=widget_id,
aid=aid,
window=window,
start_date=start_date,
end_date=end_date,
max=max,
cursor=cursor,
sort=sort,
order=order,
_headers=self.te_headers("get_dashboard_widget_data", error_status="401"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_get_dashboard_widget_data_error_403(self) -> None:
"""Integration test for get_dashboard_widget_data error path (HTTP 403)"""
dashboard_id = '646f4d2ce3c99b0536c3821e'
widget_id = 'unpmg'
aid = '1234'
window = '12h'
start_date = '2022-07-17T22:00:54Z'
end_date = '2022-07-18T22:00:54Z'
max = 10
cursor = 'bGFzdFJvdW5kSWQ9MTY4MTQxMDQ4MA'
sort = 'alertStatus'
order = thousandeyes_sdk.dashboards.DashboardOrder()
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_dashboard_widget_data(
dashboard_id=dashboard_id,
widget_id=widget_id,
aid=aid,
window=window,
start_date=start_date,
end_date=end_date,
max=max,
cursor=cursor,
sort=sort,
order=order,
_headers=self.te_headers("get_dashboard_widget_data", error_status="403"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_get_dashboard_widget_data_error_404(self) -> None:
"""Integration test for get_dashboard_widget_data error path (HTTP 404)"""
dashboard_id = '646f4d2ce3c99b0536c3821e'
widget_id = 'unpmg'
aid = '1234'
window = '12h'
start_date = '2022-07-17T22:00:54Z'
end_date = '2022-07-18T22:00:54Z'
max = 10
cursor = 'bGFzdFJvdW5kSWQ9MTY4MTQxMDQ4MA'
sort = 'alertStatus'
order = thousandeyes_sdk.dashboards.DashboardOrder()
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(404)
) as context:
self.api.get_dashboard_widget_data(
dashboard_id=dashboard_id,
widget_id=widget_id,
aid=aid,
window=window,
start_date=start_date,
end_date=end_date,
max=max,
cursor=cursor,
sort=sort,
order=order,
_headers=self.te_headers("get_dashboard_widget_data", error_status="404"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_get_dashboard_widget_data_error_429(self) -> None:
"""Integration test for get_dashboard_widget_data error path (HTTP 429)"""
dashboard_id = '646f4d2ce3c99b0536c3821e'
widget_id = 'unpmg'
aid = '1234'
window = '12h'
start_date = '2022-07-17T22:00:54Z'
end_date = '2022-07-18T22:00:54Z'
max = 10
cursor = 'bGFzdFJvdW5kSWQ9MTY4MTQxMDQ4MA'
sort = 'alertStatus'
order = thousandeyes_sdk.dashboards.DashboardOrder()
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_dashboard_widget_data(
dashboard_id=dashboard_id,
widget_id=widget_id,
aid=aid,
window=window,
start_date=start_date,
end_date=end_date,
max=max,
cursor=cursor,
sort=sort,
order=order,
_headers=self.te_headers("get_dashboard_widget_data", error_status="429"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_get_dashboard_widget_data_error_500(self) -> None:
"""Integration test for get_dashboard_widget_data error path (HTTP 500)"""
dashboard_id = '646f4d2ce3c99b0536c3821e'
widget_id = 'unpmg'
aid = '1234'
window = '12h'
start_date = '2022-07-17T22:00:54Z'
end_date = '2022-07-18T22:00:54Z'
max = 10
cursor = 'bGFzdFJvdW5kSWQ9MTY4MTQxMDQ4MA'
sort = 'alertStatus'
order = thousandeyes_sdk.dashboards.DashboardOrder()
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_dashboard_widget_data(
dashboard_id=dashboard_id,
widget_id=widget_id,
aid=aid,
window=window,
start_date=start_date,
end_date=end_date,
max=max,
cursor=cursor,
sort=sort,
order=order,
_headers=self.te_headers("get_dashboard_widget_data", error_status="500"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_get_dashboards_happy_path(self) -> None:
"""Integration test for get_dashboards success path"""
aid = '1234'
response_body_json = """
[ {
&quot;isMigratedReport&quot; : false,
&quot;dashboardCreatedBy&quot; : &quot;1&quot;,
&quot;_links&quot; : {
&quot;snapshots&quot; : {
&quot;hreflang&quot; : &quot;hreflang&quot;,
&quot;templated&quot; : true,
&quot;profile&quot; : &quot;profile&quot;,
&quot;name&quot; : &quot;name&quot;,
&quot;href&quot; : &quot;https://api.thousandeyes.com/v7/link/to/resource/id&quot;,
&quot;type&quot; : &quot;type&quot;,
&quot;deprecation&quot; : &quot;deprecation&quot;,
&quot;title&quot; : &quot;title&quot;
},
&quot;self&quot; : {
&quot;hreflang&quot; : &quot;hreflang&quot;,
&quot;templated&quot; : true,
&quot;profile&quot; : &quot;profile&quot;,
&quot;name&quot; : &quot;name&quot;,
&quot;href&quot; : &quot;https://api.thousandeyes.com/v7/link/to/resource/id&quot;,
&quot;type&quot; : &quot;type&quot;,
&quot;deprecation&quot; : &quot;deprecation&quot;,
&quot;title&quot; : &quot;title&quot;
}
},
&quot;isDefaultForUser&quot; : true,
&quot;description&quot; : &quot;HTTP Server Widgets&quot;,
&quot;isPrivate&quot; : true,
&quot;title&quot; : &quot;HTTP Server Widgets&quot;,
&quot;isBuiltIn&quot; : true,
&quot;widgets&quot; : [ {
&quot;embedUrl&quot; : &quot;https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f&quot;,
&quot;shouldExcludeAlertSuppressionWindows&quot; : true,
&quot;_links&quot; : {
&quot;self&quot; : {
&quot;hreflang&quot; : &quot;hreflang&quot;,
&quot;templated&quot; : true,
&quot;profile&quot; : &quot;profile&quot;,
&quot;name&quot; : &quot;name&quot;,
&quot;href&quot; : &quot;https://api.thousandeyes.com/v7/link/to/resource/id&quot;,
&quot;type&quot; : &quot;type&quot;,
&quot;deprecation&quot; : &quot;deprecation&quot;,
&quot;title&quot; : &quot;title&quot;
}
},
&quot;visualMode&quot; : &quot;Full&quot;,
&quot;filters&quot; : {
&quot;TEST&quot; : [ 5187, 5227 ],
&quot;ENDPOINT_MACHINE_ID&quot; : [ &quot;fbd0050c-07f7-43f7-9631-14b32f096962&quot; ]
},
&quot;title&quot; : &quot;Widget Title&quot;,
&quot;type&quot; : &quot;Agent Status&quot;,
&quot;metricGroup&quot; : &quot;BGP&quot;,
&quot;measure&quot; : {
&quot;percentileValue&quot; : 95,
&quot;type&quot; : &quot;MEAN&quot;
},
&quot;apiLink&quot; : &quot;apiLink&quot;,
&quot;metric&quot; : &quot;ENDPOINT_GATEWAY_CPU_LOAD_PERCENT&quot;,
&quot;isEmbedded&quot; : true,
&quot;id&quot; : &quot;1234&quot;,
&quot;fixedTimespan&quot; : {
&quot;unit&quot; : &quot;Days&quot;,
&quot;value&quot; : 10
},
&quot;dataSource&quot; : &quot;ENDPOINT_AGENTS&quot;,
&quot;direction&quot; : &quot;FROM_TARGET&quot;
}, {
&quot;embedUrl&quot; : &quot;https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f&quot;,
&quot;shouldExcludeAlertSuppressionWindows&quot; : true,
&quot;_links&quot; : {
&quot;self&quot; : {
&quot;hreflang&quot; : &quot;hreflang&quot;,
&quot;templated&quot; : true,
&quot;profile&quot; : &quot;profile&quot;,
&quot;name&quot; : &quot;name&quot;,
&quot;href&quot; : &quot;https://api.thousandeyes.com/v7/link/to/resource/id&quot;,
&quot;type&quot; : &quot;type&quot;,
&quot;deprecation&quot; : &quot;deprecation&quot;,
&quot;title&quot; : &quot;title&quot;
}
},
&quot;visualMode&quot; : &quot;Full&quot;,
&quot;filters&quot; : {
&quot;TEST&quot; : [ 5187, 5227 ],
&quot;ENDPOINT_MACHINE_ID&quot; : [ &quot;fbd0050c-07f7-43f7-9631-14b32f096962&quot; ]
},
&quot;title&quot; : &quot;Widget Title&quot;,
&quot;type&quot; : &quot;Agent Status&quot;,
&quot;metricGroup&quot; : &quot;BGP&quot;,
&quot;measure&quot; : {
&quot;percentileValue&quot; : 95,
&quot;type&quot; : &quot;MEAN&quot;
},
&quot;apiLink&quot; : &quot;apiLink&quot;,
&quot;metric&quot; : &quot;ENDPOINT_GATEWAY_CPU_LOAD_PERCENT&quot;,
&quot;isEmbedded&quot; : true,
&quot;id&quot; : &quot;1234&quot;,
&quot;fixedTimespan&quot; : {
&quot;unit&quot; : &quot;Days&quot;,
&quot;value&quot; : 10
},
&quot;dataSource&quot; : &quot;ENDPOINT_AGENTS&quot;,
&quot;direction&quot; : &quot;FROM_TARGET&quot;
} ],
&quot;globalFilterId&quot; : &quot;65babd9bb90bf55b17c96c8d&quot;,
&quot;modifiedBy&quot; : 1,
&quot;dashboardModifiedBy&quot; : &quot;1&quot;,
&quot;migratedReport&quot; : false,
&quot;isDefaultForAccount&quot; : false,
&quot;defaultTimespan&quot; : {
&quot;duration&quot; : 7200,
&quot;timespanDuration&quot; : 7200,
&quot;start&quot; : &quot;2023-05-16T10:14:28Z&quot;,
&quot;end&quot; : &quot;2023-05-16T11:14:28Z&quot;,
&quot;timespanStart&quot; : &quot;2023-05-16 10:14:28&quot;,
&quot;timespanEnd&quot; : &quot;2023-05-16 11:14:28&quot;
},
&quot;layout&quot; : {
&quot;layoutId&quot; : &quot;grid-layout-1&quot;,
&quot;type&quot; : &quot;grid&quot;,
&quot;details&quot; : {
&quot;widgetPositioning&quot; : [ {
&quot;x&quot; : 0,
&quot;y&quot; : 0,
&quot;w&quot; : 9,
&quot;h&quot; : 5,
&quot;id&quot; : &quot;widgetId-71lbb&quot;
} ]
}
},
&quot;accountId&quot; : 1234,
&quot;apiLink&quot; : [ {
&quot;key&quot; : &quot;&quot;
}, {
&quot;key&quot; : &quot;&quot;
} ],
&quot;dashboardId&quot; : &quot;5e1f7a99143ae6004fdc3bb4&quot;,
&quot;createdBy&quot; : 1,
&quot;globalOverride&quot; : true,
&quot;modifiedDate&quot; : &quot;2023-05-16 10:14:28&quot;,
&quot;isGlobalOverride&quot; : true,
&quot;aid&quot; : &quot;1234&quot;,
&quot;dashboardModifiedDate&quot; : &quot;2023-05-16T10:14:28Z&quot;
}, {
&quot;isMigratedReport&quot; : false,
&quot;dashboardCreatedBy&quot; : &quot;1&quot;,
&quot;_links&quot; : {
&quot;snapshots&quot; : {
&quot;hreflang&quot; : &quot;hreflang&quot;,
&quot;templated&quot; : true,
&quot;profile&quot; : &quot;profile&quot;,
&quot;name&quot; : &quot;name&quot;,
&quot;href&quot; : &quot;https://api.thousandeyes.com/v7/link/to/resource/id&quot;,
&quot;type&quot; : &quot;type&quot;,
&quot;deprecation&quot; : &quot;deprecation&quot;,
&quot;title&quot; : &quot;title&quot;
},
&quot;self&quot; : {
&quot;hreflang&quot; : &quot;hreflang&quot;,
&quot;templated&quot; : true,
&quot;profile&quot; : &quot;profile&quot;,
&quot;name&quot; : &quot;name&quot;,
&quot;href&quot; : &quot;https://api.thousandeyes.com/v7/link/to/resource/id&quot;,
&quot;type&quot; : &quot;type&quot;,
&quot;deprecation&quot; : &quot;deprecation&quot;,
&quot;title&quot; : &quot;title&quot;
}
},
&quot;isDefaultForUser&quot; : true,
&quot;description&quot; : &quot;HTTP Server Widgets&quot;,
&quot;isPrivate&quot; : true,
&quot;title&quot; : &quot;HTTP Server Widgets&quot;,
&quot;isBuiltIn&quot; : true,
&quot;widgets&quot; : [ {
&quot;embedUrl&quot; : &quot;https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f&quot;,
&quot;shouldExcludeAlertSuppressionWindows&quot; : true,
&quot;_links&quot; : {
&quot;self&quot; : {
&quot;hreflang&quot; : &quot;hreflang&quot;,
&quot;templated&quot; : true,
&quot;profile&quot; : &quot;profile&quot;,
&quot;name&quot; : &quot;name&quot;,
&quot;href&quot; : &quot;https://api.thousandeyes.com/v7/link/to/resource/id&quot;,
&quot;type&quot; : &quot;type&quot;,
&quot;deprecation&quot; : &quot;deprecation&quot;,
&quot;title&quot; : &quot;title&quot;
}
},
&quot;visualMode&quot; : &quot;Full&quot;,
&quot;filters&quot; : {
&quot;TEST&quot; : [ 5187, 5227 ],
&quot;ENDPOINT_MACHINE_ID&quot; : [ &quot;fbd0050c-07f7-43f7-9631-14b32f096962&quot; ]
},
&quot;title&quot; : &quot;Widget Title&quot;,
&quot;type&quot; : &quot;Agent Status&quot;,
&quot;metricGroup&quot; : &quot;BGP&quot;,
&quot;measure&quot; : {
&quot;percentileValue&quot; : 95,
&quot;type&quot; : &quot;MEAN&quot;
},
&quot;apiLink&quot; : &quot;apiLink&quot;,
&quot;metric&quot; : &quot;ENDPOINT_GATEWAY_CPU_LOAD_PERCENT&quot;,
&quot;isEmbedded&quot; : true,
&quot;id&quot; : &quot;1234&quot;,
&quot;fixedTimespan&quot; : {
&quot;unit&quot; : &quot;Days&quot;,
&quot;value&quot; : 10
},
&quot;dataSource&quot; : &quot;ENDPOINT_AGENTS&quot;,
&quot;direction&quot; : &quot;FROM_TARGET&quot;
}, {
&quot;embedUrl&quot; : &quot;https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f&quot;,
&quot;shouldExcludeAlertSuppressionWindows&quot; : true,
&quot;_links&quot; : {
&quot;self&quot; : {
&quot;hreflang&quot; : &quot;hreflang&quot;,
&quot;templated&quot; : true,
&quot;profile&quot; : &quot;profile&quot;,
&quot;name&quot; : &quot;name&quot;,
&quot;href&quot; : &quot;https://api.thousandeyes.com/v7/link/to/resource/id&quot;,
&quot;type&quot; : &quot;type&quot;,
&quot;deprecation&quot; : &quot;deprecation&quot;,
&quot;title&quot; : &quot;title&quot;
}
},
&quot;visualMode&quot; : &quot;Full&quot;,
&quot;filters&quot; : {
&quot;TEST&quot; : [ 5187, 5227 ],
&quot;ENDPOINT_MACHINE_ID&quot; : [ &quot;fbd0050c-07f7-43f7-9631-14b32f096962&quot; ]
},
&quot;title&quot; : &quot;Widget Title&quot;,
&quot;type&quot; : &quot;Agent Status&quot;,
&quot;metricGroup&quot; : &quot;BGP&quot;,
&quot;measure&quot; : {
&quot;percentileValue&quot; : 95,
&quot;type&quot; : &quot;MEAN&quot;
},
&quot;apiLink&quot; : &quot;apiLink&quot;,
&quot;metric&quot; : &quot;ENDPOINT_GATEWAY_CPU_LOAD_PERCENT&quot;,
&quot;isEmbedded&quot; : true,
&quot;id&quot; : &quot;1234&quot;,
&quot;fixedTimespan&quot; : {
&quot;unit&quot; : &quot;Days&quot;,
&quot;value&quot; : 10
},
&quot;dataSource&quot; : &quot;ENDPOINT_AGENTS&quot;,
&quot;direction&quot; : &quot;FROM_TARGET&quot;
} ],
&quot;globalFilterId&quot; : &quot;65babd9bb90bf55b17c96c8d&quot;,
&quot;modifiedBy&quot; : 1,
&quot;dashboardModifiedBy&quot; : &quot;1&quot;,
&quot;migratedReport&quot; : false,
&quot;isDefaultForAccount&quot; : false,
&quot;defaultTimespan&quot; : {
&quot;duration&quot; : 7200,
&quot;timespanDuration&quot; : 7200,
&quot;start&quot; : &quot;2023-05-16T10:14:28Z&quot;,
&quot;end&quot; : &quot;2023-05-16T11:14:28Z&quot;,
&quot;timespanStart&quot; : &quot;2023-05-16 10:14:28&quot;,
&quot;timespanEnd&quot; : &quot;2023-05-16 11:14:28&quot;
},
&quot;layout&quot; : {
&quot;layoutId&quot; : &quot;grid-layout-1&quot;,
&quot;type&quot; : &quot;grid&quot;,
&quot;details&quot; : {
&quot;widgetPositioning&quot; : [ {
&quot;x&quot; : 0,
&quot;y&quot; : 0,
&quot;w&quot; : 9,
&quot;h&quot; : 5,
&quot;id&quot; : &quot;widgetId-71lbb&quot;
} ]
}
},
&quot;accountId&quot; : 1234,
&quot;apiLink&quot; : [ {
&quot;key&quot; : &quot;&quot;
}, {
&quot;key&quot; : &quot;&quot;
} ],
&quot;dashboardId&quot; : &quot;5e1f7a99143ae6004fdc3bb4&quot;,
&quot;createdBy&quot; : 1,
&quot;globalOverride&quot; : true,
&quot;modifiedDate&quot; : &quot;2023-05-16 10:14:28&quot;,
&quot;isGlobalOverride&quot; : true,
&quot;aid&quot; : &quot;1234&quot;,
&quot;dashboardModifiedDate&quot; : &quot;2023-05-16T10:14:28Z&quot;
} ]
"""
expected_response = json.loads(response_body_json)
response = self.api.get_dashboards(
aid=aid,
_headers=self.te_headers("get_dashboards"),
)
assert_constructed_model_matches_example_json(response, expected_response)
def test_get_dashboards_error_400(self) -> None:
"""Integration test for get_dashboards error path (HTTP 400)"""
aid = '1234'
error_body_json = """
{
"instance" : "instance",
"detail" : "detail",
"type" : "type",
"title" : "title",
"errors" : [ {
"code" : "code",
"field" : "field",
"message" : "message"
}, {
"code" : "code",
"field" : "field",
"message" : "message"
} ],
"status" : 0
}
"""
expected_error = json.loads(error_body_json)
with self.assertRaises(
ApiException.exception_class_for_http_status(400)
) as context:
self.api.get_dashboards(
aid=aid,
_headers=self.te_headers("get_dashboards", error_status="400"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_get_dashboards_error_401(self) -> None:
"""Integration test for get_dashboards 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_dashboards(
aid=aid,
_headers=self.te_headers("get_dashboards", error_status="401"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_get_dashboards_error_403(self) -> None:
"""Integration test for get_dashboards error path (HTTP 403)"""
aid = '1234'
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_dashboards(
aid=aid,
_headers=self.te_headers("get_dashboards", error_status="403"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_get_dashboards_error_404(self) -> None:
"""Integration test for get_dashboards error path (HTTP 404)"""
aid = '1234'
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(404)
) as context:
self.api.get_dashboards(
aid=aid,
_headers=self.te_headers("get_dashboards", error_status="404"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_get_dashboards_error_429(self) -> None:
"""Integration test for get_dashboards error path (HTTP 429)"""
aid = '1234'
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_dashboards(
aid=aid,
_headers=self.te_headers("get_dashboards", error_status="429"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_get_dashboards_error_500(self) -> None:
"""Integration test for get_dashboards error path (HTTP 500)"""
aid = '1234'
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_dashboards(
aid=aid,
_headers=self.te_headers("get_dashboards", error_status="500"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_get_individual_card_data_happy_path(self) -> None:
"""Integration test for get_individual_card_data success path"""
dashboard_id = '646f4d2ce3c99b0536c3821e'
widget_id = 'unpmg'
card_id = 'rvwgs'
aid = '1234'
window = '12h'
start_date = '2022-07-17T22:00:54Z'
end_date = '2022-07-18T22:00:54Z'
response_body_json = """
{
&quot;numberOfDataPoints&quot; : 24192,
&quot;cardName&quot; : &quot;Card Name&quot;,
&quot;endDate&quot; : &quot;2023-05-16T10:14:28Z&quot;,
&quot;_links&quot; : {
&quot;self&quot; : {
&quot;hreflang&quot; : &quot;hreflang&quot;,
&quot;templated&quot; : true,
&quot;profile&quot; : &quot;profile&quot;,
&quot;name&quot; : &quot;name&quot;,
&quot;href&quot; : &quot;https://api.thousandeyes.com/v7/link/to/resource/id&quot;,
&quot;type&quot; : &quot;type&quot;,
&quot;deprecation&quot; : &quot;deprecation&quot;,
&quot;title&quot; : &quot;title&quot;
}
},
&quot;cardId&quot; : &quot;lrxxr&quot;,
&quot;alertSuppressionWindows&quot; : [ {
&quot;testIds&quot; : [ &quot;281474976710661&quot; ],
&quot;repeatUnit&quot; : &quot;week&quot;,
&quot;durationInSeconds&quot; : 7200,
&quot;repeat&quot; : &quot;custom&quot;,
&quot;name&quot; : &quot;Test dashboards&quot;,
&quot;repeatEvery&quot; : 5,
&quot;id&quot; : &quot;281474976710662&quot;,
&quot;startTimes&quot; : [ &quot;2023-05-16T10:14:28Z&quot; ]
}, {
&quot;testIds&quot; : [ &quot;281474976710661&quot; ],
&quot;repeatUnit&quot; : &quot;week&quot;,
&quot;durationInSeconds&quot; : 7200,
&quot;repeat&quot; : &quot;custom&quot;,
&quot;name&quot; : &quot;Test dashboards&quot;,
&quot;repeatEvery&quot; : 5,
&quot;id&quot; : &quot;281474976710662&quot;,
&quot;startTimes&quot; : [ &quot;2023-05-16T10:14:28Z&quot; ]
} ],
&quot;binSize&quot; : 3600,
&quot;previousValue&quot; : 500,
&quot;value&quot; : 100,
&quot;startDate&quot; : &quot;2023-05-16T10:14:28Z&quot;,
&quot;timestamp&quot; : 1567620000,
&quot;status&quot; : &quot;No data&quot;
}
"""
expected_response = json.loads(response_body_json)
response = self.api.get_individual_card_data(
dashboard_id=dashboard_id,
widget_id=widget_id,
card_id=card_id,
aid=aid,
window=window,
start_date=start_date,
end_date=end_date,
_headers=self.te_headers("get_individual_card_data"),
)
assert_constructed_model_matches_example_json(response, expected_response)
def test_get_individual_card_data_error_400(self) -> None:
"""Integration test for get_individual_card_data error path (HTTP 400)"""
dashboard_id = '646f4d2ce3c99b0536c3821e'
widget_id = 'unpmg'
card_id = 'rvwgs'
aid = '1234'
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_individual_card_data(
dashboard_id=dashboard_id,
widget_id=widget_id,
card_id=card_id,
aid=aid,
window=window,
start_date=start_date,
end_date=end_date,
_headers=self.te_headers("get_individual_card_data", error_status="400"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_get_individual_card_data_error_401(self) -> None:
"""Integration test for get_individual_card_data error path (HTTP 401)"""
dashboard_id = '646f4d2ce3c99b0536c3821e'
widget_id = 'unpmg'
card_id = 'rvwgs'
aid = '1234'
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_individual_card_data(
dashboard_id=dashboard_id,
widget_id=widget_id,
card_id=card_id,
aid=aid,
window=window,
start_date=start_date,
end_date=end_date,
_headers=self.te_headers("get_individual_card_data", error_status="401"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_get_individual_card_data_error_403(self) -> None:
"""Integration test for get_individual_card_data error path (HTTP 403)"""
dashboard_id = '646f4d2ce3c99b0536c3821e'
widget_id = 'unpmg'
card_id = 'rvwgs'
aid = '1234'
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_individual_card_data(
dashboard_id=dashboard_id,
widget_id=widget_id,
card_id=card_id,
aid=aid,
window=window,
start_date=start_date,
end_date=end_date,
_headers=self.te_headers("get_individual_card_data", error_status="403"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_get_individual_card_data_error_404(self) -> None:
"""Integration test for get_individual_card_data error path (HTTP 404)"""
dashboard_id = '646f4d2ce3c99b0536c3821e'
widget_id = 'unpmg'
card_id = 'rvwgs'
aid = '1234'
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(404)
) as context:
self.api.get_individual_card_data(
dashboard_id=dashboard_id,
widget_id=widget_id,
card_id=card_id,
aid=aid,
window=window,
start_date=start_date,
end_date=end_date,
_headers=self.te_headers("get_individual_card_data", error_status="404"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_get_individual_card_data_error_429(self) -> None:
"""Integration test for get_individual_card_data error path (HTTP 429)"""
dashboard_id = '646f4d2ce3c99b0536c3821e'
widget_id = 'unpmg'
card_id = 'rvwgs'
aid = '1234'
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_individual_card_data(
dashboard_id=dashboard_id,
widget_id=widget_id,
card_id=card_id,
aid=aid,
window=window,
start_date=start_date,
end_date=end_date,
_headers=self.te_headers("get_individual_card_data", error_status="429"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_get_individual_card_data_error_500(self) -> None:
"""Integration test for get_individual_card_data error path (HTTP 500)"""
dashboard_id = '646f4d2ce3c99b0536c3821e'
widget_id = 'unpmg'
card_id = 'rvwgs'
aid = '1234'
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_individual_card_data(
dashboard_id=dashboard_id,
widget_id=widget_id,
card_id=card_id,
aid=aid,
window=window,
start_date=start_date,
end_date=end_date,
_headers=self.te_headers("get_individual_card_data", error_status="500"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_get_individual_column_data_happy_path(self) -> None:
"""Integration test for get_individual_column_data success path"""
dashboard_id = '646f4d2ce3c99b0536c3821e'
widget_id = 'unpmg'
column_id = 'col123'
aid = '1234'
window = '12h'
start_date = '2022-07-17T22:00:54Z'
end_date = '2022-07-18T22:00:54Z'
response_body_json = """
{
&quot;_links&quot; : {
&quot;self&quot; : {
&quot;hreflang&quot; : &quot;hreflang&quot;,
&quot;templated&quot; : true,
&quot;profile&quot; : &quot;profile&quot;,
&quot;name&quot; : &quot;name&quot;,
&quot;href&quot; : &quot;https://api.thousandeyes.com/v7/link/to/resource/id&quot;,
&quot;type&quot; : &quot;type&quot;,
&quot;deprecation&quot; : &quot;deprecation&quot;,
&quot;title&quot; : &quot;title&quot;
}
},
&quot;columnId&quot; : &quot;938to&quot;,
&quot;alertSuppressionWindows&quot; : [ {
&quot;testIds&quot; : [ &quot;281474976710661&quot; ],
&quot;repeatUnit&quot; : &quot;week&quot;,
&quot;durationInSeconds&quot; : 7200,
&quot;repeat&quot; : &quot;custom&quot;,
&quot;name&quot; : &quot;Test dashboards&quot;,
&quot;repeatEvery&quot; : 5,
&quot;id&quot; : &quot;281474976710662&quot;,
&quot;startTimes&quot; : [ &quot;2023-05-16T10:14:28Z&quot; ]
}, {
&quot;testIds&quot; : [ &quot;281474976710661&quot; ],
&quot;repeatUnit&quot; : &quot;week&quot;,
&quot;durationInSeconds&quot; : 7200,
&quot;repeat&quot; : &quot;custom&quot;,
&quot;name&quot; : &quot;Test dashboards&quot;,
&quot;repeatEvery&quot; : 5,
&quot;id&quot; : &quot;281474976710662&quot;,
&quot;startTimes&quot; : [ &quot;2023-05-16T10:14:28Z&quot; ]
} ],
&quot;binSize&quot; : 3600,
&quot;points&quot; : [ {
&quot;numberOfDataPoints&quot; : 23304,
&quot;groups&quot; : [ {
&quot;groupProperty&quot; : &quot;COUNTRY&quot;,
&quot;groupValue&quot; : &quot;US&quot;
}, {
&quot;groupProperty&quot; : &quot;COUNTRY&quot;,
&quot;groupValue&quot; : &quot;US&quot;
} ],
&quot;value&quot; : 100,
&quot;timestamp&quot; : 1567620000
}, {
&quot;numberOfDataPoints&quot; : 23304,
&quot;groups&quot; : [ {
&quot;groupProperty&quot; : &quot;COUNTRY&quot;,
&quot;groupValue&quot; : &quot;US&quot;
}, {
&quot;groupProperty&quot; : &quot;COUNTRY&quot;,
&quot;groupValue&quot; : &quot;US&quot;
} ],
&quot;value&quot; : 100,
&quot;timestamp&quot; : 1567620000
} ],
&quot;status&quot; : &quot;No data&quot;
}
"""
expected_response = json.loads(response_body_json)
response = self.api.get_individual_column_data(
dashboard_id=dashboard_id,
widget_id=widget_id,
column_id=column_id,
aid=aid,
window=window,
start_date=start_date,
end_date=end_date,
_headers=self.te_headers("get_individual_column_data"),
)
assert_constructed_model_matches_example_json(response, expected_response)
def test_get_individual_column_data_error_400(self) -> None:
"""Integration test for get_individual_column_data error path (HTTP 400)"""
dashboard_id = '646f4d2ce3c99b0536c3821e'
widget_id = 'unpmg'
column_id = 'col123'
aid = '1234'
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_individual_column_data(
dashboard_id=dashboard_id,
widget_id=widget_id,
column_id=column_id,
aid=aid,
window=window,
start_date=start_date,
end_date=end_date,
_headers=self.te_headers("get_individual_column_data", error_status="400"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_get_individual_column_data_error_401(self) -> None:
"""Integration test for get_individual_column_data error path (HTTP 401)"""
dashboard_id = '646f4d2ce3c99b0536c3821e'
widget_id = 'unpmg'
column_id = 'col123'
aid = '1234'
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_individual_column_data(
dashboard_id=dashboard_id,
widget_id=widget_id,
column_id=column_id,
aid=aid,
window=window,
start_date=start_date,
end_date=end_date,
_headers=self.te_headers("get_individual_column_data", error_status="401"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_get_individual_column_data_error_403(self) -> None:
"""Integration test for get_individual_column_data error path (HTTP 403)"""
dashboard_id = '646f4d2ce3c99b0536c3821e'
widget_id = 'unpmg'
column_id = 'col123'
aid = '1234'
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_individual_column_data(
dashboard_id=dashboard_id,
widget_id=widget_id,
column_id=column_id,
aid=aid,
window=window,
start_date=start_date,
end_date=end_date,
_headers=self.te_headers("get_individual_column_data", error_status="403"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_get_individual_column_data_error_404(self) -> None:
"""Integration test for get_individual_column_data error path (HTTP 404)"""
dashboard_id = '646f4d2ce3c99b0536c3821e'
widget_id = 'unpmg'
column_id = 'col123'
aid = '1234'
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(404)
) as context:
self.api.get_individual_column_data(
dashboard_id=dashboard_id,
widget_id=widget_id,
column_id=column_id,
aid=aid,
window=window,
start_date=start_date,
end_date=end_date,
_headers=self.te_headers("get_individual_column_data", error_status="404"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_get_individual_column_data_error_429(self) -> None:
"""Integration test for get_individual_column_data error path (HTTP 429)"""
dashboard_id = '646f4d2ce3c99b0536c3821e'
widget_id = 'unpmg'
column_id = 'col123'
aid = '1234'
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_individual_column_data(
dashboard_id=dashboard_id,
widget_id=widget_id,
column_id=column_id,
aid=aid,
window=window,
start_date=start_date,
end_date=end_date,
_headers=self.te_headers("get_individual_column_data", error_status="429"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_get_individual_column_data_error_500(self) -> None:
"""Integration test for get_individual_column_data error path (HTTP 500)"""
dashboard_id = '646f4d2ce3c99b0536c3821e'
widget_id = 'unpmg'
column_id = 'col123'
aid = '1234'
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_individual_column_data(
dashboard_id=dashboard_id,
widget_id=widget_id,
column_id=column_id,
aid=aid,
window=window,
start_date=start_date,
end_date=end_date,
_headers=self.te_headers("get_individual_column_data", error_status="500"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_update_dashboard_happy_path(self) -> None:
"""Integration test for update_dashboard success path"""
request_body_json = """
{
"isMigratedReport" : false,
"_links" : {
"snapshots" : {
"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"
}
},
"isDefaultForAccount" : false,
"isDefaultForUser" : true,
"description" : "HTTP Server Widgets",
"isPrivate" : true,
"title" : "HTTP Server Widgets",
"isBuiltIn" : true,
"widgets" : [ {
"embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f",
"shouldExcludeAlertSuppressionWindows" : 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"
}
},
"visualMode" : "Full",
"filters" : {
"TEST" : [ 5187, 5227 ],
"ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ]
},
"title" : "Widget Title",
"type" : "Agent Status",
"metricGroup" : "BGP",
"measure" : {
"percentileValue" : 95,
"type" : "MEAN"
},
"apiLink" : "apiLink",
"metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT",
"isEmbedded" : true,
"id" : "1234",
"fixedTimespan" : {
"unit" : "Days",
"value" : 10
},
"dataSource" : "ENDPOINT_AGENTS",
"direction" : "FROM_TARGET"
}, {
"embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f",
"shouldExcludeAlertSuppressionWindows" : 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"
}
},
"visualMode" : "Full",
"filters" : {
"TEST" : [ 5187, 5227 ],
"ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ]
},
"title" : "Widget Title",
"type" : "Agent Status",
"metricGroup" : "BGP",
"measure" : {
"percentileValue" : 95,
"type" : "MEAN"
},
"apiLink" : "apiLink",
"metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT",
"isEmbedded" : true,
"id" : "1234",
"fixedTimespan" : {
"unit" : "Days",
"value" : 10
},
"dataSource" : "ENDPOINT_AGENTS",
"direction" : "FROM_TARGET"
} ],
"defaultTimespan" : {
"duration" : 7200,
"timespanDuration" : 7200,
"start" : "2023-05-16T10:14:28Z",
"end" : "2023-05-16T11:14:28Z",
"timespanStart" : "2023-05-16 10:14:28",
"timespanEnd" : "2023-05-16 11:14:28"
},
"layout" : {
"layoutId" : "grid-layout-1",
"type" : "grid",
"details" : {
"widgetPositioning" : [ {
"x" : 0,
"y" : 0,
"w" : 9,
"h" : 5,
"id" : "widgetId-71lbb"
} ]
}
},
"globalFilterId" : "65babd9bb90bf55b17c96c8d",
"dashboardId" : "5e1f7a99143ae6004fdc3bb4",
"createdBy" : "1",
"modifiedDate" : "2023-05-16T10:14:28Z",
"modifiedBy" : "1",
"isGlobalOverride" : true,
"aid" : "1234"
}
"""
dashboard = thousandeyes_sdk.dashboards.models.Dashboard.from_json(request_body_json)
dashboard_id = '646f4d2ce3c99b0536c3821e'
aid = '1234'
response_body_json = """
{
&quot;isMigratedReport&quot; : false,
&quot;_links&quot; : {
&quot;snapshots&quot; : {
&quot;hreflang&quot; : &quot;hreflang&quot;,
&quot;templated&quot; : true,
&quot;profile&quot; : &quot;profile&quot;,
&quot;name&quot; : &quot;name&quot;,
&quot;href&quot; : &quot;https://api.thousandeyes.com/v7/link/to/resource/id&quot;,
&quot;type&quot; : &quot;type&quot;,
&quot;deprecation&quot; : &quot;deprecation&quot;,
&quot;title&quot; : &quot;title&quot;
},
&quot;self&quot; : {
&quot;hreflang&quot; : &quot;hreflang&quot;,
&quot;templated&quot; : true,
&quot;profile&quot; : &quot;profile&quot;,
&quot;name&quot; : &quot;name&quot;,
&quot;href&quot; : &quot;https://api.thousandeyes.com/v7/link/to/resource/id&quot;,
&quot;type&quot; : &quot;type&quot;,
&quot;deprecation&quot; : &quot;deprecation&quot;,
&quot;title&quot; : &quot;title&quot;
}
},
&quot;isDefaultForAccount&quot; : false,
&quot;isDefaultForUser&quot; : true,
&quot;description&quot; : &quot;HTTP Server Widgets&quot;,
&quot;isPrivate&quot; : true,
&quot;title&quot; : &quot;HTTP Server Widgets&quot;,
&quot;isBuiltIn&quot; : true,
&quot;widgets&quot; : [ {
&quot;embedUrl&quot; : &quot;https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f&quot;,
&quot;shouldExcludeAlertSuppressionWindows&quot; : true,
&quot;_links&quot; : {
&quot;self&quot; : {
&quot;hreflang&quot; : &quot;hreflang&quot;,
&quot;templated&quot; : true,
&quot;profile&quot; : &quot;profile&quot;,
&quot;name&quot; : &quot;name&quot;,
&quot;href&quot; : &quot;https://api.thousandeyes.com/v7/link/to/resource/id&quot;,
&quot;type&quot; : &quot;type&quot;,
&quot;deprecation&quot; : &quot;deprecation&quot;,
&quot;title&quot; : &quot;title&quot;
}
},
&quot;visualMode&quot; : &quot;Full&quot;,
&quot;filters&quot; : {
&quot;TEST&quot; : [ 5187, 5227 ],
&quot;ENDPOINT_MACHINE_ID&quot; : [ &quot;fbd0050c-07f7-43f7-9631-14b32f096962&quot; ]
},
&quot;title&quot; : &quot;Widget Title&quot;,
&quot;type&quot; : &quot;Agent Status&quot;,
&quot;metricGroup&quot; : &quot;BGP&quot;,
&quot;measure&quot; : {
&quot;percentileValue&quot; : 95,
&quot;type&quot; : &quot;MEAN&quot;
},
&quot;apiLink&quot; : &quot;apiLink&quot;,
&quot;metric&quot; : &quot;ENDPOINT_GATEWAY_CPU_LOAD_PERCENT&quot;,
&quot;isEmbedded&quot; : true,
&quot;id&quot; : &quot;1234&quot;,
&quot;fixedTimespan&quot; : {
&quot;unit&quot; : &quot;Days&quot;,
&quot;value&quot; : 10
},
&quot;dataSource&quot; : &quot;ENDPOINT_AGENTS&quot;,
&quot;direction&quot; : &quot;FROM_TARGET&quot;
}, {
&quot;embedUrl&quot; : &quot;https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f&quot;,
&quot;shouldExcludeAlertSuppressionWindows&quot; : true,
&quot;_links&quot; : {
&quot;self&quot; : {
&quot;hreflang&quot; : &quot;hreflang&quot;,
&quot;templated&quot; : true,
&quot;profile&quot; : &quot;profile&quot;,
&quot;name&quot; : &quot;name&quot;,
&quot;href&quot; : &quot;https://api.thousandeyes.com/v7/link/to/resource/id&quot;,
&quot;type&quot; : &quot;type&quot;,
&quot;deprecation&quot; : &quot;deprecation&quot;,
&quot;title&quot; : &quot;title&quot;
}
},
&quot;visualMode&quot; : &quot;Full&quot;,
&quot;filters&quot; : {
&quot;TEST&quot; : [ 5187, 5227 ],
&quot;ENDPOINT_MACHINE_ID&quot; : [ &quot;fbd0050c-07f7-43f7-9631-14b32f096962&quot; ]
},
&quot;title&quot; : &quot;Widget Title&quot;,
&quot;type&quot; : &quot;Agent Status&quot;,
&quot;metricGroup&quot; : &quot;BGP&quot;,
&quot;measure&quot; : {
&quot;percentileValue&quot; : 95,
&quot;type&quot; : &quot;MEAN&quot;
},
&quot;apiLink&quot; : &quot;apiLink&quot;,
&quot;metric&quot; : &quot;ENDPOINT_GATEWAY_CPU_LOAD_PERCENT&quot;,
&quot;isEmbedded&quot; : true,
&quot;id&quot; : &quot;1234&quot;,
&quot;fixedTimespan&quot; : {
&quot;unit&quot; : &quot;Days&quot;,
&quot;value&quot; : 10
},
&quot;dataSource&quot; : &quot;ENDPOINT_AGENTS&quot;,
&quot;direction&quot; : &quot;FROM_TARGET&quot;
} ],
&quot;defaultTimespan&quot; : {
&quot;duration&quot; : 7200,
&quot;timespanDuration&quot; : 7200,
&quot;start&quot; : &quot;2023-05-16T10:14:28Z&quot;,
&quot;end&quot; : &quot;2023-05-16T11:14:28Z&quot;,
&quot;timespanStart&quot; : &quot;2023-05-16 10:14:28&quot;,
&quot;timespanEnd&quot; : &quot;2023-05-16 11:14:28&quot;
},
&quot;layout&quot; : {
&quot;layoutId&quot; : &quot;grid-layout-1&quot;,
&quot;type&quot; : &quot;grid&quot;,
&quot;details&quot; : {
&quot;widgetPositioning&quot; : [ {
&quot;x&quot; : 0,
&quot;y&quot; : 0,
&quot;w&quot; : 9,
&quot;h&quot; : 5,
&quot;id&quot; : &quot;widgetId-71lbb&quot;
} ]
}
},
&quot;globalFilterId&quot; : &quot;65babd9bb90bf55b17c96c8d&quot;,
&quot;dashboardId&quot; : &quot;5e1f7a99143ae6004fdc3bb4&quot;,
&quot;createdBy&quot; : &quot;1&quot;,
&quot;modifiedDate&quot; : &quot;2023-05-16T10:14:28Z&quot;,
&quot;modifiedBy&quot; : &quot;1&quot;,
&quot;isGlobalOverride&quot; : true,
&quot;aid&quot; : &quot;1234&quot;
}
"""
expected_response = json.loads(response_body_json)
response = self.api.update_dashboard(
dashboard_id=dashboard_id,
dashboard=dashboard,
aid=aid,
_headers=self.te_headers("update_dashboard"),
)
assert_constructed_model_matches_example_json(response, expected_response)
def test_update_dashboard_error_400(self) -> None:
"""Integration test for update_dashboard error path (HTTP 400)"""
request_body_json = """
{
"isMigratedReport" : false,
"_links" : {
"snapshots" : {
"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"
}
},
"isDefaultForAccount" : false,
"isDefaultForUser" : true,
"description" : "HTTP Server Widgets",
"isPrivate" : true,
"title" : "HTTP Server Widgets",
"isBuiltIn" : true,
"widgets" : [ {
"embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f",
"shouldExcludeAlertSuppressionWindows" : 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"
}
},
"visualMode" : "Full",
"filters" : {
"TEST" : [ 5187, 5227 ],
"ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ]
},
"title" : "Widget Title",
"type" : "Agent Status",
"metricGroup" : "BGP",
"measure" : {
"percentileValue" : 95,
"type" : "MEAN"
},
"apiLink" : "apiLink",
"metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT",
"isEmbedded" : true,
"id" : "1234",
"fixedTimespan" : {
"unit" : "Days",
"value" : 10
},
"dataSource" : "ENDPOINT_AGENTS",
"direction" : "FROM_TARGET"
}, {
"embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f",
"shouldExcludeAlertSuppressionWindows" : 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"
}
},
"visualMode" : "Full",
"filters" : {
"TEST" : [ 5187, 5227 ],
"ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ]
},
"title" : "Widget Title",
"type" : "Agent Status",
"metricGroup" : "BGP",
"measure" : {
"percentileValue" : 95,
"type" : "MEAN"
},
"apiLink" : "apiLink",
"metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT",
"isEmbedded" : true,
"id" : "1234",
"fixedTimespan" : {
"unit" : "Days",
"value" : 10
},
"dataSource" : "ENDPOINT_AGENTS",
"direction" : "FROM_TARGET"
} ],
"defaultTimespan" : {
"duration" : 7200,
"timespanDuration" : 7200,
"start" : "2023-05-16T10:14:28Z",
"end" : "2023-05-16T11:14:28Z",
"timespanStart" : "2023-05-16 10:14:28",
"timespanEnd" : "2023-05-16 11:14:28"
},
"layout" : {
"layoutId" : "grid-layout-1",
"type" : "grid",
"details" : {
"widgetPositioning" : [ {
"x" : 0,
"y" : 0,
"w" : 9,
"h" : 5,
"id" : "widgetId-71lbb"
} ]
}
},
"globalFilterId" : "65babd9bb90bf55b17c96c8d",
"dashboardId" : "5e1f7a99143ae6004fdc3bb4",
"createdBy" : "1",
"modifiedDate" : "2023-05-16T10:14:28Z",
"modifiedBy" : "1",
"isGlobalOverride" : true,
"aid" : "1234"
}
"""
dashboard = thousandeyes_sdk.dashboards.models.Dashboard.from_json(request_body_json)
dashboard_id = '646f4d2ce3c99b0536c3821e'
aid = '1234'
error_body_json = """
{
"instance" : "instance",
"detail" : "detail",
"type" : "type",
"title" : "title",
"errors" : [ {
"code" : "code",
"field" : "field",
"message" : "message"
}, {
"code" : "code",
"field" : "field",
"message" : "message"
} ],
"status" : 0
}
"""
expected_error = json.loads(error_body_json)
with self.assertRaises(
ApiException.exception_class_for_http_status(400)
) as context:
self.api.update_dashboard(
dashboard_id=dashboard_id,
dashboard=dashboard,
aid=aid,
_headers=self.te_headers("update_dashboard", error_status="400"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_update_dashboard_error_401(self) -> None:
"""Integration test for update_dashboard error path (HTTP 401)"""
request_body_json = """
{
"isMigratedReport" : false,
"_links" : {
"snapshots" : {
"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"
}
},
"isDefaultForAccount" : false,
"isDefaultForUser" : true,
"description" : "HTTP Server Widgets",
"isPrivate" : true,
"title" : "HTTP Server Widgets",
"isBuiltIn" : true,
"widgets" : [ {
"embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f",
"shouldExcludeAlertSuppressionWindows" : 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"
}
},
"visualMode" : "Full",
"filters" : {
"TEST" : [ 5187, 5227 ],
"ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ]
},
"title" : "Widget Title",
"type" : "Agent Status",
"metricGroup" : "BGP",
"measure" : {
"percentileValue" : 95,
"type" : "MEAN"
},
"apiLink" : "apiLink",
"metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT",
"isEmbedded" : true,
"id" : "1234",
"fixedTimespan" : {
"unit" : "Days",
"value" : 10
},
"dataSource" : "ENDPOINT_AGENTS",
"direction" : "FROM_TARGET"
}, {
"embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f",
"shouldExcludeAlertSuppressionWindows" : 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"
}
},
"visualMode" : "Full",
"filters" : {
"TEST" : [ 5187, 5227 ],
"ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ]
},
"title" : "Widget Title",
"type" : "Agent Status",
"metricGroup" : "BGP",
"measure" : {
"percentileValue" : 95,
"type" : "MEAN"
},
"apiLink" : "apiLink",
"metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT",
"isEmbedded" : true,
"id" : "1234",
"fixedTimespan" : {
"unit" : "Days",
"value" : 10
},
"dataSource" : "ENDPOINT_AGENTS",
"direction" : "FROM_TARGET"
} ],
"defaultTimespan" : {
"duration" : 7200,
"timespanDuration" : 7200,
"start" : "2023-05-16T10:14:28Z",
"end" : "2023-05-16T11:14:28Z",
"timespanStart" : "2023-05-16 10:14:28",
"timespanEnd" : "2023-05-16 11:14:28"
},
"layout" : {
"layoutId" : "grid-layout-1",
"type" : "grid",
"details" : {
"widgetPositioning" : [ {
"x" : 0,
"y" : 0,
"w" : 9,
"h" : 5,
"id" : "widgetId-71lbb"
} ]
}
},
"globalFilterId" : "65babd9bb90bf55b17c96c8d",
"dashboardId" : "5e1f7a99143ae6004fdc3bb4",
"createdBy" : "1",
"modifiedDate" : "2023-05-16T10:14:28Z",
"modifiedBy" : "1",
"isGlobalOverride" : true,
"aid" : "1234"
}
"""
dashboard = thousandeyes_sdk.dashboards.models.Dashboard.from_json(request_body_json)
dashboard_id = '646f4d2ce3c99b0536c3821e'
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_dashboard(
dashboard_id=dashboard_id,
dashboard=dashboard,
aid=aid,
_headers=self.te_headers("update_dashboard", error_status="401"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_update_dashboard_error_403(self) -> None:
"""Integration test for update_dashboard error path (HTTP 403)"""
request_body_json = """
{
"isMigratedReport" : false,
"_links" : {
"snapshots" : {
"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"
}
},
"isDefaultForAccount" : false,
"isDefaultForUser" : true,
"description" : "HTTP Server Widgets",
"isPrivate" : true,
"title" : "HTTP Server Widgets",
"isBuiltIn" : true,
"widgets" : [ {
"embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f",
"shouldExcludeAlertSuppressionWindows" : 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"
}
},
"visualMode" : "Full",
"filters" : {
"TEST" : [ 5187, 5227 ],
"ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ]
},
"title" : "Widget Title",
"type" : "Agent Status",
"metricGroup" : "BGP",
"measure" : {
"percentileValue" : 95,
"type" : "MEAN"
},
"apiLink" : "apiLink",
"metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT",
"isEmbedded" : true,
"id" : "1234",
"fixedTimespan" : {
"unit" : "Days",
"value" : 10
},
"dataSource" : "ENDPOINT_AGENTS",
"direction" : "FROM_TARGET"
}, {
"embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f",
"shouldExcludeAlertSuppressionWindows" : 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"
}
},
"visualMode" : "Full",
"filters" : {
"TEST" : [ 5187, 5227 ],
"ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ]
},
"title" : "Widget Title",
"type" : "Agent Status",
"metricGroup" : "BGP",
"measure" : {
"percentileValue" : 95,
"type" : "MEAN"
},
"apiLink" : "apiLink",
"metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT",
"isEmbedded" : true,
"id" : "1234",
"fixedTimespan" : {
"unit" : "Days",
"value" : 10
},
"dataSource" : "ENDPOINT_AGENTS",
"direction" : "FROM_TARGET"
} ],
"defaultTimespan" : {
"duration" : 7200,
"timespanDuration" : 7200,
"start" : "2023-05-16T10:14:28Z",
"end" : "2023-05-16T11:14:28Z",
"timespanStart" : "2023-05-16 10:14:28",
"timespanEnd" : "2023-05-16 11:14:28"
},
"layout" : {
"layoutId" : "grid-layout-1",
"type" : "grid",
"details" : {
"widgetPositioning" : [ {
"x" : 0,
"y" : 0,
"w" : 9,
"h" : 5,
"id" : "widgetId-71lbb"
} ]
}
},
"globalFilterId" : "65babd9bb90bf55b17c96c8d",
"dashboardId" : "5e1f7a99143ae6004fdc3bb4",
"createdBy" : "1",
"modifiedDate" : "2023-05-16T10:14:28Z",
"modifiedBy" : "1",
"isGlobalOverride" : true,
"aid" : "1234"
}
"""
dashboard = thousandeyes_sdk.dashboards.models.Dashboard.from_json(request_body_json)
dashboard_id = '646f4d2ce3c99b0536c3821e'
aid = '1234'
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.update_dashboard(
dashboard_id=dashboard_id,
dashboard=dashboard,
aid=aid,
_headers=self.te_headers("update_dashboard", error_status="403"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_update_dashboard_error_404(self) -> None:
"""Integration test for update_dashboard error path (HTTP 404)"""
request_body_json = """
{
"isMigratedReport" : false,
"_links" : {
"snapshots" : {
"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"
}
},
"isDefaultForAccount" : false,
"isDefaultForUser" : true,
"description" : "HTTP Server Widgets",
"isPrivate" : true,
"title" : "HTTP Server Widgets",
"isBuiltIn" : true,
"widgets" : [ {
"embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f",
"shouldExcludeAlertSuppressionWindows" : 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"
}
},
"visualMode" : "Full",
"filters" : {
"TEST" : [ 5187, 5227 ],
"ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ]
},
"title" : "Widget Title",
"type" : "Agent Status",
"metricGroup" : "BGP",
"measure" : {
"percentileValue" : 95,
"type" : "MEAN"
},
"apiLink" : "apiLink",
"metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT",
"isEmbedded" : true,
"id" : "1234",
"fixedTimespan" : {
"unit" : "Days",
"value" : 10
},
"dataSource" : "ENDPOINT_AGENTS",
"direction" : "FROM_TARGET"
}, {
"embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f",
"shouldExcludeAlertSuppressionWindows" : 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"
}
},
"visualMode" : "Full",
"filters" : {
"TEST" : [ 5187, 5227 ],
"ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ]
},
"title" : "Widget Title",
"type" : "Agent Status",
"metricGroup" : "BGP",
"measure" : {
"percentileValue" : 95,
"type" : "MEAN"
},
"apiLink" : "apiLink",
"metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT",
"isEmbedded" : true,
"id" : "1234",
"fixedTimespan" : {
"unit" : "Days",
"value" : 10
},
"dataSource" : "ENDPOINT_AGENTS",
"direction" : "FROM_TARGET"
} ],
"defaultTimespan" : {
"duration" : 7200,
"timespanDuration" : 7200,
"start" : "2023-05-16T10:14:28Z",
"end" : "2023-05-16T11:14:28Z",
"timespanStart" : "2023-05-16 10:14:28",
"timespanEnd" : "2023-05-16 11:14:28"
},
"layout" : {
"layoutId" : "grid-layout-1",
"type" : "grid",
"details" : {
"widgetPositioning" : [ {
"x" : 0,
"y" : 0,
"w" : 9,
"h" : 5,
"id" : "widgetId-71lbb"
} ]
}
},
"globalFilterId" : "65babd9bb90bf55b17c96c8d",
"dashboardId" : "5e1f7a99143ae6004fdc3bb4",
"createdBy" : "1",
"modifiedDate" : "2023-05-16T10:14:28Z",
"modifiedBy" : "1",
"isGlobalOverride" : true,
"aid" : "1234"
}
"""
dashboard = thousandeyes_sdk.dashboards.models.Dashboard.from_json(request_body_json)
dashboard_id = '646f4d2ce3c99b0536c3821e'
aid = '1234'
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(404)
) as context:
self.api.update_dashboard(
dashboard_id=dashboard_id,
dashboard=dashboard,
aid=aid,
_headers=self.te_headers("update_dashboard", error_status="404"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_update_dashboard_error_429(self) -> None:
"""Integration test for update_dashboard error path (HTTP 429)"""
request_body_json = """
{
"isMigratedReport" : false,
"_links" : {
"snapshots" : {
"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"
}
},
"isDefaultForAccount" : false,
"isDefaultForUser" : true,
"description" : "HTTP Server Widgets",
"isPrivate" : true,
"title" : "HTTP Server Widgets",
"isBuiltIn" : true,
"widgets" : [ {
"embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f",
"shouldExcludeAlertSuppressionWindows" : 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"
}
},
"visualMode" : "Full",
"filters" : {
"TEST" : [ 5187, 5227 ],
"ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ]
},
"title" : "Widget Title",
"type" : "Agent Status",
"metricGroup" : "BGP",
"measure" : {
"percentileValue" : 95,
"type" : "MEAN"
},
"apiLink" : "apiLink",
"metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT",
"isEmbedded" : true,
"id" : "1234",
"fixedTimespan" : {
"unit" : "Days",
"value" : 10
},
"dataSource" : "ENDPOINT_AGENTS",
"direction" : "FROM_TARGET"
}, {
"embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f",
"shouldExcludeAlertSuppressionWindows" : 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"
}
},
"visualMode" : "Full",
"filters" : {
"TEST" : [ 5187, 5227 ],
"ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ]
},
"title" : "Widget Title",
"type" : "Agent Status",
"metricGroup" : "BGP",
"measure" : {
"percentileValue" : 95,
"type" : "MEAN"
},
"apiLink" : "apiLink",
"metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT",
"isEmbedded" : true,
"id" : "1234",
"fixedTimespan" : {
"unit" : "Days",
"value" : 10
},
"dataSource" : "ENDPOINT_AGENTS",
"direction" : "FROM_TARGET"
} ],
"defaultTimespan" : {
"duration" : 7200,
"timespanDuration" : 7200,
"start" : "2023-05-16T10:14:28Z",
"end" : "2023-05-16T11:14:28Z",
"timespanStart" : "2023-05-16 10:14:28",
"timespanEnd" : "2023-05-16 11:14:28"
},
"layout" : {
"layoutId" : "grid-layout-1",
"type" : "grid",
"details" : {
"widgetPositioning" : [ {
"x" : 0,
"y" : 0,
"w" : 9,
"h" : 5,
"id" : "widgetId-71lbb"
} ]
}
},
"globalFilterId" : "65babd9bb90bf55b17c96c8d",
"dashboardId" : "5e1f7a99143ae6004fdc3bb4",
"createdBy" : "1",
"modifiedDate" : "2023-05-16T10:14:28Z",
"modifiedBy" : "1",
"isGlobalOverride" : true,
"aid" : "1234"
}
"""
dashboard = thousandeyes_sdk.dashboards.models.Dashboard.from_json(request_body_json)
dashboard_id = '646f4d2ce3c99b0536c3821e'
aid = '1234'
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.update_dashboard(
dashboard_id=dashboard_id,
dashboard=dashboard,
aid=aid,
_headers=self.te_headers("update_dashboard", error_status="429"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
def test_update_dashboard_error_500(self) -> None:
"""Integration test for update_dashboard error path (HTTP 500)"""
request_body_json = """
{
"isMigratedReport" : false,
"_links" : {
"snapshots" : {
"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"
}
},
"isDefaultForAccount" : false,
"isDefaultForUser" : true,
"description" : "HTTP Server Widgets",
"isPrivate" : true,
"title" : "HTTP Server Widgets",
"isBuiltIn" : true,
"widgets" : [ {
"embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f",
"shouldExcludeAlertSuppressionWindows" : 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"
}
},
"visualMode" : "Full",
"filters" : {
"TEST" : [ 5187, 5227 ],
"ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ]
},
"title" : "Widget Title",
"type" : "Agent Status",
"metricGroup" : "BGP",
"measure" : {
"percentileValue" : 95,
"type" : "MEAN"
},
"apiLink" : "apiLink",
"metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT",
"isEmbedded" : true,
"id" : "1234",
"fixedTimespan" : {
"unit" : "Days",
"value" : 10
},
"dataSource" : "ENDPOINT_AGENTS",
"direction" : "FROM_TARGET"
}, {
"embedUrl" : "https://embed.thousandeyes.com/e/00aa:3039802d-5c76-42d2-9a93-c6e5f9d3122f",
"shouldExcludeAlertSuppressionWindows" : 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"
}
},
"visualMode" : "Full",
"filters" : {
"TEST" : [ 5187, 5227 ],
"ENDPOINT_MACHINE_ID" : [ "fbd0050c-07f7-43f7-9631-14b32f096962" ]
},
"title" : "Widget Title",
"type" : "Agent Status",
"metricGroup" : "BGP",
"measure" : {
"percentileValue" : 95,
"type" : "MEAN"
},
"apiLink" : "apiLink",
"metric" : "ENDPOINT_GATEWAY_CPU_LOAD_PERCENT",
"isEmbedded" : true,
"id" : "1234",
"fixedTimespan" : {
"unit" : "Days",
"value" : 10
},
"dataSource" : "ENDPOINT_AGENTS",
"direction" : "FROM_TARGET"
} ],
"defaultTimespan" : {
"duration" : 7200,
"timespanDuration" : 7200,
"start" : "2023-05-16T10:14:28Z",
"end" : "2023-05-16T11:14:28Z",
"timespanStart" : "2023-05-16 10:14:28",
"timespanEnd" : "2023-05-16 11:14:28"
},
"layout" : {
"layoutId" : "grid-layout-1",
"type" : "grid",
"details" : {
"widgetPositioning" : [ {
"x" : 0,
"y" : 0,
"w" : 9,
"h" : 5,
"id" : "widgetId-71lbb"
} ]
}
},
"globalFilterId" : "65babd9bb90bf55b17c96c8d",
"dashboardId" : "5e1f7a99143ae6004fdc3bb4",
"createdBy" : "1",
"modifiedDate" : "2023-05-16T10:14:28Z",
"modifiedBy" : "1",
"isGlobalOverride" : true,
"aid" : "1234"
}
"""
dashboard = thousandeyes_sdk.dashboards.models.Dashboard.from_json(request_body_json)
dashboard_id = '646f4d2ce3c99b0536c3821e'
aid = '1234'
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.update_dashboard(
dashboard_id=dashboard_id,
dashboard=dashboard,
aid=aid,
_headers=self.te_headers("update_dashboard", error_status="500"),
)
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
if __name__ == '__main__':
unittest.main()