Skip to content
Open
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
40 changes: 40 additions & 0 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29582,6 +29582,19 @@ components:
type: string
x-enum-varnames:
- INCIDENT_ATTACHMENTS
IncidentCondition:
description: A condition evaluated against incident tags.
properties:
tags:
description: Tags that must match for the condition to pass.
example:
- ''
items:
type: string
type: array
required:
- tags
type: object
IncidentCreateAttributes:
description: The incident's attributes for a create request.
properties:
Expand Down Expand Up @@ -31416,6 +31429,32 @@ components:
user_defined_fields:
$ref: '#/components/schemas/RelationshipToIncidentUserDefinedFields'
type: object
IncidentScheduleTrigger:
description: Trigger a workflow from an Incident Schedule. The workflow must
be published.
properties:
incidentType:
description: Incident type filter for the schedule.
type: string
rrule:
description: Recurrence rule expression for scheduling.
example: ''
type: string
tagCondition:
$ref: '#/components/schemas/IncidentCondition'
required:
- rrule
type: object
IncidentScheduleTriggerWrapper:
description: Schema for an Incident Schedule-based trigger.
properties:
incidentScheduleTrigger:
$ref: '#/components/schemas/IncidentScheduleTrigger'
startStepNames:
$ref: '#/components/schemas/StartStepNames'
required:
- incidentScheduleTrigger
type: object
IncidentSearchResponse:
description: Response with incidents and facets.
properties:
Expand Down Expand Up @@ -67073,6 +67112,7 @@ components:
- $ref: '#/components/schemas/FormTriggerWrapper'
- $ref: '#/components/schemas/GithubWebhookTriggerWrapper'
- $ref: '#/components/schemas/IncidentTriggerWrapper'
- $ref: '#/components/schemas/IncidentScheduleTriggerWrapper'
- $ref: '#/components/schemas/MonitorTriggerWrapper'
- $ref: '#/components/schemas/NotebookTriggerWrapper'
- $ref: '#/components/schemas/OnCallTriggerWrapper'
Expand Down
6 changes: 6 additions & 0 deletions src/datadogV2/model/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8726,6 +8726,12 @@ pub mod model_incident_trigger_wrapper;
pub use self::model_incident_trigger_wrapper::IncidentTriggerWrapper;
pub mod model_incident_trigger;
pub use self::model_incident_trigger::IncidentTrigger;
pub mod model_incident_schedule_trigger_wrapper;
pub use self::model_incident_schedule_trigger_wrapper::IncidentScheduleTriggerWrapper;
pub mod model_incident_schedule_trigger;
pub use self::model_incident_schedule_trigger::IncidentScheduleTrigger;
pub mod model_incident_condition;
pub use self::model_incident_condition::IncidentCondition;
pub mod model_monitor_trigger_wrapper;
pub use self::model_monitor_trigger_wrapper::MonitorTriggerWrapper;
pub mod model_monitor_trigger;
Expand Down
92 changes: 92 additions & 0 deletions src/datadogV2/model/model_incident_condition.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
// 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};

/// A condition evaluated against incident tags.
#[non_exhaustive]
#[skip_serializing_none]
#[derive(Clone, Debug, PartialEq, Serialize)]
pub struct IncidentCondition {
/// Tags that must match for the condition to pass.
#[serde(rename = "tags")]
pub tags: Vec<String>,
#[serde(flatten)]
pub additional_properties: std::collections::BTreeMap<String, serde_json::Value>,
#[serde(skip)]
#[serde(default)]
pub(crate) _unparsed: bool,
}

impl IncidentCondition {
pub fn new(tags: Vec<String>) -> IncidentCondition {
IncidentCondition {
tags,
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 IncidentCondition {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
{
struct IncidentConditionVisitor;
impl<'a> Visitor<'a> for IncidentConditionVisitor {
type Value = IncidentCondition;

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 tags: Option<Vec<String>> = 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() {
"tags" => {
tags = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
&_ => {
if let Ok(value) = serde_json::from_value(v.clone()) {
additional_properties.insert(k, value);
}
}
}
}
let tags = tags.ok_or_else(|| M::Error::missing_field("tags"))?;

let content = IncidentCondition {
tags,
additional_properties,
_unparsed,
};

Ok(content)
}
}

deserializer.deserialize_any(IncidentConditionVisitor)
}
}
128 changes: 128 additions & 0 deletions src/datadogV2/model/model_incident_schedule_trigger.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
// 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};

/// Trigger a workflow from an Incident Schedule. The workflow must be published.
#[non_exhaustive]
#[skip_serializing_none]
#[derive(Clone, Debug, PartialEq, Serialize)]
pub struct IncidentScheduleTrigger {
/// Incident type filter for the schedule.
#[serde(rename = "incidentType")]
pub incident_type: Option<String>,
/// Recurrence rule expression for scheduling.
#[serde(rename = "rrule")]
pub rrule: String,
/// A condition evaluated against incident tags.
#[serde(rename = "tagCondition")]
pub tag_condition: Option<crate::datadogV2::model::IncidentCondition>,
#[serde(flatten)]
pub additional_properties: std::collections::BTreeMap<String, serde_json::Value>,
#[serde(skip)]
#[serde(default)]
pub(crate) _unparsed: bool,
}

impl IncidentScheduleTrigger {
pub fn new(rrule: String) -> IncidentScheduleTrigger {
IncidentScheduleTrigger {
incident_type: None,
rrule,
tag_condition: None,
additional_properties: std::collections::BTreeMap::new(),
_unparsed: false,
}
}

pub fn incident_type(mut self, value: String) -> Self {
self.incident_type = Some(value);
self
}

pub fn tag_condition(mut self, value: crate::datadogV2::model::IncidentCondition) -> Self {
self.tag_condition = Some(value);
self
}

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 IncidentScheduleTrigger {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
{
struct IncidentScheduleTriggerVisitor;
impl<'a> Visitor<'a> for IncidentScheduleTriggerVisitor {
type Value = IncidentScheduleTrigger;

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 incident_type: Option<String> = None;
let mut rrule: Option<String> = None;
let mut tag_condition: Option<crate::datadogV2::model::IncidentCondition> = 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() {
"incidentType" => {
if v.is_null() {
continue;
}
incident_type =
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
"rrule" => {
rrule = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
"tagCondition" => {
if v.is_null() {
continue;
}
tag_condition =
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
&_ => {
if let Ok(value) = serde_json::from_value(v.clone()) {
additional_properties.insert(k, value);
}
}
}
}
let rrule = rrule.ok_or_else(|| M::Error::missing_field("rrule"))?;

let content = IncidentScheduleTrigger {
incident_type,
rrule,
tag_condition,
additional_properties,
_unparsed,
};

Ok(content)
}
}

deserializer.deserialize_any(IncidentScheduleTriggerVisitor)
}
}
Loading
Loading