Skip to content

Commit 93bcb61

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
feat - Add data-jobs alert monitor type support (#4080)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent 120e2d3 commit 93bcb61

8 files changed

Lines changed: 376 additions & 0 deletions

.generator/schemas/v1/openapi.yaml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8069,6 +8069,36 @@ components:
80698069
- data_source
80708070
- query
80718071
type: object
8072+
MonitorFormulaAndFunctionDataJobsQueryDefinition:
8073+
description: A formula and functions data jobs query.
8074+
properties:
8075+
job_type:
8076+
description: |-
8077+
The type of job being monitored. Valid values include:
8078+
`databricks.job`, `spark.application`, `airflow.dag`,
8079+
`dbt.job`, `dbt.model`, `dbt.test`, `glue.job`.
8080+
Custom job types are supported with the `custom.ol.` prefix.
8081+
example: "databricks.job"
8082+
type: string
8083+
jobs_query:
8084+
description: Filter expression used to select the jobs to monitor.
8085+
example: "job_name:smoke*"
8086+
type: string
8087+
name:
8088+
description: Name of the query for use in formulas. Must be `run_query`.
8089+
example: "run_query"
8090+
type: string
8091+
query_dialect:
8092+
description: |-
8093+
Query dialect for data jobs queries. Currently only `metric` is supported.
8094+
example: "metric"
8095+
type: string
8096+
required:
8097+
- name
8098+
- jobs_query
8099+
- job_type
8100+
- query_dialect
8101+
type: object
80728102
MonitorFormulaAndFunctionDataQualityDataSource:
80738103
description: Data source for data quality queries.
80748104
enum:
@@ -8375,6 +8405,7 @@ components:
83758405
- $ref: "#/components/schemas/MonitorFormulaAndFunctionEventQueryDefinition"
83768406
- $ref: "#/components/schemas/MonitorFormulaAndFunctionCostQueryDefinition"
83778407
- $ref: "#/components/schemas/MonitorFormulaAndFunctionDataQualityQueryDefinition"
8408+
- $ref: "#/components/schemas/MonitorFormulaAndFunctionDataJobsQueryDefinition"
83788409
- $ref: "#/components/schemas/MonitorFormulaAndFunctionAggregateAugmentedQueryDefinition"
83798410
- $ref: "#/components/schemas/MonitorFormulaAndFunctionAggregateFilteredQueryDefinition"
83808411
MonitorFormulaAndFunctionReferenceTableColumn:
@@ -9207,6 +9238,7 @@ components:
92079238
- "cost alert"
92089239
- "data-quality alert"
92099240
- "network-path alert"
9241+
- "data-jobs alert"
92109242
example: "query alert"
92119243
type: string
92129244
x-enum-varnames:
@@ -9231,6 +9263,7 @@ components:
92319263
- COST_ALERT
92329264
- DATA_QUALITY_ALERT
92339265
- NETWORK_PATH_ALERT
9266+
- DATA_JOBS_ALERT
92349267
MonitorUpdateRequest:
92359268
description: Object describing a monitor update request.
92369269
properties:
Lines changed: 200 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,200 @@
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+
// MonitorFormulaAndFunctionDataJobsQueryDefinition A formula and functions data jobs query.
14+
type MonitorFormulaAndFunctionDataJobsQueryDefinition struct {
15+
// The type of job being monitored. Valid values include:
16+
// `databricks.job`, `spark.application`, `airflow.dag`,
17+
// `dbt.job`, `dbt.model`, `dbt.test`, `glue.job`.
18+
// Custom job types are supported with the `custom.ol.` prefix.
19+
JobType string `json:"job_type"`
20+
// Filter expression used to select the jobs to monitor.
21+
JobsQuery string `json:"jobs_query"`
22+
// Name of the query for use in formulas. Must be `run_query`.
23+
Name string `json:"name"`
24+
// Query dialect for data jobs queries. Currently only `metric` is supported.
25+
QueryDialect string `json:"query_dialect"`
26+
// UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct
27+
UnparsedObject map[string]interface{} `json:"-"`
28+
AdditionalProperties map[string]interface{} `json:"-"`
29+
}
30+
31+
// NewMonitorFormulaAndFunctionDataJobsQueryDefinition instantiates a new MonitorFormulaAndFunctionDataJobsQueryDefinition object.
32+
// This constructor will assign default values to properties that have it defined,
33+
// and makes sure properties required by API are set, but the set of arguments
34+
// will change when the set of required properties is changed.
35+
func NewMonitorFormulaAndFunctionDataJobsQueryDefinition(jobType string, jobsQuery string, name string, queryDialect string) *MonitorFormulaAndFunctionDataJobsQueryDefinition {
36+
this := MonitorFormulaAndFunctionDataJobsQueryDefinition{}
37+
this.JobType = jobType
38+
this.JobsQuery = jobsQuery
39+
this.Name = name
40+
this.QueryDialect = queryDialect
41+
return &this
42+
}
43+
44+
// NewMonitorFormulaAndFunctionDataJobsQueryDefinitionWithDefaults instantiates a new MonitorFormulaAndFunctionDataJobsQueryDefinition object.
45+
// This constructor will only assign default values to properties that have it defined,
46+
// but it doesn't guarantee that properties required by API are set.
47+
func NewMonitorFormulaAndFunctionDataJobsQueryDefinitionWithDefaults() *MonitorFormulaAndFunctionDataJobsQueryDefinition {
48+
this := MonitorFormulaAndFunctionDataJobsQueryDefinition{}
49+
return &this
50+
}
51+
52+
// GetJobType returns the JobType field value.
53+
func (o *MonitorFormulaAndFunctionDataJobsQueryDefinition) GetJobType() string {
54+
if o == nil {
55+
var ret string
56+
return ret
57+
}
58+
return o.JobType
59+
}
60+
61+
// GetJobTypeOk returns a tuple with the JobType field value
62+
// and a boolean to check if the value has been set.
63+
func (o *MonitorFormulaAndFunctionDataJobsQueryDefinition) GetJobTypeOk() (*string, bool) {
64+
if o == nil {
65+
return nil, false
66+
}
67+
return &o.JobType, true
68+
}
69+
70+
// SetJobType sets field value.
71+
func (o *MonitorFormulaAndFunctionDataJobsQueryDefinition) SetJobType(v string) {
72+
o.JobType = v
73+
}
74+
75+
// GetJobsQuery returns the JobsQuery field value.
76+
func (o *MonitorFormulaAndFunctionDataJobsQueryDefinition) GetJobsQuery() string {
77+
if o == nil {
78+
var ret string
79+
return ret
80+
}
81+
return o.JobsQuery
82+
}
83+
84+
// GetJobsQueryOk returns a tuple with the JobsQuery field value
85+
// and a boolean to check if the value has been set.
86+
func (o *MonitorFormulaAndFunctionDataJobsQueryDefinition) GetJobsQueryOk() (*string, bool) {
87+
if o == nil {
88+
return nil, false
89+
}
90+
return &o.JobsQuery, true
91+
}
92+
93+
// SetJobsQuery sets field value.
94+
func (o *MonitorFormulaAndFunctionDataJobsQueryDefinition) SetJobsQuery(v string) {
95+
o.JobsQuery = v
96+
}
97+
98+
// GetName returns the Name field value.
99+
func (o *MonitorFormulaAndFunctionDataJobsQueryDefinition) GetName() string {
100+
if o == nil {
101+
var ret string
102+
return ret
103+
}
104+
return o.Name
105+
}
106+
107+
// GetNameOk returns a tuple with the Name field value
108+
// and a boolean to check if the value has been set.
109+
func (o *MonitorFormulaAndFunctionDataJobsQueryDefinition) GetNameOk() (*string, bool) {
110+
if o == nil {
111+
return nil, false
112+
}
113+
return &o.Name, true
114+
}
115+
116+
// SetName sets field value.
117+
func (o *MonitorFormulaAndFunctionDataJobsQueryDefinition) SetName(v string) {
118+
o.Name = v
119+
}
120+
121+
// GetQueryDialect returns the QueryDialect field value.
122+
func (o *MonitorFormulaAndFunctionDataJobsQueryDefinition) GetQueryDialect() string {
123+
if o == nil {
124+
var ret string
125+
return ret
126+
}
127+
return o.QueryDialect
128+
}
129+
130+
// GetQueryDialectOk returns a tuple with the QueryDialect field value
131+
// and a boolean to check if the value has been set.
132+
func (o *MonitorFormulaAndFunctionDataJobsQueryDefinition) GetQueryDialectOk() (*string, bool) {
133+
if o == nil {
134+
return nil, false
135+
}
136+
return &o.QueryDialect, true
137+
}
138+
139+
// SetQueryDialect sets field value.
140+
func (o *MonitorFormulaAndFunctionDataJobsQueryDefinition) SetQueryDialect(v string) {
141+
o.QueryDialect = v
142+
}
143+
144+
// MarshalJSON serializes the struct using spec logic.
145+
func (o MonitorFormulaAndFunctionDataJobsQueryDefinition) MarshalJSON() ([]byte, error) {
146+
toSerialize := map[string]interface{}{}
147+
if o.UnparsedObject != nil {
148+
return datadog.Marshal(o.UnparsedObject)
149+
}
150+
toSerialize["job_type"] = o.JobType
151+
toSerialize["jobs_query"] = o.JobsQuery
152+
toSerialize["name"] = o.Name
153+
toSerialize["query_dialect"] = o.QueryDialect
154+
155+
for key, value := range o.AdditionalProperties {
156+
toSerialize[key] = value
157+
}
158+
return datadog.Marshal(toSerialize)
159+
}
160+
161+
// UnmarshalJSON deserializes the given payload.
162+
func (o *MonitorFormulaAndFunctionDataJobsQueryDefinition) UnmarshalJSON(bytes []byte) (err error) {
163+
all := struct {
164+
JobType *string `json:"job_type"`
165+
JobsQuery *string `json:"jobs_query"`
166+
Name *string `json:"name"`
167+
QueryDialect *string `json:"query_dialect"`
168+
}{}
169+
if err = datadog.Unmarshal(bytes, &all); err != nil {
170+
return datadog.Unmarshal(bytes, &o.UnparsedObject)
171+
}
172+
if all.JobType == nil {
173+
return fmt.Errorf("required field job_type missing")
174+
}
175+
if all.JobsQuery == nil {
176+
return fmt.Errorf("required field jobs_query missing")
177+
}
178+
if all.Name == nil {
179+
return fmt.Errorf("required field name missing")
180+
}
181+
if all.QueryDialect == nil {
182+
return fmt.Errorf("required field query_dialect missing")
183+
}
184+
additionalProperties := make(map[string]interface{})
185+
if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil {
186+
datadog.DeleteKeys(additionalProperties, &[]string{"job_type", "jobs_query", "name", "query_dialect"})
187+
} else {
188+
return err
189+
}
190+
o.JobType = *all.JobType
191+
o.JobsQuery = *all.JobsQuery
192+
o.Name = *all.Name
193+
o.QueryDialect = *all.QueryDialect
194+
195+
if len(additionalProperties) > 0 {
196+
o.AdditionalProperties = additionalProperties
197+
}
198+
199+
return nil
200+
}

api/datadogV1/model_monitor_formula_and_function_query_definition.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ type MonitorFormulaAndFunctionQueryDefinition struct {
1313
MonitorFormulaAndFunctionEventQueryDefinition *MonitorFormulaAndFunctionEventQueryDefinition
1414
MonitorFormulaAndFunctionCostQueryDefinition *MonitorFormulaAndFunctionCostQueryDefinition
1515
MonitorFormulaAndFunctionDataQualityQueryDefinition *MonitorFormulaAndFunctionDataQualityQueryDefinition
16+
MonitorFormulaAndFunctionDataJobsQueryDefinition *MonitorFormulaAndFunctionDataJobsQueryDefinition
1617
MonitorFormulaAndFunctionAggregateAugmentedQueryDefinition *MonitorFormulaAndFunctionAggregateAugmentedQueryDefinition
1718
MonitorFormulaAndFunctionAggregateFilteredQueryDefinition *MonitorFormulaAndFunctionAggregateFilteredQueryDefinition
1819

@@ -35,6 +36,11 @@ func MonitorFormulaAndFunctionDataQualityQueryDefinitionAsMonitorFormulaAndFunct
3536
return MonitorFormulaAndFunctionQueryDefinition{MonitorFormulaAndFunctionDataQualityQueryDefinition: v}
3637
}
3738

39+
// MonitorFormulaAndFunctionDataJobsQueryDefinitionAsMonitorFormulaAndFunctionQueryDefinition is a convenience function that returns MonitorFormulaAndFunctionDataJobsQueryDefinition wrapped in MonitorFormulaAndFunctionQueryDefinition.
40+
func MonitorFormulaAndFunctionDataJobsQueryDefinitionAsMonitorFormulaAndFunctionQueryDefinition(v *MonitorFormulaAndFunctionDataJobsQueryDefinition) MonitorFormulaAndFunctionQueryDefinition {
41+
return MonitorFormulaAndFunctionQueryDefinition{MonitorFormulaAndFunctionDataJobsQueryDefinition: v}
42+
}
43+
3844
// MonitorFormulaAndFunctionAggregateAugmentedQueryDefinitionAsMonitorFormulaAndFunctionQueryDefinition is a convenience function that returns MonitorFormulaAndFunctionAggregateAugmentedQueryDefinition wrapped in MonitorFormulaAndFunctionQueryDefinition.
3945
func MonitorFormulaAndFunctionAggregateAugmentedQueryDefinitionAsMonitorFormulaAndFunctionQueryDefinition(v *MonitorFormulaAndFunctionAggregateAugmentedQueryDefinition) MonitorFormulaAndFunctionQueryDefinition {
4046
return MonitorFormulaAndFunctionQueryDefinition{MonitorFormulaAndFunctionAggregateAugmentedQueryDefinition: v}
@@ -100,6 +106,23 @@ func (obj *MonitorFormulaAndFunctionQueryDefinition) UnmarshalJSON(data []byte)
100106
obj.MonitorFormulaAndFunctionDataQualityQueryDefinition = nil
101107
}
102108

109+
// try to unmarshal data into MonitorFormulaAndFunctionDataJobsQueryDefinition
110+
err = datadog.Unmarshal(data, &obj.MonitorFormulaAndFunctionDataJobsQueryDefinition)
111+
if err == nil {
112+
if obj.MonitorFormulaAndFunctionDataJobsQueryDefinition != nil && obj.MonitorFormulaAndFunctionDataJobsQueryDefinition.UnparsedObject == nil {
113+
jsonMonitorFormulaAndFunctionDataJobsQueryDefinition, _ := datadog.Marshal(obj.MonitorFormulaAndFunctionDataJobsQueryDefinition)
114+
if string(jsonMonitorFormulaAndFunctionDataJobsQueryDefinition) == "{}" { // empty struct
115+
obj.MonitorFormulaAndFunctionDataJobsQueryDefinition = nil
116+
} else {
117+
match++
118+
}
119+
} else {
120+
obj.MonitorFormulaAndFunctionDataJobsQueryDefinition = nil
121+
}
122+
} else {
123+
obj.MonitorFormulaAndFunctionDataJobsQueryDefinition = nil
124+
}
125+
103126
// try to unmarshal data into MonitorFormulaAndFunctionAggregateAugmentedQueryDefinition
104127
err = datadog.Unmarshal(data, &obj.MonitorFormulaAndFunctionAggregateAugmentedQueryDefinition)
105128
if err == nil {
@@ -139,6 +162,7 @@ func (obj *MonitorFormulaAndFunctionQueryDefinition) UnmarshalJSON(data []byte)
139162
obj.MonitorFormulaAndFunctionEventQueryDefinition = nil
140163
obj.MonitorFormulaAndFunctionCostQueryDefinition = nil
141164
obj.MonitorFormulaAndFunctionDataQualityQueryDefinition = nil
165+
obj.MonitorFormulaAndFunctionDataJobsQueryDefinition = nil
142166
obj.MonitorFormulaAndFunctionAggregateAugmentedQueryDefinition = nil
143167
obj.MonitorFormulaAndFunctionAggregateFilteredQueryDefinition = nil
144168
return datadog.Unmarshal(data, &obj.UnparsedObject)
@@ -160,6 +184,10 @@ func (obj MonitorFormulaAndFunctionQueryDefinition) MarshalJSON() ([]byte, error
160184
return datadog.Marshal(&obj.MonitorFormulaAndFunctionDataQualityQueryDefinition)
161185
}
162186

187+
if obj.MonitorFormulaAndFunctionDataJobsQueryDefinition != nil {
188+
return datadog.Marshal(&obj.MonitorFormulaAndFunctionDataJobsQueryDefinition)
189+
}
190+
163191
if obj.MonitorFormulaAndFunctionAggregateAugmentedQueryDefinition != nil {
164192
return datadog.Marshal(&obj.MonitorFormulaAndFunctionAggregateAugmentedQueryDefinition)
165193
}
@@ -188,6 +216,10 @@ func (obj *MonitorFormulaAndFunctionQueryDefinition) GetActualInstance() interfa
188216
return obj.MonitorFormulaAndFunctionDataQualityQueryDefinition
189217
}
190218

219+
if obj.MonitorFormulaAndFunctionDataJobsQueryDefinition != nil {
220+
return obj.MonitorFormulaAndFunctionDataJobsQueryDefinition
221+
}
222+
191223
if obj.MonitorFormulaAndFunctionAggregateAugmentedQueryDefinition != nil {
192224
return obj.MonitorFormulaAndFunctionAggregateAugmentedQueryDefinition
193225
}

api/datadogV1/model_monitor_type.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ const (
3636
MONITORTYPE_COST_ALERT MonitorType = "cost alert"
3737
MONITORTYPE_DATA_QUALITY_ALERT MonitorType = "data-quality alert"
3838
MONITORTYPE_NETWORK_PATH_ALERT MonitorType = "network-path alert"
39+
MONITORTYPE_DATA_JOBS_ALERT MonitorType = "data-jobs alert"
3940
)
4041

4142
var allowedMonitorTypeEnumValues = []MonitorType{
@@ -60,6 +61,7 @@ var allowedMonitorTypeEnumValues = []MonitorType{
6061
MONITORTYPE_COST_ALERT,
6162
MONITORTYPE_DATA_QUALITY_ALERT,
6263
MONITORTYPE_NETWORK_PATH_ALERT,
64+
MONITORTYPE_DATA_JOBS_ALERT,
6365
}
6466

6567
// GetAllowedValues reeturns the list of possible values.

0 commit comments

Comments
 (0)