Skip to content

Commit 7ee7f77

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-specshaneyuandd
authored
Add monitor draft status field (#3095)
* Regenerate client from commit 38b3c05a of spec repo * Update cassettes with default status --------- Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com> Co-authored-by: Shane Yuan <shane.yuan@datadoghq.com>
1 parent 33de26c commit 7ee7f77

17 files changed

Lines changed: 245 additions & 34 deletions

.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": "2025-06-04 12:51:38.802136",
8-
"spec_repo_commit": "35a63137"
7+
"regenerated": "2025-06-04 17:40:38.341419",
8+
"spec_repo_commit": "38b3c05a"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.6",
12-
"regenerated": "2025-06-04 12:51:38.821208",
13-
"spec_repo_commit": "35a63137"
12+
"regenerated": "2025-06-04 17:40:38.359022",
13+
"spec_repo_commit": "38b3c05a"
1414
}
1515
}
1616
}

.generator/schemas/v1/openapi.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6742,6 +6742,8 @@ components:
67426742
nullable: true
67436743
readOnly: true
67446744
type: string
6745+
draft_status:
6746+
$ref: '#/components/schemas/MonitorDraftStatus'
67456747
id:
67466748
description: ID of this monitor.
67476749
format: int64
@@ -6834,6 +6836,28 @@ components:
68346836
- FIREFOX_LAPTOP_LARGE
68356837
- FIREFOX_TABLET
68366838
- FIREFOX_MOBILE_SMALL
6839+
MonitorDraftStatus:
6840+
default: published
6841+
description: 'Indicates whether the monitor is in a draft or published state.
6842+
6843+
6844+
`draft`: The monitor appears as Draft and does not send notifications.
6845+
6846+
`published`: The monitor is active and evaluates conditions and notify as
6847+
configured.
6848+
6849+
6850+
This field is in preview. The draft value is only available to customers with
6851+
the feature enabled.
6852+
6853+
'
6854+
enum:
6855+
- draft
6856+
- published
6857+
type: string
6858+
x-enum-varnames:
6859+
- DRAFT
6860+
- PUBLISHED
68376861
MonitorFormulaAndFunctionCostAggregator:
68386862
description: Aggregation methods for metric queries.
68396863
enum:
@@ -7917,6 +7941,8 @@ components:
79177941
nullable: true
79187942
readOnly: true
79197943
type: string
7944+
draft_status:
7945+
$ref: '#/components/schemas/MonitorDraftStatus'
79207946
id:
79217947
description: ID of this monitor.
79227948
format: int64

