mirror of
https://github.com/thousandeyes/thousandeyes-sdk-python.git
synced 2026-08-04 08:56:50 +00:00
Success response bodies now use valid JSON quotes instead of HTML entities, and optional expand enum params are omitted when OpenAPI examples are invalid. Co-authored-by: Cursor <cursoragent@cursor.com>
1094 lines
36 KiB
Python
1094 lines
36 KiB
Python
# coding: utf-8
|
|
|
|
"""
|
|
Endpoint Agent Labels API
|
|
|
|
Manage labels applied to endpoint agents using this API.
|
|
|
|
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
|
|
|
Do not edit the class manually.
|
|
""" # noqa: E501
|
|
|
|
|
|
import json
|
|
import unittest
|
|
import thousandeyes_sdk.endpoint_labels.models
|
|
|
|
from thousandeyes_sdk.core.exceptions import ApiException
|
|
from thousandeyes_sdk.endpoint_labels.api.endpoint_agent_labels_api import EndpointAgentLabelsApi
|
|
from .integration_test_utils import IntegrationTestBase
|
|
from .test_utils import assert_constructed_model_matches_example_json
|
|
|
|
|
|
class TestEndpointAgentLabelsApiIntegration(IntegrationTestBase):
|
|
"""EndpointAgentLabelsApi integration test stubs"""
|
|
|
|
def setUp(self) -> None:
|
|
super().setUp()
|
|
self.api = EndpointAgentLabelsApi(self.api_client)
|
|
|
|
|
|
def test_create_endpoint_label_happy_path(self) -> None:
|
|
"""Integration test for create_endpoint_label success path"""
|
|
request_body_json = """
|
|
|
|
{
|
|
"color" : "#ff3333",
|
|
"matchType" : "and",
|
|
"name" : "Head office meeting rooms",
|
|
"id" : "abc-123-def",
|
|
"filters" : [ {
|
|
"mode" : "in",
|
|
"values" : [ "10.1.1.0/24", "192.168.1.0/24" ],
|
|
"key" : "vpn-client-network"
|
|
}, {
|
|
"mode" : "in",
|
|
"values" : [ "10.1.1.0/24", "192.168.1.0/24" ],
|
|
"key" : "vpn-client-network"
|
|
} ]
|
|
}
|
|
|
|
"""
|
|
label_request = thousandeyes_sdk.endpoint_labels.models.LabelRequest.from_json(request_body_json)
|
|
aid = '1234'
|
|
response_body_json = """
|
|
{
|
|
"color" : "#ff3333",
|
|
"_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"
|
|
}
|
|
},
|
|
"matchType" : "and",
|
|
"name" : "Head office meeting rooms",
|
|
"id" : "abc-123-def",
|
|
"filters" : [ {
|
|
"mode" : "in",
|
|
"values" : [ "10.1.1.0/24", "192.168.1.0/24" ],
|
|
"key" : "vpn-client-network"
|
|
}, {
|
|
"mode" : "in",
|
|
"values" : [ "10.1.1.0/24", "192.168.1.0/24" ],
|
|
"key" : "vpn-client-network"
|
|
} ]
|
|
}
|
|
"""
|
|
expected_response = json.loads(response_body_json)
|
|
response = self.api.create_endpoint_label(
|
|
|
|
aid=aid,
|
|
|
|
label_request=label_request,
|
|
|
|
_headers=self.te_headers("create_endpoint_label"),
|
|
)
|
|
assert_constructed_model_matches_example_json(response, expected_response)
|
|
|
|
|
|
def test_create_endpoint_label_error_400(self) -> None:
|
|
"""Integration test for create_endpoint_label error path (HTTP 400)"""
|
|
request_body_json = """
|
|
|
|
{
|
|
"color" : "#ff3333",
|
|
"matchType" : "and",
|
|
"name" : "Head office meeting rooms",
|
|
"id" : "abc-123-def",
|
|
"filters" : [ {
|
|
"mode" : "in",
|
|
"values" : [ "10.1.1.0/24", "192.168.1.0/24" ],
|
|
"key" : "vpn-client-network"
|
|
}, {
|
|
"mode" : "in",
|
|
"values" : [ "10.1.1.0/24", "192.168.1.0/24" ],
|
|
"key" : "vpn-client-network"
|
|
} ]
|
|
}
|
|
|
|
"""
|
|
label_request = thousandeyes_sdk.endpoint_labels.models.LabelRequest.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_endpoint_label(
|
|
|
|
aid=aid,
|
|
|
|
label_request=label_request,
|
|
|
|
_headers=self.te_headers("create_endpoint_label", error_status="400"),
|
|
)
|
|
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
|
|
|
|
|
|
def test_create_endpoint_label_error_401(self) -> None:
|
|
"""Integration test for create_endpoint_label error path (HTTP 401)"""
|
|
request_body_json = """
|
|
|
|
{
|
|
"color" : "#ff3333",
|
|
"matchType" : "and",
|
|
"name" : "Head office meeting rooms",
|
|
"id" : "abc-123-def",
|
|
"filters" : [ {
|
|
"mode" : "in",
|
|
"values" : [ "10.1.1.0/24", "192.168.1.0/24" ],
|
|
"key" : "vpn-client-network"
|
|
}, {
|
|
"mode" : "in",
|
|
"values" : [ "10.1.1.0/24", "192.168.1.0/24" ],
|
|
"key" : "vpn-client-network"
|
|
} ]
|
|
}
|
|
|
|
"""
|
|
label_request = thousandeyes_sdk.endpoint_labels.models.LabelRequest.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_endpoint_label(
|
|
|
|
aid=aid,
|
|
|
|
label_request=label_request,
|
|
|
|
_headers=self.te_headers("create_endpoint_label", error_status="401"),
|
|
)
|
|
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
|
|
|
|
|
|
def test_create_endpoint_label_error_403(self) -> None:
|
|
"""Integration test for create_endpoint_label error path (HTTP 403)"""
|
|
request_body_json = """
|
|
|
|
{
|
|
"color" : "#ff3333",
|
|
"matchType" : "and",
|
|
"name" : "Head office meeting rooms",
|
|
"id" : "abc-123-def",
|
|
"filters" : [ {
|
|
"mode" : "in",
|
|
"values" : [ "10.1.1.0/24", "192.168.1.0/24" ],
|
|
"key" : "vpn-client-network"
|
|
}, {
|
|
"mode" : "in",
|
|
"values" : [ "10.1.1.0/24", "192.168.1.0/24" ],
|
|
"key" : "vpn-client-network"
|
|
} ]
|
|
}
|
|
|
|
"""
|
|
label_request = thousandeyes_sdk.endpoint_labels.models.LabelRequest.from_json(request_body_json)
|
|
aid = '1234'
|
|
error_body_json = """
|
|
{
|
|
"instance" : "instance",
|
|
"detail" : "detail",
|
|
"type" : "type",
|
|
"title" : "title",
|
|
"status" : 0
|
|
}
|
|
"""
|
|
expected_error = json.loads(error_body_json)
|
|
with self.assertRaises(
|
|
ApiException.exception_class_for_http_status(403)
|
|
) as context:
|
|
self.api.create_endpoint_label(
|
|
|
|
aid=aid,
|
|
|
|
label_request=label_request,
|
|
|
|
_headers=self.te_headers("create_endpoint_label", error_status="403"),
|
|
)
|
|
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
|
|
|
|
|
|
def test_create_endpoint_label_error_429(self) -> None:
|
|
"""Integration test for create_endpoint_label error path (HTTP 429)"""
|
|
request_body_json = """
|
|
|
|
{
|
|
"color" : "#ff3333",
|
|
"matchType" : "and",
|
|
"name" : "Head office meeting rooms",
|
|
"id" : "abc-123-def",
|
|
"filters" : [ {
|
|
"mode" : "in",
|
|
"values" : [ "10.1.1.0/24", "192.168.1.0/24" ],
|
|
"key" : "vpn-client-network"
|
|
}, {
|
|
"mode" : "in",
|
|
"values" : [ "10.1.1.0/24", "192.168.1.0/24" ],
|
|
"key" : "vpn-client-network"
|
|
} ]
|
|
}
|
|
|
|
"""
|
|
label_request = thousandeyes_sdk.endpoint_labels.models.LabelRequest.from_json(request_body_json)
|
|
aid = '1234'
|
|
error_body_json = """
|
|
{
|
|
"instance" : "instance",
|
|
"detail" : "detail",
|
|
"type" : "type",
|
|
"title" : "title",
|
|
"status" : 0
|
|
}
|
|
"""
|
|
expected_error = json.loads(error_body_json)
|
|
with self.assertRaises(
|
|
ApiException.exception_class_for_http_status(429)
|
|
) as context:
|
|
self.api.create_endpoint_label(
|
|
|
|
aid=aid,
|
|
|
|
label_request=label_request,
|
|
|
|
_headers=self.te_headers("create_endpoint_label", error_status="429"),
|
|
)
|
|
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
|
|
|
|
|
|
|
|
|
|
def test_delete_endpoint_label_happy_path(self) -> None:
|
|
"""Integration test for delete_endpoint_label success path"""
|
|
id = 'id_example'
|
|
aid = '1234'
|
|
response = self.api.delete_endpoint_label_with_http_info(
|
|
|
|
id=id,
|
|
|
|
aid=aid,
|
|
|
|
_headers=self.te_headers("delete_endpoint_label"),
|
|
)
|
|
self.assertEqual(204, response.status_code)
|
|
self.assertIsNone(response.data)
|
|
|
|
|
|
def test_delete_endpoint_label_error_401(self) -> None:
|
|
"""Integration test for delete_endpoint_label error path (HTTP 401)"""
|
|
id = 'id_example'
|
|
aid = '1234'
|
|
error_body_json = """
|
|
{
|
|
"error_description" : "Invalid access token",
|
|
"error" : "invalid_token"
|
|
}
|
|
"""
|
|
expected_error = json.loads(error_body_json)
|
|
with self.assertRaises(
|
|
ApiException.exception_class_for_http_status(401)
|
|
) as context:
|
|
self.api.delete_endpoint_label(
|
|
|
|
id=id,
|
|
|
|
aid=aid,
|
|
|
|
_headers=self.te_headers("delete_endpoint_label", error_status="401"),
|
|
)
|
|
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
|
|
|
|
|
|
def test_delete_endpoint_label_error_403(self) -> None:
|
|
"""Integration test for delete_endpoint_label error path (HTTP 403)"""
|
|
id = 'id_example'
|
|
aid = '1234'
|
|
error_body_json = """
|
|
{
|
|
"instance" : "instance",
|
|
"detail" : "detail",
|
|
"type" : "type",
|
|
"title" : "title",
|
|
"status" : 0
|
|
}
|
|
"""
|
|
expected_error = json.loads(error_body_json)
|
|
with self.assertRaises(
|
|
ApiException.exception_class_for_http_status(403)
|
|
) as context:
|
|
self.api.delete_endpoint_label(
|
|
|
|
id=id,
|
|
|
|
aid=aid,
|
|
|
|
_headers=self.te_headers("delete_endpoint_label", error_status="403"),
|
|
)
|
|
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
|
|
|
|
|
|
def test_delete_endpoint_label_error_404(self) -> None:
|
|
"""Integration test for delete_endpoint_label error path (HTTP 404)"""
|
|
id = 'id_example'
|
|
aid = '1234'
|
|
error_body_json = """
|
|
{
|
|
"instance" : "instance",
|
|
"detail" : "detail",
|
|
"type" : "type",
|
|
"title" : "title",
|
|
"status" : 0
|
|
}
|
|
"""
|
|
expected_error = json.loads(error_body_json)
|
|
with self.assertRaises(
|
|
ApiException.exception_class_for_http_status(404)
|
|
) as context:
|
|
self.api.delete_endpoint_label(
|
|
|
|
id=id,
|
|
|
|
aid=aid,
|
|
|
|
_headers=self.te_headers("delete_endpoint_label", error_status="404"),
|
|
)
|
|
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
|
|
|
|
|
|
def test_delete_endpoint_label_error_429(self) -> None:
|
|
"""Integration test for delete_endpoint_label error path (HTTP 429)"""
|
|
id = 'id_example'
|
|
aid = '1234'
|
|
error_body_json = """
|
|
{
|
|
"instance" : "instance",
|
|
"detail" : "detail",
|
|
"type" : "type",
|
|
"title" : "title",
|
|
"status" : 0
|
|
}
|
|
"""
|
|
expected_error = json.loads(error_body_json)
|
|
with self.assertRaises(
|
|
ApiException.exception_class_for_http_status(429)
|
|
) as context:
|
|
self.api.delete_endpoint_label(
|
|
|
|
id=id,
|
|
|
|
aid=aid,
|
|
|
|
_headers=self.te_headers("delete_endpoint_label", error_status="429"),
|
|
)
|
|
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
|
|
|
|
|
|
|
|
|
|
def test_get_endpoint_label_happy_path(self) -> None:
|
|
"""Integration test for get_endpoint_label success path"""
|
|
id = 'id_example'
|
|
aid = '1234'
|
|
response_body_json = """
|
|
{
|
|
"color" : "#ff3333",
|
|
"_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"
|
|
}
|
|
},
|
|
"matchType" : "and",
|
|
"name" : "Head office meeting rooms",
|
|
"id" : "abc-123-def",
|
|
"filters" : [ {
|
|
"mode" : "in",
|
|
"values" : [ "10.1.1.0/24", "192.168.1.0/24" ],
|
|
"key" : "vpn-client-network"
|
|
}, {
|
|
"mode" : "in",
|
|
"values" : [ "10.1.1.0/24", "192.168.1.0/24" ],
|
|
"key" : "vpn-client-network"
|
|
} ]
|
|
}
|
|
"""
|
|
expected_response = json.loads(response_body_json)
|
|
response = self.api.get_endpoint_label(
|
|
|
|
id=id,
|
|
|
|
aid=aid,
|
|
|
|
_headers=self.te_headers("get_endpoint_label"),
|
|
)
|
|
assert_constructed_model_matches_example_json(response, expected_response)
|
|
|
|
|
|
def test_get_endpoint_label_error_401(self) -> None:
|
|
"""Integration test for get_endpoint_label error path (HTTP 401)"""
|
|
id = 'id_example'
|
|
aid = '1234'
|
|
error_body_json = """
|
|
{
|
|
"error_description" : "Invalid access token",
|
|
"error" : "invalid_token"
|
|
}
|
|
"""
|
|
expected_error = json.loads(error_body_json)
|
|
with self.assertRaises(
|
|
ApiException.exception_class_for_http_status(401)
|
|
) as context:
|
|
self.api.get_endpoint_label(
|
|
|
|
id=id,
|
|
|
|
aid=aid,
|
|
|
|
_headers=self.te_headers("get_endpoint_label", error_status="401"),
|
|
)
|
|
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
|
|
|
|
|
|
def test_get_endpoint_label_error_403(self) -> None:
|
|
"""Integration test for get_endpoint_label error path (HTTP 403)"""
|
|
id = 'id_example'
|
|
aid = '1234'
|
|
error_body_json = """
|
|
{
|
|
"instance" : "instance",
|
|
"detail" : "detail",
|
|
"type" : "type",
|
|
"title" : "title",
|
|
"status" : 0
|
|
}
|
|
"""
|
|
expected_error = json.loads(error_body_json)
|
|
with self.assertRaises(
|
|
ApiException.exception_class_for_http_status(403)
|
|
) as context:
|
|
self.api.get_endpoint_label(
|
|
|
|
id=id,
|
|
|
|
aid=aid,
|
|
|
|
_headers=self.te_headers("get_endpoint_label", error_status="403"),
|
|
)
|
|
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
|
|
|
|
|
|
def test_get_endpoint_label_error_404(self) -> None:
|
|
"""Integration test for get_endpoint_label error path (HTTP 404)"""
|
|
id = 'id_example'
|
|
aid = '1234'
|
|
error_body_json = """
|
|
{
|
|
"instance" : "instance",
|
|
"detail" : "detail",
|
|
"type" : "type",
|
|
"title" : "title",
|
|
"status" : 0
|
|
}
|
|
"""
|
|
expected_error = json.loads(error_body_json)
|
|
with self.assertRaises(
|
|
ApiException.exception_class_for_http_status(404)
|
|
) as context:
|
|
self.api.get_endpoint_label(
|
|
|
|
id=id,
|
|
|
|
aid=aid,
|
|
|
|
_headers=self.te_headers("get_endpoint_label", error_status="404"),
|
|
)
|
|
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
|
|
|
|
|
|
def test_get_endpoint_label_error_429(self) -> None:
|
|
"""Integration test for get_endpoint_label error path (HTTP 429)"""
|
|
id = 'id_example'
|
|
aid = '1234'
|
|
error_body_json = """
|
|
{
|
|
"instance" : "instance",
|
|
"detail" : "detail",
|
|
"type" : "type",
|
|
"title" : "title",
|
|
"status" : 0
|
|
}
|
|
"""
|
|
expected_error = json.loads(error_body_json)
|
|
with self.assertRaises(
|
|
ApiException.exception_class_for_http_status(429)
|
|
) as context:
|
|
self.api.get_endpoint_label(
|
|
|
|
id=id,
|
|
|
|
aid=aid,
|
|
|
|
_headers=self.te_headers("get_endpoint_label", error_status="429"),
|
|
)
|
|
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
|
|
|
|
|
|
|
|
|
|
def test_get_endpoint_labels_happy_path(self) -> None:
|
|
"""Integration test for get_endpoint_labels success path"""
|
|
max = 5
|
|
cursor = 'cursor_example'
|
|
aid = '1234'
|
|
response_body_json = """
|
|
{
|
|
"_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"
|
|
},
|
|
"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"
|
|
}
|
|
},
|
|
"labels" : [ {
|
|
"color" : "#ff3333",
|
|
"_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"
|
|
}
|
|
},
|
|
"matchType" : "and",
|
|
"name" : "Head office meeting rooms",
|
|
"id" : "abc-123-def",
|
|
"filters" : [ {
|
|
"mode" : "in",
|
|
"values" : [ "10.1.1.0/24", "192.168.1.0/24" ],
|
|
"key" : "vpn-client-network"
|
|
}, {
|
|
"mode" : "in",
|
|
"values" : [ "10.1.1.0/24", "192.168.1.0/24" ],
|
|
"key" : "vpn-client-network"
|
|
} ]
|
|
}, {
|
|
"color" : "#ff3333",
|
|
"_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"
|
|
}
|
|
},
|
|
"matchType" : "and",
|
|
"name" : "Head office meeting rooms",
|
|
"id" : "abc-123-def",
|
|
"filters" : [ {
|
|
"mode" : "in",
|
|
"values" : [ "10.1.1.0/24", "192.168.1.0/24" ],
|
|
"key" : "vpn-client-network"
|
|
}, {
|
|
"mode" : "in",
|
|
"values" : [ "10.1.1.0/24", "192.168.1.0/24" ],
|
|
"key" : "vpn-client-network"
|
|
} ]
|
|
} ]
|
|
}
|
|
"""
|
|
expected_response = json.loads(response_body_json)
|
|
response = self.api.get_endpoint_labels(
|
|
|
|
max=max,
|
|
|
|
cursor=cursor,
|
|
|
|
aid=aid,
|
|
|
|
_headers=self.te_headers("get_endpoint_labels"),
|
|
)
|
|
assert_constructed_model_matches_example_json(response, expected_response)
|
|
|
|
|
|
def test_get_endpoint_labels_error_401(self) -> None:
|
|
"""Integration test for get_endpoint_labels error path (HTTP 401)"""
|
|
max = 5
|
|
cursor = 'cursor_example'
|
|
aid = '1234'
|
|
error_body_json = """
|
|
{
|
|
"error_description" : "Invalid access token",
|
|
"error" : "invalid_token"
|
|
}
|
|
"""
|
|
expected_error = json.loads(error_body_json)
|
|
with self.assertRaises(
|
|
ApiException.exception_class_for_http_status(401)
|
|
) as context:
|
|
self.api.get_endpoint_labels(
|
|
|
|
max=max,
|
|
|
|
cursor=cursor,
|
|
|
|
aid=aid,
|
|
|
|
_headers=self.te_headers("get_endpoint_labels", error_status="401"),
|
|
)
|
|
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
|
|
|
|
|
|
def test_get_endpoint_labels_error_403(self) -> None:
|
|
"""Integration test for get_endpoint_labels error path (HTTP 403)"""
|
|
max = 5
|
|
cursor = 'cursor_example'
|
|
aid = '1234'
|
|
error_body_json = """
|
|
{
|
|
"instance" : "instance",
|
|
"detail" : "detail",
|
|
"type" : "type",
|
|
"title" : "title",
|
|
"status" : 0
|
|
}
|
|
"""
|
|
expected_error = json.loads(error_body_json)
|
|
with self.assertRaises(
|
|
ApiException.exception_class_for_http_status(403)
|
|
) as context:
|
|
self.api.get_endpoint_labels(
|
|
|
|
max=max,
|
|
|
|
cursor=cursor,
|
|
|
|
aid=aid,
|
|
|
|
_headers=self.te_headers("get_endpoint_labels", error_status="403"),
|
|
)
|
|
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
|
|
|
|
|
|
def test_get_endpoint_labels_error_429(self) -> None:
|
|
"""Integration test for get_endpoint_labels error path (HTTP 429)"""
|
|
max = 5
|
|
cursor = 'cursor_example'
|
|
aid = '1234'
|
|
error_body_json = """
|
|
{
|
|
"instance" : "instance",
|
|
"detail" : "detail",
|
|
"type" : "type",
|
|
"title" : "title",
|
|
"status" : 0
|
|
}
|
|
"""
|
|
expected_error = json.loads(error_body_json)
|
|
with self.assertRaises(
|
|
ApiException.exception_class_for_http_status(429)
|
|
) as context:
|
|
self.api.get_endpoint_labels(
|
|
|
|
max=max,
|
|
|
|
cursor=cursor,
|
|
|
|
aid=aid,
|
|
|
|
_headers=self.te_headers("get_endpoint_labels", error_status="429"),
|
|
)
|
|
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
|
|
|
|
|
|
|
|
|
|
def test_update_endpoint_label_happy_path(self) -> None:
|
|
"""Integration test for update_endpoint_label success path"""
|
|
request_body_json = """
|
|
|
|
{
|
|
"color" : "#ff3333",
|
|
"matchType" : "and",
|
|
"name" : "Head office meeting rooms",
|
|
"id" : "abc-123-def",
|
|
"filters" : [ {
|
|
"mode" : "in",
|
|
"values" : [ "10.1.1.0/24", "192.168.1.0/24" ],
|
|
"key" : "vpn-client-network"
|
|
}, {
|
|
"mode" : "in",
|
|
"values" : [ "10.1.1.0/24", "192.168.1.0/24" ],
|
|
"key" : "vpn-client-network"
|
|
} ]
|
|
}
|
|
|
|
"""
|
|
label = thousandeyes_sdk.endpoint_labels.models.Label.from_json(request_body_json)
|
|
id = 'id_example'
|
|
aid = '1234'
|
|
response_body_json = """
|
|
{
|
|
"color" : "#ff3333",
|
|
"_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"
|
|
}
|
|
},
|
|
"matchType" : "and",
|
|
"name" : "Head office meeting rooms",
|
|
"id" : "abc-123-def",
|
|
"filters" : [ {
|
|
"mode" : "in",
|
|
"values" : [ "10.1.1.0/24", "192.168.1.0/24" ],
|
|
"key" : "vpn-client-network"
|
|
}, {
|
|
"mode" : "in",
|
|
"values" : [ "10.1.1.0/24", "192.168.1.0/24" ],
|
|
"key" : "vpn-client-network"
|
|
} ]
|
|
}
|
|
"""
|
|
expected_response = json.loads(response_body_json)
|
|
response = self.api.update_endpoint_label(
|
|
|
|
id=id,
|
|
|
|
aid=aid,
|
|
|
|
label=label,
|
|
|
|
_headers=self.te_headers("update_endpoint_label"),
|
|
)
|
|
assert_constructed_model_matches_example_json(response, expected_response)
|
|
|
|
|
|
def test_update_endpoint_label_error_400(self) -> None:
|
|
"""Integration test for update_endpoint_label error path (HTTP 400)"""
|
|
request_body_json = """
|
|
|
|
{
|
|
"color" : "#ff3333",
|
|
"matchType" : "and",
|
|
"name" : "Head office meeting rooms",
|
|
"id" : "abc-123-def",
|
|
"filters" : [ {
|
|
"mode" : "in",
|
|
"values" : [ "10.1.1.0/24", "192.168.1.0/24" ],
|
|
"key" : "vpn-client-network"
|
|
}, {
|
|
"mode" : "in",
|
|
"values" : [ "10.1.1.0/24", "192.168.1.0/24" ],
|
|
"key" : "vpn-client-network"
|
|
} ]
|
|
}
|
|
|
|
"""
|
|
label = thousandeyes_sdk.endpoint_labels.models.Label.from_json(request_body_json)
|
|
id = 'id_example'
|
|
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_endpoint_label(
|
|
|
|
id=id,
|
|
|
|
aid=aid,
|
|
|
|
label=label,
|
|
|
|
_headers=self.te_headers("update_endpoint_label", error_status="400"),
|
|
)
|
|
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
|
|
|
|
|
|
def test_update_endpoint_label_error_401(self) -> None:
|
|
"""Integration test for update_endpoint_label error path (HTTP 401)"""
|
|
request_body_json = """
|
|
|
|
{
|
|
"color" : "#ff3333",
|
|
"matchType" : "and",
|
|
"name" : "Head office meeting rooms",
|
|
"id" : "abc-123-def",
|
|
"filters" : [ {
|
|
"mode" : "in",
|
|
"values" : [ "10.1.1.0/24", "192.168.1.0/24" ],
|
|
"key" : "vpn-client-network"
|
|
}, {
|
|
"mode" : "in",
|
|
"values" : [ "10.1.1.0/24", "192.168.1.0/24" ],
|
|
"key" : "vpn-client-network"
|
|
} ]
|
|
}
|
|
|
|
"""
|
|
label = thousandeyes_sdk.endpoint_labels.models.Label.from_json(request_body_json)
|
|
id = 'id_example'
|
|
aid = '1234'
|
|
error_body_json = """
|
|
{
|
|
"error_description" : "Invalid access token",
|
|
"error" : "invalid_token"
|
|
}
|
|
"""
|
|
expected_error = json.loads(error_body_json)
|
|
with self.assertRaises(
|
|
ApiException.exception_class_for_http_status(401)
|
|
) as context:
|
|
self.api.update_endpoint_label(
|
|
|
|
id=id,
|
|
|
|
aid=aid,
|
|
|
|
label=label,
|
|
|
|
_headers=self.te_headers("update_endpoint_label", error_status="401"),
|
|
)
|
|
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
|
|
|
|
|
|
def test_update_endpoint_label_error_403(self) -> None:
|
|
"""Integration test for update_endpoint_label error path (HTTP 403)"""
|
|
request_body_json = """
|
|
|
|
{
|
|
"color" : "#ff3333",
|
|
"matchType" : "and",
|
|
"name" : "Head office meeting rooms",
|
|
"id" : "abc-123-def",
|
|
"filters" : [ {
|
|
"mode" : "in",
|
|
"values" : [ "10.1.1.0/24", "192.168.1.0/24" ],
|
|
"key" : "vpn-client-network"
|
|
}, {
|
|
"mode" : "in",
|
|
"values" : [ "10.1.1.0/24", "192.168.1.0/24" ],
|
|
"key" : "vpn-client-network"
|
|
} ]
|
|
}
|
|
|
|
"""
|
|
label = thousandeyes_sdk.endpoint_labels.models.Label.from_json(request_body_json)
|
|
id = 'id_example'
|
|
aid = '1234'
|
|
error_body_json = """
|
|
{
|
|
"instance" : "instance",
|
|
"detail" : "detail",
|
|
"type" : "type",
|
|
"title" : "title",
|
|
"status" : 0
|
|
}
|
|
"""
|
|
expected_error = json.loads(error_body_json)
|
|
with self.assertRaises(
|
|
ApiException.exception_class_for_http_status(403)
|
|
) as context:
|
|
self.api.update_endpoint_label(
|
|
|
|
id=id,
|
|
|
|
aid=aid,
|
|
|
|
label=label,
|
|
|
|
_headers=self.te_headers("update_endpoint_label", error_status="403"),
|
|
)
|
|
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
|
|
|
|
|
|
def test_update_endpoint_label_error_404(self) -> None:
|
|
"""Integration test for update_endpoint_label error path (HTTP 404)"""
|
|
request_body_json = """
|
|
|
|
{
|
|
"color" : "#ff3333",
|
|
"matchType" : "and",
|
|
"name" : "Head office meeting rooms",
|
|
"id" : "abc-123-def",
|
|
"filters" : [ {
|
|
"mode" : "in",
|
|
"values" : [ "10.1.1.0/24", "192.168.1.0/24" ],
|
|
"key" : "vpn-client-network"
|
|
}, {
|
|
"mode" : "in",
|
|
"values" : [ "10.1.1.0/24", "192.168.1.0/24" ],
|
|
"key" : "vpn-client-network"
|
|
} ]
|
|
}
|
|
|
|
"""
|
|
label = thousandeyes_sdk.endpoint_labels.models.Label.from_json(request_body_json)
|
|
id = 'id_example'
|
|
aid = '1234'
|
|
error_body_json = """
|
|
{
|
|
"instance" : "instance",
|
|
"detail" : "detail",
|
|
"type" : "type",
|
|
"title" : "title",
|
|
"status" : 0
|
|
}
|
|
"""
|
|
expected_error = json.loads(error_body_json)
|
|
with self.assertRaises(
|
|
ApiException.exception_class_for_http_status(404)
|
|
) as context:
|
|
self.api.update_endpoint_label(
|
|
|
|
id=id,
|
|
|
|
aid=aid,
|
|
|
|
label=label,
|
|
|
|
_headers=self.te_headers("update_endpoint_label", error_status="404"),
|
|
)
|
|
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
|
|
|
|
|
|
def test_update_endpoint_label_error_429(self) -> None:
|
|
"""Integration test for update_endpoint_label error path (HTTP 429)"""
|
|
request_body_json = """
|
|
|
|
{
|
|
"color" : "#ff3333",
|
|
"matchType" : "and",
|
|
"name" : "Head office meeting rooms",
|
|
"id" : "abc-123-def",
|
|
"filters" : [ {
|
|
"mode" : "in",
|
|
"values" : [ "10.1.1.0/24", "192.168.1.0/24" ],
|
|
"key" : "vpn-client-network"
|
|
}, {
|
|
"mode" : "in",
|
|
"values" : [ "10.1.1.0/24", "192.168.1.0/24" ],
|
|
"key" : "vpn-client-network"
|
|
} ]
|
|
}
|
|
|
|
"""
|
|
label = thousandeyes_sdk.endpoint_labels.models.Label.from_json(request_body_json)
|
|
id = 'id_example'
|
|
aid = '1234'
|
|
error_body_json = """
|
|
{
|
|
"instance" : "instance",
|
|
"detail" : "detail",
|
|
"type" : "type",
|
|
"title" : "title",
|
|
"status" : 0
|
|
}
|
|
"""
|
|
expected_error = json.loads(error_body_json)
|
|
with self.assertRaises(
|
|
ApiException.exception_class_for_http_status(429)
|
|
) as context:
|
|
self.api.update_endpoint_label(
|
|
|
|
id=id,
|
|
|
|
aid=aid,
|
|
|
|
label=label,
|
|
|
|
_headers=self.te_headers("update_endpoint_label", error_status="429"),
|
|
)
|
|
assert_constructed_model_matches_example_json(context.exception.data, expected_error)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|