Skip to content

Commit ae051a4

Browse files
author
ci.datadog-api-spec
committed
Regenerate client from commit 6cba7b1 of spec repo
1 parent 27f9b78 commit ae051a4

15 files changed

+395
-12
lines changed

.generator/schemas/v1/openapi.yaml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7255,6 +7255,12 @@ components:
72557255
Monitor:
72567256
description: Object describing a monitor.
72577257
properties:
7258+
assets:
7259+
description: The list of monitor assets tied to a monitor, which represents
7260+
key links for users to take action on monitor alerts (for example, runbooks).
7261+
items:
7262+
$ref: '#/components/schemas/MonitorAsset'
7263+
type: array
72587264
created:
72597265
description: Timestamp of the monitor creation.
72607266
format: date-time
@@ -7338,6 +7344,52 @@ components:
73387344
- type
73397345
- query
73407346
type: object
7347+
MonitorAsset:
7348+
description: 'Represents key links tied to a monitor to help users take action
7349+
on alerts.
7350+
7351+
This feature is in Preview and only available to users with the feature enabled.'
7352+
properties:
7353+
category:
7354+
$ref: '#/components/schemas/MonitorAssetCategory'
7355+
name:
7356+
description: Name for the monitor asset
7357+
example: Monitor Runbook
7358+
type: string
7359+
resource_key:
7360+
description: Represents the identifier of the internal Datadog resource
7361+
that this asset represents. IDs in this field should be passed in as strings.
7362+
example: '12345'
7363+
type: string
7364+
resource_type:
7365+
$ref: '#/components/schemas/MonitorAssetResourceType'
7366+
url:
7367+
description: URL link for the asset. For links with an internal resource
7368+
type set, this should be the relative path to where the Datadog domain
7369+
is appended internally. For external links, this should be the full URL
7370+
path.
7371+
example: /notebooks/12345
7372+
type: string
7373+
required:
7374+
- name
7375+
- url
7376+
- category
7377+
type: object
7378+
MonitorAssetCategory:
7379+
description: Indicates the type of asset this entity represents on a monitor.
7380+
enum:
7381+
- runbook
7382+
example: runbook
7383+
type: string
7384+
x-enum-varnames:
7385+
- RUNBOOK
7386+
MonitorAssetResourceType:
7387+
description: Type of internal Datadog resource associated with a monitor asset.
7388+
enum:
7389+
- notebook
7390+
type: string
7391+
x-enum-varnames:
7392+
- NOTEBOOK
73417393
MonitorDeviceID:
73427394
description: ID of the device the Synthetics monitor is running on. Same as
73437395
`SyntheticsDeviceID`.
@@ -8452,6 +8504,13 @@ components:
84528504
MonitorUpdateRequest:
84538505
description: Object describing a monitor update request.
84548506
properties:
8507+
assets:
8508+
description: The list of monitor assets tied to a monitor, which represents
8509+
key links for users to take action on monitor alerts (for example, runbooks).
8510+
items:
8511+
$ref: '#/components/schemas/MonitorAsset'
8512+
nullable: true
8513+
type: array
84558514
created:
84568515
description: Timestamp of the monitor creation.
84578516
format: date-time
@@ -31584,6 +31643,13 @@ paths:
3158431643
required: false
3158531644
schema:
3158631645
type: boolean
31646+
- description: If this argument is set to `true`, the returned data includes
31647+
all assets tied to this monitor.
31648+
in: query
31649+
name: with_assets
31650+
required: false
31651+
schema:
31652+
type: boolean
3158731653
responses:
3158831654
'200':
3158931655
content:

docs/datadog_api_client.v1.model.rst

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2223,6 +2223,27 @@ datadog\_api\_client.v1.model.monitor module
22232223
:members:
22242224
:show-inheritance:
22252225

