Skip to content

Commit 4fc57df

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add Datastore trigger to Workflow Automation public API (#935)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent c5a4e15 commit 4fc57df

File tree

5 files changed

+250
-0
lines changed

5 files changed

+250
-0
lines changed

.generator/schemas/v2/openapi.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14697,6 +14697,23 @@ components:
1469714697
x-enum-varnames:
1469814698
- NONE
1469914699
- UUID
14700+
DatastoreTrigger:
14701+
description: Trigger a workflow from a Datastore. For automatic triggering a
14702+
handle must be configured and the workflow must be published.
14703+
properties:
14704+
rateLimit:
14705+
$ref: '#/components/schemas/TriggerRateLimit'
14706+
type: object
14707+
DatastoreTriggerWrapper:
14708+
description: Schema for a Datastore-based trigger.
14709+
properties:
14710+
datastoreTrigger:
14711+
$ref: '#/components/schemas/DatastoreTrigger'
14712+
startStepNames:
14713+
$ref: '#/components/schemas/StartStepNames'
14714+
required:
14715+
- datastoreTrigger
14716+
type: object
1470014717
Date:
1470114718
description: Date as Unix timestamp in milliseconds.
1470214719
example: 1722439510282
@@ -47710,6 +47727,7 @@ components:
4771047727
- $ref: '#/components/schemas/CaseTriggerWrapper'
4771147728
- $ref: '#/components/schemas/ChangeEventTriggerWrapper'
4771247729
- $ref: '#/components/schemas/DatabaseMonitoringTriggerWrapper'
47730+
- $ref: '#/components/schemas/DatastoreTriggerWrapper'
4771347731
- $ref: '#/components/schemas/DashboardTriggerWrapper'
4771447732
- $ref: '#/components/schemas/GithubWebhookTriggerWrapper'
4771547733
- $ref: '#/components/schemas/IncidentTriggerWrapper'

src/datadogV2/model/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6242,6 +6242,10 @@ pub mod model_change_event_trigger_wrapper;
62426242
pub use self::model_change_event_trigger_wrapper::ChangeEventTriggerWrapper;
62436243
pub mod model_database_monitoring_trigger_wrapper;
62446244
pub use self::model_database_monitoring_trigger_wrapper::DatabaseMonitoringTriggerWrapper;
6245+
pub mod model_datastore_trigger_wrapper;
6246+
pub use self::model_datastore_trigger_wrapper::DatastoreTriggerWrapper;
6247+
pub mod model_datastore_trigger;
6248+
pub use self::model_datastore_trigger::DatastoreTrigger;
62456249
pub mod model_dashboard_trigger_wrapper;
62466250
pub use self::model_dashboard_trigger_wrapper::DashboardTriggerWrapper;
62476251
pub mod model_github_webhook_trigger_wrapper;
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
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+
use serde::de::{Error, MapAccess, Visitor};
5+
use serde::{Deserialize, Deserializer, Serialize};
6+
use serde_with::skip_serializing_none;
7+
use std::fmt::{self, Formatter};
8+
9+
/// Trigger a workflow from a Datastore. For automatic triggering a handle must be configured and the workflow must be published.
10+
#[non_exhaustive]
11+
#[skip_serializing_none]
12+
#[derive(Clone, Debug, PartialEq, Serialize)]
13+
pub struct DatastoreTrigger {
14+
/// Defines a rate limit for a trigger.
15+
#[serde(rename = "rateLimit")]
16+
pub rate_limit: Option<crate::datadogV2::model::TriggerRateLimit>,
17+
#[serde(flatten)]
18+
pub additional_properties: std::collections::BTreeMap<String, serde_json::Value>,
19+
#[serde(skip)]
20+
#[serde(default)]
21+
pub(crate) _unparsed: bool,
22+
}
23+
24+
impl DatastoreTrigger {
25+
pub fn new() -> DatastoreTrigger {
26+
DatastoreTrigger {
27+
rate_limit: None,
28+
additional_properties: std::collections::BTreeMap::new(),
29+
_unparsed: false,
30+
}
31+
}
32+
33+
pub fn rate_limit(mut self, value: crate::datadogV2::model::TriggerRateLimit) -> Self {
34+
self.rate_limit = Some(value);
35+
self
36+
}
37+
38+
pub fn additional_properties(
39+
mut self,
40+
value: std::collections::BTreeMap<String, serde_json::Value>,
41+
) -> Self {
42+
self.additional_properties = value;
43+
self
44+
}
45+
}
46+
47+
impl Default for DatastoreTrigger {
48+
fn default() -> Self {
49+
Self::new()
50+
}
51+
}
52+
53+
impl<'de> Deserialize<'de> for DatastoreTrigger {
54+
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
55+
where
56+
D: Deserializer<'de>,
57+
{
58+
struct DatastoreTriggerVisitor;
59+
impl<'a> Visitor<'a> for DatastoreTriggerVisitor {
60+
type Value = DatastoreTrigger;
61+
62+
fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result {
63+
f.write_str("a mapping")
64+
}
65+
66+
fn visit_map<M>(self, mut map: M) -> Result<Self::Value, M::Error>
67+
where
68+
M: MapAccess<'a>,
69+
{
70+
let mut rate_limit: Option<crate::datadogV2::model::TriggerRateLimit> = None;
71+
let mut additional_properties: std::collections::BTreeMap<
72+
String,
73+
serde_json::Value,
74+
> = std::collections::BTreeMap::new();
75+
let mut _unparsed = false;
76+
77+
while let Some((k, v)) = map.next_entry::<String, serde_json::Value>()? {
78+
match k.as_str() {
79+
"rateLimit" => {
80+
if v.is_null() {
81+
continue;
82+
}
83+
rate_limit = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
84+
}
85+
&_ => {
86+
if let Ok(value) = serde_json::from_value(v.clone()) {
87+
additional_properties.insert(k, value);
88+
}
89+
}
90+
}
91+
}
92+
93+
let content = DatastoreTrigger {
94+
rate_limit,
95+
additional_properties,
96+
_unparsed,
97+
};
98+
99+
Ok(content)
100+
}
101+
}
102+
103+
deserializer.deserialize_any(DatastoreTriggerVisitor)
104+
}
105+
}
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
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+
use serde::de::{Error, MapAccess, Visitor};
5+
use serde::{Deserialize, Deserializer, Serialize};
6+
use serde_with::skip_serializing_none;
7+
use std::fmt::{self, Formatter};
8+
9+
/// Schema for a Datastore-based trigger.
10+
#[non_exhaustive]
11+
#[skip_serializing_none]
12+
#[derive(Clone, Debug, PartialEq, Serialize)]
13+
pub struct DatastoreTriggerWrapper {
14+
/// Trigger a workflow from a Datastore. For automatic triggering a handle must be configured and the workflow must be published.
15+
#[serde(rename = "datastoreTrigger")]
16+
pub datastore_trigger: crate::datadogV2::model::DatastoreTrigger,
17+
/// A list of steps that run first after a trigger fires.
18+
#[serde(rename = "startStepNames")]
19+
pub start_step_names: Option<Vec<String>>,
20+
#[serde(flatten)]
21+
pub additional_properties: std::collections::BTreeMap<String, serde_json::Value>,
22+
#[serde(skip)]
23+
#[serde(default)]
24+
pub(crate) _unparsed: bool,
25+
}
26+
27+
impl DatastoreTriggerWrapper {
28+
pub fn new(
29+
datastore_trigger: crate::datadogV2::model::DatastoreTrigger,
30+
) -> DatastoreTriggerWrapper {
31+
DatastoreTriggerWrapper {
32+
datastore_trigger,
33+
start_step_names: None,
34+
additional_properties: std::collections::BTreeMap::new(),
35+
_unparsed: false,
36+
}
37+
}
38+
39+
pub fn start_step_names(mut self, value: Vec<String>) -> Self {
40+
self.start_step_names = Some(value);
41+
self
42+
}
43+
44+
pub fn additional_properties(
45+
mut self,
46+
value: std::collections::BTreeMap<String, serde_json::Value>,
47+
) -> Self {
48+
self.additional_properties = value;
49+
self
50+
}
51+
}
52+
53+
impl<'de> Deserialize<'de> for DatastoreTriggerWrapper {
54+
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
55+
where
56+
D: Deserializer<'de>,
57+
{
58+
struct DatastoreTriggerWrapperVisitor;
59+
impl<'a> Visitor<'a> for DatastoreTriggerWrapperVisitor {
60+
type Value = DatastoreTriggerWrapper;
61+
62+
fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result {
63+
f.write_str("a mapping")
64+
}
65+
66+
fn visit_map<M>(self, mut map: M) -> Result<Self::Value, M::Error>
67+
where
68+
M: MapAccess<'a>,
69+
{
70+
let mut datastore_trigger: Option<crate::datadogV2::model::DatastoreTrigger> = None;
71+
let mut start_step_names: Option<Vec<String>> = None;
72+
let mut additional_properties: std::collections::BTreeMap<
73+
String,
74+
serde_json::Value,
75+
> = std::collections::BTreeMap::new();
76+
let mut _unparsed = false;
77+
78+
while let Some((k, v)) = map.next_entry::<String, serde_json::Value>()? {
79+
match k.as_str() {
80+
"datastoreTrigger" => {
81+
datastore_trigger =
82+
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
83+
}
84+
"startStepNames" => {
85+
if v.is_null() {
86+
continue;
87+
}
88+
start_step_names =
89+
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
90+
}
91+
&_ => {
92+
if let Ok(value) = serde_json::from_value(v.clone()) {
93+
additional_properties.insert(k, value);
94+
}
95+
}
96+
}
97+
}
98+
let datastore_trigger = datastore_trigger
99+
.ok_or_else(|| M::Error::missing_field("datastore_trigger"))?;
100+
101+
let content = DatastoreTriggerWrapper {
102+
datastore_trigger,
103+
start_step_names,
104+
additional_properties,
105+
_unparsed,
106+
};
107+
108+
Ok(content)
109+
}
110+
}
111+
112+
deserializer.deserialize_any(DatastoreTriggerWrapperVisitor)
113+
}
114+
}

src/datadogV2/model/model_trigger.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ pub enum Trigger {
1515
DatabaseMonitoringTriggerWrapper(
1616
Box<crate::datadogV2::model::DatabaseMonitoringTriggerWrapper>,
1717
),
18+
DatastoreTriggerWrapper(Box<crate::datadogV2::model::DatastoreTriggerWrapper>),
1819
DashboardTriggerWrapper(Box<crate::datadogV2::model::DashboardTriggerWrapper>),
1920
GithubWebhookTriggerWrapper(Box<crate::datadogV2::model::GithubWebhookTriggerWrapper>),
2021
IncidentTriggerWrapper(Box<crate::datadogV2::model::IncidentTriggerWrapper>),
@@ -72,6 +73,14 @@ impl<'de> Deserialize<'de> for Trigger {
7273
return Ok(Trigger::DatabaseMonitoringTriggerWrapper(_v));
7374
}
7475
}
76+
if let Ok(_v) = serde_json::from_value::<
77+
Box<crate::datadogV2::model::DatastoreTriggerWrapper>,
78+
>(value.clone())
79+
{
80+
if !_v._unparsed {
81+
return Ok(Trigger::DatastoreTriggerWrapper(_v));
82+
}
83+
}
7584
if let Ok(_v) = serde_json::from_value::<
7685
Box<crate::datadogV2::model::DashboardTriggerWrapper>,
7786
>(value.clone())

0 commit comments

Comments
 (0)