From fdff34062dd2e389cbe58ae7b5d56b5d4bebc85f Mon Sep 17 00:00:00 2001 From: Kevin Zou Date: Thu, 29 Feb 2024 09:46:57 -0500 Subject: [PATCH] properly handle file download --- .generator/src/generator/templates/api.j2 | 8 +++++++- src/datadogV2/api/api_cloud_workload_security.rs | 15 +++++---------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/.generator/src/generator/templates/api.j2 b/.generator/src/generator/templates/api.j2 index ed8a3cce6..19d152ebb 100644 --- a/.generator/src/generator/templates/api.j2 +++ b/.generator/src/generator/templates/api.j2 @@ -229,7 +229,13 @@ impl {{ structName }} { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - {%- if returnType %} + {%- if returnType == "Vec" %} + Ok(ResponseContent { + status: local_status, + content: local_content.clone(), + entity: Some(local_content.into_bytes()), + }) + {%- elif returnType %} match serde_json::from_str::<{{ returnType }}>(&local_content) { Ok(e) => return Ok(ResponseContent { status: local_status, diff --git a/src/datadogV2/api/api_cloud_workload_security.rs b/src/datadogV2/api/api_cloud_workload_security.rs index 976ccd0d4..15ad06f52 100644 --- a/src/datadogV2/api/api_cloud_workload_security.rs +++ b/src/datadogV2/api/api_cloud_workload_security.rs @@ -317,16 +317,11 @@ impl CloudWorkloadSecurityAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - match serde_json::from_str::>(&local_content) { - Ok(e) => { - return Ok(ResponseContent { - status: local_status, - content: local_content, - entity: Some(e), - }) - } - Err(e) => return Err(crate::datadog::Error::Serde(e)), - }; + Ok(ResponseContent { + status: local_status, + content: local_content.clone(), + entity: Some(local_content.into_bytes()), + }) } else { let local_entity: Option = serde_json::from_str(&local_content).ok();