Skip to content

Commit e67bb2a

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
and
ci.datadog-api-spec
authored
Change type to enum to discriminate included items in the response of ListCatalogEntity (#568)
Co-authored-by: ci.datadog-api-spec <[email protected]>
1 parent c975857 commit e67bb2a

13 files changed

+371
-29
lines changed

Diff for: .apigentools-info

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
"spec_versions": {
55
"v1": {
66
"apigentools_version": "1.6.6",
7-
"regenerated": "2025-03-20 15:01:20.219057",
8-
"spec_repo_commit": "0f5c928e"
7+
"regenerated": "2025-03-24 14:58:35.892637",
8+
"spec_repo_commit": "764de5f0"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.6",
12-
"regenerated": "2025-03-20 15:01:20.234833",
13-
"spec_repo_commit": "0f5c928e"
12+
"regenerated": "2025-03-24 14:58:35.908322",
13+
"spec_repo_commit": "764de5f0"
1414
}
1515
}
1616
}

Diff for: .generator/schemas/v2/openapi.yaml

+40-10
Original file line numberDiff line numberDiff line change
@@ -11936,9 +11936,15 @@ components:
1193611936
description: Incident ID.
1193711937
type: string
1193811938
type:
11939-
description: Incident description.
11940-
type: string
11939+
$ref: '#/components/schemas/EntityResponseIncludedIncidentType'
1194111940
type: object
11941+
EntityResponseIncludedIncidentType:
11942+
description: Incident description.
11943+
enum:
11944+
- incident
11945+
type: string
11946+
x-enum-varnames:
11947+
- INCIDENT
1194211948
EntityResponseIncludedOncall:
1194311949
description: Included oncall.
1194411950
properties:
@@ -11948,9 +11954,15 @@ components:
1194811954
description: Oncall ID.
1194911955
type: string
1195011956
type:
11951-
description: Oncall type.
11952-
type: string
11957+
$ref: '#/components/schemas/EntityResponseIncludedOncallType'
1195311958
type: object
11959+
EntityResponseIncludedOncallType:
11960+
description: Oncall type.
11961+
enum:
11962+
- oncall
11963+
type: string
11964+
x-enum-varnames:
11965+
- ONCALL
1195411966
EntityResponseIncludedRawSchema:
1195511967
description: Included raw schema.
1195611968
properties:
@@ -11960,8 +11972,7 @@ components:
1196011972
description: Raw schema ID.
1196111973
type: string
1196211974
type:
11963-
description: Raw schema type.
11964-
type: string
11975+
$ref: '#/components/schemas/EntityResponseIncludedRawSchemaType'
1196511976
type: object
1196611977
EntityResponseIncludedRawSchemaAttributes:
1196711978
description: Included raw schema attributes.
@@ -11970,6 +11981,13 @@ components:
1197011981
description: Schema from user input in base64 encoding.
1197111982
type: string
1197211983
type: object
11984+
EntityResponseIncludedRawSchemaType:
11985+
description: Raw schema type.
11986+
enum:
11987+
- rawSchema
11988+
type: string
11989+
x-enum-varnames:
11990+
- RAW_SCHEMA
1197311991
EntityResponseIncludedRelatedEntity:
1197411992
description: Included related entity.
1197511993
properties:
@@ -11981,8 +11999,7 @@ components:
1198111999
meta:
1198212000
$ref: '#/components/schemas/EntityResponseIncludedRelatedEntityMeta'
1198312001
type:
11984-
description: Related entity.
11985-
type: string
12002+
$ref: '#/components/schemas/EntityResponseIncludedRelatedEntityType'
1198612003
type: object
1198712004
EntityResponseIncludedRelatedEntityAttributes:
1198812005
description: Related entity attributes.
@@ -12018,6 +12035,13 @@ components:
1201812035
description: Entity relation source.
1201912036
type: string
1202012037
type: object
12038+
EntityResponseIncludedRelatedEntityType:
12039+
description: Related entity.
12040+
enum:
12041+
- relatedEntity
12042+
type: string
12043+
x-enum-varnames:
12044+
- RELATED_ENTITY
1202112045
EntityResponseIncludedRelatedIncidentAttributes:
1202212046
description: Incident attributes.
1202312047
properties:
@@ -12075,15 +12099,21 @@ components:
1207512099
description: Entity ID.
1207612100
type: string
1207712101
type:
12078-
description: Schema type.
12079-
type: string
12102+
$ref: '#/components/schemas/EntityResponseIncludedSchemaType'
1208012103
type: object
1208112104
EntityResponseIncludedSchemaAttributes:
1208212105
description: Included schema.
1208312106
properties:
1208412107
schema:
1208512108
$ref: '#/components/schemas/EntityV3'
1208612109
type: object
12110+
EntityResponseIncludedSchemaType:
12111+
description: Schema type.
12112+
enum:
12113+
- schema
12114+
type: string
12115+
x-enum-varnames:
12116+
- SCHEMA
1208712117
EntityResponseMeta:
1208812118
description: Entity metadata.
1208912119
properties:

