Skip to content

Commit

Permalink
Regenerate client from commit 7b7ec49c of spec repo
Browse files Browse the repository at this point in the history
  • Loading branch information
ci.datadog-api-spec committed Dec 20, 2024
1 parent 6ffe35d commit 783bae0
Show file tree
Hide file tree
Showing 5 changed files with 203 additions and 4 deletions.
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": "2024-12-19 07:26:20.419256",
"spec_repo_commit": "5dd2cbe4"
"regenerated": "2024-12-20 20:08:00.597493",
"spec_repo_commit": "7b7ec49c"
},
"v2": {
"apigentools_version": "1.6.6",
"regenerated": "2024-12-19 07:26:20.435562",
"spec_repo_commit": "5dd2cbe4"
"regenerated": "2024-12-20 20:08:00.612334",
"spec_repo_commit": "7b7ec49c"
}
}
}
24 changes: 24 additions & 0 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14770,6 +14770,12 @@ components:
the error.
example: Missing required attribute in body
type: string
meta:
additionalProperties: {}
description: Non-standard meta-information about the error
type: object
source:
$ref: '#/components/schemas/JSONAPIErrorItemSource'
status:
description: Status code of the response.
example: '400'
Expand All @@ -14779,6 +14785,24 @@ components:
example: Bad Request
type: string
type: object
JSONAPIErrorItemSource:
description: References to the source of the error.
properties:
header:
description: a string indicating the name of a single request header which
caused the error.
example: Authorization
type: string
parameter:
description: A string indicating which URI query parameter caused the error.
example: limit
type: string
pointer:
description: A JSON Pointer to the value in the request document that caused
the error.
example: /data/attributes/title
type: string
type: object
JSONAPIErrorResponse:
description: API error response.
properties:
Expand Down
2 changes: 2 additions & 0 deletions src/datadogV2/model/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ pub mod model_jsonapi_error_response;
pub use self::model_jsonapi_error_response::JSONAPIErrorResponse;
pub mod model_jsonapi_error_item;
pub use self::model_jsonapi_error_item::JSONAPIErrorItem;
pub mod model_jsonapi_error_item_source;
pub use self::model_jsonapi_error_item_source::JSONAPIErrorItemSource;
pub mod model_open_api_file;
pub use self::model_open_api_file::OpenAPIFile;
pub mod model_update_open_api_response;
Expand Down
34 changes: 34 additions & 0 deletions src/datadogV2/model/model_jsonapi_error_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ pub struct JSONAPIErrorItem {
/// A human-readable explanation specific to this occurrence of the error.
#[serde(rename = "detail")]
pub detail: Option<String>,
/// Non-standard meta-information about the error
#[serde(rename = "meta")]
pub meta: Option<std::collections::BTreeMap<String, serde_json::Value>>,
/// References to the source of the error.
#[serde(rename = "source")]
pub source: Option<crate::datadogV2::model::JSONAPIErrorItemSource>,
/// Status code of the response.
#[serde(rename = "status")]
pub status: Option<String>,
Expand All @@ -31,6 +37,8 @@ impl JSONAPIErrorItem {
pub fn new() -> JSONAPIErrorItem {
JSONAPIErrorItem {
detail: None,
meta: None,
source: None,
status: None,
title: None,
additional_properties: std::collections::BTreeMap::new(),
Expand All @@ -43,6 +51,16 @@ impl JSONAPIErrorItem {
self
}

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

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

pub fn status(mut self, value: String) -> Self {
self.status = Some(value);
self
Expand Down Expand Up @@ -86,6 +104,8 @@ impl<'de> Deserialize<'de> for JSONAPIErrorItem {
M: MapAccess<'a>,
{
let mut detail: Option<String> = None;
let mut meta: Option<std::collections::BTreeMap<String, serde_json::Value>> = None;
let mut source: Option<crate::datadogV2::model::JSONAPIErrorItemSource> = None;
let mut status: Option<String> = None;
let mut title: Option<String> = None;
let mut additional_properties: std::collections::BTreeMap<
Expand All @@ -102,6 +122,18 @@ impl<'de> Deserialize<'de> for JSONAPIErrorItem {
}
detail = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
"meta" => {
if v.is_null() {
continue;
}
meta = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
"source" => {
if v.is_null() {
continue;
}
source = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
"status" => {
if v.is_null() {
continue;
Expand All @@ -124,6 +156,8 @@ impl<'de> Deserialize<'de> for JSONAPIErrorItem {

let content = JSONAPIErrorItem {
detail,
meta,
source,
status,
title,
additional_properties,
Expand Down
139 changes: 139 additions & 0 deletions src/datadogV2/model/model_jsonapi_error_item_source.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
// 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};

/// References to the source of the error.
#[non_exhaustive]
#[skip_serializing_none]
#[derive(Clone, Debug, PartialEq, Serialize)]
pub struct JSONAPIErrorItemSource {
/// a string indicating the name of a single request header which caused the error.
#[serde(rename = "header")]
pub header: Option<String>,
/// A string indicating which URI query parameter caused the error.
#[serde(rename = "parameter")]
pub parameter: Option<String>,
/// A JSON Pointer to the value in the request document that caused the error.
#[serde(rename = "pointer")]
pub pointer: Option<String>,
#[serde(flatten)]
pub additional_properties: std::collections::BTreeMap<String, serde_json::Value>,
#[serde(skip)]
#[serde(default)]
pub(crate) _unparsed: bool,
}

impl JSONAPIErrorItemSource {
pub fn new() -> JSONAPIErrorItemSource {
JSONAPIErrorItemSource {
header: None,
parameter: None,
pointer: None,
additional_properties: std::collections::BTreeMap::new(),
_unparsed: false,
}
}

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

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

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

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

impl Default for JSONAPIErrorItemSource {
fn default() -> Self {
Self::new()
}
}

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

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 header: Option<String> = None;
let mut parameter: Option<String> = None;
let mut pointer: Option<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() {
"header" => {
if v.is_null() {
continue;
}
header = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
"parameter" => {
if v.is_null() {
continue;
}
parameter = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
"pointer" => {
if v.is_null() {
continue;
}
pointer = 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 content = JSONAPIErrorItemSource {
header,
parameter,
pointer,
additional_properties,
_unparsed,
};

Ok(content)
}
}

deserializer.deserialize_any(JSONAPIErrorItemSourceVisitor)
}
}

0 comments on commit 783bae0

Please sign in to comment.