Skip to content

Add monitor draft status field #2566

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .apigentools-info
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"spec_versions": {
"v1": {
"apigentools_version": "1.6.6",
"regenerated": "2025-06-04 12:51:42.024933",
"spec_repo_commit": "35a63137"
"regenerated": "2025-06-04 17:40:37.993718",
"spec_repo_commit": "38b3c05a"
},
"v2": {
"apigentools_version": "1.6.6",
"regenerated": "2025-06-04 12:51:42.039930",
"spec_repo_commit": "35a63137"
"regenerated": "2025-06-04 17:40:38.008535",
"spec_repo_commit": "38b3c05a"
}
}
}
26 changes: 26 additions & 0 deletions .generator/schemas/v1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6742,6 +6742,8 @@ components:
nullable: true
readOnly: true
type: string
draft_status:
$ref: '#/components/schemas/MonitorDraftStatus'
id:
description: ID of this monitor.
format: int64
Expand Down Expand Up @@ -6834,6 +6836,28 @@ components:
- FIREFOX_LAPTOP_LARGE
- FIREFOX_TABLET
- FIREFOX_MOBILE_SMALL
MonitorDraftStatus:
default: published
description: 'Indicates whether the monitor is in a draft or published state.


`draft`: The monitor appears as Draft and does not send notifications.

`published`: The monitor is active and evaluates conditions and notify as
configured.


This field is in preview. The draft value is only available to customers with
the feature enabled.

'
enum:
- draft
- published
type: string
x-enum-varnames:
- DRAFT
- PUBLISHED
MonitorFormulaAndFunctionCostAggregator:
description: Aggregation methods for metric queries.
enum:
Expand Down Expand Up @@ -7917,6 +7941,8 @@ components:
nullable: true
readOnly: true
type: string
draft_status:
$ref: '#/components/schemas/MonitorDraftStatus'
id:
description: ID of this monitor.
format: int64
Expand Down
7 changes: 7 additions & 0 deletions docs/datadog_api_client.v1.model.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2041,6 +2041,13 @@ datadog\_api\_client.v1.model.monitor\_device\_id module
:members:
:show-inheritance:

datadog\_api\_client.v1.model.monitor\_draft\_status module
-----------------------------------------------------------

.. automodule:: datadog_api_client.v1.model.monitor_draft_status
:members:
:show-inheritance:

datadog\_api\_client.v1.model.monitor\_formula\_and\_function\_cost\_aggregator module
--------------------------------------------------------------------------------------

Expand Down
2 changes: 2 additions & 0 deletions examples/v1/monitors/CreateMonitor_1539578087.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v1.api.monitors_api import MonitorsApi
from datadog_api_client.v1.model.monitor import Monitor
from datadog_api_client.v1.model.monitor_draft_status import MonitorDraftStatus
from datadog_api_client.v1.model.monitor_options import MonitorOptions
from datadog_api_client.v1.model.monitor_options_custom_schedule import MonitorOptionsCustomSchedule
from datadog_api_client.v1.model.monitor_options_custom_schedule_recurrence import (
Expand Down Expand Up @@ -45,6 +46,7 @@
),
),
type=MonitorType.QUERY_ALERT,
draft_status=MonitorDraftStatus.PUBLISHED,
)

configuration = Configuration()
Expand Down
2 changes: 2 additions & 0 deletions examples/v1/monitors/CreateMonitor_440013737.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v1.api.monitors_api import MonitorsApi
from datadog_api_client.v1.model.monitor import Monitor
from datadog_api_client.v1.model.monitor_draft_status import MonitorDraftStatus
from datadog_api_client.v1.model.monitor_options import MonitorOptions
from datadog_api_client.v1.model.monitor_thresholds import MonitorThresholds
from datadog_api_client.v1.model.monitor_type import MonitorType
Expand All @@ -24,6 +25,7 @@
critical=1.0,
),
),
draft_status=MonitorDraftStatus.DRAFT,
)

