|
3 | 3 | # Copyright 2019-Present Datadog, Inc. |
4 | 4 | from __future__ import annotations |
5 | 5 |
|
6 | | -from typing import List, Union, TYPE_CHECKING |
7 | 6 |
|
8 | 7 | from datadog_api_client.model_utils import ( |
9 | | - ModelNormal, |
| 8 | + ModelComposed, |
10 | 9 | cached_property, |
11 | | - unset, |
12 | | - UnsetType, |
13 | 10 | ) |
14 | 11 |
|
15 | 12 |
|
16 | | -if TYPE_CHECKING: |
17 | | - from datadog_api_client.v1.model.topology_query_data_source import TopologyQueryDataSource |
18 | | - |
19 | | - |
20 | | -class TopologyQuery(ModelNormal): |
21 | | - validations = { |
22 | | - "filters": { |
23 | | - "min_items": 1, |
24 | | - }, |
25 | | - } |
26 | | - |
27 | | - @cached_property |
28 | | - def openapi_types(_): |
29 | | - from datadog_api_client.v1.model.topology_query_data_source import TopologyQueryDataSource |
30 | | - |
31 | | - return { |
32 | | - "data_source": (TopologyQueryDataSource,), |
33 | | - "filters": ([str],), |
34 | | - "service": (str,), |
35 | | - } |
36 | | - |
37 | | - attribute_map = { |
38 | | - "data_source": "data_source", |
39 | | - "filters": "filters", |
40 | | - "service": "service", |
41 | | - } |
42 | | - |
43 | | - def __init__( |
44 | | - self_, |
45 | | - data_source: Union[TopologyQueryDataSource, UnsetType] = unset, |
46 | | - filters: Union[List[str], UnsetType] = unset, |
47 | | - service: Union[str, UnsetType] = unset, |
48 | | - **kwargs, |
49 | | - ): |
| 13 | +class TopologyQuery(ModelComposed): |
| 14 | + def __init__(self, **kwargs): |
50 | 15 | """ |
51 | | - Query to service-based topology data sources like the service map or data streams. |
| 16 | + A topology data source query. |
52 | 17 |
|
53 | 18 | :param data_source: Name of the data source |
54 | | - :type data_source: TopologyQueryDataSource, optional |
| 19 | + :type data_source: TopologyQueryDataStreamsOrServiceMapDataSource |
55 | 20 |
|
56 | 21 | :param filters: Your environment and primary tag (or * if enabled for your account). |
57 | | - :type filters: [str], optional |
| 22 | + :type filters: [str] |
| 23 | +
|
| 24 | + :param query_string: A search string for filtering services, used in `data_streams` queries only. When set, this replaces the `service` field |
| 25 | + :type query_string: str, optional |
58 | 26 |
|
59 | 27 | :param service: Name of the service |
60 | 28 | :type service: str, optional |
61 | 29 | """ |
62 | | - if data_source is not unset: |
63 | | - kwargs["data_source"] = data_source |
64 | | - if filters is not unset: |
65 | | - kwargs["filters"] = filters |
66 | | - if service is not unset: |
67 | | - kwargs["service"] = service |
68 | 30 | super().__init__(kwargs) |
| 31 | + |
| 32 | + @cached_property |
| 33 | + def _composed_schemas(_): |
| 34 | + # we need this here to make our import statements work |
| 35 | + # we must store _composed_schemas in here so the code is only run |
| 36 | + # when we invoke this method. If we kept this at the class |
| 37 | + # level we would get an error because the class level |
| 38 | + # code would be run when this module is imported, and these composed |
| 39 | + # classes don't exist yet because their module has not finished |
| 40 | + # loading |
| 41 | + from datadog_api_client.v1.model.topology_query_data_streams_or_service_map import ( |
| 42 | + TopologyQueryDataStreamsOrServiceMap, |
| 43 | + ) |
| 44 | + |
| 45 | + return { |
| 46 | + "oneOf": [ |
| 47 | + TopologyQueryDataStreamsOrServiceMap, |
| 48 | + ], |
| 49 | + } |
0 commit comments