Skip to content
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
23 changes: 23 additions & 0 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59651,6 +59651,7 @@ components:
oneOf:
- $ref: "#/components/schemas/SendSlackMessageAction"
- $ref: "#/components/schemas/SendTeamsMessageAction"
- $ref: "#/components/schemas/TriggerWorkflowAutomationAction"
RoutingRuleAttributes:
description: Defines the configurable attributes of a routing rule, such as actions, query, time restriction, and urgency.
properties:
Expand Down Expand Up @@ -79447,6 +79448,28 @@ components:
type: string
x-enum-varnames:
- MONITOR_ALERT_TRIGGER
TriggerWorkflowAutomationAction:
description: "Triggers a Workflow Automation."
properties:
handle:
description: "The handle of the Workflow Automation to trigger."
example: my-workflow-handle
type: string
type:
$ref: "#/components/schemas/TriggerWorkflowAutomationActionType"
required:
- type
- handle
type: object
TriggerWorkflowAutomationActionType:
default: workflow
description: "Indicates that the action triggers a Workflow Automation."
enum:
- workflow
example: workflow
type: string
x-enum-varnames:
- TRIGGER_WORKFLOW_AUTOMATION
UCConfigPair:
description: The definition of `UCConfigPair` object.
example:
Expand Down
4 changes: 4 additions & 0 deletions src/datadogV2/model/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6210,6 +6210,10 @@ pub mod model_send_teams_message_action;
pub use self::model_send_teams_message_action::SendTeamsMessageAction;
pub mod model_send_teams_message_action_type;
pub use self::model_send_teams_message_action_type::SendTeamsMessageActionType;
pub mod model_trigger_workflow_automation_action;
pub use self::model_trigger_workflow_automation_action::TriggerWorkflowAutomationAction;
pub mod model_trigger_workflow_automation_action_type;
pub use self::model_trigger_workflow_automation_action_type::TriggerWorkflowAutomationActionType;
pub mod model_routing_rule_action;
pub use self::model_routing_rule_action::RoutingRuleAction;
pub mod model_time_restrictions;
Expand Down
9 changes: 9 additions & 0 deletions src/datadogV2/model/model_routing_rule_action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use serde::{Deserialize, Deserializer, Serialize};
pub enum RoutingRuleAction {
SendSlackMessageAction(Box<crate::datadogV2::model::SendSlackMessageAction>),
SendTeamsMessageAction(Box<crate::datadogV2::model::SendTeamsMessageAction>),
TriggerWorkflowAutomationAction(Box<crate::datadogV2::model::TriggerWorkflowAutomationAction>),
UnparsedObject(crate::datadog::UnparsedObject),
}

Expand All @@ -33,6 +34,14 @@ impl<'de> Deserialize<'de> for RoutingRuleAction {
return Ok(RoutingRuleAction::SendTeamsMessageAction(_v));
}
}
if let Ok(_v) = serde_json::from_value::<
Box<crate::datadogV2::model::TriggerWorkflowAutomationAction>,
>(value.clone())
{
if !_v._unparsed {
return Ok(RoutingRuleAction::TriggerWorkflowAutomationAction(_v));
}
}

return Ok(RoutingRuleAction::UnparsedObject(
crate::datadog::UnparsedObject { value },
Expand Down
115 changes: 115 additions & 0 deletions src/datadogV2/model/model_trigger_workflow_automation_action.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
// 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.
use serde::de::{Error, MapAccess, Visitor};
use serde::{Deserialize, Deserializer, Serialize};
use serde_with::skip_serializing_none;
use std::fmt::{self, Formatter};

/// Triggers a Workflow Automation.
#[non_exhaustive]
#[skip_serializing_none]
#[derive(Clone, Debug, PartialEq, Serialize)]
pub struct TriggerWorkflowAutomationAction {
/// The handle of the Workflow Automation to trigger.
#[serde(rename = "handle")]
pub handle: String,
/// Indicates that the action triggers a Workflow Automation.
#[serde(rename = "type")]
pub type_: crate::datadogV2::model::TriggerWorkflowAutomationActionType,
#[serde(flatten)]
pub additional_properties: std::collections::BTreeMap<String, serde_json::Value>,
#[serde(skip)]
#[serde(default)]
pub(crate) _unparsed: bool,
}

impl TriggerWorkflowAutomationAction {
pub fn new(
handle: String,
type_: crate::datadogV2::model::TriggerWorkflowAutomationActionType,
) -> TriggerWorkflowAutomationAction {
TriggerWorkflowAutomationAction {
handle,
type_,
additional_properties: std::collections::BTreeMap::new(),
_unparsed: false,
}
}

pub fn additional_properties(
mut self,
value: std::collections::BTreeMap<String, serde_json::Value>,
) -> Self {
self.additional_properties = value;
self
}
}

impl<'de> Deserialize<'de> for TriggerWorkflowAutomationAction {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
{
struct TriggerWorkflowAutomationActionVisitor;
impl<'a> Visitor<'a> for TriggerWorkflowAutomationActionVisitor {
type Value = TriggerWorkflowAutomationAction;

fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result {
f.write_str("a mapping")
}

fn visit_map<M>(self, mut map: M) -> Result<Self::Value, M::Error>
where
M: MapAccess<'a>,
{
let mut handle: Option<String> = None;
let mut type_: Option<
crate::datadogV2::model::TriggerWorkflowAutomationActionType,
> = None;
let mut additional_properties: std::collections::BTreeMap<
String,
serde_json::Value,
> = std::collections::BTreeMap::new();
let mut _unparsed = false;

while let Some((k, v)) = map.next_entry::<String, serde_json::Value>()? {
match k.as_str() {
"handle" => {
handle = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
"type" => {
type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
if let Some(ref _type_) = type_ {
match _type_ {
crate::datadogV2::model::TriggerWorkflowAutomationActionType::UnparsedObject(_type_) => {
_unparsed = true;
},
_ => {}
}
}
}
&_ => {
if let Ok(value) = serde_json::from_value(v.clone()) {
additional_properties.insert(k, value);
}
}
}
}
let handle = handle.ok_or_else(|| M::Error::missing_field("handle"))?;
let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?;

let content = TriggerWorkflowAutomationAction {
handle,
type_,
additional_properties,
_unparsed,
};

Ok(content)
}
}

deserializer.deserialize_any(TriggerWorkflowAutomationActionVisitor)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// 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.

use serde::{Deserialize, Deserializer, Serialize, Serializer};

#[non_exhaustive]
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum TriggerWorkflowAutomationActionType {
TRIGGER_WORKFLOW_AUTOMATION,
UnparsedObject(crate::datadog::UnparsedObject),
}

impl ToString for TriggerWorkflowAutomationActionType {
fn to_string(&self) -> String {
match self {
Self::TRIGGER_WORKFLOW_AUTOMATION => String::from("workflow"),
Self::UnparsedObject(v) => v.value.to_string(),
}
}
}

impl Serialize for TriggerWorkflowAutomationActionType {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
match self {
Self::UnparsedObject(v) => v.serialize(serializer),
_ => serializer.serialize_str(self.to_string().as_str()),
}
}
}

impl<'de> Deserialize<'de> for TriggerWorkflowAutomationActionType {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
{
let s: String = String::deserialize(deserializer)?;
Ok(match s.as_str() {
"workflow" => Self::TRIGGER_WORKFLOW_AUTOMATION,
_ => Self::UnparsedObject(crate::datadog::UnparsedObject {
value: serde_json::Value::String(s.into()),
}),
})
}
}
Loading