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
85 changes: 82 additions & 3 deletions .generator/schemas/v1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11481,6 +11481,60 @@ components:
example: UTC
type: string
type: object
SLOCountCondition:
description: 'A metric SLI specification, composed of three parts: the good
events formula, the total events formula,

and the involved queries.'
example:
good_events_formula: query1 - query2
queries:
- data_source: metrics
name: query1
query: sum:trace.servlet.request.hits{*} by {env}.as_count()
- data_source: metrics
name: query2
query: sum:trace.servlet.request.errors{*} by {env}.as_count()
total_events_formula: query1
properties:
good_events_formula:
$ref: '#/components/schemas/SLOFormula'
queries:
example:
- data_source: metrics
name: query1
query: sum:trace.servlet.request.hits{*} by {env}.as_count()
items:
$ref: '#/components/schemas/SLODataSourceQueryDefinition'
minItems: 1
type: array
total_events_formula:
$ref: '#/components/schemas/SLOFormula'
required:
- good_events_formula
- total_events_formula
- queries
type: object
SLOCountSpec:
additionalProperties: false
description: A metric SLI specification.
example:
count:
good_events_formula: query1 - query2
queries:
- data_source: metrics
name: query1
query: sum:trace.servlet.request.hits{*} by {env}.as_count()
- data_source: metrics
name: query2
query: sum:trace.servlet.request.errors{*} by {env}.as_count()
total_events_formula: query1
properties:
count:
$ref: '#/components/schemas/SLOCountCondition'
required:
- count
type: object
SLOCreator:
description: The creator of the SLO
nullable: true
Expand Down Expand Up @@ -12328,8 +12382,16 @@ components:
type: string
query:
$ref: '#/components/schemas/ServiceLevelObjectiveQuery'
description: 'The metric query of good / total events. This is not allowed
if the `sli_specification` field

is used in the same request.'
sli_specification:
$ref: '#/components/schemas/SLOSliSpec'
description: 'A generic SLI specification. This is currently used for time-slice
and metric SLOs only.

This is not allowed if the `query` field is used in the same request.'
tags:
description: 'A list of tags associated with this service level objective.

Expand Down Expand Up @@ -12386,9 +12448,10 @@ components:
type: object
SLOSliSpec:
description: A generic SLI specification. This is currently used for time-slice
SLOs only.
and metric SLOs only.
oneOf:
- $ref: '#/components/schemas/SLOTimeSliceSpec'
- $ref: '#/components/schemas/SLOCountSpec'
SLOState:
description: State of the SLO.
enum:
Expand Down Expand Up @@ -13479,8 +13542,16 @@ components:
type: string
query:
$ref: '#/components/schemas/ServiceLevelObjectiveQuery'
description: 'The metric query of good / total events. This is not allowed
if the `sli_specification` field

is used in the same request.'
sli_specification:
$ref: '#/components/schemas/SLOSliSpec'
description: 'A generic SLI specification. This is currently used for time-slice
and metric SLOs only.

This is not allowed if the `query` field is used in the same request.'
tags:
description: 'A list of tags associated with this service level objective.

Expand Down Expand Up @@ -13540,8 +13611,8 @@ components:
- type
type: object
ServiceLevelObjectiveQuery:
description: 'A metric-based SLO. **Required if type is `metric`**. Note that
Datadog only allows the sum by aggregator
description: 'A now deprecated metric SLO. Note that Datadog only allows the
sum by aggregator

to be used because this will sum up all request counts instead of averaging
them, or taking the max or
Expand Down Expand Up @@ -13610,8 +13681,16 @@ components:
type: string
query:
$ref: '#/components/schemas/ServiceLevelObjectiveQuery'
description: 'The metric query of good / total events. This is not allowed
if the `sli_specification` field

is used in the same request.'
sli_specification:
$ref: '#/components/schemas/SLOSliSpec'
description: 'A generic SLI specification. This is currently used for time-slice
and metric SLOs only.

This is not allowed if the `query` field is used in the same request.'
tags:
description: 'A list of tags associated with this service level objective.