2226+
datadog\_api\_client.v1.model.monitor\_asset module
2227+
---------------------------------------------------
2228+
2229+
.. automodule:: datadog_api_client.v1.model.monitor_asset
2230+
:members:
2231+
:show-inheritance:
2232+
2233+
datadog\_api\_client.v1.model.monitor\_asset\_category module
2234+
-------------------------------------------------------------
2235+
2236+
.. automodule:: datadog_api_client.v1.model.monitor_asset_category
2237+
:members:
2238+
:show-inheritance:
2239+
2240+
datadog\_api\_client.v1.model.monitor\_asset\_resource\_type module
2241+
-------------------------------------------------------------------
2242+
2243+
.. automodule:: datadog_api_client.v1.model.monitor_asset_resource_type
2244+
:members:
2245+
:show-inheritance:
2246+
22262247
datadog\_api\_client.v1.model.monitor\_device\_id module
22272248
--------------------------------------------------------
22282249

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
"""
2+
Create a monitor with assets returns "OK" response
3+
"""
4+
5+
from datadog_api_client import ApiClient, Configuration
6+
from datadog_api_client.v1.api.monitors_api import MonitorsApi
7+
from datadog_api_client.v1.model.monitor import Monitor
8+
from datadog_api_client.v1.model.monitor_asset import MonitorAsset
9+
from datadog_api_client.v1.model.monitor_asset_category import MonitorAssetCategory
10+
from datadog_api_client.v1.model.monitor_asset_resource_type import MonitorAssetResourceType
11+
from datadog_api_client.v1.model.monitor_options import MonitorOptions
12+
from datadog_api_client.v1.model.monitor_options_scheduling_options import MonitorOptionsSchedulingOptions
13+
from datadog_api_client.v1.model.monitor_options_scheduling_options_evaluation_window import (
14+
MonitorOptionsSchedulingOptionsEvaluationWindow,
15+
)
16+
from datadog_api_client.v1.model.monitor_thresholds import MonitorThresholds
17+
from datadog_api_client.v1.model.monitor_type import MonitorType
18+
19+
body = Monitor(
20+
assets=[
21+
MonitorAsset(
22+
category=MonitorAssetCategory.RUNBOOK,
23+
name="Monitor Runbook",
24+
resource_key="12345",
25+
resource_type=MonitorAssetResourceType.NOTEBOOK,
26+
url="/notebooks/12345",
27+
),
28+
],
29+
name="Example-Monitor",
30+
type=MonitorType.METRIC_ALERT,
31+
query="avg(current_1mo):avg:system.load.5{*} > 0.5",
32+
message="some message Notify: @hipchat-channel",
33+
options=MonitorOptions(
34+
thresholds=MonitorThresholds(
35+
critical=0.5,
36+
),
37+
scheduling_options=MonitorOptionsSchedulingOptions(
38+
evaluation_window=MonitorOptionsSchedulingOptionsEvaluationWindow(
39+
day_starts="04:00",
40+
month_starts=1,
41+
),
42+
),
43+
),
44+
)
45+
46+
configuration = Configuration()
47+
with ApiClient(configuration) as api_client:
48+
api_instance = MonitorsApi(api_client)
49+
response = api_instance.create_monitor(body=body)
50+
51+
print(response)

