Skip to content

Commit f079744

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add custom schedule to monitor scheduling options (#1681)
Co-authored-by: ci.datadog-api-spec <[email protected]>
1 parent f74ac02 commit f079744

11 files changed

+282
-6
lines changed

.apigentools-info

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
"spec_versions": {
55
"v1": {
66
"apigentools_version": "1.6.6",
7-
"regenerated": "2023-10-04 20:38:45.655558",
8-
"spec_repo_commit": "79ab1c3c"
7+
"regenerated": "2023-10-05 15:54:41.516135",
8+
"spec_repo_commit": "432a5a71"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.6",
12-
"regenerated": "2023-10-04 20:38:45.670703",
13-
"spec_repo_commit": "79ab1c3c"
12+
"regenerated": "2023-10-05 15:54:41.542763",
13+
"spec_repo_commit": "432a5a71"
1414
}
1515
}
1616
}

.generator/schemas/v1/openapi.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6839,6 +6839,33 @@ components:
68396839
type: string
68406840
readOnly: true
68416841
type: object
6842+
MonitorOptionsCustomSchedule:
6843+
description: Configuration options for the custom schedule. **This feature is
6844+
in private beta.**
6845+
properties:
6846+
recurrences:
6847+
description: Array of custom schedule recurrences.
6848+
items:
6849+
$ref: '#/components/schemas/MonitorOptionsCustomScheduleRecurrence'
6850+
type: array
6851+
type: object
6852+
MonitorOptionsCustomScheduleRecurrence:
6853+
description: Configuration for a recurrence set on the monitor options for custom
6854+
schedule.
6855+
properties:
6856+
rrule:
6857+
description: Defines the recurrence rule (RRULE) for a given schedule.
6858+
example: FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR
6859+
type: string
6860+
start:
6861+
description: Defines the start date and time of the recurring schedule.
6862+
example: '2023-08-31T16:30:00'
6863+
type: string
6864+
timezone:
6865+
description: Defines the timezone the schedule runs on.
6866+
example: Europe/Paris
6867+
type: string
6868+
type: object
68426869
MonitorOptionsNotificationPresets:
68436870
default: show_all
68446871
description: Toggles the display of additional content sent in the monitor notification.
@@ -6856,6 +6883,8 @@ components:
68566883
MonitorOptionsSchedulingOptions:
68576884
description: Configuration options for scheduling.
68586885
properties:
6886+
custom_schedule:
6887+
$ref: '#/components/schemas/MonitorOptionsCustomSchedule'
68596888
evaluation_window:
68606889
$ref: '#/components/schemas/MonitorOptionsSchedulingOptionsEvaluationWindow'
68616890
type: object

docs/datadog_api_client.v1.model.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2024,6 +2024,20 @@ monitor\_options\_aggregation
20242024
:members:
20252025
:show-inheritance:
20262026