api/datadogV1/model_monitor.go

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@ type Monitor struct {
1919
Creator *Creator `json:"creator,omitempty"`
2020
// Whether or not the monitor is deleted. (Always `null`)
2121
Deleted datadog.NullableTime `json:"deleted,omitempty"`
22+
// Indicates whether the monitor is in a draft or published state.
23+
//
24+
// `draft`: The monitor appears as Draft and does not send notifications.
25+
// `published`: The monitor is active and evaluates conditions and notify as configured.
26+
//
27+
// This field is in preview. The draft value is only available to customers with the feature enabled.
28+
//
29+
DraftStatus *MonitorDraftStatus `json:"draft_status,omitempty"`
2230
// ID of this monitor.
2331
Id *int64 `json:"id,omitempty"`
2432
// A list of active v1 downtimes that match this monitor.
@@ -58,6 +66,8 @@ type Monitor struct {
5866
// will change when the set of required properties is changed.
5967
func NewMonitor(query string, typeVar MonitorType) *Monitor {
6068
this := Monitor{}
69+
var draftStatus MonitorDraftStatus = MONITORDRAFTSTATUS_PUBLISHED
70+
this.DraftStatus = &draftStatus
6171
this.Query = query
6272
this.Type = typeVar
6373
return &this
@@ -68,6 +78,8 @@ func NewMonitor(query string, typeVar MonitorType) *Monitor {
6878
// but it doesn't guarantee that properties required by API are set.
6979
func NewMonitorWithDefaults() *Monitor {
7080
this := Monitor{}
81+
var draftStatus MonitorDraftStatus = MONITORDRAFTSTATUS_PUBLISHED
82+
this.DraftStatus = &draftStatus
7183
return &this
7284
}
7385

@@ -166,6 +178,34 @@ func (o *Monitor) UnsetDeleted() {
166178
o.Deleted.Unset()
167179
}
168180

181+
// GetDraftStatus returns the DraftStatus field value if set, zero value otherwise.
182+
func (o *Monitor) GetDraftStatus() MonitorDraftStatus {
183+
if o == nil || o.DraftStatus == nil {
184+
var ret MonitorDraftStatus
185+
return ret
186+
}
187+
return *o.DraftStatus
188+
}
189+
190+
// GetDraftStatusOk returns a tuple with the DraftStatus field value if set, nil otherwise
191+
// and a boolean to check if the value has been set.
192+
func (o *Monitor) GetDraftStatusOk() (*MonitorDraftStatus, bool) {
193+
if o == nil || o.DraftStatus == nil {
194+
return nil, false
195+
}
196+
return o.DraftStatus, true
197+
}
198+
199+
// HasDraftStatus returns a boolean if a field has been set.
200+
func (o *Monitor) HasDraftStatus() bool {
201+
return o != nil && o.DraftStatus != nil
202+
}
203+
204+
// SetDraftStatus gets a reference to the given MonitorDraftStatus and assigns it to the DraftStatus field.
205+
func (o *Monitor) SetDraftStatus(v MonitorDraftStatus) {
206+
o.DraftStatus = &v
207+
}
208+
169209
// GetId returns the Id field value if set, zero value otherwise.
170210
func (o *Monitor) GetId() int64 {
171211
if o == nil || o.Id == nil {
@@ -589,6 +629,9 @@ func (o Monitor) MarshalJSON() ([]byte, error) {
589629
if o.Deleted.IsSet() {
590630
toSerialize["deleted"] = o.Deleted.Get()
591631
}
632+
if o.DraftStatus != nil {
633+
toSerialize["draft_status"] = o.DraftStatus
634+
}
592635
if o.Id != nil {
593636
toSerialize["id"] = o.Id
594637
}
@@ -644,6 +687,7 @@ func (o *Monitor) UnmarshalJSON(bytes []byte) (err error) {
644687
Created *time.Time `json:"created,omitempty"`
645688
Creator *Creator `json:"creator,omitempty"`
646689
Deleted datadog.NullableTime `json:"deleted,omitempty"`
690+
DraftStatus *MonitorDraftStatus `json:"draft_status,omitempty"`
647691
Id *int64 `json:"id,omitempty"`
648692
MatchingDowntimes []MatchingDowntime `json:"matching_downtimes,omitempty"`
649693
Message *string `json:"message,omitempty"`
@@ -670,7 +714,7 @@ func (o *Monitor) UnmarshalJSON(bytes []byte) (err error) {
670714
}
671715
additionalProperties := make(map[string]interface{})
672716
if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil {
673-
datadog.DeleteKeys(additionalProperties, &[]string{"created", "creator", "deleted", "id", "matching_downtimes", "message", "modified", "multi", "name", "options", "overall_state", "priority", "query", "restricted_roles", "state", "tags", "type"})
717+
datadog.DeleteKeys(additionalProperties, &[]string{"created", "creator", "deleted", "draft_status", "id", "matching_downtimes", "message", "modified", "multi", "name", "options", "overall_state", "priority", "query", "restricted_roles", "state", "tags", "type"})
674718
} else {
675719
return err
676720
}
@@ -682,6 +726,11 @@ func (o *Monitor) UnmarshalJSON(bytes []byte) (err error) {
682726
}
683727
o.Creator = all.Creator
684728
o.Deleted = all.Deleted
729+
if all.DraftStatus != nil && !all.DraftStatus.IsValid() {
730+
hasInvalidField = true
731+
} else {
732+
o.DraftStatus = all.DraftStatus
733+
}
685734
o.Id = all.Id
686735
o.MatchingDowntimes = all.MatchingDowntimes
687736
o.Message = all.Message
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
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+
5+
package datadogV1
6+
7+
import (
8+
"fmt"
9+
10+
"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
11+
)
12+
13+
// MonitorDraftStatus Indicates whether the monitor is in a draft or published state.
14+
//
15+
// `draft`: The monitor appears as Draft and does not send notifications.
16+
// `published`: The monitor is active and evaluates conditions and notify as configured.
17+
//
18+
// This field is in preview. The draft value is only available to customers with the feature enabled.
19+
type MonitorDraftStatus string
20+
21+
// List of MonitorDraftStatus.
22+
const (
23+
MONITORDRAFTSTATUS_DRAFT MonitorDraftStatus = "draft"
24+
MONITORDRAFTSTATUS_PUBLISHED MonitorDraftStatus = "published"
25+
)
26+
27+
var allowedMonitorDraftStatusEnumValues = []MonitorDraftStatus{
28+
MONITORDRAFTSTATUS_DRAFT,
29+
MONITORDRAFTSTATUS_PUBLISHED,
30+
}
31+
32+
// GetAllowedValues reeturns the list of possible values.
33+
func (v *MonitorDraftStatus) GetAllowedValues() []MonitorDraftStatus {
34+
return allowedMonitorDraftStatusEnumValues
35+
}
36+
37+
// UnmarshalJSON deserializes the given payload.
38+
func (v *MonitorDraftStatus) UnmarshalJSON(src []byte) error {
39+
var value string
40+
err := datadog.Unmarshal(src, &value)
41+
if err != nil {
42+
return err
43+
}
44+
*v = MonitorDraftStatus(value)
45+
return nil
46+
}
47+
48+
// NewMonitorDraftStatusFromValue returns a pointer to a valid MonitorDraftStatus
49+
// for the value passed as argument, or an error if the value passed is not allowed by the enum.
50+
func NewMonitorDraftStatusFromValue(v string) (*MonitorDraftStatus, error) {
51+
ev := MonitorDraftStatus(v)
52+
if ev.IsValid() {
53+
return &ev, nil
54+
}
55+
return nil, fmt.Errorf("invalid value '%v' for MonitorDraftStatus: valid values are %v", v, allowedMonitorDraftStatusEnumValues)
56+
}
57+
58+
// IsValid return true if the value is valid for the enum, false otherwise.
59+
func (v MonitorDraftStatus) IsValid() bool {
60+
for _, existing := range allowedMonitorDraftStatusEnumValues {
61+
if existing == v {
62+
return true
63+
}
64+
}
65+
return false
66+
}
67+
68+
// Ptr returns reference to MonitorDraftStatus value.
69+
func (v MonitorDraftStatus) Ptr() *MonitorDraftStatus {
70+
return &v
71+
}

api/datadogV1/model_monitor_update_request.go

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ type MonitorUpdateRequest struct {
1818
Creator *Creator `json:"creator,omitempty"`
1919
// Whether or not the monitor is deleted. (Always `null`)
2020
Deleted datadog.NullableTime `json:"deleted,omitempty"`
21+
// Indicates whether the monitor is in a draft or published state.
22+
//
23+
// `draft`: The monitor appears as Draft and does not send notifications.
24+
// `published`: The monitor is active and evaluates conditions and notify as configured.
25+
//
26+
// This field is in preview. The draft value is only available to customers with the feature enabled.
27+
//
28+
DraftStatus *MonitorDraftStatus `json:"draft_status,omitempty"`
2129
// ID of this monitor.
2230
Id *int64 `json:"id,omitempty"`
2331
// A message to include with notifications for this monitor.
@@ -55,6 +63,8 @@ type MonitorUpdateRequest struct {
5563
// will change when the set of required properties is changed.
5664
func NewMonitorUpdateRequest() *MonitorUpdateRequest {
5765
this := MonitorUpdateRequest{}
66+
var draftStatus MonitorDraftStatus = MONITORDRAFTSTATUS_PUBLISHED
67+
this.DraftStatus = &draftStatus
5868
return &this
5969
}
6070

@@ -63,6 +73,8 @@ func NewMonitorUpdateRequest() *MonitorUpdateRequest {
6373
// but it doesn't guarantee that properties required by API are set.
6474
func NewMonitorUpdateRequestWithDefaults() *MonitorUpdateRequest {
6575
this := MonitorUpdateRequest{}
76+
var draftStatus MonitorDraftStatus = MONITORDRAFTSTATUS_PUBLISHED
77+
this.DraftStatus = &draftStatus
6678
return &this
6779
}
6880

@@ -161,6 +173,34 @@ func (o *MonitorUpdateRequest) UnsetDeleted() {
161173
o.Deleted.Unset()
162174
}
163175

176+
// GetDraftStatus returns the DraftStatus field value if set, zero value otherwise.
177+
func (o *MonitorUpdateRequest) GetDraftStatus() MonitorDraftStatus {
178+
if o == nil || o.DraftStatus == nil {
179+
var ret MonitorDraftStatus
180+
return ret
181+
}
182+
return *o.DraftStatus
183+
}
184+
185+
// GetDraftStatusOk returns a tuple with the DraftStatus field value if set, nil otherwise
186+
// and a boolean to check if the value has been set.
187+
func (o *MonitorUpdateRequest) GetDraftStatusOk() (*MonitorDraftStatus, bool) {
188+
if o == nil || o.DraftStatus == nil {
189+
return nil, false
190+
}
191+
return o.DraftStatus, true
192+
}
193+
194+
// HasDraftStatus returns a boolean if a field has been set.
195+
func (o *MonitorUpdateRequest) HasDraftStatus() bool {
196+
return o != nil && o.DraftStatus != nil
197+
}
198+
199+
// SetDraftStatus gets a reference to the given MonitorDraftStatus and assigns it to the DraftStatus field.
200+
func (o *MonitorUpdateRequest) SetDraftStatus(v MonitorDraftStatus) {
201+
o.DraftStatus = &v
202+
}
203+
164204
// GetId returns the Id field value if set, zero value otherwise.
165205
func (o *MonitorUpdateRequest) GetId() int64 {
166206
if o == nil || o.Id == nil {
@@ -566,6 +606,9 @@ func (o MonitorUpdateRequest) MarshalJSON() ([]byte, error) {
566606
if o.Deleted.IsSet() {
567607
toSerialize["deleted"] = o.Deleted.Get()
568608
}
609+
if o.DraftStatus != nil {
610+
toSerialize["draft_status"] = o.DraftStatus
611+
}
569612
if o.Id != nil {
570613
toSerialize["id"] = o.Id
571614
}
@@ -622,6 +665,7 @@ func (o *MonitorUpdateRequest) UnmarshalJSON(bytes []byte) (err error) {
622665
Created *time.Time `json:"created,omitempty"`
623666
Creator *Creator `json:"creator,omitempty"`
624667
Deleted datadog.NullableTime `json:"deleted,omitempty"`
668+
DraftStatus *MonitorDraftStatus `json:"draft_status,omitempty"`
625669
Id *int64 `json:"id,omitempty"`
626670
Message *string `json:"message,omitempty"`
627671
Modified *time.Time `json:"modified,omitempty"`
@@ -641,7 +685,7 @@ func (o *MonitorUpdateRequest) UnmarshalJSON(bytes []byte) (err error) {
641685
}
642686
additionalProperties := make(map[string]interface{})
643687
if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil {
644-
datadog.DeleteKeys(additionalProperties, &[]string{"created", "creator", "deleted", "id", "message", "modified", "multi", "name", "options", "overall_state", "priority", "query", "restricted_roles", "state", "tags", "type"})
688+
datadog.DeleteKeys(additionalProperties, &[]string{"created", "creator", "deleted", "draft_status", "id", "message", "modified", "multi", "name", "options", "overall_state", "priority", "query", "restricted_roles", "state", "tags", "type"})
645689
} else {
646690
return err
647691
}
@@ -653,6 +697,11 @@ func (o *MonitorUpdateRequest) UnmarshalJSON(bytes []byte) (err error) {
653697
}
654698
o.Creator = all.Creator
655699
o.Deleted = all.Deleted
700+
if all.DraftStatus != nil && !all.DraftStatus.IsValid() {
701+
hasInvalidField = true
702+
} else {
703+
o.DraftStatus = all.DraftStatus
704+
}
656705
o.Id = all.Id
657706
o.Message = all.Message
658707
o.Modified = all.Modified

examples/v1/monitors/CreateMonitor_1539578087.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ func main() {
4040
},
4141
},
4242
},
43-
Type: datadogV1.MONITORTYPE_QUERY_ALERT,
43+
Type: datadogV1.MONITORTYPE_QUERY_ALERT,
44+
DraftStatus: datadogV1.MONITORDRAFTSTATUS_PUBLISHED.Ptr(),
4445
}
4546
ctx := datadog.NewDefaultContext(context.Background())
4647
configuration := datadog.NewConfiguration()

examples/v1/monitors/CreateMonitor_440013737.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ func main() {
2828
Critical: datadog.PtrFloat64(1),
2929
},
3030
},
31+
DraftStatus: datadogV1.MONITORDRAFTSTATUS_DRAFT.Ptr(),
3132
}
3233
ctx := datadog.NewDefaultContext(context.Background())
3334
configuration := datadog.NewConfiguration()

tests/api/datadogV1/cassettes/TestMonitorCanDeleteErrors.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ interactions:
1313
remote_addr: ""
1414
request_uri: ""
1515
body: |
16-
{"query":"avg(last_5m):sum:system.net.bytes_rcvd{host:host0} \u003e 100","type":"query alert"}
16+
{"draft_status":"published","query":"avg(last_5m):sum:system.net.bytes_rcvd{host:host0} \u003e 100","type":"query alert"}
1717
form: {}
1818
headers:
1919
Accept:
@@ -83,7 +83,7 @@ interactions:
8383
remote_addr: ""
8484
request_uri: ""
8585
body: |
86-
{"query":"49714524","type":"composite"}
86+
{"draft_status":"published","query":"49714524","type":"composite"}
8787
form: {}
8888
headers:
8989
Accept:

tests/api/datadogV1/cassettes/TestMonitorUpdateErrors/400_Bad_Request.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ interactions:
1313
remote_addr: ""
1414
request_uri: ""
1515
body: |
16-
{"type":"composite"}
16+
{"draft_status":"published","type":"composite"}
1717
form: {}
1818
headers:
1919
Accept:

0 commit comments

Comments
 (0)