Skip to content
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

Add type in Data Deletion API #465

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-01-17 19:31:39.291784",
"spec_repo_commit": "45186abe"
"regenerated": "2025-01-17 20:19:11.087129",
"spec_repo_commit": "4e5906d6"
},
"v2": {
"apigentools_version": "1.6.6",
"regenerated": "2025-01-17 19:31:39.307288",
"spec_repo_commit": "45186abe"
"regenerated": "2025-01-17 20:19:11.102017",
"spec_repo_commit": "4e5906d6"
}
}
}
11 changes: 11 additions & 0 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7378,9 +7378,20 @@ components:
properties:
attributes:
$ref: '#/components/schemas/CreateDataDeletionRequestBodyAttributes'
type:
$ref: '#/components/schemas/CreateDataDeletionRequestBodyDataType'
required:
- attributes
- type
type: object
CreateDataDeletionRequestBodyDataType:
description: The deletion request type.
enum:
- create_deletion_req
example: create_deletion_req
type: string
x-enum-varnames:
- CREATE_DELETION_REQ
CreateDataDeletionResponseBody:
description: The response from the create data deletion request endpoint.
properties:
Expand Down
2 changes: 2 additions & 0 deletions examples/v2_data-deletion_CreateDataDeletionRequest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use datadog_api_client::datadogV2::api_data_deletion::DataDeletionAPI;
use datadog_api_client::datadogV2::model::CreateDataDeletionRequestBody;
use datadog_api_client::datadogV2::model::CreateDataDeletionRequestBodyAttributes;
use datadog_api_client::datadogV2::model::CreateDataDeletionRequestBodyData;
use datadog_api_client::datadogV2::model::CreateDataDeletionRequestBodyDataType;
use std::collections::BTreeMap;