Diff for: src/datadogV2/model/mod.rs

+10
Original file line numberDiff line numberDiff line change
@@ -792,26 +792,36 @@ pub mod model_entity_v3_api_spec_interface;
792792
pub use self::model_entity_v3_api_spec_interface::EntityV3APISpecInterface;
793793
pub mod model_entity_v3;
794794
pub use self::model_entity_v3::EntityV3;
795+
pub mod model_entity_response_included_schema_type;
796+
pub use self::model_entity_response_included_schema_type::EntityResponseIncludedSchemaType;
795797
pub mod model_entity_response_included_raw_schema;
796798
pub use self::model_entity_response_included_raw_schema::EntityResponseIncludedRawSchema;
797799
pub mod model_entity_response_included_raw_schema_attributes;
798800
pub use self::model_entity_response_included_raw_schema_attributes::EntityResponseIncludedRawSchemaAttributes;
801+
pub mod model_entity_response_included_raw_schema_type;
802+
pub use self::model_entity_response_included_raw_schema_type::EntityResponseIncludedRawSchemaType;
799803
pub mod model_entity_response_included_related_entity;
800804
pub use self::model_entity_response_included_related_entity::EntityResponseIncludedRelatedEntity;
801805
pub mod model_entity_response_included_related_entity_attributes;
802806
pub use self::model_entity_response_included_related_entity_attributes::EntityResponseIncludedRelatedEntityAttributes;
803807
pub mod model_entity_response_included_related_entity_meta;
804808
pub use self::model_entity_response_included_related_entity_meta::EntityResponseIncludedRelatedEntityMeta;
809+
pub mod model_entity_response_included_related_entity_type;
810+
pub use self::model_entity_response_included_related_entity_type::EntityResponseIncludedRelatedEntityType;
805811
pub mod model_entity_response_included_oncall;
806812
pub use self::model_entity_response_included_oncall::EntityResponseIncludedOncall;
807813
pub mod model_entity_response_included_related_oncall_attributes;
808814
pub use self::model_entity_response_included_related_oncall_attributes::EntityResponseIncludedRelatedOncallAttributes;
809815
pub mod model_entity_response_included_related_oncall_escalation_item;
810816
pub use self::model_entity_response_included_related_oncall_escalation_item::EntityResponseIncludedRelatedOncallEscalationItem;
817+
pub mod model_entity_response_included_oncall_type;
818+
pub use self::model_entity_response_included_oncall_type::EntityResponseIncludedOncallType;
811819
pub mod model_entity_response_included_incident;
812820
pub use self::model_entity_response_included_incident::EntityResponseIncludedIncident;
813821
pub mod model_entity_response_included_related_incident_attributes;
814822
pub use self::model_entity_response_included_related_incident_attributes::EntityResponseIncludedRelatedIncidentAttributes;
823+
pub mod model_entity_response_included_incident_type;
824+
pub use self::model_entity_response_included_incident_type::EntityResponseIncludedIncidentType;
815825
pub mod model_list_entity_catalog_response_included_item;
816826
pub use self::model_list_entity_catalog_response_included_item::ListEntityCatalogResponseIncludedItem;
817827
pub mod model_list_entity_catalog_response_links;

Diff for: src/datadogV2/model/model_entity_response_included_incident.rs

