Skip to content

Commit 097b605

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add workflow schedule overlap behavior (#1865)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent a928eda commit 097b605

4 files changed

Lines changed: 97 additions & 0 deletions

File tree

.generator/schemas/v2/openapi.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87680,13 +87680,26 @@ components:
8768087680
ScheduleTrigger:
8768187681
description: "Trigger a workflow from a Schedule. The workflow must be published."
8768287682
properties:
87683+
overlapBehavior:
87684+
$ref: "#/components/schemas/ScheduleTriggerOverlapBehavior"
8768387685
rruleExpression:
8768487686
description: "Recurrence rule expression for scheduling."
8768587687
example: ""
8768687688
type: string
8768787689
required:
8768887690
- rruleExpression
8768987691
type: object
87692+
ScheduleTriggerOverlapBehavior:
87693+
default: EXCLUSIVE_RUN
87694+
description: Controls whether a scheduled workflow run may start while another instance is still running.
87695+
enum:
87696+
- EXCLUSIVE_RUN
87697+
- OVERLAP_ALLOWED
87698+
example: EXCLUSIVE_RUN
87699+
type: string
87700+
x-enum-varnames:
87701+
- EXCLUSIVE_RUN
87702+
- OVERLAP_ALLOWED
8769087703
ScheduleTriggerWrapper:
8769187704
description: "Schema for a Schedule-based trigger."
8769287705
properties:

src/datadogV2/model/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13878,6 +13878,8 @@ pub mod model_schedule_trigger_wrapper;
1387813878
pub use self::model_schedule_trigger_wrapper::ScheduleTriggerWrapper;
1387913879
pub mod model_schedule_trigger;
1388013880
pub use self::model_schedule_trigger::ScheduleTrigger;
13881+
pub mod model_schedule_trigger_overlap_behavior;
13882+
pub use self::model_schedule_trigger_overlap_behavior::ScheduleTriggerOverlapBehavior;
1388113883
pub mod model_security_trigger_wrapper;
1388213884
pub use self::model_security_trigger_wrapper::SecurityTriggerWrapper;
1388313885
pub mod model_security_trigger;

src/datadogV2/model/model_schedule_trigger.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ use std::fmt::{self, Formatter};
1111
#[skip_serializing_none]
1212
#[derive(Clone, Debug, PartialEq, Serialize)]
1313
pub struct ScheduleTrigger {
14+
/// Controls whether a scheduled workflow run may start while another instance is still running.
15+
#[serde(rename = "overlapBehavior")]
16+
pub overlap_behavior: Option<crate::datadogV2::model::ScheduleTriggerOverlapBehavior>,
1417
/// Recurrence rule expression for scheduling.
1518
#[serde(rename = "rruleExpression")]
1619
pub rrule_expression: String,
@@ -24,12 +27,21 @@ pub struct ScheduleTrigger {
2427
impl ScheduleTrigger {
2528
pub fn new(rrule_expression: String) -> ScheduleTrigger {
2629
ScheduleTrigger {
30+
overlap_behavior: None,
2731
rrule_expression,
2832
additional_properties: std::collections::BTreeMap::new(),
2933
_unparsed: false,
3034
}
3135
}
3236

37+
pub fn overlap_behavior(
38+
mut self,
39+
value: crate::datadogV2::model::ScheduleTriggerOverlapBehavior,
40+
) -> Self {
41+
self.overlap_behavior = Some(value);
42+
self
43+
}
44+
3345
pub fn additional_properties(
3446
mut self,
3547
value: std::collections::BTreeMap<String, serde_json::Value>,
@@ -56,6 +68,9 @@ impl<'de> Deserialize<'de> for ScheduleTrigger {
5668
where
5769
M: MapAccess<'a>,
5870
{
71+
let mut overlap_behavior: Option<
72+
crate::datadogV2::model::ScheduleTriggerOverlapBehavior,
73+
> = None;
5974
let mut rrule_expression: Option<String> = None;
6075
let mut additional_properties: std::collections::BTreeMap<
6176
String,
@@ -65,6 +80,21 @@ impl<'de> Deserialize<'de> for ScheduleTrigger {
6580

6681
while let Some((k, v)) = map.next_entry::<String, serde_json::Value>()? {
6782
match k.as_str() {
83+
"overlapBehavior" => {
84+
if v.is_null() {
85+
continue;
86+
}
87+
overlap_behavior =
88+
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
89+
if let Some(ref _overlap_behavior) = overlap_behavior {
90+
match _overlap_behavior {
91+
crate::datadogV2::model::ScheduleTriggerOverlapBehavior::UnparsedObject(_overlap_behavior) => {
92+
_unparsed = true;
93+
},
94+
_ => {}
95+
}
96+
}
97+
}
6898
"rruleExpression" => {
6999
rrule_expression =
70100
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
@@ -80,6 +110,7 @@ impl<'de> Deserialize<'de> for ScheduleTrigger {
80110
rrule_expression.ok_or_else(|| M::Error::missing_field("rrule_expression"))?;
81111

82112
let content = ScheduleTrigger {
113+
overlap_behavior,
83114
rrule_expression,
84115
additional_properties,
85116
_unparsed,
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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+
use serde::{Deserialize, Deserializer, Serialize, Serializer};
6+
7+
#[non_exhaustive]
8+
#[derive(Clone, Debug, Eq, PartialEq)]
9+
pub enum ScheduleTriggerOverlapBehavior {
10+
EXCLUSIVE_RUN,
11+
OVERLAP_ALLOWED,
12+
UnparsedObject(crate::datadog::UnparsedObject),
13+
}
14+
15+
impl ToString for ScheduleTriggerOverlapBehavior {
16+
fn to_string(&self) -> String {
17+
match self {
18+
Self::EXCLUSIVE_RUN => String::from("EXCLUSIVE_RUN"),
19+
Self::OVERLAP_ALLOWED => String::from("OVERLAP_ALLOWED"),
20+
Self::UnparsedObject(v) => v.value.to_string(),
21+
}
22+
}
23+
}
24+
25+
impl Serialize for ScheduleTriggerOverlapBehavior {
26+
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
27+
where
28+
S: Serializer,
29+
{
30+
match self {
31+
Self::UnparsedObject(v) => v.serialize(serializer),
32+
_ => serializer.serialize_str(self.to_string().as_str()),
33+
}
34+
}
35+
}
36+
37+
impl<'de> Deserialize<'de> for ScheduleTriggerOverlapBehavior {
38+
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
39+
where
40+
D: Deserializer<'de>,
41+
{
42+
let s: String = String::deserialize(deserializer)?;
43+
Ok(match s.as_str() {
44+
"EXCLUSIVE_RUN" => Self::EXCLUSIVE_RUN,
45+
"OVERLAP_ALLOWED" => Self::OVERLAP_ALLOWED,
46+
_ => Self::UnparsedObject(crate::datadog::UnparsedObject {
47+
value: serde_json::Value::String(s.into()),
48+
}),
49+
})
50+
}
51+
}

0 commit comments

Comments
 (0)