#[tokio::main]
Expand All @@ -18,6 +19,7 @@ async fn main() {
1704063600000,
)
.indexes(vec!["test-index".to_string(), "test-index-2".to_string()]),
CreateDataDeletionRequestBodyDataType::CREATE_DELETION_REQ,
));
let mut configuration = datadog::Configuration::new();
configuration.set_unstable_operation_enabled("v2.CreateDataDeletionRequest", true);
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 @@ -1180,6 +1180,8 @@ pub mod model_create_data_deletion_request_body_data;
pub use self::model_create_data_deletion_request_body_data::CreateDataDeletionRequestBodyData;
pub mod model_create_data_deletion_request_body_attributes;
pub use self::model_create_data_deletion_request_body_attributes::CreateDataDeletionRequestBodyAttributes;
pub mod model_create_data_deletion_request_body_data_type;
pub use self::model_create_data_deletion_request_body_data_type::CreateDataDeletionRequestBodyDataType;
pub mod model_create_data_deletion_response_body;
pub use self::model_create_data_deletion_response_body::CreateDataDeletionResponseBody;
pub mod model_data_deletion_response_item;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ pub struct CreateDataDeletionRequestBodyData {
/// Attributes for creating a data deletion request.
#[serde(rename = "attributes")]
pub attributes: crate::datadogV2::model::CreateDataDeletionRequestBodyAttributes,
/// The deletion request type.
#[serde(rename = "type")]
pub type_: crate::datadogV2::model::CreateDataDeletionRequestBodyDataType,
#[serde(flatten)]
pub additional_properties: std::collections::BTreeMap<String, serde_json::Value>,
#[serde(skip)]
Expand All @@ -24,9 +27,11 @@ pub struct CreateDataDeletionRequestBodyData {
impl CreateDataDeletionRequestBodyData {
pub fn new(
attributes: crate::datadogV2::model::CreateDataDeletionRequestBodyAttributes,
type_: crate::datadogV2::model::CreateDataDeletionRequestBodyDataType,
) -> CreateDataDeletionRequestBodyData {
CreateDataDeletionRequestBodyData {
attributes,
type_,
additional_properties: std::collections::BTreeMap::new(),
_unparsed: false,
}
Expand Down Expand Up @@ -61,6 +66,9 @@ impl<'de> Deserialize<'de> for CreateDataDeletionRequestBodyData {
let mut attributes: Option<
crate::datadogV2::model::CreateDataDeletionRequestBodyAttributes,
> = None;
let mut type_: Option<
crate::datadogV2::model::CreateDataDeletionRequestBodyDataType,
> = None;
let mut additional_properties: std::collections::BTreeMap<
String,
serde_json::Value,
Expand All @@ -72,6 +80,17 @@ impl<'de> Deserialize<'de> for CreateDataDeletionRequestBodyData {
"attributes" => {
attributes = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
"type" => {
type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
if let Some(ref _type_) = type_ {
match _type_ {
crate::datadogV2::model::CreateDataDeletionRequestBodyDataType::UnparsedObject(_type_) => {
_unparsed = true;
},
_ => {}
}
}
}
&_ => {
if let Ok(value) = serde_json::from_value(v.clone()) {
additional_properties.insert(k, value);
Expand All @@ -80,9 +99,11 @@ impl<'de> Deserialize<'de> for CreateDataDeletionRequestBodyData {
}
}
let attributes = attributes.ok_or_else(|| M::Error::missing_field("attributes"))?;
let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?;

let content = CreateDataDeletionRequestBodyData {
attributes,
type_,
additional_properties,
_unparsed,
};
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 CreateDataDeletionRequestBodyDataType {
CREATE_DELETION_REQ,
UnparsedObject(crate::datadog::UnparsedObject),
}

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

impl Serialize for CreateDataDeletionRequestBodyDataType {
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 CreateDataDeletionRequestBodyDataType {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
{
let s: String = String::deserialize(deserializer)?;
Ok(match s.as_str() {
"create_deletion_req" => Self::CREATE_DELETION_REQ,
_ => Self::UnparsedObject(crate::datadog::UnparsedObject {
value: serde_json::Value::String(s.into()),
}),
})
}
}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2024-12-05T09:23:41.160Z
2025-01-15T14:25:54.929Z
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"message": "Bad Request"
}
},
"recorded_at": "Thu, 05 Dec 2024 09:23:41 GMT"
"recorded_at": "Wed, 15 Jan 2025 14:25:54 GMT"
}
],
"recorded_with": "VCR 6.0.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2024-12-05T09:23:41.674Z
2025-01-15T14:26:08.930Z
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
"request": {
"body": {
"string": "{\"data\":{\"attributes\":{\"from\":1672527600000,\"indexes\":[\"test-index\",\"test-index-2\"],\"query\":{\"host\":\"abc\",\"service\":\"xyz\"},\"to\":1704063600000}}}",
"string": "{\"data\":{\"attributes\":{\"from\":1672527600000,\"indexes\":[\"test-index\",\"test-index-2\"],\"query\":{\"host\":\"abc\",\"service\":\"xyz\"},\"to\":1704063600000},\"type\":\"create_deletion_req\"}}",
"encoding": null
},
"headers": {
Expand All @@ -19,7 +19,7 @@
},
"response": {
"body": {
"string": "{\"data\":{\"id\":\"523\",\"type\":\"deletion_request\",\"attributes\":{\"created_at\":\"2024-12-05T09:23:42.016613164Z\",\"created_by\":\"[email protected]\",\"from_time\":1672527600000,\"indexes\":[\"test-index\",\"test-index-2\"],\"is_created\":false,\"org_id\":321813,\"product\":\"logs\",\"query\":\"host:abc service:xyz\",\"starting_at\":\"0001-01-01T00:00:00Z\",\"status\":\"pending\",\"to_time\":1704063600000,\"total_unrestricted\":0,\"updated_at\":\"2024-12-05T09:23:42.016613164Z\"}},\"meta\":{\"product\":\"logs\"}}",
"string": "{\"data\":{\"id\":\"753\",\"type\":\"deletion_request\",\"attributes\":{\"created_at\":\"2025-01-15T14:26:09.447960191Z\",\"created_by\":\"[email protected]\",\"from_time\":1672527600000,\"indexes\":[\"test-index\",\"test-index-2\"],\"is_created\":false,\"org_id\":321813,\"product\":\"logs\",\"query\":\"host:abc service:xyz\",\"starting_at\":\"0001-01-01T00:00:00Z\",\"status\":\"pending\",\"to_time\":1704063600000,\"total_unrestricted\":0,\"updated_at\":\"2025-01-15T14:26:09.447960191Z\"}},\"meta\":{\"product\":\"logs\"}}",
"encoding": null
},
"headers": {
Expand All @@ -32,7 +32,7 @@
"message": "OK"
}
},
"recorded_at": "Thu, 05 Dec 2024 09:23:41 GMT"
"recorded_at": "Wed, 15 Jan 2025 14:26:08 GMT"
},
{
"request": {
Expand All @@ -43,11 +43,11 @@
]
},
"method": "put",
"uri": "https://api.datadoghq.com/api/v2/deletion/requests/523/cancel"
"uri": "https://api.datadoghq.com/api/v2/deletion/requests/753/cancel"
},
"response": {
"body": {
"string": "{\"data\":{\"id\":\"523\",\"type\":\"deletion_request\",\"attributes\":{\"created_at\":\"2024-12-05T09:23:42.016613Z\",\"created_by\":\"[email protected]\",\"from_time\":1672527600000,\"indexes\":[\"test-index\",\"test-index-2\"],\"is_created\":false,\"org_id\":321813,\"product\":\"logs\",\"query\":\"host:abc service:xyz\",\"starting_at\":\"0001-01-01T00:00:00Z\",\"status\":\"canceled\",\"to_time\":1704063600000,\"total_unrestricted\":0,\"updated_at\":\"2024-12-05T09:23:42.384299Z\"}},\"meta\":{\"product\":\"logs\",\"request_status\":\"canceled\"}}",
"string": "{\"data\":{\"id\":\"753\",\"type\":\"deletion_request\",\"attributes\":{\"created_at\":\"2025-01-15T14:26:09.44796Z\",\"created_by\":\"[email protected]\",\"from_time\":1672527600000,\"indexes\":[\"test-index\",\"test-index-2\"],\"is_created\":false,\"org_id\":321813,\"product\":\"logs\",\"query\":\"host:abc service:xyz\",\"starting_at\":\"0001-01-01T00:00:00Z\",\"status\":\"canceled\",\"to_time\":1704063600000,\"total_unrestricted\":0,\"updated_at\":\"2025-01-15T14:26:10.016496Z\"}},\"meta\":{\"product\":\"logs\",\"request_status\":\"canceled\"}}",
"encoding": null
},
"headers": {
Expand All @@ -60,7 +60,7 @@
"message": "OK"
}
},
"recorded_at": "Thu, 05 Dec 2024 09:23:41 GMT"
"recorded_at": "Wed, 15 Jan 2025 14:26:08 GMT"
},
{
"request": {
Expand All @@ -71,11 +71,11 @@
]
},
"method": "put",
"uri": "https://api.datadoghq.com/api/v2/deletion/requests/523/cancel"
"uri": "https://api.datadoghq.com/api/v2/deletion/requests/753/cancel"
},
"response": {
"body": {
"string": "{\"data\":{\"id\":\"523\",\"type\":\"deletion_request\",\"attributes\":{\"created_at\":\"2024-12-05T09:23:42.016613Z\",\"created_by\":\"[email protected]\",\"from_time\":1672527600000,\"indexes\":[\"test-index\",\"test-index-2\"],\"is_created\":false,\"org_id\":321813,\"product\":\"logs\",\"query\":\"host:abc service:xyz\",\"starting_at\":\"0001-01-01T00:00:00Z\",\"status\":\"canceled\",\"to_time\":1704063600000,\"total_unrestricted\":0,\"updated_at\":\"2024-12-05T09:23:42.384299Z\"}},\"meta\":{\"product\":\"logs\",\"request_status\":\"canceled\"}}",
"string": "{\"data\":{\"id\":\"753\",\"type\":\"deletion_request\",\"attributes\":{\"created_at\":\"2025-01-15T14:26:09.44796Z\",\"created_by\":\"[email protected]\",\"from_time\":1672527600000,\"indexes\":[\"test-index\",\"test-index-2\"],\"is_created\":false,\"org_id\":321813,\"product\":\"logs\",\"query\":\"host:abc service:xyz\",\"starting_at\":\"0001-01-01T00:00:00Z\",\"status\":\"canceled\",\"to_time\":1704063600000,\"total_unrestricted\":0,\"updated_at\":\"2025-01-15T14:26:10.016496Z\"}},\"meta\":{\"product\":\"logs\",\"request_status\":\"canceled\"}}",
"encoding": null
},
"headers": {
Expand All @@ -88,7 +88,7 @@
"message": "OK"
}
},
"recorded_at": "Thu, 05 Dec 2024 09:23:41 GMT"
"recorded_at": "Wed, 15 Jan 2025 14:26:08 GMT"
}
],
"recorded_with": "VCR 6.0.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2024-12-05T09:23:42.850Z
2025-01-15T14:26:26.195Z
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"message": "Precondition Failed"
}
},
"recorded_at": "Thu, 05 Dec 2024 09:23:42 GMT"
"recorded_at": "Wed, 15 Jan 2025 14:26:26 GMT"
}
],
"recorded_with": "VCR 6.0.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2024-12-05T09:23:43.197Z
2025-01-15T14:27:27.929Z
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
"request": {
"body": {
"string": "{\"data\":{\"attributes\":{\"from\":1672527600000,\"indexes\":[\"test-index\",\"test-index-2\"],\"query\":{\"host\":\"abc\",\"service\":\"xyz\"},\"to\":1704063600000}}}",
"string": "{\"data\":{\"attributes\":{\"from\":1672527600000,\"indexes\":[\"test-index\",\"test-index-2\"],\"query\":{\"host\":\"abc\",\"service\":\"xyz\"},\"to\":1704063600000},\"type\":\"create_deletion_req\"}}",
"encoding": null
},
"headers": {
Expand All @@ -19,7 +19,7 @@
},
"response": {
"body": {
"string": "{\"data\":{\"id\":\"524\",\"type\":\"deletion_request\",\"attributes\":{\"created_at\":\"2024-12-05T09:23:43.527574137Z\",\"created_by\":\"[email protected]\",\"from_time\":1672527600000,\"indexes\":[\"test-index\",\"test-index-2\"],\"is_created\":false,\"org_id\":321813,\"product\":\"logs\",\"query\":\"host:abc service:xyz\",\"starting_at\":\"0001-01-01T00:00:00Z\",\"status\":\"pending\",\"to_time\":1704063600000,\"total_unrestricted\":0,\"updated_at\":\"2024-12-05T09:23:43.527574137Z\"}},\"meta\":{\"product\":\"logs\"}}",
"string": "{\"data\":{\"id\":\"754\",\"type\":\"deletion_request\",\"attributes\":{\"created_at\":\"2025-01-15T14:27:28.457837225Z\",\"created_by\":\"[email protected]\",\"from_time\":1672527600000,\"indexes\":[\"test-index\",\"test-index-2\"],\"is_created\":false,\"org_id\":321813,\"product\":\"logs\",\"query\":\"host:abc service:xyz\",\"starting_at\":\"0001-01-01T00:00:00Z\",\"status\":\"pending\",\"to_time\":1704063600000,\"total_unrestricted\":0,\"updated_at\":\"2025-01-15T14:27:28.457837225Z\"}},\"meta\":{\"product\":\"logs\"}}",
"encoding": null
},
"headers": {
Expand All @@ -32,7 +32,7 @@
"message": "OK"
}
},
"recorded_at": "Thu, 05 Dec 2024 09:23:43 GMT"
"recorded_at": "Wed, 15 Jan 2025 14:27:27 GMT"
},
{
"request": {
Expand All @@ -43,11 +43,11 @@
]
},
"method": "put",
"uri": "https://api.datadoghq.com/api/v2/deletion/requests/524/cancel"
"uri": "https://api.datadoghq.com/api/v2/deletion/requests/754/cancel"
},
"response": {
"body": {
"string": "{\"data\":{\"id\":\"524\",\"type\":\"deletion_request\",\"attributes\":{\"created_at\":\"2024-12-05T09:23:43.527574Z\",\"created_by\":\"[email protected]\",\"from_time\":1672527600000,\"indexes\":[\"test-index\",\"test-index-2\"],\"is_created\":false,\"org_id\":321813,\"product\":\"logs\",\"query\":\"host:abc service:xyz\",\"starting_at\":\"0001-01-01T00:00:00Z\",\"status\":\"canceled\",\"to_time\":1704063600000,\"total_unrestricted\":0,\"updated_at\":\"2024-12-05T09:23:44.017414Z\"}},\"meta\":{\"product\":\"logs\",\"request_status\":\"canceled\"}}",
"string": "{\"data\":{\"id\":\"754\",\"type\":\"deletion_request\",\"attributes\":{\"created_at\":\"2025-01-15T14:27:28.457837Z\",\"created_by\":\"[email protected]\",\"from_time\":1672527600000,\"indexes\":[\"test-index\",\"test-index-2\"],\"is_created\":false,\"org_id\":321813,\"product\":\"logs\",\"query\":\"host:abc service:xyz\",\"starting_at\":\"0001-01-01T00:00:00Z\",\"status\":\"canceled\",\"to_time\":1704063600000,\"total_unrestricted\":0,\"updated_at\":\"2025-01-15T14:27:28.841156Z\"}},\"meta\":{\"product\":\"logs\",\"request_status\":\"canceled\"}}",
"encoding": null
},
"headers": {
Expand All @@ -60,7 +60,7 @@
"message": "OK"
}
},
"recorded_at": "Thu, 05 Dec 2024 09:23:43 GMT"
"recorded_at": "Wed, 15 Jan 2025 14:27:27 GMT"
}
],
"recorded_with": "VCR 6.0.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2024-12-05T09:23:44.038Z
2025-01-15T14:27:45.329Z
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
"request": {
"body": {
"string": "{\"data\":{\"attributes\":{\"from\":1672527600000,\"indexes\":[\"test-index\",\"test-index-2\"],\"query\":{},\"to\":1704063600000}}}",
"string": "{\"data\":{\"attributes\":{\"from\":1672527600000,\"indexes\":[\"test-index\",\"test-index-2\"],\"query\":{},\"to\":1704063600000},\"type\":\"create_deletion_req\"}}",
"encoding": null
},
"headers": {
Expand Down Expand Up @@ -32,7 +32,7 @@
"message": "Precondition Failed"
}
},
"recorded_at": "Thu, 05 Dec 2024 09:23:44 GMT"
"recorded_at": "Wed, 15 Jan 2025 14:27:45 GMT"
}
],
"recorded_with": "VCR 6.0.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2024-12-05T09:23:44.395Z
2025-01-15T14:28:03.053Z
Loading
Loading