mirror of
https://github.com/thousandeyes/thousandeyes-sdk-python.git
synced 2025-12-05 22:16:52 +00:00
Some checks failed
Python CI / build (push) Has been cancelled
* [GitHub Bot] Generated python SDK * Updated README --------- Co-authored-by: API Team <api-team@thousandeyes.com> Co-authored-by: Miguel Pragosa <mpragosa@thousandeyes.com>
730 lines
37 KiB
Python
730 lines
37 KiB
Python
# coding: utf-8
|
|
|
|
"""
|
|
Event Detection API
|
|
|
|
Event detection occurs when ThousandEyes identifies that error signals related to a component (proxy, network node, AS, server etc) have deviated from the baselines established by events. * To determine this, ThousandEyes takes the test results from all accounts groups within an organization, and analyzes that data. * Noisy test results (those that have too many errors in a short window) are removed until they stabilize, and the rest of the results are tagged with the components associated with that test result (for example, proxy, network, or server). * Next, any increase in failures from the test results and each component helps in determining the problem domain and which component may be at fault. * When this failure rate increases beyond a pre-defined threshold (set by the algorithm), an event is triggered and an email notification is sent to the user (if they've enabled email alerts). With the Events API, you can perform the following tasks on the ThousandEyes platform: * **Retrieve Events**: Obtain a list of events and detailed information for each event. For more information about events, see [Event Detection](https://docs.thousandeyes.com/product-documentation/event-detection).
|
|
|
|
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
|
|
|
Do not edit the class manually.
|
|
""" # noqa: E501
|
|
|
|
import warnings
|
|
from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt
|
|
from typing import Any, Dict, List, Optional, Tuple, Union
|
|
from typing_extensions import Annotated
|
|
from importlib.metadata import version
|
|
|
|
import thousandeyes_sdk.event_detection.models
|
|
|
|
from datetime import datetime
|
|
from pydantic import Field, StrictInt, StrictStr, field_validator
|
|
from typing import Optional
|
|
from typing_extensions import Annotated
|
|
from thousandeyes_sdk.event_detection.models.event_detail import EventDetail
|
|
from thousandeyes_sdk.event_detection.models.events import Events
|
|
|
|
from thousandeyes_sdk.core.api_client import ApiClient, RequestSerialized
|
|
from thousandeyes_sdk.core.api_response import ApiResponse
|
|
from thousandeyes_sdk.core.rest import RESTResponseType
|
|
|
|
|
|
class EventsApi:
|
|
"""NOTE: This class is auto generated by OpenAPI Generator
|
|
Ref: https://openapi-generator.tech
|
|
|
|
Do not edit the class manually.
|
|
"""
|
|
|
|
def __init__(self, api_client=None) -> None:
|
|
if api_client is None:
|
|
api_client = ApiClient.get_default()
|
|
api_client.user_agent = "ThousandEyesSDK-Python/{0}".format(version("thousandeyes-sdk-event-detection"))
|
|
self.api_client = api_client
|
|
|
|
|
|
@validate_call
|
|
def get_event(
|
|
self,
|
|
id: Annotated[StrictStr, Field(description="Unique event ID.")],
|
|
aid: Annotated[Optional[StrictStr], Field(description="A unique identifier associated with your account group. You can retrieve your `AccountGroupId` from the `/account-groups` endpoint. Note that you must be assigned to the target account group. Specifying this parameter without being assigned to the target account group will result in an error response.")] = None,
|
|
_request_timeout: Union[
|
|
None,
|
|
Annotated[StrictFloat, Field(gt=0)],
|
|
Tuple[
|
|
Annotated[StrictFloat, Field(gt=0)],
|
|
Annotated[StrictFloat, Field(gt=0)]
|
|
]
|
|
] = None,
|
|
_request_auth: Optional[Dict[StrictStr, Any]] = None,
|
|
_content_type: Optional[StrictStr] = None,
|
|
_headers: Optional[Dict[StrictStr, Any]] = None,
|
|
_host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
|
|
) -> EventDetail:
|
|
"""Retrieve event
|
|
|
|
Returns detailed information about an event using its ID.
|
|
|
|
:param id: Unique event ID. (required)
|
|
:type id: str
|
|
:param aid: A unique identifier associated with your account group. You can retrieve your `AccountGroupId` from the `/account-groups` endpoint. Note that you must be assigned to the target account group. Specifying this parameter without being assigned to the target account group will result in an error response.
|
|
:type aid: str
|
|
:param _request_timeout: timeout setting for this request. If one
|
|
number provided, it will be total request
|
|
timeout. It can also be a pair (tuple) of
|
|
(connection, read) timeouts.
|
|
:type _request_timeout: int, tuple(int, int), optional
|
|
:param _request_auth: set to override the auth_settings for an a single
|
|
request; this effectively ignores the
|
|
authentication in the spec for a single request.
|
|
:type _request_auth: dict, optional
|
|
:param _content_type: force content-type for the request.
|
|
:type _content_type: str, Optional
|
|
:param _headers: set to override the headers for a single
|
|
request; this effectively ignores the headers
|
|
in the spec for a single request.
|
|
:type _headers: dict, optional
|
|
:param _host_index: set to override the host_index for a single
|
|
request; this effectively ignores the host_index
|
|
in the spec for a single request.
|
|
:type _host_index: int, optional
|
|
:return: Returns the result object.
|
|
""" # noqa: E501
|
|
|
|
_param = self._get_event_serialize(
|
|
id=id,
|
|
aid=aid,
|
|
_request_auth=_request_auth,
|
|
_content_type=_content_type,
|
|
_headers=_headers,
|
|
_host_index=_host_index
|
|
)
|
|
|
|
_response_types_map: Dict[str, Optional[str]] = {
|
|
'200': "EventDetail",
|
|
'401': "UnauthorizedError",
|
|
'403': "Error",
|
|
'404': "Error",
|
|
'429': "Error",
|
|
'500': "Error",
|
|
'502': "Error",
|
|
}
|
|
response_data = self.api_client.call_api(
|
|
*_param,
|
|
_request_timeout=_request_timeout
|
|
)
|
|
response_data.read()
|
|
return self.api_client.response_deserialize(
|
|
response_data=response_data,
|
|
response_types_map=_response_types_map,
|
|
models=thousandeyes_sdk.event_detection.models,
|
|
).data
|
|
|
|
|
|
@validate_call
|
|
def get_event_with_http_info(
|
|
self,
|
|
id: Annotated[StrictStr, Field(description="Unique event ID.")],
|
|
aid: Annotated[Optional[StrictStr], Field(description="A unique identifier associated with your account group. You can retrieve your `AccountGroupId` from the `/account-groups` endpoint. Note that you must be assigned to the target account group. Specifying this parameter without being assigned to the target account group will result in an error response.")] = None,
|
|
_request_timeout: Union[
|
|
None,
|
|
Annotated[StrictFloat, Field(gt=0)],
|
|
Tuple[
|
|
Annotated[StrictFloat, Field(gt=0)],
|
|
Annotated[StrictFloat, Field(gt=0)]
|
|
]
|
|
] = None,
|
|
_request_auth: Optional[Dict[StrictStr, Any]] = None,
|
|
_content_type: Optional[StrictStr] = None,
|
|
_headers: Optional[Dict[StrictStr, Any]] = None,
|
|
_host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
|
|
) -> ApiResponse[EventDetail]:
|
|
"""Retrieve event
|
|
|
|
Returns detailed information about an event using its ID.
|
|
|
|
:param id: Unique event ID. (required)
|
|
:type id: str
|
|
:param aid: A unique identifier associated with your account group. You can retrieve your `AccountGroupId` from the `/account-groups` endpoint. Note that you must be assigned to the target account group. Specifying this parameter without being assigned to the target account group will result in an error response.
|
|
:type aid: str
|
|
:param _request_timeout: timeout setting for this request. If one
|
|
number provided, it will be total request
|
|
timeout. It can also be a pair (tuple) of
|
|
(connection, read) timeouts.
|
|
:type _request_timeout: int, tuple(int, int), optional
|
|
:param _request_auth: set to override the auth_settings for an a single
|
|
request; this effectively ignores the
|
|
authentication in the spec for a single request.
|
|
:type _request_auth: dict, optional
|
|
:param _content_type: force content-type for the request.
|
|
:type _content_type: str, Optional
|
|
:param _headers: set to override the headers for a single
|
|
request; this effectively ignores the headers
|
|
in the spec for a single request.
|
|
:type _headers: dict, optional
|
|
:param _host_index: set to override the host_index for a single
|
|
request; this effectively ignores the host_index
|
|
in the spec for a single request.
|
|
:type _host_index: int, optional
|
|
:return: Returns the result object.
|
|
""" # noqa: E501
|
|
|
|
_param = self._get_event_serialize(
|
|
id=id,
|
|
aid=aid,
|
|
_request_auth=_request_auth,
|
|
_content_type=_content_type,
|
|
_headers=_headers,
|
|
_host_index=_host_index
|
|
)
|
|
|
|
_response_types_map: Dict[str, Optional[str]] = {
|
|
'200': "EventDetail",
|
|
'401': "UnauthorizedError",
|
|
'403': "Error",
|
|
'404': "Error",
|
|
'429': "Error",
|
|
'500': "Error",
|
|
'502': "Error",
|
|
}
|
|
response_data = self.api_client.call_api(
|
|
*_param,
|
|
_request_timeout=_request_timeout
|
|
)
|
|
response_data.read()
|
|
return self.api_client.response_deserialize(
|
|
response_data=response_data,
|
|
response_types_map=_response_types_map,
|
|
models=thousandeyes_sdk.event_detection.models,
|
|
)
|
|
|
|
|
|
@validate_call
|
|
def get_event_without_preload_content(
|
|
self,
|
|
id: Annotated[StrictStr, Field(description="Unique event ID.")],
|
|
aid: Annotated[Optional[StrictStr], Field(description="A unique identifier associated with your account group. You can retrieve your `AccountGroupId` from the `/account-groups` endpoint. Note that you must be assigned to the target account group. Specifying this parameter without being assigned to the target account group will result in an error response.")] = None,
|
|
_request_timeout: Union[
|
|
None,
|
|
Annotated[StrictFloat, Field(gt=0)],
|
|
Tuple[
|
|
Annotated[StrictFloat, Field(gt=0)],
|
|
Annotated[StrictFloat, Field(gt=0)]
|
|
]
|
|
] = None,
|
|
_request_auth: Optional[Dict[StrictStr, Any]] = None,
|
|
_content_type: Optional[StrictStr] = None,
|
|
_headers: Optional[Dict[StrictStr, Any]] = None,
|
|
_host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
|
|
) -> RESTResponseType:
|
|
"""Retrieve event
|
|
|
|
Returns detailed information about an event using its ID.
|
|
|
|
:param id: Unique event ID. (required)
|
|
:type id: str
|
|
:param aid: A unique identifier associated with your account group. You can retrieve your `AccountGroupId` from the `/account-groups` endpoint. Note that you must be assigned to the target account group. Specifying this parameter without being assigned to the target account group will result in an error response.
|
|
:type aid: str
|
|
:param _request_timeout: timeout setting for this request. If one
|
|
number provided, it will be total request
|
|
timeout. It can also be a pair (tuple) of
|
|
(connection, read) timeouts.
|
|
:type _request_timeout: int, tuple(int, int), optional
|
|
:param _request_auth: set to override the auth_settings for an a single
|
|
request; this effectively ignores the
|
|
authentication in the spec for a single request.
|
|
:type _request_auth: dict, optional
|
|
:param _content_type: force content-type for the request.
|
|
:type _content_type: str, Optional
|
|
:param _headers: set to override the headers for a single
|
|
request; this effectively ignores the headers
|
|
in the spec for a single request.
|
|
:type _headers: dict, optional
|
|
:param _host_index: set to override the host_index for a single
|
|
request; this effectively ignores the host_index
|
|
in the spec for a single request.
|
|
:type _host_index: int, optional
|
|
:return: Returns the result object.
|
|
""" # noqa: E501
|
|
|
|
_param = self._get_event_serialize(
|
|
id=id,
|
|
aid=aid,
|
|
_request_auth=_request_auth,
|
|
_content_type=_content_type,
|
|
_headers=_headers,
|
|
_host_index=_host_index
|
|
)
|
|
|
|
_response_types_map: Dict[str, Optional[str]] = {
|
|
'200': "EventDetail",
|
|
'401': "UnauthorizedError",
|
|
'403': "Error",
|
|
'404': "Error",
|
|
'429': "Error",
|
|
'500': "Error",
|
|
'502': "Error",
|
|
}
|
|
response_data = self.api_client.call_api(
|
|
*_param,
|
|
_request_timeout=_request_timeout
|
|
)
|
|
return response_data.response
|
|
|
|
|
|
def _get_event_serialize(
|
|
self,
|
|
id,
|
|
aid,
|
|
_request_auth,
|
|
_content_type,
|
|
_headers,
|
|
_host_index,
|
|
) -> RequestSerialized:
|
|
|
|
_host = None
|
|
|
|
_collection_formats: Dict[str, str] = {
|
|
}
|
|
|
|
_path_params: Dict[str, str] = {}
|
|
_query_params: List[Tuple[str, str]] = []
|
|
_header_params: Dict[str, Optional[str]] = _headers or {}
|
|
_form_params: List[Tuple[str, str]] = []
|
|
_files: Dict[str, Union[str, bytes]] = {}
|
|
_body_params: Optional[bytes] = None
|
|
|
|
# process the path parameters
|
|
if id is not None:
|
|
_path_params['id'] = id
|
|
# process the query parameters
|
|
if aid is not None:
|
|
|
|
_query_params.append(('aid', aid))
|
|
|
|
# process the header parameters
|
|
# process the form parameters
|
|
# process the body parameter
|
|
|
|
|
|
# set the HTTP header `Accept`
|
|
_header_params['Accept'] = self.api_client.select_header_accept(
|
|
[
|
|
'application/hal+json',
|
|
'application/json',
|
|
'application/problem+json'
|
|
]
|
|
)
|
|
|
|
|
|
# authentication setting
|
|
_auth_settings: List[str] = [
|
|
'BearerAuth'
|
|
]
|
|
|
|
return self.api_client.param_serialize(
|
|
method='GET',
|
|
resource_path='/v7/events/{id}',
|
|
path_params=_path_params,
|
|
query_params=_query_params,
|
|
header_params=_header_params,
|
|
body=_body_params,
|
|
post_params=_form_params,
|
|
files=_files,
|
|
auth_settings=_auth_settings,
|
|
collection_formats=_collection_formats,
|
|
_host=_host,
|
|
_request_auth=_request_auth
|
|
)
|
|
|
|
|
|
|
|
|
|
@validate_call
|
|
def get_events(
|
|
self,
|
|
aid: Annotated[Optional[StrictStr], Field(description="A unique identifier associated with your account group. You can retrieve your `AccountGroupId` from the `/account-groups` endpoint. Note that you must be assigned to the target account group. Specifying this parameter without being assigned to the target account group will result in an error response.")] = None,
|
|
window: Annotated[Optional[Annotated[str, Field(strict=True)]], Field(description="A dynamic time interval up to the current time of the request. Specify the interval as a number followed by an optional type: `s` for seconds (default if no type is specified), `m` for minutes, `h` for hours, `d` for days, and `w` for weeks. For a precise date range, use `startDate` and `endDate`.")] = None,
|
|
start_date: Annotated[Optional[datetime], Field(description="Use with the `endDate` parameter. Include the complete time (hours, minutes, and seconds) in UTC time zone, following the ISO 8601 date-time format. See the example for reference. Please note that this parameter can't be used with `window`.")] = None,
|
|
end_date: Annotated[Optional[datetime], Field(description="Defaults to current time the request is made. Use with the `startDate` parameter. Include the complete time (hours, minutes, and seconds) in UTC time zone, following the ISO 8601 date-time format. See the example for reference. Please note that this parameter can't be used with `window`.")] = None,
|
|
max: Annotated[Optional[StrictInt], Field(description="(Optional) Maximum number of objects to return.")] = None,
|
|
cursor: Annotated[Optional[StrictStr], Field(description="(Optional) Opaque cursor used for pagination. Clients should use `next` value from `_links` instead of this parameter.")] = None,
|
|
_request_timeout: Union[
|
|
None,
|
|
Annotated[StrictFloat, Field(gt=0)],
|
|
Tuple[
|
|
Annotated[StrictFloat, Field(gt=0)],
|
|
Annotated[StrictFloat, Field(gt=0)]
|
|
]
|
|
] = None,
|
|
_request_auth: Optional[Dict[StrictStr, Any]] = None,
|
|
_content_type: Optional[StrictStr] = None,
|
|
_headers: Optional[Dict[StrictStr, Any]] = None,
|
|
_host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
|
|
) -> Events:
|
|
"""List events
|
|
|
|
Retrieves a list of events within the specified time window. If no events are active during the specified time range, an empty response is returned. **Note**: You must provide either a time window using the `window` parameter or specify `startDate` and `endDate`.
|
|
|
|
:param aid: A unique identifier associated with your account group. You can retrieve your `AccountGroupId` from the `/account-groups` endpoint. Note that you must be assigned to the target account group. Specifying this parameter without being assigned to the target account group will result in an error response.
|
|
:type aid: str
|
|
:param window: A dynamic time interval up to the current time of the request. Specify the interval as a number followed by an optional type: `s` for seconds (default if no type is specified), `m` for minutes, `h` for hours, `d` for days, and `w` for weeks. For a precise date range, use `startDate` and `endDate`.
|
|
:type window: str
|
|
:param start_date: Use with the `endDate` parameter. Include the complete time (hours, minutes, and seconds) in UTC time zone, following the ISO 8601 date-time format. See the example for reference. Please note that this parameter can't be used with `window`.
|
|
:type start_date: datetime
|
|
:param end_date: Defaults to current time the request is made. Use with the `startDate` parameter. Include the complete time (hours, minutes, and seconds) in UTC time zone, following the ISO 8601 date-time format. See the example for reference. Please note that this parameter can't be used with `window`.
|
|
:type end_date: datetime
|
|
:param max: (Optional) Maximum number of objects to return.
|
|
:type max: int
|
|
:param cursor: (Optional) Opaque cursor used for pagination. Clients should use `next` value from `_links` instead of this parameter.
|
|
:type cursor: str
|
|
:param _request_timeout: timeout setting for this request. If one
|
|
number provided, it will be total request
|
|
timeout. It can also be a pair (tuple) of
|
|
(connection, read) timeouts.
|
|
:type _request_timeout: int, tuple(int, int), optional
|
|
:param _request_auth: set to override the auth_settings for an a single
|
|
request; this effectively ignores the
|
|
authentication in the spec for a single request.
|
|
:type _request_auth: dict, optional
|
|
:param _content_type: force content-type for the request.
|
|
:type _content_type: str, Optional
|
|
:param _headers: set to override the headers for a single
|
|
request; this effectively ignores the headers
|
|
in the spec for a single request.
|
|
:type _headers: dict, optional
|
|
:param _host_index: set to override the host_index for a single
|
|
request; this effectively ignores the host_index
|
|
in the spec for a single request.
|
|
:type _host_index: int, optional
|
|
:return: Returns the result object.
|
|
""" # noqa: E501
|
|
|
|
_param = self._get_events_serialize(
|
|
aid=aid,
|
|
window=window,
|
|
start_date=start_date,
|
|
end_date=end_date,
|
|
max=max,
|
|
cursor=cursor,
|
|
_request_auth=_request_auth,
|
|
_content_type=_content_type,
|
|
_headers=_headers,
|
|
_host_index=_host_index
|
|
)
|
|
|
|
_response_types_map: Dict[str, Optional[str]] = {
|
|
'200': "Events",
|
|
'400': "ValidationError",
|
|
'401': "UnauthorizedError",
|
|
'403': "Error",
|
|
'404': "Error",
|
|
'429': "Error",
|
|
'500': "Error",
|
|
'502': "Error",
|
|
}
|
|
response_data = self.api_client.call_api(
|
|
*_param,
|
|
_request_timeout=_request_timeout
|
|
)
|
|
response_data.read()
|
|
return self.api_client.response_deserialize(
|
|
response_data=response_data,
|
|
response_types_map=_response_types_map,
|
|
models=thousandeyes_sdk.event_detection.models,
|
|
).data
|
|
|
|
|
|
@validate_call
|
|
def get_events_with_http_info(
|
|
self,
|
|
aid: Annotated[Optional[StrictStr], Field(description="A unique identifier associated with your account group. You can retrieve your `AccountGroupId` from the `/account-groups` endpoint. Note that you must be assigned to the target account group. Specifying this parameter without being assigned to the target account group will result in an error response.")] = None,
|
|
window: Annotated[Optional[Annotated[str, Field(strict=True)]], Field(description="A dynamic time interval up to the current time of the request. Specify the interval as a number followed by an optional type: `s` for seconds (default if no type is specified), `m` for minutes, `h` for hours, `d` for days, and `w` for weeks. For a precise date range, use `startDate` and `endDate`.")] = None,
|
|
start_date: Annotated[Optional[datetime], Field(description="Use with the `endDate` parameter. Include the complete time (hours, minutes, and seconds) in UTC time zone, following the ISO 8601 date-time format. See the example for reference. Please note that this parameter can't be used with `window`.")] = None,
|
|
end_date: Annotated[Optional[datetime], Field(description="Defaults to current time the request is made. Use with the `startDate` parameter. Include the complete time (hours, minutes, and seconds) in UTC time zone, following the ISO 8601 date-time format. See the example for reference. Please note that this parameter can't be used with `window`.")] = None,
|
|
max: Annotated[Optional[StrictInt], Field(description="(Optional) Maximum number of objects to return.")] = None,
|
|
cursor: Annotated[Optional[StrictStr], Field(description="(Optional) Opaque cursor used for pagination. Clients should use `next` value from `_links` instead of this parameter.")] = None,
|
|
_request_timeout: Union[
|
|
None,
|
|
Annotated[StrictFloat, Field(gt=0)],
|
|
Tuple[
|
|
Annotated[StrictFloat, Field(gt=0)],
|
|
Annotated[StrictFloat, Field(gt=0)]
|
|
]
|
|
] = None,
|
|
_request_auth: Optional[Dict[StrictStr, Any]] = None,
|
|
_content_type: Optional[StrictStr] = None,
|
|
_headers: Optional[Dict[StrictStr, Any]] = None,
|
|
_host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
|
|
) -> ApiResponse[Events]:
|
|
"""List events
|
|
|
|
Retrieves a list of events within the specified time window. If no events are active during the specified time range, an empty response is returned. **Note**: You must provide either a time window using the `window` parameter or specify `startDate` and `endDate`.
|
|
|
|
:param aid: A unique identifier associated with your account group. You can retrieve your `AccountGroupId` from the `/account-groups` endpoint. Note that you must be assigned to the target account group. Specifying this parameter without being assigned to the target account group will result in an error response.
|
|
:type aid: str
|
|
:param window: A dynamic time interval up to the current time of the request. Specify the interval as a number followed by an optional type: `s` for seconds (default if no type is specified), `m` for minutes, `h` for hours, `d` for days, and `w` for weeks. For a precise date range, use `startDate` and `endDate`.
|
|
:type window: str
|
|
:param start_date: Use with the `endDate` parameter. Include the complete time (hours, minutes, and seconds) in UTC time zone, following the ISO 8601 date-time format. See the example for reference. Please note that this parameter can't be used with `window`.
|
|
:type start_date: datetime
|
|
:param end_date: Defaults to current time the request is made. Use with the `startDate` parameter. Include the complete time (hours, minutes, and seconds) in UTC time zone, following the ISO 8601 date-time format. See the example for reference. Please note that this parameter can't be used with `window`.
|
|
:type end_date: datetime
|
|
:param max: (Optional) Maximum number of objects to return.
|
|
:type max: int
|
|
:param cursor: (Optional) Opaque cursor used for pagination. Clients should use `next` value from `_links` instead of this parameter.
|
|
:type cursor: str
|
|
:param _request_timeout: timeout setting for this request. If one
|
|
number provided, it will be total request
|
|
timeout. It can also be a pair (tuple) of
|
|
(connection, read) timeouts.
|
|
:type _request_timeout: int, tuple(int, int), optional
|
|
:param _request_auth: set to override the auth_settings for an a single
|
|
request; this effectively ignores the
|
|
authentication in the spec for a single request.
|
|
:type _request_auth: dict, optional
|
|
:param _content_type: force content-type for the request.
|
|
:type _content_type: str, Optional
|
|
:param _headers: set to override the headers for a single
|
|
request; this effectively ignores the headers
|
|
in the spec for a single request.
|
|
:type _headers: dict, optional
|
|
:param _host_index: set to override the host_index for a single
|
|
request; this effectively ignores the host_index
|
|
in the spec for a single request.
|
|
:type _host_index: int, optional
|
|
:return: Returns the result object.
|
|
""" # noqa: E501
|
|
|
|
_param = self._get_events_serialize(
|
|
aid=aid,
|
|
window=window,
|
|
start_date=start_date,
|
|
end_date=end_date,
|
|
max=max,
|
|
cursor=cursor,
|
|
_request_auth=_request_auth,
|
|
_content_type=_content_type,
|
|
_headers=_headers,
|
|
_host_index=_host_index
|
|
)
|
|
|
|
_response_types_map: Dict[str, Optional[str]] = {
|
|
'200': "Events",
|
|
'400': "ValidationError",
|
|
'401': "UnauthorizedError",
|
|
'403': "Error",
|
|
'404': "Error",
|
|
'429': "Error",
|
|
'500': "Error",
|
|
'502': "Error",
|
|
}
|
|
response_data = self.api_client.call_api(
|
|
*_param,
|
|
_request_timeout=_request_timeout
|
|
)
|
|
response_data.read()
|
|
return self.api_client.response_deserialize(
|
|
response_data=response_data,
|
|
response_types_map=_response_types_map,
|
|
models=thousandeyes_sdk.event_detection.models,
|
|
)
|
|
|
|
|
|
@validate_call
|
|
def get_events_without_preload_content(
|
|
self,
|
|
aid: Annotated[Optional[StrictStr], Field(description="A unique identifier associated with your account group. You can retrieve your `AccountGroupId` from the `/account-groups` endpoint. Note that you must be assigned to the target account group. Specifying this parameter without being assigned to the target account group will result in an error response.")] = None,
|
|
window: Annotated[Optional[Annotated[str, Field(strict=True)]], Field(description="A dynamic time interval up to the current time of the request. Specify the interval as a number followed by an optional type: `s` for seconds (default if no type is specified), `m` for minutes, `h` for hours, `d` for days, and `w` for weeks. For a precise date range, use `startDate` and `endDate`.")] = None,
|
|
start_date: Annotated[Optional[datetime], Field(description="Use with the `endDate` parameter. Include the complete time (hours, minutes, and seconds) in UTC time zone, following the ISO 8601 date-time format. See the example for reference. Please note that this parameter can't be used with `window`.")] = None,
|
|
end_date: Annotated[Optional[datetime], Field(description="Defaults to current time the request is made. Use with the `startDate` parameter. Include the complete time (hours, minutes, and seconds) in UTC time zone, following the ISO 8601 date-time format. See the example for reference. Please note that this parameter can't be used with `window`.")] = None,
|
|
max: Annotated[Optional[StrictInt], Field(description="(Optional) Maximum number of objects to return.")] = None,
|
|
cursor: Annotated[Optional[StrictStr], Field(description="(Optional) Opaque cursor used for pagination. Clients should use `next` value from `_links` instead of this parameter.")] = None,
|
|
_request_timeout: Union[
|
|
None,
|
|
Annotated[StrictFloat, Field(gt=0)],
|
|
Tuple[
|
|
Annotated[StrictFloat, Field(gt=0)],
|
|
Annotated[StrictFloat, Field(gt=0)]
|
|
]
|
|
] = None,
|
|
_request_auth: Optional[Dict[StrictStr, Any]] = None,
|
|
_content_type: Optional[StrictStr] = None,
|
|
_headers: Optional[Dict[StrictStr, Any]] = None,
|
|
_host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
|
|
) -> RESTResponseType:
|
|
"""List events
|
|
|
|
Retrieves a list of events within the specified time window. If no events are active during the specified time range, an empty response is returned. **Note**: You must provide either a time window using the `window` parameter or specify `startDate` and `endDate`.
|
|
|
|
:param aid: A unique identifier associated with your account group. You can retrieve your `AccountGroupId` from the `/account-groups` endpoint. Note that you must be assigned to the target account group. Specifying this parameter without being assigned to the target account group will result in an error response.
|
|
:type aid: str
|
|
:param window: A dynamic time interval up to the current time of the request. Specify the interval as a number followed by an optional type: `s` for seconds (default if no type is specified), `m` for minutes, `h` for hours, `d` for days, and `w` for weeks. For a precise date range, use `startDate` and `endDate`.
|
|
:type window: str
|
|
:param start_date: Use with the `endDate` parameter. Include the complete time (hours, minutes, and seconds) in UTC time zone, following the ISO 8601 date-time format. See the example for reference. Please note that this parameter can't be used with `window`.
|
|
:type start_date: datetime
|
|
:param end_date: Defaults to current time the request is made. Use with the `startDate` parameter. Include the complete time (hours, minutes, and seconds) in UTC time zone, following the ISO 8601 date-time format. See the example for reference. Please note that this parameter can't be used with `window`.
|
|
:type end_date: datetime
|
|
:param max: (Optional) Maximum number of objects to return.
|
|
:type max: int
|
|
:param cursor: (Optional) Opaque cursor used for pagination. Clients should use `next` value from `_links` instead of this parameter.
|
|
:type cursor: str
|
|
:param _request_timeout: timeout setting for this request. If one
|
|
number provided, it will be total request
|
|
timeout. It can also be a pair (tuple) of
|
|
(connection, read) timeouts.
|
|
:type _request_timeout: int, tuple(int, int), optional
|
|
:param _request_auth: set to override the auth_settings for an a single
|
|
request; this effectively ignores the
|
|
authentication in the spec for a single request.
|
|
:type _request_auth: dict, optional
|
|
:param _content_type: force content-type for the request.
|
|
:type _content_type: str, Optional
|
|
:param _headers: set to override the headers for a single
|
|
request; this effectively ignores the headers
|
|
in the spec for a single request.
|
|
:type _headers: dict, optional
|
|
:param _host_index: set to override the host_index for a single
|
|
request; this effectively ignores the host_index
|
|
in the spec for a single request.
|
|
:type _host_index: int, optional
|
|
:return: Returns the result object.
|
|
""" # noqa: E501
|
|
|
|
_param = self._get_events_serialize(
|
|
aid=aid,
|
|
window=window,
|
|
start_date=start_date,
|
|
end_date=end_date,
|
|
max=max,
|
|
cursor=cursor,
|
|
_request_auth=_request_auth,
|
|
_content_type=_content_type,
|
|
_headers=_headers,
|
|
_host_index=_host_index
|
|
)
|
|
|
|
_response_types_map: Dict[str, Optional[str]] = {
|
|
'200': "Events",
|
|
'400': "ValidationError",
|
|
'401': "UnauthorizedError",
|
|
'403': "Error",
|
|
'404': "Error",
|
|
'429': "Error",
|
|
'500': "Error",
|
|
'502': "Error",
|
|
}
|
|
response_data = self.api_client.call_api(
|
|
*_param,
|
|
_request_timeout=_request_timeout
|
|
)
|
|
return response_data.response
|
|
|
|
|
|
def _get_events_serialize(
|
|
self,
|
|
aid,
|
|
window,
|
|
start_date,
|
|
end_date,
|
|
max,
|
|
cursor,
|
|
_request_auth,
|
|
_content_type,
|
|
_headers,
|
|
_host_index,
|
|
) -> RequestSerialized:
|
|
|
|
_host = None
|
|
|
|
_collection_formats: Dict[str, str] = {
|
|
}
|
|
|
|
_path_params: Dict[str, str] = {}
|
|
_query_params: List[Tuple[str, str]] = []
|
|
_header_params: Dict[str, Optional[str]] = _headers or {}
|
|
_form_params: List[Tuple[str, str]] = []
|
|
_files: Dict[str, Union[str, bytes]] = {}
|
|
_body_params: Optional[bytes] = None
|
|
|
|
# process the path parameters
|
|
# process the query parameters
|
|
if aid is not None:
|
|
|
|
_query_params.append(('aid', aid))
|
|
|
|
if window is not None:
|
|
|
|
_query_params.append(('window', window))
|
|
|
|
if start_date is not None:
|
|
if isinstance(start_date, datetime):
|
|
_query_params.append(
|
|
(
|
|
'startDate',
|
|
start_date.strftime(
|
|
self.api_client.configuration.datetime_format
|
|
)
|
|
)
|
|
)
|
|
else:
|
|
_query_params.append(('startDate', start_date))
|
|
|
|
if end_date is not None:
|
|
if isinstance(end_date, datetime):
|
|
_query_params.append(
|
|
(
|
|
'endDate',
|
|
end_date.strftime(
|
|
self.api_client.configuration.datetime_format
|
|
)
|
|
)
|
|
)
|
|
else:
|
|
_query_params.append(('endDate', end_date))
|
|
|
|
if max is not None:
|
|
|
|
_query_params.append(('max', max))
|
|
|
|
if cursor is not None:
|
|
|
|
_query_params.append(('cursor', cursor))
|
|
|
|
# process the header parameters
|
|
# process the form parameters
|
|
# process the body parameter
|
|
|
|
|
|
# set the HTTP header `Accept`
|
|
_header_params['Accept'] = self.api_client.select_header_accept(
|
|
[
|
|
'application/hal+json',
|
|
'application/json',
|
|
'application/problem+json'
|
|
]
|
|
)
|
|
|
|
|
|
# authentication setting
|
|
_auth_settings: List[str] = [
|
|
'BearerAuth'
|
|
]
|
|
|
|
return self.api_client.param_serialize(
|
|
method='GET',
|
|
resource_path='/v7/events',
|
|
path_params=_path_params,
|
|
query_params=_query_params,
|
|
header_params=_header_params,
|
|
body=_body_params,
|
|
post_params=_form_params,
|
|
files=_files,
|
|
auth_settings=_auth_settings,
|
|
collection_formats=_collection_formats,
|
|
_host=_host,
|
|
_request_auth=_request_auth
|
|
)
|
|
|
|
|