2027+
monitor\_options\_custom\_schedule
2028+
----------------------------------
2029+
2030+
.. automodule:: datadog_api_client.v1.model.monitor_options_custom_schedule
2031+
:members:
2032+
:show-inheritance:
2033+
2034+
monitor\_options\_custom\_schedule\_recurrence
2035+
----------------------------------------------
2036+
2037+
.. automodule:: datadog_api_client.v1.model.monitor_options_custom_schedule_recurrence
2038+
:members:
2039+
:show-inheritance:
2040+
20272041
monitor\_options\_notification\_presets
20282042
---------------------------------------
20292043

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
"""
2+
Create a metric monitor with a custom schedule 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_options import MonitorOptions
9+
from datadog_api_client.v1.model.monitor_options_custom_schedule import MonitorOptionsCustomSchedule
10+
from datadog_api_client.v1.model.monitor_options_custom_schedule_recurrence import (
11+
MonitorOptionsCustomScheduleRecurrence,
12+
)
13+
from datadog_api_client.v1.model.monitor_options_scheduling_options import MonitorOptionsSchedulingOptions
14+
from datadog_api_client.v1.model.monitor_options_scheduling_options_evaluation_window import (
15+
MonitorOptionsSchedulingOptionsEvaluationWindow,
16+
)
17+
from datadog_api_client.v1.model.monitor_thresholds import MonitorThresholds
18+
from datadog_api_client.v1.model.monitor_type import MonitorType
19+
from datadog_api_client.v1.model.on_missing_data_option import OnMissingDataOption
20+
21+
body = Monitor(
22+
message="some message Notify: @hipchat-channel",
23+
name="Example-Monitor",
24+
query="avg(current_1mo):avg:system.load.5{*} > 0.5",
25+
tags=[],
26+
options=MonitorOptions(
27+
thresholds=MonitorThresholds(
28+
critical=0.5,
29+
),
30+
notify_audit=False,
31+
on_missing_data=OnMissingDataOption.DEFAULT,
32+
include_tags=False,
33+
scheduling_options=MonitorOptionsSchedulingOptions(
34+
evaluation_window=MonitorOptionsSchedulingOptionsEvaluationWindow(
35+
day_starts="04:00",
36+
month_starts=1,
37+
),
38+
custom_schedule=MonitorOptionsCustomSchedule(
39+
recurrences=[
40+
MonitorOptionsCustomScheduleRecurrence(
41+
rrule="FREQ=DAILY;INTERVAL=1",
42+
timezone="America/Los_Angeles",
43+
start="2024-10-26T09:13:00",
44+
),
45+
],
46+
),
47+
),
48+
),
49+
type=MonitorType.QUERY_ALERT,
50+
)
51+
52+
configuration = Configuration()
53+
with ApiClient(configuration) as api_client:
54+
api_instance = MonitorsApi(api_client)
55+
response = api_instance.create_monitor(body=body)
56+
57+
print(response)
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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 List, 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_options_custom_schedule_recurrence import (
18+
MonitorOptionsCustomScheduleRecurrence,
19+
)
20+
21+
22+
class MonitorOptionsCustomSchedule(ModelNormal):
23+
@cached_property
24+
def openapi_types(_):
25+
from datadog_api_client.v1.model.monitor_options_custom_schedule_recurrence import (
26+
MonitorOptionsCustomScheduleRecurrence,
27+
)
28+
29+
return {
30+
"recurrences": ([MonitorOptionsCustomScheduleRecurrence],),
31+
}
32+
33+
attribute_map = {
34+
"recurrences": "recurrences",
35+
}
36+
37+
def __init__(self_, recurrences: Union[List[MonitorOptionsCustomScheduleRecurrence], UnsetType] = unset, **kwargs):
38+
"""
39+
Configuration options for the custom schedule. **This feature is in private beta.**
40+
41+
:param recurrences: Array of custom schedule recurrences.
42+
:type recurrences: [MonitorOptionsCustomScheduleRecurrence], optional
43+
"""
44+
if recurrences is not unset:
45+
kwargs["recurrences"] = recurrences
46+
super().__init__(kwargs)
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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
7+
8+
from datadog_api_client.model_utils import (
9+
ModelNormal,
10+
cached_property,
11+
unset,
12+
UnsetType,
13+
)
14+
15+
16+
class MonitorOptionsCustomScheduleRecurrence(ModelNormal):
17+
@cached_property
18+
def openapi_types(_):
19+
return {
20+
"rrule": (str,),
21+
"start": (str,),
22+
"timezone": (str,),
23+
}
24+
25+
attribute_map = {
26+
"rrule": "rrule",
27+
"start": "start",
28+
"timezone": "timezone",
29+
}
30+
31+
def __init__(
32+
self_,
33+
rrule: Union[str, UnsetType] = unset,
34+
start: Union[str, UnsetType] = unset,
35+
timezone: Union[str, UnsetType] = unset,
36+
**kwargs,
37+
):
38+
"""
39+
Configuration for a recurrence set on the monitor options for custom schedule.
40+
41+
:param rrule: Defines the recurrence rule (RRULE) for a given schedule.
42+
:type rrule: str, optional
43+
44+
:param start: Defines the start date and time of the recurring schedule.
45+
:type start: str, optional
46+
47+
:param timezone: Defines the timezone the schedule runs on.
48+
:type timezone: str, optional
49+
"""
50+
if rrule is not unset:
51+
kwargs["rrule"] = rrule
52+
if start is not unset:
53+
kwargs["start"] = start
54+
if timezone is not unset:
55+
kwargs["timezone"] = timezone
56+
super().__init__(kwargs)

src/datadog_api_client/v1/model/monitor_options_scheduling_options.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515

1616
if TYPE_CHECKING:
17+
from datadog_api_client.v1.model.monitor_options_custom_schedule import MonitorOptionsCustomSchedule
1718
from datadog_api_client.v1.model.monitor_options_scheduling_options_evaluation_window import (
1819
MonitorOptionsSchedulingOptionsEvaluationWindow,
1920
)
@@ -22,27 +23,38 @@
2223
class MonitorOptionsSchedulingOptions(ModelNormal):
2324
@cached_property
2425
def openapi_types(_):
26+
from datadog_api_client.v1.model.monitor_options_custom_schedule import MonitorOptionsCustomSchedule
2527
from datadog_api_client.v1.model.monitor_options_scheduling_options_evaluation_window import (
2628
MonitorOptionsSchedulingOptionsEvaluationWindow,
2729
)
2830

2931
return {
32+
"custom_schedule": (MonitorOptionsCustomSchedule,),
3033
"evaluation_window": (MonitorOptionsSchedulingOptionsEvaluationWindow,),
3134
}
3235

3336
attribute_map = {
37+
"custom_schedule": "custom_schedule",
3438
"evaluation_window": "evaluation_window",
3539
}
3640

3741
def __init__(
38-
self_, evaluation_window: Union[MonitorOptionsSchedulingOptionsEvaluationWindow, UnsetType] = unset, **kwargs
42+
self_,
43+
custom_schedule: Union[MonitorOptionsCustomSchedule, UnsetType] = unset,
44+
evaluation_window: Union[MonitorOptionsSchedulingOptionsEvaluationWindow, UnsetType] = unset,
45+
**kwargs,
3946
):
4047
"""
4148
Configuration options for scheduling.
4249
50+
:param custom_schedule: Configuration options for the custom schedule. **This feature is in private beta.**
51+
:type custom_schedule: MonitorOptionsCustomSchedule, optional
52+
4353
:param evaluation_window: Configuration options for the evaluation window. If ``hour_starts`` is set, no other fields may be set. Otherwise, ``day_starts`` and ``month_starts`` must be set together.
4454
:type evaluation_window: MonitorOptionsSchedulingOptionsEvaluationWindow, optional
4555
"""
56+
if custom_schedule is not unset:
57+
kwargs["custom_schedule"] = custom_schedule
4658
if evaluation_window is not unset:
4759
kwargs["evaluation_window"] = evaluation_window
4860
super().__init__(kwargs)

src/datadog_api_client/v1/models/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,10 @@
337337
from datadog_api_client.v1.model.monitor_group_search_result import MonitorGroupSearchResult
338338
from datadog_api_client.v1.model.monitor_options import MonitorOptions
339339
from datadog_api_client.v1.model.monitor_options_aggregation import MonitorOptionsAggregation
340+
from datadog_api_client.v1.model.monitor_options_custom_schedule import MonitorOptionsCustomSchedule
341+
from datadog_api_client.v1.model.monitor_options_custom_schedule_recurrence import (
342+
MonitorOptionsCustomScheduleRecurrence,
343+
)
340344
from datadog_api_client.v1.model.monitor_options_notification_presets import MonitorOptionsNotificationPresets
341345
from datadog_api_client.v1.model.monitor_options_scheduling_options import MonitorOptionsSchedulingOptions
342346
from datadog_api_client.v1.model.monitor_options_scheduling_options_evaluation_window import (
@@ -1222,6 +1226,8 @@
12221226
"MonitorGroupSearchResult",
12231227
"MonitorOptions",
12241228
"MonitorOptionsAggregation",
1229+
"MonitorOptionsCustomSchedule",
1230+
"MonitorOptionsCustomScheduleRecurrence",
12251231
"MonitorOptionsNotificationPresets",
12261232
"MonitorOptionsSchedulingOptions",
12271233
"MonitorOptionsSchedulingOptionsEvaluationWindow",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2023-10-04T18:33:20.272Z
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
interactions:
2+
- request:
3+
body: '{"message":"some message Notify: @hipchat-channel","name":"Test-Create_a_metric_monitor_with_a_custom_schedule_returns_OK_response-1696444400","options":{"include_tags":false,"notify_audit":false,"on_missing_data":"default","scheduling_options":{"custom_schedule":{"recurrences":[{"rrule":"FREQ=DAILY;INTERVAL=1","start":"2024-10-26T09:13:00","timezone":"America/Los_Angeles"}]},"evaluation_window":{"day_starts":"04:00","month_starts":1}},"thresholds":{"critical":0.5}},"query":"avg(current_1mo):avg:system.load.5{*}
4+
> 0.5","tags":[],"type":"query alert"}'
5+
headers:
6+
accept:
7+
- application/json
8+
content-type:
9+
- application/json
10+
method: POST
11+
uri: https://api.datadoghq.com/api/v1/monitor
12+
response:
13+
body:
14+
string: '{"id":132537965,"org_id":321813,"type":"query alert","name":"Test-Create_a_metric_monitor_with_a_custom_schedule_returns_OK_response-1696444400","message":"some
15+
message Notify: @hipchat-channel","tags":[],"query":"avg(current_1mo):avg:system.load.5{*}
16+
> 0.5","options":{"include_tags":false,"notify_audit":false,"on_missing_data":"default","scheduling_options":{"custom_schedule":{"recurrences":[{"rrule":"FREQ=DAILY;INTERVAL=1","start":"2024-10-26T09:13:00","timezone":"America/Los_Angeles"}]},"evaluation_window":{"day_starts":"04:00","month_starts":1}},"thresholds":{"critical":0.5},"new_host_delay":300,"silenced":{}},"multi":false,"created_at":1696444400000,"created":"2023-10-04T18:33:20.388003+00:00","modified":"2023-10-04T18:33:20.388003+00:00","deleted":null,"restricted_roles":null,"priority":null,"overall_state_modified":null,"overall_state":"No
17+
Data","creator":{"name":"CI Account","handle":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","email":"[email protected]","id":2320499}}
18+
19+
'
20+
headers:
21+
content-type:
22+
- application/json
23+
status:
24+
code: 200
25+
message: OK
26+
- request:
27+
body: null
28+
headers:
29+
accept:
30+
- application/json
31+
method: DELETE
32+
uri: https://api.datadoghq.com/api/v1/monitor/132537965
33+
response:
34+
body:
35+
string: '{"deleted_monitor_id":132537965}
36+
37+
'
38+
headers:
39+
content-type:
40+
- application/json
41+
status:
42+
code: 200
43+
message: OK
44+
version: 1

0 commit comments

Comments
 (0)