+15-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub struct EntityResponseIncludedIncident {
2020
pub id: Option<String>,
2121
/// Incident description.
2222
#[serde(rename = "type")]
23-
pub type_: Option<String>,
23+
pub type_: Option<crate::datadogV2::model::EntityResponseIncludedIncidentType>,
2424
#[serde(flatten)]
2525
pub additional_properties: std::collections::BTreeMap<String, serde_json::Value>,
2626
#[serde(skip)]
@@ -52,7 +52,10 @@ impl EntityResponseIncludedIncident {
5252
self
5353
}
5454

55-
pub fn type_(mut self, value: String) -> Self {
55+
pub fn type_(
56+
mut self,
57+
value: crate::datadogV2::model::EntityResponseIncludedIncidentType,
58+
) -> Self {
5659
self.type_ = Some(value);
5760
self
5861
}
@@ -93,7 +96,8 @@ impl<'de> Deserialize<'de> for EntityResponseIncludedIncident {
9396
crate::datadogV2::model::EntityResponseIncludedRelatedIncidentAttributes,
9497
> = None;
9598
let mut id: Option<String> = None;
96-
let mut type_: Option<String> = None;
99+
let mut type_: Option<crate::datadogV2::model::EntityResponseIncludedIncidentType> =
100+
None;
97101
let mut additional_properties: std::collections::BTreeMap<
98102
String,
99103
serde_json::Value,
@@ -119,6 +123,14 @@ impl<'de> Deserialize<'de> for EntityResponseIncludedIncident {
119123
continue;
120124
}
121125
type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
126+
if let Some(ref _type_) = type_ {
127+
match _type_ {
128+
crate::datadogV2::model::EntityResponseIncludedIncidentType::UnparsedObject(_type_) => {
129+
_unparsed = true;
130+
},
131+
_ => {}
132+
}
133+
}
122134
}
123135
&_ => {
124136
if let Ok(value) = serde_json::from_value(v.clone()) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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 EntityResponseIncludedIncidentType {
10+
INCIDENT,
11+
UnparsedObject(crate::datadog::UnparsedObject),
12+
}
13+
14+
impl ToString for EntityResponseIncludedIncidentType {
15+
fn to_string(&self) -> String {
16+
match self {
17+
Self::INCIDENT => String::from("incident"),
18+
Self::UnparsedObject(v) => v.value.to_string(),
19+
}
20+
}
21+
}
22+
23+
impl Serialize for EntityResponseIncludedIncidentType {
24+
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
25+
where
26+
S: Serializer,
27+
{
28+
match self {
29+
Self::UnparsedObject(v) => v.serialize(serializer),
30+
_ => serializer.serialize_str(self.to_string().as_str()),
31+
}
32+
}
33+
}
34+
35+
impl<'de> Deserialize<'de> for EntityResponseIncludedIncidentType {
36+
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
37+
where
38+
D: Deserializer<'de>,
39+
{
40+
let s: String = String::deserialize(deserializer)?;
41+
Ok(match s.as_str() {
42+
"incident" => Self::INCIDENT,
43+
_ => Self::UnparsedObject(crate::datadog::UnparsedObject {
44+
value: serde_json::Value::String(s.into()),
45+
}),
46+
})
47+
}
48+
}

Diff for: src/datadogV2/model/model_entity_response_included_oncall.rs

+15-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub struct EntityResponseIncludedOncall {
1919
pub id: Option<String>,
2020
/// Oncall type.
2121
#[serde(rename = "type")]
22-
pub type_: Option<String>,
22+
pub type_: Option<crate::datadogV2::model::EntityResponseIncludedOncallType>,
2323
#[serde(flatten)]
2424
pub additional_properties: std::collections::BTreeMap<String, serde_json::Value>,
2525
#[serde(skip)]
@@ -51,7 +51,10 @@ impl EntityResponseIncludedOncall {
5151
self
5252
}
5353

54-
pub fn type_(mut self, value: String) -> Self {
54+
pub fn type_(
55+
mut self,
56+
value: crate::datadogV2::model::EntityResponseIncludedOncallType,
57+
) -> Self {
5558
self.type_ = Some(value);
5659
self
5760
}
@@ -92,7 +95,8 @@ impl<'de> Deserialize<'de> for EntityResponseIncludedOncall {
9295
crate::datadogV2::model::EntityResponseIncludedRelatedOncallAttributes,
9396
> = None;
9497
let mut id: Option<String> = None;
95-
let mut type_: Option<String> = None;
98+
let mut type_: Option<crate::datadogV2::model::EntityResponseIncludedOncallType> =
99+
None;
96100
let mut additional_properties: std::collections::BTreeMap<
97101
String,
98102
serde_json::Value,
@@ -118,6 +122,14 @@ impl<'de> Deserialize<'de> for EntityResponseIncludedOncall {
118122
continue;
119123
}
120124
type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
125+
if let Some(ref _type_) = type_ {
126+
match _type_ {
127+
crate::datadogV2::model::EntityResponseIncludedOncallType::UnparsedObject(_type_) => {
128+
_unparsed = true;
129+
},
130+
_ => {}
131+
}
132+
}
121133
}
122134
&_ => {
123135
if let Ok(value) = serde_json::from_value(v.clone()) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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 EntityResponseIncludedOncallType {
10+
ONCALL,
11+
UnparsedObject(crate::datadog::UnparsedObject),
12+
}
13+
14+
impl ToString for EntityResponseIncludedOncallType {
15+
fn to_string(&self) -> String {
16+
match self {
17+
Self::ONCALL => String::from("oncall"),
18+
Self::UnparsedObject(v) => v.value.to_string(),
19+
}
20+
}
21+
}
22+
23+
impl Serialize for EntityResponseIncludedOncallType {
24+
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
25+
where
26+
S: Serializer,
27+
{
28+
match self {
29+
Self::UnparsedObject(v) => v.serialize(serializer),
30+
_ => serializer.serialize_str(self.to_string().as_str()),
31+
}
32+
}
33+
}
34+
35+
impl<'de> Deserialize<'de> for EntityResponseIncludedOncallType {
36+
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
37+
where
38+
D: Deserializer<'de>,
39+
{
40+
let s: String = String::deserialize(deserializer)?;
41+
Ok(match s.as_str() {
42+
"oncall" => Self::ONCALL,
43+
_ => Self::UnparsedObject(crate::datadog::UnparsedObject {
44+
value: serde_json::Value::String(s.into()),
45+
}),
46+
})
47+
}
48+
}

0 commit comments

Comments
 (0)