Expand Down
4 changes: 4 additions & 0 deletions src/datadogV1/model/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1232,6 +1232,10 @@ pub mod model_slo_data_source_query_definition;
pub use self::model_slo_data_source_query_definition::SLODataSourceQueryDefinition;
pub mod model_slo_time_slice_interval;
pub use self::model_slo_time_slice_interval::SLOTimeSliceInterval;
pub mod model_slo_count_spec;
pub use self::model_slo_count_spec::SLOCountSpec;
pub mod model_slo_count_condition;
pub use self::model_slo_count_condition::SLOCountCondition;
pub mod model_slo_sli_spec;
pub use self::model_slo_sli_spec::SLOSliSpec;
pub mod model_slo_threshold;
Expand Down
4 changes: 2 additions & 2 deletions src/datadogV1/model/model_service_level_objective.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@ pub struct ServiceLevelObjective {
/// The name of the service level objective object.
#[serde(rename = "name")]
pub name: String,
/// A metric-based SLO. **Required if type is `metric`**. Note that Datadog only allows the sum by aggregator
/// A now deprecated metric SLO. Note that Datadog only allows the sum by aggregator
/// to be used because this will sum up all request counts instead of averaging them, or taking the max or
/// min of all of those requests.
#[serde(rename = "query")]
pub query: Option<crate::datadogV1::model::ServiceLevelObjectiveQuery>,
/// A generic SLI specification. This is currently used for time-slice SLOs only.
/// A generic SLI specification. This is currently used for time-slice and metric SLOs only.
#[serde(rename = "sli_specification")]
pub sli_specification: Option<crate::datadogV1::model::SLOSliSpec>,
/// A list of tags associated with this service level objective.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use serde::{Deserialize, Deserializer, Serialize};
use serde_with::skip_serializing_none;
use std::fmt::{self, Formatter};

/// A metric-based SLO. **Required if type is `metric`**. Note that Datadog only allows the sum by aggregator
/// A now deprecated metric SLO. Note that Datadog only allows the sum by aggregator
/// to be used because this will sum up all request counts instead of averaging them, or taking the max or
/// min of all of those requests.
#[non_exhaustive]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ pub struct ServiceLevelObjectiveRequest {
/// The name of the service level objective object.
#[serde(rename = "name")]
pub name: String,
/// A metric-based SLO. **Required if type is `metric`**. Note that Datadog only allows the sum by aggregator
/// A now deprecated metric SLO. Note that Datadog only allows the sum by aggregator
/// to be used because this will sum up all request counts instead of averaging them, or taking the max or
/// min of all of those requests.
#[serde(rename = "query")]
pub query: Option<crate::datadogV1::model::ServiceLevelObjectiveQuery>,
/// A generic SLI specification. This is currently used for time-slice SLOs only.
/// A generic SLI specification. This is currently used for time-slice and metric SLOs only.
#[serde(rename = "sli_specification")]
pub sli_specification: Option<crate::datadogV1::model::SLOSliSpec>,
/// A list of tags associated with this service level objective.
Expand Down
122 changes: 122 additions & 0 deletions src/datadogV1/model/model_slo_count_condition.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
// 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 metric SLI specification, composed of three parts: the good events formula, the total events formula,
/// and the involved queries.
#[non_exhaustive]
#[skip_serializing_none]
#[derive(Clone, Debug, PartialEq, Serialize)]
pub struct SLOCountCondition {
/// A formula that specifies how to combine the results of multiple queries.
#[serde(rename = "good_events_formula")]
pub good_events_formula: crate::datadogV1::model::SLOFormula,
#[serde(rename = "queries")]
pub queries: Vec<crate::datadogV1::model::SLODataSourceQueryDefinition>,
/// A formula that specifies how to combine the results of multiple queries.
#[serde(rename = "total_events_formula")]
pub total_events_formula: crate::datadogV1::model::SLOFormula,
#[serde(flatten)]
pub additional_properties: std::collections::BTreeMap<String, serde_json::Value>,
#[serde(skip)]
#[serde(default)]
pub(crate) _unparsed: bool,
}

impl SLOCountCondition {
pub fn new(
good_events_formula: crate::datadogV1::model::SLOFormula,
queries: Vec<crate::datadogV1::model::SLODataSourceQueryDefinition>,
total_events_formula: crate::datadogV1::model::SLOFormula,
) -> SLOCountCondition {
SLOCountCondition {
good_events_formula,
queries,
total_events_formula,
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 SLOCountCondition {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
{
struct SLOCountConditionVisitor;
impl<'a> Visitor<'a> for SLOCountConditionVisitor {
type Value = SLOCountCondition;

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 good_events_formula: Option<crate::datadogV1::model::SLOFormula> = None;
let mut queries: Option<
Vec<crate::datadogV1::model::SLODataSourceQueryDefinition>,
> = None;
let mut total_events_formula: Option<crate::datadogV1::model::SLOFormula> = 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() {
"good_events_formula" => {
good_events_formula =
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
"queries" => {
queries = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
"total_events_formula" => {
total_events_formula =
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 good_events_formula = good_events_formula
.ok_or_else(|| M::Error::missing_field("good_events_formula"))?;
let queries = queries.ok_or_else(|| M::Error::missing_field("queries"))?;
let total_events_formula = total_events_formula
.ok_or_else(|| M::Error::missing_field("total_events_formula"))?;

let content = SLOCountCondition {
good_events_formula,
queries,
total_events_formula,
additional_properties,
_unparsed,
};

Ok(content)
}
}

deserializer.deserialize_any(SLOCountConditionVisitor)
}
}
74 changes: 74 additions & 0 deletions src/datadogV1/model/model_slo_count_spec.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
// 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 metric SLI specification.
#[non_exhaustive]
#[skip_serializing_none]
#[derive(Clone, Debug, PartialEq, Serialize)]
pub struct SLOCountSpec {
/// A metric SLI specification, composed of three parts: the good events formula, the total events formula,
/// and the involved queries.
#[serde(rename = "count")]
pub count: crate::datadogV1::model::SLOCountCondition,
#[serde(skip)]
#[serde(default)]
pub(crate) _unparsed: bool,
}

impl SLOCountSpec {
pub fn new(count: crate::datadogV1::model::SLOCountCondition) -> SLOCountSpec {
SLOCountSpec {
count,
_unparsed: false,
}
}
}

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

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 count: Option<crate::datadogV1::model::SLOCountCondition> = None;
let mut _unparsed = false;

while let Some((k, v)) = map.next_entry::<String, serde_json::Value>()? {
match k.as_str() {
"count" => {
count = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
&_ => {
return Err(serde::de::Error::custom(
"Additional properties not allowed",
));
}
}
}
let count = count.ok_or_else(|| M::Error::missing_field("count"))?;

let content = SLOCountSpec { count, _unparsed };

Ok(content)
}
}

deserializer.deserialize_any(SLOCountSpecVisitor)
}
}
4 changes: 2 additions & 2 deletions src/datadogV1/model/model_slo_response_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ pub struct SLOResponseData {
/// The name of the service level objective object.
#[serde(rename = "name")]
pub name: Option<String>,
/// A metric-based SLO. **Required if type is `metric`**. Note that Datadog only allows the sum by aggregator
/// A now deprecated metric SLO. Note that Datadog only allows the sum by aggregator
/// to be used because this will sum up all request counts instead of averaging them, or taking the max or
/// min of all of those requests.
#[serde(rename = "query")]
pub query: Option<crate::datadogV1::model::ServiceLevelObjectiveQuery>,
/// A generic SLI specification. This is currently used for time-slice SLOs only.
/// A generic SLI specification. This is currently used for time-slice and metric SLOs only.
#[serde(rename = "sli_specification")]
pub sli_specification: Option<crate::datadogV1::model::SLOSliSpec>,
/// A list of tags associated with this service level objective.
Expand Down
Loading