configuration = Configuration()
Expand Down
15 changes: 15 additions & 0 deletions src/datadog_api_client/v1/model/monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

if TYPE_CHECKING:
from datadog_api_client.v1.model.creator import Creator
from datadog_api_client.v1.model.monitor_draft_status import MonitorDraftStatus
from datadog_api_client.v1.model.matching_downtime import MatchingDowntime
from datadog_api_client.v1.model.monitor_options import MonitorOptions
from datadog_api_client.v1.model.monitor_overall_states import MonitorOverallStates
Expand All @@ -28,6 +29,7 @@ class Monitor(ModelNormal):
@cached_property
def openapi_types(_):
from datadog_api_client.v1.model.creator import Creator
from datadog_api_client.v1.model.monitor_draft_status import MonitorDraftStatus
from datadog_api_client.v1.model.matching_downtime import MatchingDowntime
from datadog_api_client.v1.model.monitor_options import MonitorOptions
from datadog_api_client.v1.model.monitor_overall_states import MonitorOverallStates
Expand All @@ -38,6 +40,7 @@ def openapi_types(_):
"created": (datetime,),
"creator": (Creator,),
"deleted": (datetime, none_type),
"draft_status": (MonitorDraftStatus,),
"id": (int,),
"matching_downtimes": ([MatchingDowntime],),
"message": (str,),
Expand All @@ -58,6 +61,7 @@ def openapi_types(_):
"created": "created",
"creator": "creator",
"deleted": "deleted",
"draft_status": "draft_status",
"id": "id",
"matching_downtimes": "matching_downtimes",
"message": "message",
Expand Down Expand Up @@ -91,6 +95,7 @@ def __init__(
created: Union[datetime, UnsetType] = unset,
creator: Union[Creator, UnsetType] = unset,
deleted: Union[datetime, none_type, UnsetType] = unset,
draft_status: Union[MonitorDraftStatus, UnsetType] = unset,
id: Union[int, UnsetType] = unset,
matching_downtimes: Union[List[MatchingDowntime], UnsetType] = unset,
message: Union[str, UnsetType] = unset,
Expand All @@ -117,6 +122,14 @@ def __init__(
:param deleted: Whether or not the monitor is deleted. (Always ``null`` )
:type deleted: datetime, none_type, optional

:param draft_status: Indicates whether the monitor is in a draft or published state.

``draft`` : The monitor appears as Draft and does not send notifications.
``published`` : The monitor is active and evaluates conditions and notify as configured.

This field is in preview. The draft value is only available to customers with the feature enabled.
:type draft_status: MonitorDraftStatus, optional

:param id: ID of this monitor.
:type id: int, optional

Expand Down Expand Up @@ -165,6 +178,8 @@ def __init__(
kwargs["creator"] = creator
if deleted is not unset:
kwargs["deleted"] = deleted
if draft_status is not unset:
kwargs["draft_status"] = draft_status
if id is not unset:
kwargs["id"] = id
if matching_downtimes is not unset:
Expand Down
44 changes: 44 additions & 0 deletions src/datadog_api_client/v1/model/monitor_draft_status.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
# This product includes software developed at Datadog (https://www.datadoghq.com/).
# Copyright 2019-Present Datadog, Inc.
from __future__ import annotations


from datadog_api_client.model_utils import (
ModelSimple,
cached_property,
)

from typing import ClassVar


class MonitorDraftStatus(ModelSimple):
"""
Indicates whether the monitor is in a draft or published state.

`draft`: The monitor appears as Draft and does not send notifications.
`published`: The monitor is active and evaluates conditions and notify as configured.

This field is in preview. The draft value is only available to customers with the feature enabled.


:param value: If omitted defaults to "published". Must be one of ["draft", "published"].
:type value: str
"""

allowed_values = {
"draft",
"published",
}
DRAFT: ClassVar["MonitorDraftStatus"]
PUBLISHED: ClassVar["MonitorDraftStatus"]

@cached_property
def openapi_types(_):
return {
"value": (str,),
}


MonitorDraftStatus.DRAFT = MonitorDraftStatus("draft")
MonitorDraftStatus.PUBLISHED = MonitorDraftStatus("published")
15 changes: 15 additions & 0 deletions src/datadog_api_client/v1/model/monitor_update_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

if TYPE_CHECKING:
from datadog_api_client.v1.model.creator import Creator
from datadog_api_client.v1.model.monitor_draft_status import MonitorDraftStatus
from datadog_api_client.v1.model.monitor_options import MonitorOptions
from datadog_api_client.v1.model.monitor_overall_states import MonitorOverallStates
from datadog_api_client.v1.model.monitor_state import MonitorState
Expand All @@ -27,6 +28,7 @@ class MonitorUpdateRequest(ModelNormal):
@cached_property
def openapi_types(_):
from datadog_api_client.v1.model.creator import Creator
from datadog_api_client.v1.model.monitor_draft_status import MonitorDraftStatus
from datadog_api_client.v1.model.monitor_options import MonitorOptions
from datadog_api_client.v1.model.monitor_overall_states import MonitorOverallStates
from datadog_api_client.v1.model.monitor_state import MonitorState
Expand All @@ -36,6 +38,7 @@ def openapi_types(_):
"created": (datetime,),
"creator": (Creator,),
"deleted": (datetime, none_type),
"draft_status": (MonitorDraftStatus,),
"id": (int,),
"message": (str,),
"modified": (datetime,),
Expand All @@ -55,6 +58,7 @@ def openapi_types(_):
"created": "created",
"creator": "creator",
"deleted": "deleted",
"draft_status": "draft_status",
"id": "id",
"message": "message",
"modified": "modified",
Expand Down Expand Up @@ -85,6 +89,7 @@ def __init__(
created: Union[datetime, UnsetType] = unset,
creator: Union[Creator, UnsetType] = unset,
deleted: Union[datetime, none_type, UnsetType] = unset,
draft_status: Union[MonitorDraftStatus, UnsetType] = unset,
id: Union[int, UnsetType] = unset,
message: Union[str, UnsetType] = unset,
modified: Union[datetime, UnsetType] = unset,
Expand Down Expand Up @@ -112,6 +117,14 @@ def __init__(
:param deleted: Whether or not the monitor is deleted. (Always ``null`` )
:type deleted: datetime, none_type, optional

:param draft_status: Indicates whether the monitor is in a draft or published state.

``draft`` : The monitor appears as Draft and does not send notifications.
``published`` : The monitor is active and evaluates conditions and notify as configured.

This field is in preview. The draft value is only available to customers with the feature enabled.
:type draft_status: MonitorDraftStatus, optional

:param id: ID of this monitor.
:type id: int, optional

Expand Down Expand Up @@ -157,6 +170,8 @@ def __init__(
kwargs["creator"] = creator
if deleted is not unset:
kwargs["deleted"] = deleted
if draft_status is not unset:
kwargs["draft_status"] = draft_status
if id is not unset:
kwargs["id"] = id
if message is not unset:
Expand Down
2 changes: 2 additions & 0 deletions src/datadog_api_client/v1/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@
from datadog_api_client.v1.model.metrics_query_unit import MetricsQueryUnit
from datadog_api_client.v1.model.monitor import Monitor
from datadog_api_client.v1.model.monitor_device_id import MonitorDeviceID
from datadog_api_client.v1.model.monitor_draft_status import MonitorDraftStatus
from datadog_api_client.v1.model.monitor_formula_and_function_cost_aggregator import (
MonitorFormulaAndFunctionCostAggregator,
)
Expand Down Expand Up @@ -1376,6 +1377,7 @@
"MetricsQueryUnit",
"Monitor",
"MonitorDeviceID",
"MonitorDraftStatus",
"MonitorFormulaAndFunctionCostAggregator",
"MonitorFormulaAndFunctionCostDataSource",
"MonitorFormulaAndFunctionCostQueryDefinition",
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2023-11-09T17:58:50.774Z
2025-05-14T22:28:29.992Z
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
interactions:
- request:
body: '{"message":"some message Notify: @hipchat-channel","name":"Test-Create_a_metric_monitor_with_a_custom_schedule_returns_OK_response-1699552730","options":{"include_tags":false,"notify_audit":false,"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{*}
body: '{"draft_status":"published","message":"some message Notify: @hipchat-channel","name":"Test-Create_a_metric_monitor_with_a_custom_schedule_returns_OK_response-1747261709","options":{"include_tags":false,"notify_audit":false,"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{*}
> 0.5","tags":[],"type":"query alert"}'
headers:
accept:
Expand All @@ -11,10 +11,10 @@ interactions:
uri: https://api.datadoghq.com/api/v1/monitor
response:
body:
string: '{"id":134549556,"org_id":321813,"type":"query alert","name":"Test-Create_a_metric_monitor_with_a_custom_schedule_returns_OK_response-1699552730","message":"some
string: '{"id":172140210,"org_id":2,"type":"query alert","name":"Test-Create_a_metric_monitor_with_a_custom_schedule_returns_OK_response-1747261709","message":"some
message Notify: @hipchat-channel","tags":[],"query":"avg(current_1mo):avg:system.load.5{*}
> 0.5","options":{"include_tags":false,"notify_audit":false,"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":1699552731000,"created":"2023-11-09T17:58:51.118858+00:00","modified":"2023-11-09T17:58:51.118858+00:00","deleted":null,"restricted_roles":null,"priority":null,"overall_state_modified":null,"overall_state":"No
Data","creator":{"name":"CI Account","handle":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","email":"team-intg-tools-libs-spam@datadoghq.com","id":2320499}}
> 0.5","options":{"include_tags":false,"notify_audit":false,"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":{},"avalanche_window":20},"multi":false,"created_at":1747261710000,"created":"2025-05-14T22:28:30.512529+00:00","modified":"2025-05-14T22:28:30.512529+00:00","deleted":null,"priority":null,"draft_status":"published","restricted_roles":null,"restriction_policy":null,"overall_state_modified":null,"overall_state":"No
Data","creator":{"name":"Carl Martensen","handle":"carl.martensen@datadoghq.com","email":"carl.martensen@datadoghq.com","id":638339},"run_as":null,"restricted":true}

'
headers:
Expand All @@ -29,10 +29,10 @@ interactions:
accept:
- application/json
method: DELETE
uri: https://api.datadoghq.com/api/v1/monitor/134549556
uri: https://api.datadoghq.com/api/v1/monitor/172140210
response:
body:
string: '{"deleted_monitor_id":134549556}
string: '{"deleted_monitor_id":172140210}

'
headers:
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2022-02-02T21:04:10.597Z
2025-05-14T22:27:13.829Z
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
interactions:
- request:
body: '{"message":"some message Notify: @hipchat-channel","name":"Test-Create_a_RUM_formula_and_functions_monitor_returns_OK_response-1643835850","options":{"thresholds":{"critical":0.8},"variables":[{"compute":{"aggregation":"count"},"data_source":"rum","group_by":[],"indexes":["*"],"name":"query2","search":{"query":""}},{"compute":{"aggregation":"count"},"data_source":"rum","group_by":[],"indexes":["*"],"name":"query1","search":{"query":"status:error"}}]},"priority":3,"query":"formula(\"query2
/ query1 * 100\").last(\"15m\") >= 0.8","tags":["test:testcreatearumformulaandfunctionsmonitorreturnsokresponse1643835850","env:ci"],"type":"rum
body: '{"message":"some message Notify: @hipchat-channel","name":"Test-Create_a_RUM_formula_and_functions_monitor_returns_OK_response-1747261633","options":{"thresholds":{"critical":0.8},"variables":[{"compute":{"aggregation":"count"},"data_source":"rum","group_by":[],"indexes":["*"],"name":"query2","search":{"query":""}},{"compute":{"aggregation":"count"},"data_source":"rum","group_by":[],"indexes":["*"],"name":"query1","search":{"query":"status:error"}}]},"priority":3,"query":"formula(\"query2
/ query1 * 100\").last(\"15m\") >= 0.8","tags":["test:testcreatearumformulaandfunctionsmonitorreturnsokresponse1747261633","env:ci"],"type":"rum
alert"}'
headers:
accept:
Expand All @@ -12,9 +12,12 @@ interactions:
uri: https://api.datadoghq.com/api/v1/monitor
response:
body:
string: '{"restricted_roles":null,"tags":["test:testcreatearumformulaandfunctionsmonitorreturnsokresponse1643835850","env:ci"],"deleted":null,"query":"formula(\"query2
/ query1 * 100\").last(\"15m\") >= 0.8","message":"some message Notify: @hipchat-channel","id":62683819,"multi":false,"name":"Test-Create_a_RUM_formula_and_functions_monitor_returns_OK_response-1643835850","created":"2022-02-02T21:04:10.947341+00:00","created_at":1643835850000,"creator":{"id":1445416,"handle":"frog@datadoghq.com","name":null,"email":"frog@datadoghq.com"},"org_id":321813,"modified":"2022-02-02T21:04:10.947341+00:00","priority":3,"overall_state_modified":null,"overall_state":"No
Data","type":"rum alert","options":{"notify_audit":false,"locked":false,"silenced":{},"include_tags":true,"thresholds":{"critical":0.8},"new_host_delay":300,"notify_no_data":false,"groupby_simple_monitor":false,"variables":[{"search":{"query":""},"data_source":"rum","compute":{"aggregation":"count"},"name":"query2","indexes":["*"],"group_by":[]},{"search":{"query":"status:error"},"data_source":"rum","compute":{"aggregation":"count"},"name":"query1","indexes":["*"],"group_by":[]}]}}'
string: '{"id":172140181,"org_id":2,"type":"rum alert","name":"Test-Create_a_RUM_formula_and_functions_monitor_returns_OK_response-1747261633","message":"some
message Notify: @hipchat-channel","tags":["test:testcreatearumformulaandfunctionsmonitorreturnsokresponse1747261633","env:ci"],"query":"formula(\"query2
/ query1 * 100\").last(\"15m\") >= 0.8","options":{"thresholds":{"critical":0.8},"variables":[{"compute":{"aggregation":"count"},"data_source":"rum","group_by":[],"indexes":["*"],"name":"query2","search":{"query":""}},{"compute":{"aggregation":"count"},"data_source":"rum","group_by":[],"indexes":["*"],"name":"query1","search":{"query":"status:error"}}],"notify_no_data":false,"notify_audit":false,"new_host_delay":300,"include_tags":true,"groupby_simple_monitor":false,"silenced":{},"avalanche_window":20},"multi":false,"created_at":1747261634000,"created":"2025-05-14T22:27:14.329045+00:00","modified":"2025-05-14T22:27:14.329045+00:00","deleted":null,"priority":3,"draft_status":"published","restricted_roles":null,"restriction_policy":null,"overall_state_modified":null,"overall_state":"No
Data","creator":{"name":"Carl Martensen","handle":"carl.martensen@datadoghq.com","email":"carl.martensen@datadoghq.com","id":638339},"run_as":null,"restricted":true}

'
headers:
content-type:
- application/json
Expand All @@ -27,10 +30,12 @@ interactions:
accept:
- application/json
method: DELETE
uri: https://api.datadoghq.com/api/v1/monitor/62683819
uri: https://api.datadoghq.com/api/v1/monitor/172140181
response:
body:
string: '{"deleted_monitor_id":62683819}'
string: '{"deleted_monitor_id":172140181}

'
headers:
content-type:
- application/json
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2022-03-17T20:05:01.132Z
2025-05-14T22:17:22.560Z
Loading