src/datadog_api_client/v1/api/monitors_api.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,11 @@ def __init__(self, api_client=None):
135135
"attribute": "with_downtimes",
136136
"location": "query",
137137
},
138+
"with_assets": {
139+
"openapi_types": (bool,),
140+
"attribute": "with_assets",
141+
"location": "query",
142+
},
138143
},
139144
headers_map={
140145
"accept": ["application/json"],
@@ -640,6 +645,7 @@ def get_monitor(
640645
*,
641646
group_states: Union[str, UnsetType] = unset,
642647
with_downtimes: Union[bool, UnsetType] = unset,
648+
with_assets: Union[bool, UnsetType] = unset,
643649
) -> Monitor:
644650
"""Get a monitor's details.
645651
@@ -651,6 +657,8 @@ def get_monitor(
651657
:type group_states: str, optional
652658
:param with_downtimes: If this argument is set to true, then the returned data includes all current active downtimes for the monitor.
653659
:type with_downtimes: bool, optional
660+
:param with_assets: If this argument is set to ``true`` , the returned data includes all assets tied to this monitor.
661+
:type with_assets: bool, optional
654662
:rtype: Monitor
655663
"""
656664
kwargs: Dict[str, Any] = {}
@@ -662,6 +670,9 @@ def get_monitor(
662670
if with_downtimes is not unset:
663671
kwargs["with_downtimes"] = with_downtimes
664672

673+
if with_assets is not unset:
674+
kwargs["with_assets"] = with_assets
675+
665676
return self._get_monitor_endpoint.call_with_http_info(**kwargs)
666677

667678
def list_monitors(

src/datadog_api_client/v1/model/monitor.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717

1818
if TYPE_CHECKING:
19+
from datadog_api_client.v1.model.monitor_asset import MonitorAsset
1920
from datadog_api_client.v1.model.creator import Creator
2021
from datadog_api_client.v1.model.monitor_draft_status import MonitorDraftStatus
2122
from datadog_api_client.v1.model.matching_downtime import MatchingDowntime
@@ -28,6 +29,7 @@
2829
class Monitor(ModelNormal):
2930
@cached_property
3031
def openapi_types(_):
32+
from datadog_api_client.v1.model.monitor_asset import MonitorAsset
3133
from datadog_api_client.v1.model.creator import Creator
3234
from datadog_api_client.v1.model.monitor_draft_status import MonitorDraftStatus
3335
from datadog_api_client.v1.model.matching_downtime import MatchingDowntime
@@ -37,6 +39,7 @@ def openapi_types(_):
3739
from datadog_api_client.v1.model.monitor_type import MonitorType
3840

3941
return {
42+
"assets": ([MonitorAsset],),
4043
"created": (datetime,),
4144
"creator": (Creator,),
4245
"deleted": (datetime, none_type),
@@ -58,6 +61,7 @@ def openapi_types(_):
5861
}
5962

6063
attribute_map = {
64+
"assets": "assets",
6165
"created": "created",
6266
"creator": "creator",
6367
"deleted": "deleted",
@@ -92,6 +96,7 @@ def __init__(
9296
self_,
9397
query: str,
9498
type: MonitorType,
99+
assets: Union[List[MonitorAsset], UnsetType] = unset,
95100
created: Union[datetime, UnsetType] = unset,
96101
creator: Union[Creator, UnsetType] = unset,
97102
deleted: Union[datetime, none_type, UnsetType] = unset,
@@ -113,6 +118,9 @@ def __init__(
113118
"""
114119
Object describing a monitor.
115120
121+
:param assets: The list of monitor assets tied to a monitor, which represents key links for users to take action on monitor alerts (for example, runbooks).
122+
:type assets: [MonitorAsset], optional
123+
116124
:param created: Timestamp of the monitor creation.
117125
:type created: datetime, optional
118126
@@ -172,6 +180,8 @@ def __init__(
172180
:param type: The type of the monitor. For more information about ``type`` , see the `monitor options <https://docs.datadoghq.com/monitors/guide/monitor_api_options/>`_ docs.
173181
:type type: MonitorType
174182
"""
183+
if assets is not unset:
184+
kwargs["assets"] = assets
175185
if created is not unset:
176186
kwargs["created"] = created
177187
if creator is not unset:
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
2+
# This product includes software developed at Datadog (https://www.datadoghq.com/).
3+
# Copyright 2019-Present Datadog, Inc.
4+
from __future__ import annotations
5+
6+
from typing import Union, TYPE_CHECKING
7+
8+
from datadog_api_client.model_utils import (
9+
ModelNormal,
10+
cached_property,
11+
unset,
12+
UnsetType,
13+
)
14+
15+
16+
if TYPE_CHECKING:
17+
from datadog_api_client.v1.model.monitor_asset_category import MonitorAssetCategory
18+
from datadog_api_client.v1.model.monitor_asset_resource_type import MonitorAssetResourceType
19+
20+
21+
class MonitorAsset(ModelNormal):
22+
@cached_property
23+
def openapi_types(_):
24+
from datadog_api_client.v1.model.monitor_asset_category import MonitorAssetCategory
25+
from datadog_api_client.v1.model.monitor_asset_resource_type import MonitorAssetResourceType
26+
27+
return {
28+
"category": (MonitorAssetCategory,),
29+
"name": (str,),
30+
"resource_key": (str,),
31+
"resource_type": (MonitorAssetResourceType,),
32+
"url": (str,),
33+
}
34+
35+
attribute_map = {
36+
"category": "category",
37+
"name": "name",
38+
"resource_key": "resource_key",
39+
"resource_type": "resource_type",
40+
"url": "url",
41+
}
42+
43+
def __init__(
44+
self_,
45+
category: MonitorAssetCategory,
46+
name: str,
47+
url: str,
48+
resource_key: Union[str, UnsetType] = unset,
49+
resource_type: Union[MonitorAssetResourceType, UnsetType] = unset,
50+
**kwargs,
51+
):
52+
"""
53+
Represents key links tied to a monitor to help users take action on alerts.
54+
This feature is in Preview and only available to users with the feature enabled.
55+
56+
:param category: Indicates the type of asset this entity represents on a monitor.
57+
:type category: MonitorAssetCategory
58+
59+
:param name: Name for the monitor asset
60+
:type name: str
61+
62+
:param resource_key: Represents the identifier of the internal Datadog resource that this asset represents. IDs in this field should be passed in as strings.
63+
:type resource_key: str, optional
64+
65+
:param resource_type: Type of internal Datadog resource associated with a monitor asset.
66+
:type resource_type: MonitorAssetResourceType, optional
67+
68+
:param url: URL link for the asset. For links with an internal resource type set, this should be the relative path to where the Datadog domain is appended internally. For external links, this should be the full URL path.
69+
:type url: str
70+
"""
71+
if resource_key is not unset:
72+
kwargs["resource_key"] = resource_key
73+
if resource_type is not unset:
74+
kwargs["resource_type"] = resource_type
75+
super().__init__(kwargs)
76+
77+
self_.category = category
78+
self_.name = name
79+
self_.url = url
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
2+
# This product includes software developed at Datadog (https://www.datadoghq.com/).
3+
# Copyright 2019-Present Datadog, Inc.
4+
from __future__ import annotations
5+
6+
7+
from datadog_api_client.model_utils import (
8+
ModelSimple,
9+
cached_property,
10+
)
11+
12+
from typing import ClassVar
13+
14+
15+
class MonitorAssetCategory(ModelSimple):
16+
"""
17+
Indicates the type of asset this entity represents on a monitor.
18+
19+
:param value: If omitted defaults to "runbook". Must be one of ["runbook"].
20+
:type value: str
21+
"""
22+
23+
allowed_values = {
24+
"runbook",
25+
}
26+
RUNBOOK: ClassVar["MonitorAssetCategory"]
27+
28+
@cached_property
29+
def openapi_types(_):
30+
return {
31+
"value": (str,),
32+
}
33+
34+
35+
MonitorAssetCategory.RUNBOOK = MonitorAssetCategory("runbook")

0 commit comments

Comments
 (0)