thousandeyes-sdk-python/thousandeyes-sdk-dashboards/test/test_dashboards_api_integration.py
Kevin 39517ce6d1 Fix mock server nested body matching and array response tests.
Recursively ignore read-only fields in nested request objects and
regenerate dashboards/streaming integration tests for list responses.

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

5102 lines
192 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 = """
{
"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"
}
"""
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 = """
{
"isMigratedReport" : false,
"dashboardCreatedBy" : "1",
"_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"
}
},
"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"
} ],
"globalFilterId" : "65babd9bb90bf55b17c96c8d",
"modifiedBy" : 1,
"dashboardModifiedBy" : "1",
"migratedReport" : false,
"isDefaultForAccount" : false,
"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"
} ]
}
},
"accountId" : 1234,
"apiLink" : [ {
"key" : ""
}, {
"key" : ""
} ],
"dashboardId" : "5e1f7a99143ae6004fdc3bb4",
"createdBy" : 1,
"globalOverride" : true,
"modifiedDate" : "2023-05-16 10:14:28",
"isGlobalOverride" : true,
"aid" : "1234",
"dashboardModifiedDate" : "2023-05-16T10:14:28Z"
}
"""
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'
response_body_json = """
{
"groupLabels" : [ {
"groupProperty" : "AGENT",
"groupLabels" : [ {
"groupId" : "2565",
"groupLabel" : "San Francisco, CA"
}, {
"groupId" : "2565",
"groupLabel" : "San Francisco, CA"
} ]
}, {
"groupProperty" : "AGENT",
"groupLabels" : [ {
"groupId" : "2565",
"groupLabel" : "San Francisco, CA"
}, {
"groupId" : "2565",
"groupLabel" : "San Francisco, CA"
} ]
} ],
"data" : {
"alerts" : [ {
"alertType" : "network-end-to-end-server",
"durationInSeconds" : 25,
"alertSource" : "Http Test",
"active" : true,
"testId" : "56512",
"startTime" : "2023-06-02T08:54:00Z",
"alertId" : "2004945",
"ruleId" : "281724",
"alertRule" : "Http Test Rule"
}, {
"alertType" : "network-end-to-end-server",
"durationInSeconds" : 25,
"alertSource" : "Http Test",
"active" : true,
"testId" : "56512",
"startTime" : "2023-06-02T08:54:00Z",
"alertId" : "2004945",
"ruleId" : "281724",
"alertRule" : "Http Test Rule"
} ],
"summary" : {
"offline" : 2,
"online" : 10,
"disabled" : 3
},
"totalAlerts" : 500,
"cards" : [ {
"numberOfDataPoints" : 24192,
"cardName" : "Card Name",
"endDate" : "2023-05-16T10:14:28Z",
"_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"
}
},
"cardId" : "lrxxr",
"alertSuppressionWindows" : [ {
"testIds" : [ "281474976710661" ],
"repeatUnit" : "week",
"durationInSeconds" : 7200,
"repeat" : "custom",
"name" : "Test dashboards",
"repeatEvery" : 5,
"id" : "281474976710662",
"startTimes" : [ "2023-05-16T10:14:28Z" ]
}, {
"testIds" : [ "281474976710661" ],
"repeatUnit" : "week",
"durationInSeconds" : 7200,
"repeat" : "custom",
"name" : "Test dashboards",
"repeatEvery" : 5,
"id" : "281474976710662",
"startTimes" : [ "2023-05-16T10:14:28Z" ]
} ],
"binSize" : 3600,
"previousValue" : 500,
"value" : 100,
"startDate" : "2023-05-16T10:14:28Z",
"timestamp" : 1567620000,
"status" : "No data"
}, {
"numberOfDataPoints" : 24192,
"cardName" : "Card Name",
"endDate" : "2023-05-16T10:14:28Z",
"_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"
}
},
"cardId" : "lrxxr",
"alertSuppressionWindows" : [ {
"testIds" : [ "281474976710661" ],
"repeatUnit" : "week",
"durationInSeconds" : 7200,
"repeat" : "custom",
"name" : "Test dashboards",
"repeatEvery" : 5,
"id" : "281474976710662",
"startTimes" : [ "2023-05-16T10:14:28Z" ]
}, {
"testIds" : [ "281474976710661" ],
"repeatUnit" : "week",
"durationInSeconds" : 7200,
"repeat" : "custom",
"name" : "Test dashboards",
"repeatEvery" : 5,
"id" : "281474976710662",
"startTimes" : [ "2023-05-16T10:14:28Z" ]
} ],
"binSize" : 3600,
"previousValue" : 500,
"value" : 100,
"startDate" : "2023-05-16T10:14:28Z",
"timestamp" : 1567620000,
"status" : "No data"
} ],
"tests" : [ {
"graphlets" : [ {
"metric" : "Availability",
"testId" : "68257",
"points" : [ {
"x" : 1580403900,
"y" : 128.249
}, {
"x" : 1580403900,
"y" : 128.249
} ]
}, {
"metric" : "Availability",
"testId" : "68257",
"points" : [ {
"x" : 1580403900,
"y" : 128.249
}, {
"x" : 1580403900,
"y" : 128.249
} ]
} ],
"alertCount" : 398,
"testType" : "Web - HTTP Server",
"testId" : "68256",
"isShared" : true,
"testName" : "Http Test Name",
"target" : "www.google.com"
}, {
"graphlets" : [ {
"metric" : "Availability",
"testId" : "68257",
"points" : [ {
"x" : 1580403900,
"y" : 128.249
}, {
"x" : 1580403900,
"y" : 128.249
} ]
}, {
"metric" : "Availability",
"testId" : "68257",
"points" : [ {
"x" : 1580403900,
"y" : 128.249
}, {
"x" : 1580403900,
"y" : 128.249
} ]
} ],
"alertCount" : 398,
"testType" : "Web - HTTP Server",
"testId" : "68256",
"isShared" : true,
"testName" : "Http Test Name",
"target" : "www.google.com"
} ],
"columns" : [ {
"_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"
}
},
"columnId" : "938to",
"alertSuppressionWindows" : [ {
"testIds" : [ "281474976710661" ],
"repeatUnit" : "week",
"durationInSeconds" : 7200,
"repeat" : "custom",
"name" : "Test dashboards",
"repeatEvery" : 5,
"id" : "281474976710662",
"startTimes" : [ "2023-05-16T10:14:28Z" ]
}, {
"testIds" : [ "281474976710661" ],
"repeatUnit" : "week",
"durationInSeconds" : 7200,
"repeat" : "custom",
"name" : "Test dashboards",
"repeatEvery" : 5,
"id" : "281474976710662",
"startTimes" : [ "2023-05-16T10:14:28Z" ]
} ],
"binSize" : 3600,
"points" : [ {
"numberOfDataPoints" : 23304,
"groups" : [ {
"groupProperty" : "COUNTRY",
"groupValue" : "US"
}, {
"groupProperty" : "COUNTRY",
"groupValue" : "US"
} ],
"value" : 100,
"timestamp" : 1567620000
}, {
"numberOfDataPoints" : 23304,
"groups" : [ {
"groupProperty" : "COUNTRY",
"groupValue" : "US"
}, {
"groupProperty" : "COUNTRY",
"groupValue" : "US"
} ],
"value" : 100,
"timestamp" : 1567620000
} ],
"status" : "No data"
}, {
"_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"
}
},
"columnId" : "938to",
"alertSuppressionWindows" : [ {
"testIds" : [ "281474976710661" ],
"repeatUnit" : "week",
"durationInSeconds" : 7200,
"repeat" : "custom",
"name" : "Test dashboards",
"repeatEvery" : 5,
"id" : "281474976710662",
"startTimes" : [ "2023-05-16T10:14:28Z" ]
}, {
"testIds" : [ "281474976710661" ],
"repeatUnit" : "week",
"durationInSeconds" : 7200,
"repeat" : "custom",
"name" : "Test dashboards",
"repeatEvery" : 5,
"id" : "281474976710662",
"startTimes" : [ "2023-05-16T10:14:28Z" ]
} ],
"binSize" : 3600,
"points" : [ {
"numberOfDataPoints" : 23304,
"groups" : [ {
"groupProperty" : "COUNTRY",
"groupValue" : "US"
}, {
"groupProperty" : "COUNTRY",
"groupValue" : "US"
} ],
"value" : 100,
"timestamp" : 1567620000
}, {
"numberOfDataPoints" : 23304,
"groups" : [ {
"groupProperty" : "COUNTRY",
"groupValue" : "US"
}, {
"groupProperty" : "COUNTRY",
"groupValue" : "US"
} ],
"value" : 100,
"timestamp" : 1567620000
} ],
"status" : "No data"
} ],
"alertSuppressionWindows" : [ {
"testIds" : [ "281474976710661" ],
"repeatUnit" : "week",
"durationInSeconds" : 7200,
"repeat" : "custom",
"name" : "Test dashboards",
"repeatEvery" : 5,
"id" : "281474976710662",
"startTimes" : [ "2023-05-16T10:14:28Z" ]
}, {
"testIds" : [ "281474976710661" ],
"repeatUnit" : "week",
"durationInSeconds" : 7200,
"repeat" : "custom",
"name" : "Test dashboards",
"repeatEvery" : 5,
"id" : "281474976710662",
"startTimes" : [ "2023-05-16T10:14:28Z" ]
} ],
"activeAlerts" : 483,
"startRound" : 1384309800,
"points" : [ {
"numberOfDataPoints" : 23304,
"groups" : [ {
"groupProperty" : "COUNTRY",
"groupValue" : "US"
}, {
"groupProperty" : "COUNTRY",
"groupValue" : "US"
} ],
"value" : 100,
"timestamp" : 1567620000
}, {
"numberOfDataPoints" : 23304,
"groups" : [ {
"groupProperty" : "COUNTRY",
"groupValue" : "US"
}, {
"groupProperty" : "COUNTRY",
"groupValue" : "US"
} ],
"value" : 100,
"timestamp" : 1567620000
} ],
"agents" : [ {
"agentId" : "6522",
"agentName" : "0c3898000117",
"location" : {
"locationName" : "San Francisco, California, US",
"latitude" : 37.77493,
"longitude" : -122.41942
},
"ipInfo" : {
"ipv6" : "ipv6",
"privateIp" : "172.58.92.31",
"operativeSystemVersion" : "operativeSystemVersion",
"publicIp" : "172.58.92.31"
},
"status" : "online"
}, {
"agentId" : "6522",
"agentName" : "0c3898000117",
"location" : {
"locationName" : "San Francisco, California, US",
"latitude" : 37.77493,
"longitude" : -122.41942
},
"ipInfo" : {
"ipv6" : "ipv6",
"privateIp" : "172.58.92.31",
"operativeSystemVersion" : "operativeSystemVersion",
"publicIp" : "172.58.92.31"
},
"status" : "online"
} ],
"status" : "No data"
},
"endDate" : "2022-07-18T22:00:54Z",
"_links" : {
"next" : {
"hreflang" : "hreflang",
"templated" : true,
"profile" : "profile",
"name" : "name",
"href" : "https://api.thousandeyes.com/v7/link/to/resource/id",
"type" : "type",
"deprecation" : "deprecation",
"title" : "title"
},
"previous" : {
"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"
}
},
"binSize" : 3600,
"startDate" : "2022-07-17T22:00:54Z"
}
"""
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,
_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'
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,
_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'
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,
_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'
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,
_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'
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,
_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'
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,
_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'
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,
_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 = """
[ {
"isMigratedReport" : false,
"dashboardCreatedBy" : "1",
"_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"
}
},
"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"
} ],
"globalFilterId" : "65babd9bb90bf55b17c96c8d",
"modifiedBy" : 1,
"dashboardModifiedBy" : "1",
"migratedReport" : false,
"isDefaultForAccount" : false,
"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"
} ]
}
},
"accountId" : 1234,
"apiLink" : [ {
"key" : ""
}, {
"key" : ""
} ],
"dashboardId" : "5e1f7a99143ae6004fdc3bb4",
"createdBy" : 1,
"globalOverride" : true,
"modifiedDate" : "2023-05-16 10:14:28",
"isGlobalOverride" : true,
"aid" : "1234",
"dashboardModifiedDate" : "2023-05-16T10:14:28Z"
}, {
"isMigratedReport" : false,
"dashboardCreatedBy" : "1",
"_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"
}
},
"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"
} ],
"globalFilterId" : "65babd9bb90bf55b17c96c8d",
"modifiedBy" : 1,
"dashboardModifiedBy" : "1",
"migratedReport" : false,
"isDefaultForAccount" : false,
"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"
} ]
}
},
"accountId" : 1234,
"apiLink" : [ {
"key" : ""
}, {
"key" : ""
} ],
"dashboardId" : "5e1f7a99143ae6004fdc3bb4",
"createdBy" : 1,
"globalOverride" : true,
"modifiedDate" : "2023-05-16 10:14:28",
"isGlobalOverride" : true,
"aid" : "1234",
"dashboardModifiedDate" : "2023-05-16T10:14:28Z"
} ]
"""
expected_response = json.loads(response_body_json)
response = self.api.get_dashboards(
aid=aid,
_headers=self.te_headers("get_dashboards"),
)
self.assertIsInstance(response, list)
self.assertEqual(len(response), len(expected_response))
for index, element in enumerate(response):
assert_constructed_model_matches_example_json(element, expected_response[index])
def test_get_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 = """
{
"numberOfDataPoints" : 24192,
"cardName" : "Card Name",
"endDate" : "2023-05-16T10:14:28Z",
"_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"
}
},
"cardId" : "lrxxr",
"alertSuppressionWindows" : [ {
"testIds" : [ "281474976710661" ],
"repeatUnit" : "week",
"durationInSeconds" : 7200,
"repeat" : "custom",
"name" : "Test dashboards",
"repeatEvery" : 5,
"id" : "281474976710662",
"startTimes" : [ "2023-05-16T10:14:28Z" ]
}, {
"testIds" : [ "281474976710661" ],
"repeatUnit" : "week",
"durationInSeconds" : 7200,
"repeat" : "custom",
"name" : "Test dashboards",
"repeatEvery" : 5,
"id" : "281474976710662",
"startTimes" : [ "2023-05-16T10:14:28Z" ]
} ],
"binSize" : 3600,
"previousValue" : 500,
"value" : 100,
"startDate" : "2023-05-16T10:14:28Z",
"timestamp" : 1567620000,
"status" : "No data"
}
"""
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 = """
{
"_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"
}
},
"columnId" : "938to",
"alertSuppressionWindows" : [ {
"testIds" : [ "281474976710661" ],
"repeatUnit" : "week",
"durationInSeconds" : 7200,
"repeat" : "custom",
"name" : "Test dashboards",
"repeatEvery" : 5,
"id" : "281474976710662",
"startTimes" : [ "2023-05-16T10:14:28Z" ]
}, {
"testIds" : [ "281474976710661" ],
"repeatUnit" : "week",
"durationInSeconds" : 7200,
"repeat" : "custom",
"name" : "Test dashboards",
"repeatEvery" : 5,
"id" : "281474976710662",
"startTimes" : [ "2023-05-16T10:14:28Z" ]
} ],
"binSize" : 3600,
"points" : [ {
"numberOfDataPoints" : 23304,
"groups" : [ {
"groupProperty" : "COUNTRY",
"groupValue" : "US"
}, {
"groupProperty" : "COUNTRY",
"groupValue" : "US"
} ],
"value" : 100,
"timestamp" : 1567620000
}, {
"numberOfDataPoints" : 23304,
"groups" : [ {
"groupProperty" : "COUNTRY",
"groupValue" : "US"
}, {
"groupProperty" : "COUNTRY",
"groupValue" : "US"
} ],
"value" : 100,
"timestamp" : 1567620000
} ],
"status" : "No data"
}
"""
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 = """
{
"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"
}
"""
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()