Skip to content

Change type to enum to discriminate included items in the response of ListCatalogEntity #568

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
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
8 changes: 4 additions & 4 deletions .apigentools-info
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"spec_versions": {
"v1": {
"apigentools_version": "1.6.6",
"regenerated": "2025-03-20 15:01:20.219057",
"spec_repo_commit": "0f5c928e"
"regenerated": "2025-03-24 14:58:35.892637",
"spec_repo_commit": "764de5f0"
},
"v2": {
"apigentools_version": "1.6.6",
"regenerated": "2025-03-20 15:01:20.234833",
"spec_repo_commit": "0f5c928e"
"regenerated": "2025-03-24 14:58:35.908322",
"spec_repo_commit": "764de5f0"
}
}
}
50 changes: 40 additions & 10 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11936,9 +11936,15 @@ components:
description: Incident ID.
type: string
type:
description: Incident description.
type: string
$ref: '#/components/schemas/EntityResponseIncludedIncidentType'
type: object
EntityResponseIncludedIncidentType:
description: Incident description.
enum:
- incident
type: string
x-enum-varnames:
- INCIDENT
EntityResponseIncludedOncall:
description: Included oncall.
properties:
Expand All @@ -11948,9 +11954,15 @@ components:
description: Oncall ID.
type: string
type:
description: Oncall type.
type: string
$ref: '#/components/schemas/EntityResponseIncludedOncallType'
type: object
EntityResponseIncludedOncallType:
description: Oncall type.
enum:
- oncall
type: string
x-enum-varnames:
- ONCALL
EntityResponseIncludedRawSchema:
description: Included raw schema.
properties:
Expand All @@ -11960,8 +11972,7 @@ components:
description: Raw schema ID.
type: string
type:
description: Raw schema type.
type: string
$ref: '#/components/schemas/EntityResponseIncludedRawSchemaType'
type: object
EntityResponseIncludedRawSchemaAttributes:
description: Included raw schema attributes.
Expand All @@ -11970,6 +11981,13 @@ components:
description: Schema from user input in base64 encoding.
type: string
type: object
EntityResponseIncludedRawSchemaType:
description: Raw schema type.
enum:
- rawSchema
type: string
x-enum-varnames:
- RAW_SCHEMA
EntityResponseIncludedRelatedEntity:
description: Included related entity.
properties:
Expand All @@ -11981,8 +11999,7 @@ components:
meta:
$ref: '#/components/schemas/EntityResponseIncludedRelatedEntityMeta'
type:
description: Related entity.
type: string
$ref: '#/components/schemas/EntityResponseIncludedRelatedEntityType'
type: object
EntityResponseIncludedRelatedEntityAttributes:
description: Related entity attributes.
Expand Down Expand Up @@ -12018,6 +12035,13 @@ components:
description: Entity relation source.
type: string
type: object
EntityResponseIncludedRelatedEntityType:
description: Related entity.
enum:
- relatedEntity
type: string
x-enum-varnames:
- RELATED_ENTITY
EntityResponseIncludedRelatedIncidentAttributes:
description: Incident attributes.
properties:
Expand Down Expand Up @@ -12075,15 +12099,21 @@ components:
description: Entity ID.
type: string
type:
description: Schema type.
type: string
$ref: '#/components/schemas/EntityResponseIncludedSchemaType'
type: object
EntityResponseIncludedSchemaAttributes:
description: Included schema.
properties:
schema:
$ref: '#/components/schemas/EntityV3'
type: object
EntityResponseIncludedSchemaType:
description: Schema type.
enum:
- schema
type: string
x-enum-varnames:
- SCHEMA
EntityResponseMeta:
description: Entity metadata.
properties:
Expand Down
10 changes: 10 additions & 0 deletions src/datadogV2/model/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -792,26 +792,36 @@ pub mod model_entity_v3_api_spec_interface;
pub use self::model_entity_v3_api_spec_interface::EntityV3APISpecInterface;
pub mod model_entity_v3;
pub use self::model_entity_v3::EntityV3;
pub mod model_entity_response_included_schema_type;
pub use self::model_entity_response_included_schema_type::EntityResponseIncludedSchemaType;
pub mod model_entity_response_included_raw_schema;
pub use self::model_entity_response_included_raw_schema::EntityResponseIncludedRawSchema;
pub mod model_entity_response_included_raw_schema_attributes;
pub use self::model_entity_response_included_raw_schema_attributes::EntityResponseIncludedRawSchemaAttributes;
pub mod model_entity_response_included_raw_schema_type;
pub use self::model_entity_response_included_raw_schema_type::EntityResponseIncludedRawSchemaType;
pub mod model_entity_response_included_related_entity;
pub use self::model_entity_response_included_related_entity::EntityResponseIncludedRelatedEntity;
pub mod model_entity_response_included_related_entity_attributes;
pub use self::model_entity_response_included_related_entity_attributes::EntityResponseIncludedRelatedEntityAttributes;
pub mod model_entity_response_included_related_entity_meta;
pub use self::model_entity_response_included_related_entity_meta::EntityResponseIncludedRelatedEntityMeta;
pub mod model_entity_response_included_related_entity_type;
pub use self::model_entity_response_included_related_entity_type::EntityResponseIncludedRelatedEntityType;
pub mod model_entity_response_included_oncall;
pub use self::model_entity_response_included_oncall::EntityResponseIncludedOncall;
pub mod model_entity_response_included_related_oncall_attributes;
pub use self::model_entity_response_included_related_oncall_attributes::EntityResponseIncludedRelatedOncallAttributes;
pub mod model_entity_response_included_related_oncall_escalation_item;
pub use self::model_entity_response_included_related_oncall_escalation_item::EntityResponseIncludedRelatedOncallEscalationItem;
pub mod model_entity_response_included_oncall_type;
pub use self::model_entity_response_included_oncall_type::EntityResponseIncludedOncallType;
pub mod model_entity_response_included_incident;
pub use self::model_entity_response_included_incident::EntityResponseIncludedIncident;
pub mod model_entity_response_included_related_incident_attributes;
pub use self::model_entity_response_included_related_incident_attributes::EntityResponseIncludedRelatedIncidentAttributes;
pub mod model_entity_response_included_incident_type;
pub use self::model_entity_response_included_incident_type::EntityResponseIncludedIncidentType;
pub mod model_list_entity_catalog_response_included_item;
pub use self::model_list_entity_catalog_response_included_item::ListEntityCatalogResponseIncludedItem;
pub mod model_list_entity_catalog_response_links;
Expand Down
18 changes: 15 additions & 3 deletions src/datadogV2/model/model_entity_response_included_incident.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub struct EntityResponseIncludedIncident {
pub id: Option<String>,
/// Incident description.
#[serde(rename = "type")]
pub type_: Option<String>,
pub type_: Option<crate::datadogV2::model::EntityResponseIncludedIncidentType>,
#[serde(flatten)]
pub additional_properties: std::collections::BTreeMap<String, serde_json::Value>,
#[serde(skip)]
Expand Down Expand Up @@ -52,7 +52,10 @@ impl EntityResponseIncludedIncident {
self
}

pub fn type_(mut self, value: String) -> Self {
pub fn type_(
mut self,
value: crate::datadogV2::model::EntityResponseIncludedIncidentType,
) -> Self {
self.type_ = Some(value);
self
}
Expand Down Expand Up @@ -93,7 +96,8 @@ impl<'de> Deserialize<'de> for EntityResponseIncludedIncident {
crate::datadogV2::model::EntityResponseIncludedRelatedIncidentAttributes,
> = None;
let mut id: Option<String> = None;
let mut type_: Option<String> = None;
let mut type_: Option<crate::datadogV2::model::EntityResponseIncludedIncidentType> =
None;
let mut additional_properties: std::collections::BTreeMap<
String,
serde_json::Value,
Expand All @@ -119,6 +123,14 @@ impl<'de> Deserialize<'de> for EntityResponseIncludedIncident {
continue;
}
type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
if let Some(ref _type_) = type_ {
match _type_ {
crate::datadogV2::model::EntityResponseIncludedIncidentType::UnparsedObject(_type_) => {
_unparsed = true;
},
_ => {}
}
}
}
&_ => {
if let Ok(value) = serde_json::from_value(v.clone()) {
Expand Down
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 EntityResponseIncludedIncidentType {
INCIDENT,
UnparsedObject(crate::datadog::UnparsedObject),
}

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

impl Serialize for EntityResponseIncludedIncidentType {
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 EntityResponseIncludedIncidentType {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
{
let s: String = String::deserialize(deserializer)?;
Ok(match s.as_str() {
"incident" => Self::INCIDENT,
_ => Self::UnparsedObject(crate::datadog::UnparsedObject {
value: serde_json::Value::String(s.into()),
}),
})
}
}
18 changes: 15 additions & 3 deletions src/datadogV2/model/model_entity_response_included_oncall.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub struct EntityResponseIncludedOncall {
pub id: Option<String>,
/// Oncall type.
#[serde(rename = "type")]
pub type_: Option<String>,
pub type_: Option<crate::datadogV2::model::EntityResponseIncludedOncallType>,
#[serde(flatten)]
pub additional_properties: std::collections::BTreeMap<String, serde_json::Value>,
#[serde(skip)]
Expand Down Expand Up @@ -51,7 +51,10 @@ impl EntityResponseIncludedOncall {
self
}

pub fn type_(mut self, value: String) -> Self {
pub fn type_(
mut self,
value: crate::datadogV2::model::EntityResponseIncludedOncallType,
) -> Self {
self.type_ = Some(value);
self
}
Expand Down Expand Up @@ -92,7 +95,8 @@ impl<'de> Deserialize<'de> for EntityResponseIncludedOncall {
crate::datadogV2::model::EntityResponseIncludedRelatedOncallAttributes,
> = None;
let mut id: Option<String> = None;
let mut type_: Option<String> = None;
let mut type_: Option<crate::datadogV2::model::EntityResponseIncludedOncallType> =
None;
let mut additional_properties: std::collections::BTreeMap<
String,
serde_json::Value,
Expand All @@ -118,6 +122,14 @@ impl<'de> Deserialize<'de> for EntityResponseIncludedOncall {
continue;
}
type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
if let Some(ref _type_) = type_ {
match _type_ {
crate::datadogV2::model::EntityResponseIncludedOncallType::UnparsedObject(_type_) => {
_unparsed = true;
},
_ => {}
}
}
}
&_ => {
if let Ok(value) = serde_json::from_value(v.clone()) {
Expand Down
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 EntityResponseIncludedOncallType {
ONCALL,
UnparsedObject(crate::datadog::UnparsedObject),
}

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

impl Serialize for EntityResponseIncludedOncallType {
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 EntityResponseIncludedOncallType {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
{
let s: String = String::deserialize(deserializer)?;
Ok(match s.as_str() {
"oncall" => Self::ONCALL,
_ => Self::UnparsedObject(crate::datadog::UnparsedObject {
value: serde_json::Value::String(s.into()),
}),
})
}
}
Loading
Loading