From 0fbeb752d4cdc124d136470ca626fbacc46894d4 Mon Sep 17 00:00:00 2001 From: skarimo <40482491+skarimo@users.noreply.github.com> Date: Thu, 29 Feb 2024 16:58:50 -0500 Subject: [PATCH] Remove Option wrapper in successful responses (#20) Co-authored-by: Kevin Zou --- .generator/src/generator/templates/api.j2 | 28 +- src/datadogV1/api/api_authentication.rs | 35 +- src/datadogV1/api/api_aws_integration.rs | 398 ++++-- src/datadogV1/api/api_aws_logs_integration.rs | 233 +++- src/datadogV1/api/api_azure_integration.rs | 155 ++- src/datadogV1/api/api_dashboard_lists.rs | 159 ++- src/datadogV1/api/api_dashboards.rs | 344 +++-- src/datadogV1/api/api_downtimes.rs | 185 ++- src/datadogV1/api/api_events.rs | 90 +- src/datadogV1/api/api_gcp_integration.rs | 123 +- src/datadogV1/api/api_hosts.rs | 119 +- src/datadogV1/api/api_ip_ranges.rs | 29 +- src/datadogV1/api/api_key_management.rs | 322 +++-- src/datadogV1/api/api_logs.rs | 62 +- src/datadogV1/api/api_logs_indexes.rs | 181 ++- src/datadogV1/api/api_logs_pipelines.rs | 189 ++- src/datadogV1/api/api_metrics.rs | 223 ++- src/datadogV1/api/api_monitors.rs | 309 +++-- src/datadogV1/api/api_notebooks.rs | 124 +- src/datadogV1/api/api_organizations.rs | 190 ++- .../api/api_pager_duty_integration.rs | 70 +- src/datadogV1/api/api_security_monitoring.rs | 93 +- src/datadogV1/api/api_service_checks.rs | 35 +- ...api_service_level_objective_corrections.rs | 141 +- .../api/api_service_level_objectives.rs | 313 +++-- src/datadogV1/api/api_slack_integration.rs | 128 +- src/datadogV1/api/api_snapshots.rs | 29 +- src/datadogV1/api/api_synthetics.rs | 884 ++++++++---- src/datadogV1/api/api_tags.rs | 120 +- src/datadogV1/api/api_usage_metering.rs | 1230 +++++++++++------ src/datadogV1/api/api_users.rs | 148 +- src/datadogV1/api/api_webhooks_integration.rs | 206 ++- .../api/api_apm_retention_filters.rs | 136 +- src/datadogV2/api/api_audit.rs | 64 +- src/datadogV2/api/api_authn_mappings.rs | 132 +- .../api/api_ci_visibility_pipelines.rs | 124 +- src/datadogV2/api/api_ci_visibility_tests.rs | 101 +- .../api/api_cloud_cost_management.rs | 276 ++-- .../api/api_cloud_workload_security.rs | 156 ++- .../api/api_cloudflare_integration.rs | 132 +- src/datadogV2/api/api_confluent_cloud.rs | 276 ++-- src/datadogV2/api/api_container_images.rs | 35 +- src/datadogV2/api/api_containers.rs | 32 +- src/datadogV2/api/api_dashboard_lists.rs | 128 +- src/datadogV2/api/api_dora_metrics.rs | 67 +- src/datadogV2/api/api_downtimes.rs | 157 ++- src/datadogV2/api/api_events.rs | 62 +- src/datadogV2/api/api_fastly_integration.rs | 282 ++-- src/datadogV2/api/api_gcp_integration.rs | 163 ++- src/datadogV2/api/api_incident_services.rs | 144 +- src/datadogV2/api/api_incident_teams.rs | 132 +- src/datadogV2/api/api_incidents.rs | 481 +++++-- src/datadogV2/api/api_ip_allowlist.rs | 64 +- src/datadogV2/api/api_key_management.rs | 360 +++-- src/datadogV2/api/api_logs.rs | 124 +- src/datadogV2/api/api_logs_archives.rs | 220 ++- src/datadogV2/api/api_logs_metrics.rs | 132 +- src/datadogV2/api/api_metrics.rs | 420 ++++-- src/datadogV2/api/api_monitors.rs | 128 +- src/datadogV2/api/api_okta_integration.rs | 132 +- src/datadogV2/api/api_opsgenie_integration.rs | 144 +- src/datadogV2/api/api_organizations.rs | 4 +- src/datadogV2/api/api_powerpack.rs | 128 +- src/datadogV2/api/api_processes.rs | 32 +- src/datadogV2/api/api_restriction_policies.rs | 70 +- src/datadogV2/api/api_roles.rs | 372 +++-- src/datadogV2/api/api_rum.rs | 236 ++-- src/datadogV2/api/api_security_monitoring.rs | 553 +++++--- .../api/api_sensitive_data_scanner.rs | 279 ++-- src/datadogV2/api/api_service_accounts.rs | 158 ++- src/datadogV2/api/api_service_definition.rs | 97 +- src/datadogV2/api/api_service_scorecards.rs | 129 +- src/datadogV2/api/api_spans.rs | 92 +- src/datadogV2/api/api_spans_metrics.rs | 132 +- src/datadogV2/api/api_synthetics.rs | 62 +- src/datadogV2/api/api_teams.rs | 434 ++++-- src/datadogV2/api/api_usage_metering.rs | 314 +++-- src/datadogV2/api/api_users.rs | 249 ++-- 78 files changed, 10288 insertions(+), 4752 deletions(-) diff --git a/.generator/src/generator/templates/api.j2 b/.generator/src/generator/templates/api.j2 index 012a76b02..ed8a3cce6 100644 --- a/.generator/src/generator/templates/api.j2 +++ b/.generator/src/generator/templates/api.j2 @@ -98,9 +98,19 @@ impl {{ structName }} { {% if operation.description is defined %} {{ operation.description | block_comment }} {%- endif %} - pub async fn {{operation.operationId | snake_case}}(&self{% for name, parameter in requiredParams %}, {{name|variable_name}}: {{ get_type_for_parameter(parameter, version) }}{% endfor %}{% if operation|has_optional_parameter %}, params: {{operation.operationId}}OptionalParams{% endif %}) -> Result, Error<{{operation.operationId}}Error>> { + pub async fn {{operation.operationId | snake_case}}(&self{% for name, parameter in requiredParams %}, {{name|variable_name}}: {{ get_type_for_parameter(parameter, version) }}{% endfor %}{% if operation|has_optional_parameter %}, params: {{operation.operationId}}OptionalParams{% endif %}) -> Result<{% if returnType %}{{returnType}}{% else %}(){% endif %}, Error<{{operation.operationId}}Error>> { match self.{{operation.operationId | snake_case}}_with_http_info({% for name, parameter in requiredParams %}{{name|variable_name}}{% if loop.last %}{% if operation|has_optional_parameter %}, {% endif %}{% else %}, {% endif %}{% endfor %}{% if operation|has_optional_parameter %} params{% endif %}).await { - Ok(response_content) => Ok(response_content.entity), + {%- if returnType %} + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom("response content was None"))) + } + }, + {%- else%} + Ok(_) => Ok(()), + {%- endif%} Err(err) => Err(err), } } @@ -220,12 +230,14 @@ impl {{ structName }} { if !local_status.is_client_error() && !local_status.is_server_error() { {%- if returnType %} - let local_entity: Option<{{returnType}}> = serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + match serde_json::from_str::<{{ returnType }}>(&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)), + }; {%- else %} Ok(ResponseContent { status: local_status, diff --git a/src/datadogV1/api/api_authentication.rs b/src/datadogV1/api/api_authentication.rs index fd5277387..27125f773 100644 --- a/src/datadogV1/api/api_authentication.rs +++ b/src/datadogV1/api/api_authentication.rs @@ -38,12 +38,18 @@ impl AuthenticationAPI { /// Check if the API key (not the APP key) is valid. If invalid, a 403 is returned. pub async fn validate( &self, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self.validate_with_http_info().await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -85,13 +91,18 @@ impl AuthenticationAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = ResponseContent { diff --git a/src/datadogV1/api/api_aws_integration.rs b/src/datadogV1/api/api_aws_integration.rs index d1d44fbd5..2028675c4 100644 --- a/src/datadogV1/api/api_aws_integration.rs +++ b/src/datadogV1/api/api_aws_integration.rs @@ -219,12 +219,18 @@ impl AWSIntegrationAPI { pub async fn create_aws_account( &self, body: crate::datadogV1::model::AWSAccount, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self.create_aws_account_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -280,13 +286,18 @@ impl AWSIntegrationAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -304,14 +315,22 @@ impl AWSIntegrationAPI { &self, body: crate::datadogV1::model::AWSEventBridgeCreateRequest, ) -> Result< - Option, + crate::datadogV1::model::AWSEventBridgeCreateResponse, Error, > { match self .create_aws_event_bridge_source_with_http_info(body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -364,13 +383,18 @@ impl AWSIntegrationAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -387,12 +411,18 @@ impl AWSIntegrationAPI { pub async fn create_aws_tag_filter( &self, body: crate::datadogV1::model::AWSTagFilterCreateRequest, - ) -> Result< - Option>, - Error, - > { + ) -> Result, Error> + { match self.create_aws_tag_filter_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -445,13 +475,18 @@ impl AWSIntegrationAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option> = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -468,12 +503,18 @@ impl AWSIntegrationAPI { pub async fn create_new_aws_external_id( &self, body: crate::datadogV1::model::AWSAccount, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self.create_new_aws_external_id_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -526,13 +567,18 @@ impl AWSIntegrationAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -549,12 +595,18 @@ impl AWSIntegrationAPI { pub async fn delete_aws_account( &self, body: crate::datadogV1::model::AWSAccountDeleteRequest, - ) -> Result< - Option>, - Error, - > { + ) -> Result, Error> + { match self.delete_aws_account_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -607,13 +659,18 @@ impl AWSIntegrationAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option> = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -631,14 +688,22 @@ impl AWSIntegrationAPI { &self, body: crate::datadogV1::model::AWSEventBridgeDeleteRequest, ) -> Result< - Option, + crate::datadogV1::model::AWSEventBridgeDeleteResponse, Error, > { match self .delete_aws_event_bridge_source_with_http_info(body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -691,13 +756,18 @@ impl AWSIntegrationAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -714,12 +784,18 @@ impl AWSIntegrationAPI { pub async fn delete_aws_tag_filter( &self, body: crate::datadogV1::model::AWSTagFilterDeleteRequest, - ) -> Result< - Option>, - Error, - > { + ) -> Result, Error> + { match self.delete_aws_tag_filter_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -772,13 +848,18 @@ impl AWSIntegrationAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option> = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -795,10 +876,17 @@ impl AWSIntegrationAPI { pub async fn list_aws_accounts( &self, params: ListAWSAccountsOptionalParams, - ) -> Result, Error> - { + ) -> Result> { match self.list_aws_accounts_with_http_info(params).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -862,13 +950,18 @@ impl AWSIntegrationAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -885,11 +978,19 @@ impl AWSIntegrationAPI { pub async fn list_aws_event_bridge_sources( &self, ) -> Result< - Option, + crate::datadogV1::model::AWSEventBridgeListResponse, Error, > { match self.list_aws_event_bridge_sources_with_http_info().await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -934,13 +1035,18 @@ impl AWSIntegrationAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -957,12 +1063,18 @@ impl AWSIntegrationAPI { pub async fn list_aws_tag_filters( &self, account_id: String, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self.list_aws_tag_filters_with_http_info(account_id).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -1010,13 +1122,18 @@ impl AWSIntegrationAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -1032,9 +1149,17 @@ impl AWSIntegrationAPI { /// List all namespace rules for a given Datadog-AWS integration. This endpoint takes no arguments. pub async fn list_available_aws_namespaces( &self, - ) -> Result>, Error> { + ) -> Result, Error> { match self.list_available_aws_namespaces_with_http_info().await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -1076,12 +1201,16 @@ impl AWSIntegrationAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option> = serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -1099,12 +1228,18 @@ impl AWSIntegrationAPI { &self, body: crate::datadogV1::model::AWSAccount, params: UpdateAWSAccountOptionalParams, - ) -> Result< - Option>, - Error, - > { + ) -> Result, Error> + { match self.update_aws_account_with_http_info(body, params).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -1176,13 +1311,18 @@ impl AWSIntegrationAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option> = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); diff --git a/src/datadogV1/api/api_aws_logs_integration.rs b/src/datadogV1/api/api_aws_logs_integration.rs index a7075c60b..7d2a49251 100644 --- a/src/datadogV1/api/api_aws_logs_integration.rs +++ b/src/datadogV1/api/api_aws_logs_integration.rs @@ -106,12 +106,18 @@ impl AWSLogsIntegrationAPI { pub async fn check_aws_logs_lambda_async( &self, body: crate::datadogV1::model::AWSAccountAndLambdaRequest, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self.check_aws_logs_lambda_async_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -171,13 +177,18 @@ impl AWSLogsIntegrationAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -203,15 +214,21 @@ impl AWSLogsIntegrationAPI { pub async fn check_aws_logs_services_async( &self, body: crate::datadogV1::model::AWSLogsServicesRequest, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self .check_aws_logs_services_async_with_http_info(body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -273,13 +290,18 @@ impl AWSLogsIntegrationAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -296,12 +318,18 @@ impl AWSLogsIntegrationAPI { pub async fn create_aws_lambda_arn( &self, body: crate::datadogV1::model::AWSAccountAndLambdaRequest, - ) -> Result< - Option>, - Error, - > { + ) -> Result, Error> + { match self.create_aws_lambda_arn_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -354,13 +382,18 @@ impl AWSLogsIntegrationAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option> = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -377,12 +410,18 @@ impl AWSLogsIntegrationAPI { pub async fn delete_aws_lambda_arn( &self, body: crate::datadogV1::model::AWSAccountAndLambdaRequest, - ) -> Result< - Option>, - Error, - > { + ) -> Result, Error> + { match self.delete_aws_lambda_arn_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -435,13 +474,18 @@ impl AWSLogsIntegrationAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option> = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -459,11 +503,19 @@ impl AWSLogsIntegrationAPI { &self, body: crate::datadogV1::model::AWSLogsServicesRequest, ) -> Result< - Option>, + std::collections::BTreeMap, Error, > { match self.enable_aws_log_services_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -516,13 +568,18 @@ impl AWSLogsIntegrationAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option> = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -539,11 +596,19 @@ impl AWSLogsIntegrationAPI { pub async fn list_aws_logs_integrations( &self, ) -> Result< - Option>, + Vec, Error, > { match self.list_aws_logs_integrations_with_http_info().await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -588,13 +653,18 @@ impl AWSLogsIntegrationAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option> = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -611,11 +681,19 @@ impl AWSLogsIntegrationAPI { pub async fn list_aws_logs_services( &self, ) -> Result< - Option>, + Vec, Error, > { match self.list_aws_logs_services_with_http_info().await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -660,13 +738,18 @@ impl AWSLogsIntegrationAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option> = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); diff --git a/src/datadogV1/api/api_azure_integration.rs b/src/datadogV1/api/api_azure_integration.rs index f9f18326a..35914078a 100644 --- a/src/datadogV1/api/api_azure_integration.rs +++ b/src/datadogV1/api/api_azure_integration.rs @@ -87,11 +87,19 @@ impl AzureIntegrationAPI { &self, body: crate::datadogV1::model::AzureAccount, ) -> Result< - Option>, + std::collections::BTreeMap, Error, > { match self.create_azure_integration_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -150,13 +158,18 @@ impl AzureIntegrationAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option> = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -174,11 +187,19 @@ impl AzureIntegrationAPI { &self, body: crate::datadogV1::model::AzureAccount, ) -> Result< - Option>, + std::collections::BTreeMap, Error, > { match self.delete_azure_integration_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -231,13 +252,18 @@ impl AzureIntegrationAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option> = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -253,10 +279,17 @@ impl AzureIntegrationAPI { /// List all Datadog-Azure integrations configured in your Datadog account. pub async fn list_azure_integration( &self, - ) -> Result>, Error> - { + ) -> Result, Error> { match self.list_azure_integration_with_http_info().await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -301,13 +334,17 @@ impl AzureIntegrationAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option> = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -325,11 +362,19 @@ impl AzureIntegrationAPI { &self, body: crate::datadogV1::model::AzureAccount, ) -> Result< - Option>, + std::collections::BTreeMap, Error, > { match self.update_azure_host_filters_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -382,13 +427,18 @@ impl AzureIntegrationAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option> = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -408,11 +458,19 @@ impl AzureIntegrationAPI { &self, body: crate::datadogV1::model::AzureAccount, ) -> Result< - Option>, + std::collections::BTreeMap, Error, > { match self.update_azure_integration_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -467,13 +525,18 @@ impl AzureIntegrationAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option> = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); diff --git a/src/datadogV1/api/api_dashboard_lists.rs b/src/datadogV1/api/api_dashboard_lists.rs index fe1f23b6a..cd54785a7 100644 --- a/src/datadogV1/api/api_dashboard_lists.rs +++ b/src/datadogV1/api/api_dashboard_lists.rs @@ -80,10 +80,17 @@ impl DashboardListsAPI { pub async fn create_dashboard_list( &self, body: crate::datadogV1::model::DashboardList, - ) -> Result, Error> - { + ) -> Result> { match self.create_dashboard_list_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -136,13 +143,16 @@ impl DashboardListsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -159,12 +169,18 @@ impl DashboardListsAPI { pub async fn delete_dashboard_list( &self, list_id: i64, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self.delete_dashboard_list_with_http_info(list_id).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -211,13 +227,18 @@ impl DashboardListsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -234,9 +255,17 @@ impl DashboardListsAPI { pub async fn get_dashboard_list( &self, list_id: i64, - ) -> Result, Error> { + ) -> Result> { match self.get_dashboard_list_with_http_info(list_id).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -281,13 +310,16 @@ impl DashboardListsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -303,12 +335,18 @@ impl DashboardListsAPI { /// Fetch all of your existing dashboard list definitions. pub async fn list_dashboard_lists( &self, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self.list_dashboard_lists_with_http_info().await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -353,13 +391,18 @@ impl DashboardListsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -377,13 +420,20 @@ impl DashboardListsAPI { &self, list_id: i64, body: crate::datadogV1::model::DashboardList, - ) -> Result, Error> - { + ) -> Result> { match self .update_dashboard_list_with_http_info(list_id, body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -438,13 +488,16 @@ impl DashboardListsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); diff --git a/src/datadogV1/api/api_dashboards.rs b/src/datadogV1/api/api_dashboards.rs index 16c0f4d56..616c8d187 100644 --- a/src/datadogV1/api/api_dashboards.rs +++ b/src/datadogV1/api/api_dashboards.rs @@ -240,9 +240,17 @@ impl DashboardsAPI { pub async fn create_dashboard( &self, body: crate::datadogV1::model::Dashboard, - ) -> Result, Error> { + ) -> Result> { match self.create_dashboard_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -294,13 +302,16 @@ impl DashboardsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -317,10 +328,17 @@ impl DashboardsAPI { pub async fn create_public_dashboard( &self, body: crate::datadogV1::model::SharedDashboard, - ) -> Result, Error> - { + ) -> Result> { match self.create_public_dashboard_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -373,13 +391,16 @@ impl DashboardsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -396,10 +417,17 @@ impl DashboardsAPI { pub async fn delete_dashboard( &self, dashboard_id: String, - ) -> Result, Error> - { + ) -> Result> { match self.delete_dashboard_with_http_info(dashboard_id).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -446,13 +474,18 @@ impl DashboardsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -469,9 +502,9 @@ impl DashboardsAPI { pub async fn delete_dashboards( &self, body: crate::datadogV1::model::DashboardBulkDeleteRequest, - ) -> Result, Error> { + ) -> Result<(), Error> { match self.delete_dashboards_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(_) => Ok(()), Err(err) => Err(err), } } @@ -543,11 +576,19 @@ impl DashboardsAPI { &self, token: String, ) -> Result< - Option, + crate::datadogV1::model::DeleteSharedDashboardResponse, Error, > { match self.delete_public_dashboard_with_http_info(token).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -594,13 +635,18 @@ impl DashboardsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -618,12 +664,12 @@ impl DashboardsAPI { &self, token: String, body: crate::datadogV1::model::SharedDashboardInvites, - ) -> Result, Error> { + ) -> Result<(), Error> { match self .delete_public_dashboard_invitation_with_http_info(token, body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(_) => Ok(()), Err(err) => Err(err), } } @@ -696,9 +742,17 @@ impl DashboardsAPI { pub async fn get_dashboard( &self, dashboard_id: String, - ) -> Result, Error> { + ) -> Result> { match self.get_dashboard_with_http_info(dashboard_id).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -742,13 +796,16 @@ impl DashboardsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = ResponseContent { @@ -764,10 +821,17 @@ impl DashboardsAPI { pub async fn get_public_dashboard( &self, token: String, - ) -> Result, Error> - { + ) -> Result> { match self.get_public_dashboard_with_http_info(token).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -814,13 +878,16 @@ impl DashboardsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -839,14 +906,22 @@ impl DashboardsAPI { token: String, params: GetPublicDashboardInvitationsOptionalParams, ) -> Result< - Option, + crate::datadogV1::model::SharedDashboardInvites, Error, > { match self .get_public_dashboard_invitations_with_http_info(token, params) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -907,13 +982,18 @@ impl DashboardsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -933,9 +1013,17 @@ impl DashboardsAPI { pub async fn list_dashboards( &self, params: ListDashboardsOptionalParams, - ) -> Result, Error> { + ) -> Result> { match self.list_dashboards_with_http_info(params).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -1007,13 +1095,17 @@ impl DashboardsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -1030,9 +1122,9 @@ impl DashboardsAPI { pub async fn restore_dashboards( &self, body: crate::datadogV1::model::DashboardRestoreRequest, - ) -> Result, Error> { + ) -> Result<(), Error> { match self.restore_dashboards_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(_) => Ok(()), Err(err) => Err(err), } } @@ -1105,14 +1197,22 @@ impl DashboardsAPI { token: String, body: crate::datadogV1::model::SharedDashboardInvites, ) -> Result< - Option, + crate::datadogV1::model::SharedDashboardInvites, Error, > { match self .send_public_dashboard_invitation_with_http_info(token, body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -1167,13 +1267,18 @@ impl DashboardsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -1191,12 +1296,20 @@ impl DashboardsAPI { &self, dashboard_id: String, body: crate::datadogV1::model::Dashboard, - ) -> Result, Error> { + ) -> Result> { match self .update_dashboard_with_http_info(dashboard_id, body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -1249,13 +1362,16 @@ impl DashboardsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -1273,13 +1389,20 @@ impl DashboardsAPI { &self, token: String, body: crate::datadogV1::model::SharedDashboardUpdateRequest, - ) -> Result, Error> - { + ) -> Result> { match self .update_public_dashboard_with_http_info(token, body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -1334,13 +1457,16 @@ impl DashboardsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); diff --git a/src/datadogV1/api/api_downtimes.rs b/src/datadogV1/api/api_downtimes.rs index 9665a3c8a..7dc63bfe2 100644 --- a/src/datadogV1/api/api_downtimes.rs +++ b/src/datadogV1/api/api_downtimes.rs @@ -124,9 +124,9 @@ impl DowntimesAPI { pub async fn cancel_downtime( &self, downtime_id: i64, - ) -> Result, Error> { + ) -> Result<(), Error> { match self.cancel_downtime_with_http_info(downtime_id).await { - Ok(response_content) => Ok(response_content.entity), + Ok(_) => Ok(()), Err(err) => Err(err), } } @@ -191,12 +191,18 @@ impl DowntimesAPI { pub async fn cancel_downtimes_by_scope( &self, body: crate::datadogV1::model::CancelDowntimesByScopeRequest, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self.cancel_downtimes_by_scope_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -249,13 +255,18 @@ impl DowntimesAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -272,9 +283,17 @@ impl DowntimesAPI { pub async fn create_downtime( &self, body: crate::datadogV1::model::Downtime, - ) -> Result, Error> { + ) -> Result> { match self.create_downtime_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -325,13 +344,16 @@ impl DowntimesAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -348,9 +370,17 @@ impl DowntimesAPI { pub async fn get_downtime( &self, downtime_id: i64, - ) -> Result, Error> { + ) -> Result> { match self.get_downtime_with_http_info(downtime_id).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -394,13 +424,16 @@ impl DowntimesAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = ResponseContent { @@ -416,9 +449,17 @@ impl DowntimesAPI { pub async fn list_downtimes( &self, params: ListDowntimesOptionalParams, - ) -> Result>, Error> { + ) -> Result, Error> { match self.list_downtimes_with_http_info(params).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -475,13 +516,16 @@ impl DowntimesAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option> = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -498,10 +542,17 @@ impl DowntimesAPI { pub async fn list_monitor_downtimes( &self, monitor_id: i64, - ) -> Result>, Error> - { + ) -> Result, Error> { match self.list_monitor_downtimes_with_http_info(monitor_id).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -548,13 +599,16 @@ impl DowntimesAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option> = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -572,9 +626,17 @@ impl DowntimesAPI { &self, downtime_id: i64, body: crate::datadogV1::model::Downtime, - ) -> Result, Error> { + ) -> Result> { match self.update_downtime_with_http_info(downtime_id, body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -627,13 +689,16 @@ impl DowntimesAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); diff --git a/src/datadogV1/api/api_events.rs b/src/datadogV1/api/api_events.rs index 97a581a2b..72a792dc0 100644 --- a/src/datadogV1/api/api_events.rs +++ b/src/datadogV1/api/api_events.rs @@ -119,9 +119,17 @@ impl EventsAPI { pub async fn create_event( &self, body: crate::datadogV1::model::EventCreateRequest, - ) -> Result, Error> { + ) -> Result> { match self.create_event_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -172,13 +180,18 @@ impl EventsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = ResponseContent { @@ -197,9 +210,17 @@ impl EventsAPI { pub async fn get_event( &self, event_id: i64, - ) -> Result, Error> { + ) -> Result> { match self.get_event_with_http_info(event_id).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -246,13 +267,16 @@ impl EventsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = ResponseContent { @@ -278,9 +302,17 @@ impl EventsAPI { start: i64, end: i64, params: ListEventsOptionalParams, - ) -> Result, Error> { + ) -> Result> { match self.list_events_with_http_info(start, end, params).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -369,13 +401,17 @@ impl EventsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = ResponseContent { diff --git a/src/datadogV1/api/api_gcp_integration.rs b/src/datadogV1/api/api_gcp_integration.rs index 2b0eff2c1..e67900da7 100644 --- a/src/datadogV1/api/api_gcp_integration.rs +++ b/src/datadogV1/api/api_gcp_integration.rs @@ -71,11 +71,19 @@ impl GCPIntegrationAPI { &self, body: crate::datadogV1::model::GCPAccount, ) -> Result< - Option>, + std::collections::BTreeMap, Error, > { match self.create_gcp_integration_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -128,13 +136,18 @@ impl GCPIntegrationAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option> = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -152,11 +165,19 @@ impl GCPIntegrationAPI { &self, body: crate::datadogV1::model::GCPAccount, ) -> Result< - Option>, + std::collections::BTreeMap, Error, > { match self.delete_gcp_integration_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -209,13 +230,18 @@ impl GCPIntegrationAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option> = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -231,10 +257,17 @@ impl GCPIntegrationAPI { /// This endpoint is deprecated – use the V2 endpoints instead. List all Datadog-GCP integrations configured in your Datadog account. pub async fn list_gcp_integration( &self, - ) -> Result>, Error> - { + ) -> Result, Error> { match self.list_gcp_integration_with_http_info().await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -279,13 +312,16 @@ impl GCPIntegrationAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option> = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -306,11 +342,19 @@ impl GCPIntegrationAPI { &self, body: crate::datadogV1::model::GCPAccount, ) -> Result< - Option>, + std::collections::BTreeMap, Error, > { match self.update_gcp_integration_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -366,13 +410,18 @@ impl GCPIntegrationAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option> = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); diff --git a/src/datadogV1/api/api_hosts.rs b/src/datadogV1/api/api_hosts.rs index b3166c914..22baad335 100644 --- a/src/datadogV1/api/api_hosts.rs +++ b/src/datadogV1/api/api_hosts.rs @@ -152,9 +152,17 @@ impl HostsAPI { pub async fn get_host_totals( &self, params: GetHostTotalsOptionalParams, - ) -> Result, Error> { + ) -> Result> { match self.get_host_totals_with_http_info(params).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -207,13 +215,16 @@ impl HostsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -233,9 +244,17 @@ impl HostsAPI { pub async fn list_hosts( &self, params: ListHostsOptionalParams, - ) -> Result, Error> { + ) -> Result> { match self.list_hosts_with_http_info(params).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -325,13 +344,17 @@ impl HostsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = ResponseContent { @@ -348,9 +371,17 @@ impl HostsAPI { &self, host_name: String, body: crate::datadogV1::model::HostMuteSettings, - ) -> Result, Error> { + ) -> Result> { match self.mute_host_with_http_info(host_name, body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -403,13 +434,17 @@ impl HostsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = ResponseContent { @@ -425,9 +460,17 @@ impl HostsAPI { pub async fn unmute_host( &self, host_name: String, - ) -> Result, Error> { + ) -> Result> { match self.unmute_host_with_http_info(host_name).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -472,13 +515,17 @@ impl HostsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = ResponseContent { diff --git a/src/datadogV1/api/api_ip_ranges.rs b/src/datadogV1/api/api_ip_ranges.rs index aa40a0a13..efac8fdae 100644 --- a/src/datadogV1/api/api_ip_ranges.rs +++ b/src/datadogV1/api/api_ip_ranges.rs @@ -37,9 +37,17 @@ impl IPRangesAPI { /// Get information about Datadog IP ranges. pub async fn get_ip_ranges( &self, - ) -> Result, Error> { + ) -> Result> { match self.get_ip_ranges_with_http_info().await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -72,13 +80,16 @@ impl IPRangesAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = ResponseContent { diff --git a/src/datadogV1/api/api_key_management.rs b/src/datadogV1/api/api_key_management.rs index 5f3dcd8ab..6d764a406 100644 --- a/src/datadogV1/api/api_key_management.rs +++ b/src/datadogV1/api/api_key_management.rs @@ -133,9 +133,17 @@ impl KeyManagementAPI { pub async fn create_api_key( &self, body: crate::datadogV1::model::ApiKey, - ) -> Result, Error> { + ) -> Result> { match self.create_api_key_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -186,13 +194,16 @@ impl KeyManagementAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = ResponseContent { @@ -208,12 +219,18 @@ impl KeyManagementAPI { pub async fn create_application_key( &self, body: crate::datadogV1::model::ApplicationKey, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self.create_application_key_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -266,13 +283,18 @@ impl KeyManagementAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -289,9 +311,17 @@ impl KeyManagementAPI { pub async fn delete_api_key( &self, key: String, - ) -> Result, Error> { + ) -> Result> { match self.delete_api_key_with_http_info(key).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -336,13 +366,16 @@ impl KeyManagementAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = ResponseContent { @@ -358,12 +391,18 @@ impl KeyManagementAPI { pub async fn delete_application_key( &self, key: String, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self.delete_application_key_with_http_info(key).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -410,13 +449,18 @@ impl KeyManagementAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -433,9 +477,17 @@ impl KeyManagementAPI { pub async fn get_api_key( &self, key: String, - ) -> Result, Error> { + ) -> Result> { match self.get_api_key_with_http_info(key).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -480,13 +532,16 @@ impl KeyManagementAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = ResponseContent { @@ -502,12 +557,18 @@ impl KeyManagementAPI { pub async fn get_application_key( &self, key: String, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self.get_application_key_with_http_info(key).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -554,13 +615,18 @@ impl KeyManagementAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -576,9 +642,17 @@ impl KeyManagementAPI { /// Get all API keys available for your account. pub async fn list_api_keys( &self, - ) -> Result, Error> { + ) -> Result> { match self.list_api_keys_with_http_info().await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -621,13 +695,18 @@ impl KeyManagementAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = ResponseContent { @@ -642,12 +721,18 @@ impl KeyManagementAPI { /// Get all application keys available for your Datadog account. pub async fn list_application_keys( &self, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self.list_application_keys_with_http_info().await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -692,13 +777,18 @@ impl KeyManagementAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -716,9 +806,17 @@ impl KeyManagementAPI { &self, key: String, body: crate::datadogV1::model::ApiKey, - ) -> Result, Error> { + ) -> Result> { match self.update_api_key_with_http_info(key, body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -771,13 +869,16 @@ impl KeyManagementAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = ResponseContent { @@ -794,12 +895,18 @@ impl KeyManagementAPI { &self, key: String, body: crate::datadogV1::model::ApplicationKey, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self.update_application_key_with_http_info(key, body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -854,13 +961,18 @@ impl KeyManagementAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); diff --git a/src/datadogV1/api/api_logs.rs b/src/datadogV1/api/api_logs.rs index 9d728e179..231d8aa6e 100644 --- a/src/datadogV1/api/api_logs.rs +++ b/src/datadogV1/api/api_logs.rs @@ -83,9 +83,17 @@ impl LogsAPI { pub async fn list_logs( &self, body: crate::datadogV1::model::LogsListRequest, - ) -> Result, Error> { + ) -> Result> { match self.list_logs_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -144,13 +152,17 @@ impl LogsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = ResponseContent { @@ -185,10 +197,17 @@ impl LogsAPI { &self, body: Vec, params: SubmitLogOptionalParams, - ) -> Result>, Error> - { + ) -> Result, Error> { match self.submit_log_with_http_info(body, params).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -270,13 +289,18 @@ impl LogsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option> = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = ResponseContent { diff --git a/src/datadogV1/api/api_logs_indexes.rs b/src/datadogV1/api/api_logs_indexes.rs index c1c457e18..c31480827 100644 --- a/src/datadogV1/api/api_logs_indexes.rs +++ b/src/datadogV1/api/api_logs_indexes.rs @@ -88,9 +88,17 @@ impl LogsIndexesAPI { pub async fn create_logs_index( &self, body: crate::datadogV1::model::LogsIndex, - ) -> Result, Error> { + ) -> Result> { match self.create_logs_index_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -141,13 +149,16 @@ impl LogsIndexesAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -164,9 +175,17 @@ impl LogsIndexesAPI { pub async fn get_logs_index( &self, name: String, - ) -> Result, Error> { + ) -> Result> { match self.get_logs_index_with_http_info(name).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -210,13 +229,16 @@ impl LogsIndexesAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = ResponseContent { @@ -231,10 +253,17 @@ impl LogsIndexesAPI { /// Get the current order of your log indexes. This endpoint takes no JSON arguments. pub async fn get_logs_index_order( &self, - ) -> Result, Error> - { + ) -> Result> { match self.get_logs_index_order_with_http_info().await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -279,13 +308,17 @@ impl LogsIndexesAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -302,10 +335,17 @@ impl LogsIndexesAPI { /// This endpoint returns an array of the `LogIndex` objects of your organization. pub async fn list_log_indexes( &self, - ) -> Result, Error> - { + ) -> Result> { match self.list_log_indexes_with_http_info().await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -351,13 +391,18 @@ impl LogsIndexesAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -379,9 +424,17 @@ impl LogsIndexesAPI { &self, name: String, body: crate::datadogV1::model::LogsIndexUpdateRequest, - ) -> Result, Error> { + ) -> Result> { match self.update_logs_index_with_http_info(name, body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -438,13 +491,16 @@ impl LogsIndexesAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -462,10 +518,17 @@ impl LogsIndexesAPI { pub async fn update_logs_index_order( &self, body: crate::datadogV1::model::LogsIndexesOrder, - ) -> Result, Error> - { + ) -> Result> { match self.update_logs_index_order_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -519,13 +582,17 @@ impl LogsIndexesAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); diff --git a/src/datadogV1/api/api_logs_pipelines.rs b/src/datadogV1/api/api_logs_pipelines.rs index 3b7dffff5..609b90b2b 100644 --- a/src/datadogV1/api/api_logs_pipelines.rs +++ b/src/datadogV1/api/api_logs_pipelines.rs @@ -99,9 +99,17 @@ impl LogsPipelinesAPI { pub async fn create_logs_pipeline( &self, body: crate::datadogV1::model::LogsPipeline, - ) -> Result, Error> { + ) -> Result> { match self.create_logs_pipeline_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -154,13 +162,16 @@ impl LogsPipelinesAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -178,9 +189,9 @@ impl LogsPipelinesAPI { pub async fn delete_logs_pipeline( &self, pipeline_id: String, - ) -> Result, Error> { + ) -> Result<(), Error> { match self.delete_logs_pipeline_with_http_info(pipeline_id).await { - Ok(response_content) => Ok(response_content.entity), + Ok(_) => Ok(()), Err(err) => Err(err), } } @@ -247,9 +258,17 @@ impl LogsPipelinesAPI { pub async fn get_logs_pipeline( &self, pipeline_id: String, - ) -> Result, Error> { + ) -> Result> { match self.get_logs_pipeline_with_http_info(pipeline_id).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -295,13 +314,16 @@ impl LogsPipelinesAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -318,10 +340,17 @@ impl LogsPipelinesAPI { /// This endpoint takes no JSON arguments. pub async fn get_logs_pipeline_order( &self, - ) -> Result, Error> - { + ) -> Result> { match self.get_logs_pipeline_order_with_http_info().await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -367,13 +396,18 @@ impl LogsPipelinesAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -390,10 +424,17 @@ impl LogsPipelinesAPI { /// This endpoint takes no JSON arguments. pub async fn list_logs_pipelines( &self, - ) -> Result>, Error> - { + ) -> Result, Error> { match self.list_logs_pipelines_with_http_info().await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -439,13 +480,17 @@ impl LogsPipelinesAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option> = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -466,12 +511,20 @@ impl LogsPipelinesAPI { &self, pipeline_id: String, body: crate::datadogV1::model::LogsPipeline, - ) -> Result, Error> { + ) -> Result> { match self .update_logs_pipeline_with_http_info(pipeline_id, body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -529,13 +582,16 @@ impl LogsPipelinesAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -556,12 +612,18 @@ impl LogsPipelinesAPI { pub async fn update_logs_pipeline_order( &self, body: crate::datadogV1::model::LogsPipelinesOrder, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self.update_logs_pipeline_order_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -618,13 +680,18 @@ impl LogsPipelinesAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); diff --git a/src/datadogV1/api/api_metrics.rs b/src/datadogV1/api/api_metrics.rs index a8f903df3..f14e827f7 100644 --- a/src/datadogV1/api/api_metrics.rs +++ b/src/datadogV1/api/api_metrics.rs @@ -170,10 +170,17 @@ impl MetricsAPI { pub async fn get_metric_metadata( &self, metric_name: String, - ) -> Result, Error> - { + ) -> Result> { match self.get_metric_metadata_with_http_info(metric_name).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -220,13 +227,16 @@ impl MetricsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -244,10 +254,17 @@ impl MetricsAPI { &self, from: i64, params: ListActiveMetricsOptionalParams, - ) -> Result, Error> - { + ) -> Result> { match self.list_active_metrics_with_http_info(from, params).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -308,13 +325,18 @@ impl MetricsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -331,10 +353,17 @@ impl MetricsAPI { pub async fn list_metrics( &self, q: String, - ) -> Result, Error> - { + ) -> Result> { match self.list_metrics_with_http_info(q).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -382,13 +411,18 @@ impl MetricsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = ResponseContent { @@ -406,10 +440,17 @@ impl MetricsAPI { from: i64, to: i64, query: String, - ) -> Result, Error> - { + ) -> Result> { match self.query_metrics_with_http_info(from, to, query).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -461,13 +502,18 @@ impl MetricsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = ResponseContent { @@ -484,15 +530,21 @@ impl MetricsAPI { &self, body: crate::datadogV1::model::DistributionPointsPayload, params: SubmitDistributionPointsOptionalParams, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self .submit_distribution_points_with_http_info(body, params) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -550,13 +602,18 @@ impl MetricsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -584,10 +641,17 @@ impl MetricsAPI { &self, body: crate::datadogV1::model::MetricsPayload, params: SubmitMetricsOptionalParams, - ) -> Result, Error> - { + ) -> Result> { match self.submit_metrics_with_http_info(body, params).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -655,13 +719,18 @@ impl MetricsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -679,13 +748,20 @@ impl MetricsAPI { &self, metric_name: String, body: crate::datadogV1::model::MetricMetadata, - ) -> Result, Error> - { + ) -> Result> { match self .update_metric_metadata_with_http_info(metric_name, body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -740,13 +816,16 @@ impl MetricsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); diff --git a/src/datadogV1/api/api_monitors.rs b/src/datadogV1/api/api_monitors.rs index bd02f7f8c..02024460b 100644 --- a/src/datadogV1/api/api_monitors.rs +++ b/src/datadogV1/api/api_monitors.rs @@ -365,14 +365,22 @@ impl MonitorsAPI { &self, monitor_ids: Vec, ) -> Result< - Option, + crate::datadogV1::model::CheckCanDeleteMonitorResponse, Error, > { match self .check_can_delete_monitor_with_http_info(monitor_ids) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -428,13 +436,18 @@ impl MonitorsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -632,9 +645,17 @@ impl MonitorsAPI { pub async fn create_monitor( &self, body: crate::datadogV1::model::Monitor, - ) -> Result, Error> { + ) -> Result> { match self.create_monitor_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -865,13 +886,16 @@ impl MonitorsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -889,9 +913,17 @@ impl MonitorsAPI { &self, monitor_id: i64, params: DeleteMonitorOptionalParams, - ) -> Result, Error> { + ) -> Result> { match self.delete_monitor_with_http_info(monitor_id, params).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -945,13 +977,16 @@ impl MonitorsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -969,9 +1004,17 @@ impl MonitorsAPI { &self, monitor_id: i64, params: GetMonitorOptionalParams, - ) -> Result, Error> { + ) -> Result> { match self.get_monitor_with_http_info(monitor_id, params).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -1029,13 +1072,16 @@ impl MonitorsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = ResponseContent { @@ -1051,9 +1097,17 @@ impl MonitorsAPI { pub async fn list_monitors( &self, params: ListMonitorsOptionalParams, - ) -> Result>, Error> { + ) -> Result, Error> { match self.list_monitors_with_http_info(params).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -1140,13 +1194,16 @@ impl MonitorsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option> = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = ResponseContent { @@ -1162,12 +1219,18 @@ impl MonitorsAPI { pub async fn search_monitor_groups( &self, params: SearchMonitorGroupsOptionalParams, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self.search_monitor_groups_with_http_info(params).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -1236,13 +1299,18 @@ impl MonitorsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -1259,10 +1327,17 @@ impl MonitorsAPI { pub async fn search_monitors( &self, params: SearchMonitorsOptionalParams, - ) -> Result, Error> - { + ) -> Result> { match self.search_monitors_with_http_info(params).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -1331,13 +1406,18 @@ impl MonitorsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -1355,9 +1435,17 @@ impl MonitorsAPI { &self, monitor_id: i64, body: crate::datadogV1::model::MonitorUpdateRequest, - ) -> Result, Error> { + ) -> Result> { match self.update_monitor_with_http_info(monitor_id, body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -1409,13 +1497,16 @@ impl MonitorsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -1434,14 +1525,22 @@ impl MonitorsAPI { monitor_id: i64, body: crate::datadogV1::model::Monitor, ) -> Result< - Option>, + std::collections::BTreeMap, Error, > { match self .validate_existing_monitor_with_http_info(monitor_id, body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -1496,13 +1595,18 @@ impl MonitorsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option> = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -1521,12 +1625,18 @@ impl MonitorsAPI { pub async fn validate_monitor( &self, body: crate::datadogV1::model::Monitor, - ) -> Result< - Option>, - Error, - > { + ) -> Result, Error> + { match self.validate_monitor_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -1581,13 +1691,18 @@ impl MonitorsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option> = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); diff --git a/src/datadogV1/api/api_notebooks.rs b/src/datadogV1/api/api_notebooks.rs index c1004046c..c80231f69 100644 --- a/src/datadogV1/api/api_notebooks.rs +++ b/src/datadogV1/api/api_notebooks.rs @@ -163,9 +163,17 @@ impl NotebooksAPI { pub async fn create_notebook( &self, body: crate::datadogV1::model::NotebookCreateRequest, - ) -> Result, Error> { + ) -> Result> { match self.create_notebook_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -218,13 +226,17 @@ impl NotebooksAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -241,9 +253,9 @@ impl NotebooksAPI { pub async fn delete_notebook( &self, notebook_id: i64, - ) -> Result, Error> { + ) -> Result<(), Error> { match self.delete_notebook_with_http_info(notebook_id).await { - Ok(response_content) => Ok(response_content.entity), + Ok(_) => Ok(()), Err(err) => Err(err), } } @@ -308,9 +320,17 @@ impl NotebooksAPI { pub async fn get_notebook( &self, notebook_id: i64, - ) -> Result, Error> { + ) -> Result> { match self.get_notebook_with_http_info(notebook_id).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -355,13 +375,17 @@ impl NotebooksAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = ResponseContent { @@ -378,9 +402,17 @@ impl NotebooksAPI { pub async fn list_notebooks( &self, params: ListNotebooksOptionalParams, - ) -> Result, Error> { + ) -> Result> { match self.list_notebooks_with_http_info(params).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -480,13 +512,17 @@ impl NotebooksAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -504,9 +540,17 @@ impl NotebooksAPI { &self, notebook_id: i64, body: crate::datadogV1::model::NotebookUpdateRequest, - ) -> Result, Error> { + ) -> Result> { match self.update_notebook_with_http_info(notebook_id, body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -561,13 +605,17 @@ impl NotebooksAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); diff --git a/src/datadogV1/api/api_organizations.rs b/src/datadogV1/api/api_organizations.rs index 000f1a251..ba892e46f 100644 --- a/src/datadogV1/api/api_organizations.rs +++ b/src/datadogV1/api/api_organizations.rs @@ -99,12 +99,18 @@ impl OrganizationsAPI { pub async fn create_child_org( &self, body: crate::datadogV1::model::OrganizationCreateBody, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self.create_child_org_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -166,13 +172,18 @@ impl OrganizationsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -189,10 +200,17 @@ impl OrganizationsAPI { pub async fn downgrade_org( &self, public_id: String, - ) -> Result, Error> - { + ) -> Result> { match self.downgrade_org_with_http_info(public_id).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -239,13 +257,18 @@ impl OrganizationsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = ResponseContent { @@ -261,9 +284,17 @@ impl OrganizationsAPI { pub async fn get_org( &self, public_id: String, - ) -> Result, Error> { + ) -> Result> { match self.get_org_with_http_info(public_id).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -308,13 +339,18 @@ impl OrganizationsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = ResponseContent { @@ -329,10 +365,17 @@ impl OrganizationsAPI { /// This endpoint returns data on your top-level organization. pub async fn list_orgs( &self, - ) -> Result, Error> - { + ) -> Result> { match self.list_orgs_with_http_info().await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -377,13 +420,18 @@ impl OrganizationsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = ResponseContent { @@ -400,9 +448,17 @@ impl OrganizationsAPI { &self, public_id: String, body: crate::datadogV1::model::Organization, - ) -> Result, Error> { + ) -> Result> { match self.update_org_with_http_info(public_id, body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -455,13 +511,18 @@ impl OrganizationsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = ResponseContent { @@ -483,12 +544,20 @@ impl OrganizationsAPI { &self, public_id: String, idp_file: Vec, - ) -> Result, Error> { + ) -> Result> { match self .upload_idp_for_org_with_http_info(public_id, idp_file) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -547,13 +616,16 @@ impl OrganizationsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); diff --git a/src/datadogV1/api/api_pager_duty_integration.rs b/src/datadogV1/api/api_pager_duty_integration.rs index a641fb774..1918c4e2e 100644 --- a/src/datadogV1/api/api_pager_duty_integration.rs +++ b/src/datadogV1/api/api_pager_duty_integration.rs @@ -72,14 +72,22 @@ impl PagerDutyIntegrationAPI { &self, body: crate::datadogV1::model::PagerDutyService, ) -> Result< - Option, + crate::datadogV1::model::PagerDutyServiceName, Error, > { match self .create_pager_duty_integration_service_with_http_info(body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -132,13 +140,18 @@ impl PagerDutyIntegrationAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -155,12 +168,12 @@ impl PagerDutyIntegrationAPI { pub async fn delete_pager_duty_integration_service( &self, service_name: String, - ) -> Result, Error> { + ) -> Result<(), Error> { match self .delete_pager_duty_integration_service_with_http_info(service_name) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(_) => Ok(()), Err(err) => Err(err), } } @@ -226,14 +239,22 @@ impl PagerDutyIntegrationAPI { &self, service_name: String, ) -> Result< - Option, + crate::datadogV1::model::PagerDutyServiceName, Error, > { match self .get_pager_duty_integration_service_with_http_info(service_name) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -280,13 +301,18 @@ impl PagerDutyIntegrationAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -304,12 +330,12 @@ impl PagerDutyIntegrationAPI { &self, service_name: String, body: crate::datadogV1::model::PagerDutyServiceKey, - ) -> Result, Error> { + ) -> Result<(), Error> { match self .update_pager_duty_integration_service_with_http_info(service_name, body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(_) => Ok(()), Err(err) => Err(err), } } diff --git a/src/datadogV1/api/api_security_monitoring.rs b/src/datadogV1/api/api_security_monitoring.rs index 377c1dc22..163606f05 100644 --- a/src/datadogV1/api/api_security_monitoring.rs +++ b/src/datadogV1/api/api_security_monitoring.rs @@ -65,14 +65,22 @@ impl SecurityMonitoringAPI { signal_id: String, body: crate::datadogV1::model::AddSignalToIncidentRequest, ) -> Result< - Option, + crate::datadogV1::model::SuccessfulSignalUpdateResponse, Error, > { match self .add_security_monitoring_signal_to_incident_with_http_info(signal_id, body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -127,13 +135,18 @@ impl SecurityMonitoringAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -152,14 +165,22 @@ impl SecurityMonitoringAPI { signal_id: String, body: crate::datadogV1::model::SignalAssigneeUpdateRequest, ) -> Result< - Option, + crate::datadogV1::model::SuccessfulSignalUpdateResponse, Error, > { match self .edit_security_monitoring_signal_assignee_with_http_info(signal_id, body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -214,13 +235,18 @@ impl SecurityMonitoringAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -239,14 +265,22 @@ impl SecurityMonitoringAPI { signal_id: String, body: crate::datadogV1::model::SignalStateUpdateRequest, ) -> Result< - Option, + crate::datadogV1::model::SuccessfulSignalUpdateResponse, Error, > { match self .edit_security_monitoring_signal_state_with_http_info(signal_id, body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -301,13 +335,18 @@ impl SecurityMonitoringAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); diff --git a/src/datadogV1/api/api_service_checks.rs b/src/datadogV1/api/api_service_checks.rs index 251524dc8..ddf0ae6f5 100644 --- a/src/datadogV1/api/api_service_checks.rs +++ b/src/datadogV1/api/api_service_checks.rs @@ -46,12 +46,18 @@ impl ServiceChecksAPI { pub async fn submit_service_check( &self, body: Vec, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self.submit_service_check_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -105,13 +111,18 @@ impl ServiceChecksAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); diff --git a/src/datadogV1/api/api_service_level_objective_corrections.rs b/src/datadogV1/api/api_service_level_objective_corrections.rs index e86a09b16..40b880afc 100644 --- a/src/datadogV1/api/api_service_level_objective_corrections.rs +++ b/src/datadogV1/api/api_service_level_objective_corrections.rs @@ -104,12 +104,18 @@ impl ServiceLevelObjectiveCorrectionsAPI { pub async fn create_slo_correction( &self, body: crate::datadogV1::model::SLOCorrectionCreateRequest, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self.create_slo_correction_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -162,13 +168,18 @@ impl ServiceLevelObjectiveCorrectionsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -185,12 +196,12 @@ impl ServiceLevelObjectiveCorrectionsAPI { pub async fn delete_slo_correction( &self, slo_correction_id: String, - ) -> Result, Error> { + ) -> Result<(), Error> { match self .delete_slo_correction_with_http_info(slo_correction_id) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(_) => Ok(()), Err(err) => Err(err), } } @@ -255,13 +266,20 @@ impl ServiceLevelObjectiveCorrectionsAPI { pub async fn get_slo_correction( &self, slo_correction_id: String, - ) -> Result, Error> - { + ) -> Result> { match self .get_slo_correction_with_http_info(slo_correction_id) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -308,13 +326,18 @@ impl ServiceLevelObjectiveCorrectionsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -331,12 +354,18 @@ impl ServiceLevelObjectiveCorrectionsAPI { pub async fn list_slo_correction( &self, params: ListSLOCorrectionOptionalParams, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self.list_slo_correction_with_http_info(params).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -395,13 +424,18 @@ impl ServiceLevelObjectiveCorrectionsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -419,15 +453,21 @@ impl ServiceLevelObjectiveCorrectionsAPI { &self, slo_correction_id: String, body: crate::datadogV1::model::SLOCorrectionUpdateRequest, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self .update_slo_correction_with_http_info(slo_correction_id, body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -482,13 +522,18 @@ impl ServiceLevelObjectiveCorrectionsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); diff --git a/src/datadogV1/api/api_service_level_objectives.rs b/src/datadogV1/api/api_service_level_objectives.rs index 875bf98c1..0829eb3f5 100644 --- a/src/datadogV1/api/api_service_level_objectives.rs +++ b/src/datadogV1/api/api_service_level_objectives.rs @@ -286,12 +286,18 @@ impl ServiceLevelObjectivesAPI { pub async fn check_can_delete_slo( &self, ids: String, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self.check_can_delete_slo_with_http_info(ids).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -340,13 +346,18 @@ impl ServiceLevelObjectivesAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -363,9 +374,17 @@ impl ServiceLevelObjectivesAPI { pub async fn create_slo( &self, body: crate::datadogV1::model::ServiceLevelObjectiveRequest, - ) -> Result, Error> { + ) -> Result> { match self.create_slo_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -416,13 +435,16 @@ impl ServiceLevelObjectivesAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = ResponseContent { @@ -442,9 +464,17 @@ impl ServiceLevelObjectivesAPI { &self, slo_id: String, params: DeleteSLOOptionalParams, - ) -> Result, Error> { + ) -> Result> { match self.delete_slo_with_http_info(slo_id, params).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -501,13 +531,17 @@ impl ServiceLevelObjectivesAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = ResponseContent { @@ -527,12 +561,18 @@ impl ServiceLevelObjectivesAPI { pub async fn delete_slo_timeframe_in_bulk( &self, body: std::collections::BTreeMap>, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self.delete_slo_timeframe_in_bulk_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -589,13 +629,18 @@ impl ServiceLevelObjectivesAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -613,9 +658,17 @@ impl ServiceLevelObjectivesAPI { &self, slo_id: String, params: GetSLOOptionalParams, - ) -> Result, Error> { + ) -> Result> { match self.get_slo_with_http_info(slo_id, params).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -668,13 +721,16 @@ impl ServiceLevelObjectivesAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = ResponseContent { @@ -690,12 +746,18 @@ impl ServiceLevelObjectivesAPI { pub async fn get_slo_corrections( &self, slo_id: String, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self.get_slo_corrections_with_http_info(slo_id).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -742,13 +804,18 @@ impl ServiceLevelObjectivesAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -775,13 +842,20 @@ impl ServiceLevelObjectivesAPI { from_ts: i64, to_ts: i64, params: GetSLOHistoryOptionalParams, - ) -> Result, Error> - { + ) -> Result> { match self .get_slo_history_with_http_info(slo_id, from_ts, to_ts, params) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -853,13 +927,18 @@ impl ServiceLevelObjectivesAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -876,9 +955,17 @@ impl ServiceLevelObjectivesAPI { pub async fn list_slos( &self, params: ListSLOsOptionalParams, - ) -> Result, Error> { + ) -> Result> { match self.list_slos_with_http_info(params).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -954,13 +1041,16 @@ impl ServiceLevelObjectivesAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = ResponseContent { @@ -976,9 +1066,17 @@ impl ServiceLevelObjectivesAPI { pub async fn search_slo( &self, params: SearchSLOOptionalParams, - ) -> Result, Error> { + ) -> Result> { match self.search_slo_with_http_info(params).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -1045,13 +1143,17 @@ impl ServiceLevelObjectivesAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = ResponseContent { @@ -1068,9 +1170,17 @@ impl ServiceLevelObjectivesAPI { &self, slo_id: String, body: crate::datadogV1::model::ServiceLevelObjective, - ) -> Result, Error> { + ) -> Result> { match self.update_slo_with_http_info(slo_id, body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -1123,13 +1233,16 @@ impl ServiceLevelObjectivesAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = ResponseContent { diff --git a/src/datadogV1/api/api_slack_integration.rs b/src/datadogV1/api/api_slack_integration.rs index 1fd0f04d8..3ec5ef4d2 100644 --- a/src/datadogV1/api/api_slack_integration.rs +++ b/src/datadogV1/api/api_slack_integration.rs @@ -87,14 +87,22 @@ impl SlackIntegrationAPI { account_name: String, body: crate::datadogV1::model::SlackIntegrationChannel, ) -> Result< - Option, + crate::datadogV1::model::SlackIntegrationChannel, Error, > { match self .create_slack_integration_channel_with_http_info(account_name, body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -149,13 +157,18 @@ impl SlackIntegrationAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -174,14 +187,22 @@ impl SlackIntegrationAPI { account_name: String, channel_name: String, ) -> Result< - Option, + crate::datadogV1::model::SlackIntegrationChannel, Error, > { match self .get_slack_integration_channel_with_http_info(account_name, channel_name) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -231,13 +252,18 @@ impl SlackIntegrationAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -255,14 +281,22 @@ impl SlackIntegrationAPI { &self, account_name: String, ) -> Result< - Option>, + Vec, Error, > { match self .get_slack_integration_channels_with_http_info(account_name) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -309,13 +343,18 @@ impl SlackIntegrationAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option> = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -333,12 +372,12 @@ impl SlackIntegrationAPI { &self, account_name: String, channel_name: String, - ) -> Result, Error> { + ) -> Result<(), Error> { match self .remove_slack_integration_channel_with_http_info(account_name, channel_name) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(_) => Ok(()), Err(err) => Err(err), } } @@ -409,14 +448,22 @@ impl SlackIntegrationAPI { channel_name: String, body: crate::datadogV1::model::SlackIntegrationChannel, ) -> Result< - Option, + crate::datadogV1::model::SlackIntegrationChannel, Error, > { match self .update_slack_integration_channel_with_http_info(account_name, channel_name, body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -474,13 +521,18 @@ impl SlackIntegrationAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); diff --git a/src/datadogV1/api/api_snapshots.rs b/src/datadogV1/api/api_snapshots.rs index 8d0c00203..91e7ec9c4 100644 --- a/src/datadogV1/api/api_snapshots.rs +++ b/src/datadogV1/api/api_snapshots.rs @@ -98,12 +98,20 @@ impl SnapshotsAPI { start: i64, end: i64, params: GetGraphSnapshotOptionalParams, - ) -> Result, Error> { + ) -> Result> { match self .get_graph_snapshot_with_http_info(start, end, params) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -185,13 +193,16 @@ impl SnapshotsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); diff --git a/src/datadogV1/api/api_synthetics.rs b/src/datadogV1/api/api_synthetics.rs index 650f05d33..4e7020235 100644 --- a/src/datadogV1/api/api_synthetics.rs +++ b/src/datadogV1/api/api_synthetics.rs @@ -400,12 +400,18 @@ impl SyntheticsAPI { pub async fn create_global_variable( &self, body: crate::datadogV1::model::SyntheticsGlobalVariable, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self.create_global_variable_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -458,13 +464,18 @@ impl SyntheticsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -482,11 +493,19 @@ impl SyntheticsAPI { &self, body: crate::datadogV1::model::SyntheticsPrivateLocation, ) -> Result< - Option, + crate::datadogV1::model::SyntheticsPrivateLocationCreationResponse, Error, > { match self.create_private_location_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -539,14 +558,19 @@ impl SyntheticsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option< + match serde_json::from_str::< crate::datadogV1::model::SyntheticsPrivateLocationCreationResponse, - > = serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + >(&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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -563,12 +587,18 @@ impl SyntheticsAPI { pub async fn create_synthetics_api_test( &self, body: crate::datadogV1::model::SyntheticsAPITest, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self.create_synthetics_api_test_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -621,13 +651,17 @@ impl SyntheticsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -645,14 +679,22 @@ impl SyntheticsAPI { &self, body: crate::datadogV1::model::SyntheticsBrowserTest, ) -> Result< - Option, + crate::datadogV1::model::SyntheticsBrowserTest, Error, > { match self .create_synthetics_browser_test_with_http_info(body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -705,13 +747,18 @@ impl SyntheticsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -728,12 +775,12 @@ impl SyntheticsAPI { pub async fn delete_global_variable( &self, variable_id: String, - ) -> Result, Error> { + ) -> Result<(), Error> { match self .delete_global_variable_with_http_info(variable_id) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(_) => Ok(()), Err(err) => Err(err), } } @@ -798,12 +845,12 @@ impl SyntheticsAPI { pub async fn delete_private_location( &self, location_id: String, - ) -> Result, Error> { + ) -> Result<(), Error> { match self .delete_private_location_with_http_info(location_id) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(_) => Ok(()), Err(err) => Err(err), } } @@ -868,12 +915,18 @@ impl SyntheticsAPI { pub async fn delete_tests( &self, body: crate::datadogV1::model::SyntheticsDeleteTestsPayload, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self.delete_tests_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -926,13 +979,18 @@ impl SyntheticsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = ResponseContent { @@ -949,15 +1007,21 @@ impl SyntheticsAPI { &self, variable_id: String, body: crate::datadogV1::model::SyntheticsGlobalVariable, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self .edit_global_variable_with_http_info(variable_id, body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -1012,13 +1076,18 @@ impl SyntheticsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -1036,9 +1105,17 @@ impl SyntheticsAPI { pub async fn get_api_test( &self, public_id: String, - ) -> Result, Error> { + ) -> Result> { match self.get_api_test_with_http_info(public_id).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -1084,13 +1161,17 @@ impl SyntheticsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = ResponseContent { @@ -1108,14 +1189,22 @@ impl SyntheticsAPI { public_id: String, params: GetAPITestLatestResultsOptionalParams, ) -> Result< - Option, + crate::datadogV1::model::SyntheticsGetAPITestLatestResultsResponse, Error, > { match self .get_api_test_latest_results_with_http_info(public_id, params) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -1188,14 +1277,19 @@ impl SyntheticsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option< + match serde_json::from_str::< crate::datadogV1::model::SyntheticsGetAPITestLatestResultsResponse, - > = serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + >(&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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -1213,15 +1307,21 @@ impl SyntheticsAPI { &self, public_id: String, result_id: String, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self .get_api_test_result_with_http_info(public_id, result_id) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -1270,13 +1370,18 @@ impl SyntheticsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -1294,10 +1399,17 @@ impl SyntheticsAPI { pub async fn get_browser_test( &self, public_id: String, - ) -> Result, Error> - { + ) -> Result> { match self.get_browser_test_with_http_info(public_id).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -1345,13 +1457,18 @@ impl SyntheticsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -1370,14 +1487,22 @@ impl SyntheticsAPI { public_id: String, params: GetBrowserTestLatestResultsOptionalParams, ) -> Result< - Option, + crate::datadogV1::model::SyntheticsGetBrowserTestLatestResultsResponse, Error, > { match self .get_browser_test_latest_results_with_http_info(public_id, params) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -1450,14 +1575,19 @@ impl SyntheticsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option< + match serde_json::from_str::< crate::datadogV1::model::SyntheticsGetBrowserTestLatestResultsResponse, - > = serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + >(&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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -1476,14 +1606,22 @@ impl SyntheticsAPI { public_id: String, result_id: String, ) -> Result< - Option, + crate::datadogV1::model::SyntheticsBrowserTestResultFull, Error, > { match self .get_browser_test_result_with_http_info(public_id, result_id) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -1532,13 +1670,18 @@ impl SyntheticsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -1555,12 +1698,18 @@ impl SyntheticsAPI { pub async fn get_global_variable( &self, variable_id: String, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self.get_global_variable_with_http_info(variable_id).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -1607,13 +1756,18 @@ impl SyntheticsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -1630,12 +1784,18 @@ impl SyntheticsAPI { pub async fn get_private_location( &self, location_id: String, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self.get_private_location_with_http_info(location_id).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -1682,13 +1842,18 @@ impl SyntheticsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -1705,12 +1870,18 @@ impl SyntheticsAPI { pub async fn get_synthetics_ci_batch( &self, batch_id: String, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self.get_synthetics_ci_batch_with_http_info(batch_id).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -1757,13 +1928,18 @@ impl SyntheticsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -1779,9 +1955,17 @@ impl SyntheticsAPI { /// Get the default locations settings. pub async fn get_synthetics_default_locations( &self, - ) -> Result>, Error> { + ) -> Result, Error> { match self.get_synthetics_default_locations_with_http_info().await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -1823,12 +2007,16 @@ impl SyntheticsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option> = serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -1845,9 +2033,17 @@ impl SyntheticsAPI { pub async fn get_test( &self, public_id: String, - ) -> Result, Error> { + ) -> Result> { match self.get_test_with_http_info(public_id).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -1892,13 +2088,18 @@ impl SyntheticsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = ResponseContent { @@ -1914,11 +2115,19 @@ impl SyntheticsAPI { pub async fn list_global_variables( &self, ) -> Result< - Option, + crate::datadogV1::model::SyntheticsListGlobalVariablesResponse, Error, > { match self.list_global_variables_with_http_info().await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -1963,14 +2172,19 @@ impl SyntheticsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option< + match serde_json::from_str::< crate::datadogV1::model::SyntheticsListGlobalVariablesResponse, - > = serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + >(&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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -1987,10 +2201,17 @@ impl SyntheticsAPI { /// tests. No arguments required. pub async fn list_locations( &self, - ) -> Result, Error> - { + ) -> Result> { match self.list_locations_with_http_info().await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -2036,13 +2257,18 @@ impl SyntheticsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -2059,10 +2285,17 @@ impl SyntheticsAPI { pub async fn list_tests( &self, params: ListTestsOptionalParams, - ) -> Result, Error> - { + ) -> Result> { match self.list_tests_with_http_info(params).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -2121,13 +2354,18 @@ impl SyntheticsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = ResponseContent { @@ -2144,9 +2382,17 @@ impl SyntheticsAPI { &self, public_id: String, body: crate::datadogV1::model::SyntheticsPatchTestBody, - ) -> Result, Error> { + ) -> Result> { match self.patch_test_with_http_info(public_id, body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -2201,13 +2447,18 @@ impl SyntheticsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = ResponseContent { @@ -2223,12 +2474,18 @@ impl SyntheticsAPI { pub async fn trigger_ci_tests( &self, body: crate::datadogV1::model::SyntheticsCITestBody, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self.trigger_ci_tests_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -2281,13 +2538,18 @@ impl SyntheticsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -2304,12 +2566,18 @@ impl SyntheticsAPI { pub async fn trigger_tests( &self, body: crate::datadogV1::model::SyntheticsTriggerBody, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self.trigger_tests_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -2362,13 +2630,18 @@ impl SyntheticsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = ResponseContent { @@ -2385,9 +2658,17 @@ impl SyntheticsAPI { &self, public_id: String, body: crate::datadogV1::model::SyntheticsAPITest, - ) -> Result, Error> { + ) -> Result> { match self.update_api_test_with_http_info(public_id, body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -2442,13 +2723,17 @@ impl SyntheticsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -2466,13 +2751,20 @@ impl SyntheticsAPI { &self, public_id: String, body: crate::datadogV1::model::SyntheticsBrowserTest, - ) -> Result, Error> - { + ) -> Result> { match self .update_browser_test_with_http_info(public_id, body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -2527,13 +2819,18 @@ impl SyntheticsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -2551,15 +2848,21 @@ impl SyntheticsAPI { &self, location_id: String, body: crate::datadogV1::model::SyntheticsPrivateLocation, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self .update_private_location_with_http_info(location_id, body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -2614,13 +2917,18 @@ impl SyntheticsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -2638,12 +2946,20 @@ impl SyntheticsAPI { &self, public_id: String, body: crate::datadogV1::model::SyntheticsUpdateTestPauseStatusPayload, - ) -> Result, Error> { + ) -> Result> { match self .update_test_pause_status_with_http_info(public_id, body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -2695,12 +3011,16 @@ impl SyntheticsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); diff --git a/src/datadogV1/api/api_tags.rs b/src/datadogV1/api/api_tags.rs index abe6156c8..0d491582f 100644 --- a/src/datadogV1/api/api_tags.rs +++ b/src/datadogV1/api/api_tags.rs @@ -169,12 +169,20 @@ impl TagsAPI { host_name: String, body: crate::datadogV1::model::HostTags, params: CreateHostTagsOptionalParams, - ) -> Result, Error> { + ) -> Result> { match self .create_host_tags_with_http_info(host_name, body, params) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -237,13 +245,16 @@ impl TagsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -262,12 +273,12 @@ impl TagsAPI { &self, host_name: String, params: DeleteHostTagsOptionalParams, - ) -> Result, Error> { + ) -> Result<(), Error> { match self .delete_host_tags_with_http_info(host_name, params) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(_) => Ok(()), Err(err) => Err(err), } } @@ -343,9 +354,17 @@ impl TagsAPI { &self, host_name: String, params: GetHostTagsOptionalParams, - ) -> Result, Error> { + ) -> Result> { match self.get_host_tags_with_http_info(host_name, params).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -398,13 +417,16 @@ impl TagsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = ResponseContent { @@ -420,9 +442,17 @@ impl TagsAPI { pub async fn list_host_tags( &self, params: ListHostTagsOptionalParams, - ) -> Result, Error> { + ) -> Result> { match self.list_host_tags_with_http_info(params).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -474,13 +504,16 @@ impl TagsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = ResponseContent { @@ -499,12 +532,20 @@ impl TagsAPI { host_name: String, body: crate::datadogV1::model::HostTags, params: UpdateHostTagsOptionalParams, - ) -> Result, Error> { + ) -> Result> { match self .update_host_tags_with_http_info(host_name, body, params) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -567,13 +608,16 @@ impl TagsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); diff --git a/src/datadogV1/api/api_usage_metering.rs b/src/datadogV1/api/api_usage_metering.rs index bad331637..9867d17d4 100644 --- a/src/datadogV1/api/api_usage_metering.rs +++ b/src/datadogV1/api/api_usage_metering.rs @@ -1216,11 +1216,19 @@ impl UsageMeteringAPI { &self, params: GetDailyCustomReportsOptionalParams, ) -> Result< - Option, + crate::datadogV1::model::UsageCustomReportsResponse, Error, > { match self.get_daily_custom_reports_with_http_info(params).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -1291,13 +1299,18 @@ impl UsageMeteringAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -1331,14 +1344,22 @@ impl UsageMeteringAPI { usage_type: crate::datadogV1::model::HourlyUsageAttributionUsageType, params: GetHourlyUsageAttributionOptionalParams, ) -> Result< - Option, + crate::datadogV1::model::HourlyUsageAttributionResponse, Error, > { match self .get_hourly_usage_attribution_with_http_info(start_hr, usage_type, params) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -1425,13 +1446,18 @@ impl UsageMeteringAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -1451,14 +1477,22 @@ impl UsageMeteringAPI { start_hr: String, params: GetIncidentManagementOptionalParams, ) -> Result< - Option, + crate::datadogV1::model::UsageIncidentManagementResponse, Error, > { match self .get_incident_management_with_http_info(start_hr, params) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -1515,13 +1549,18 @@ impl UsageMeteringAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -1540,15 +1579,21 @@ impl UsageMeteringAPI { &self, start_hr: String, params: GetIngestedSpansOptionalParams, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self .get_ingested_spans_with_http_info(start_hr, params) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -1605,13 +1650,18 @@ impl UsageMeteringAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -1631,11 +1681,19 @@ impl UsageMeteringAPI { &self, params: GetMonthlyCustomReportsOptionalParams, ) -> Result< - Option, + crate::datadogV1::model::UsageCustomReportsResponse, Error, > { match self.get_monthly_custom_reports_with_http_info(params).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -1706,13 +1764,18 @@ impl UsageMeteringAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -1746,14 +1809,22 @@ impl UsageMeteringAPI { fields: crate::datadogV1::model::MonthlyUsageAttributionSupportedMetrics, params: GetMonthlyUsageAttributionOptionalParams, ) -> Result< - Option, + crate::datadogV1::model::MonthlyUsageAttributionResponse, Error, > { match self .get_monthly_usage_attribution_with_http_info(start_month, fields, params) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -1850,13 +1921,18 @@ impl UsageMeteringAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -1876,14 +1952,22 @@ impl UsageMeteringAPI { &self, report_id: String, ) -> Result< - Option, + crate::datadogV1::model::UsageSpecifiedCustomReportsResponse, Error, > { match self .get_specified_daily_custom_reports_with_http_info(report_id) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -1932,13 +2016,18 @@ impl UsageMeteringAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -1958,14 +2047,22 @@ impl UsageMeteringAPI { &self, report_id: String, ) -> Result< - Option, + crate::datadogV1::model::UsageSpecifiedCustomReportsResponse, Error, > { match self .get_specified_monthly_custom_reports_with_http_info(report_id) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -2014,13 +2111,18 @@ impl UsageMeteringAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -2039,15 +2141,21 @@ impl UsageMeteringAPI { &self, start_hr: String, params: GetUsageAnalyzedLogsOptionalParams, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self .get_usage_analyzed_logs_with_http_info(start_hr, params) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -2104,13 +2212,18 @@ impl UsageMeteringAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -2131,15 +2244,21 @@ impl UsageMeteringAPI { start_month: String, fields: crate::datadogV1::model::UsageAttributionSupportedMetrics, params: GetUsageAttributionOptionalParams, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self .get_usage_attribution_with_http_info(start_month, fields, params) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -2224,13 +2343,18 @@ impl UsageMeteringAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -2249,15 +2373,21 @@ impl UsageMeteringAPI { &self, start_hr: String, params: GetUsageAuditLogsOptionalParams, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self .get_usage_audit_logs_with_http_info(start_hr, params) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -2314,13 +2444,18 @@ impl UsageMeteringAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -2338,11 +2473,19 @@ impl UsageMeteringAPI { &self, params: GetUsageBillableSummaryOptionalParams, ) -> Result< - Option, + crate::datadogV1::model::UsageBillableSummaryResponse, Error, > { match self.get_usage_billable_summary_with_http_info(params).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -2396,13 +2539,18 @@ impl UsageMeteringAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -2421,10 +2569,17 @@ impl UsageMeteringAPI { &self, start_hr: String, params: GetUsageCIAppOptionalParams, - ) -> Result, Error> - { + ) -> Result> { match self.get_usage_ci_app_with_http_info(start_hr, params).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -2481,13 +2636,18 @@ impl UsageMeteringAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -2506,9 +2666,17 @@ impl UsageMeteringAPI { &self, start_hr: String, params: GetUsageCWSOptionalParams, - ) -> Result, Error> { + ) -> Result> { match self.get_usage_cws_with_http_info(start_hr, params).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -2563,13 +2731,17 @@ impl UsageMeteringAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = ResponseContent { @@ -2588,14 +2760,22 @@ impl UsageMeteringAPI { start_hr: String, params: GetUsageCloudSecurityPostureManagementOptionalParams, ) -> Result< - Option, + crate::datadogV1::model::UsageCloudSecurityPostureManagementResponse, Error, > { match self .get_usage_cloud_security_posture_management_with_http_info(start_hr, params) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -2652,14 +2832,19 @@ impl UsageMeteringAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option< + match serde_json::from_str::< crate::datadogV1::model::UsageCloudSecurityPostureManagementResponse, - > = serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + >(&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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -2678,9 +2863,17 @@ impl UsageMeteringAPI { &self, start_hr: String, params: GetUsageDBMOptionalParams, - ) -> Result, Error> { + ) -> Result> { match self.get_usage_dbm_with_http_info(start_hr, params).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -2735,13 +2928,17 @@ impl UsageMeteringAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = ResponseContent { @@ -2759,13 +2956,20 @@ impl UsageMeteringAPI { &self, start_hr: String, params: GetUsageFargateOptionalParams, - ) -> Result, Error> - { + ) -> Result> { match self .get_usage_fargate_with_http_info(start_hr, params) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -2822,13 +3026,18 @@ impl UsageMeteringAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -2847,10 +3056,17 @@ impl UsageMeteringAPI { &self, start_hr: String, params: GetUsageHostsOptionalParams, - ) -> Result, Error> - { + ) -> Result> { match self.get_usage_hosts_with_http_info(start_hr, params).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -2907,13 +3123,18 @@ impl UsageMeteringAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -2932,15 +3153,21 @@ impl UsageMeteringAPI { &self, start_hr: String, params: GetUsageIndexedSpansOptionalParams, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self .get_usage_indexed_spans_with_http_info(start_hr, params) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -2997,13 +3224,18 @@ impl UsageMeteringAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -3022,15 +3254,21 @@ impl UsageMeteringAPI { &self, start_hr: String, params: GetUsageInternetOfThingsOptionalParams, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self .get_usage_internet_of_things_with_http_info(start_hr, params) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -3087,13 +3325,17 @@ impl UsageMeteringAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -3112,10 +3354,17 @@ impl UsageMeteringAPI { &self, start_hr: String, params: GetUsageLambdaOptionalParams, - ) -> Result, Error> - { + ) -> Result> { match self.get_usage_lambda_with_http_info(start_hr, params).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -3172,13 +3421,18 @@ impl UsageMeteringAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -3197,9 +3451,17 @@ impl UsageMeteringAPI { &self, start_hr: String, params: GetUsageLogsOptionalParams, - ) -> Result, Error> { + ) -> Result> { match self.get_usage_logs_with_http_info(start_hr, params).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -3254,13 +3516,17 @@ impl UsageMeteringAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = ResponseContent { @@ -3277,15 +3543,21 @@ impl UsageMeteringAPI { &self, start_hr: String, params: GetUsageLogsByIndexOptionalParams, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self .get_usage_logs_by_index_with_http_info(start_hr, params) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -3353,13 +3625,18 @@ impl UsageMeteringAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -3379,14 +3656,22 @@ impl UsageMeteringAPI { start_hr: String, params: GetUsageLogsByRetentionOptionalParams, ) -> Result< - Option, + crate::datadogV1::model::UsageLogsByRetentionResponse, Error, > { match self .get_usage_logs_by_retention_with_http_info(start_hr, params) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -3443,13 +3728,18 @@ impl UsageMeteringAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -3468,15 +3758,21 @@ impl UsageMeteringAPI { &self, start_hr: String, params: GetUsageNetworkFlowsOptionalParams, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self .get_usage_network_flows_with_http_info(start_hr, params) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -3533,13 +3829,18 @@ impl UsageMeteringAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -3558,15 +3859,21 @@ impl UsageMeteringAPI { &self, start_hr: String, params: GetUsageNetworkHostsOptionalParams, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self .get_usage_network_hosts_with_http_info(start_hr, params) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -3623,13 +3930,18 @@ impl UsageMeteringAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -3649,14 +3961,22 @@ impl UsageMeteringAPI { start_hr: String, params: GetUsageOnlineArchiveOptionalParams, ) -> Result< - Option, + crate::datadogV1::model::UsageOnlineArchiveResponse, Error, > { match self .get_usage_online_archive_with_http_info(start_hr, params) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -3713,13 +4033,18 @@ impl UsageMeteringAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -3738,15 +4063,21 @@ impl UsageMeteringAPI { &self, start_hr: String, params: GetUsageProfilingOptionalParams, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self .get_usage_profiling_with_http_info(start_hr, params) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -3803,13 +4134,18 @@ impl UsageMeteringAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -3828,15 +4164,21 @@ impl UsageMeteringAPI { &self, start_hr: String, params: GetUsageRumSessionsOptionalParams, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self .get_usage_rum_sessions_with_http_info(start_hr, params) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -3898,13 +4240,18 @@ impl UsageMeteringAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -3923,13 +4270,20 @@ impl UsageMeteringAPI { &self, start_hr: String, params: GetUsageRumUnitsOptionalParams, - ) -> Result, Error> - { + ) -> Result> { match self .get_usage_rum_units_with_http_info(start_hr, params) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -3986,13 +4340,18 @@ impl UsageMeteringAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -4011,9 +4370,17 @@ impl UsageMeteringAPI { &self, start_hr: String, params: GetUsageSDSOptionalParams, - ) -> Result, Error> { + ) -> Result> { match self.get_usage_sds_with_http_info(start_hr, params).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -4068,13 +4435,17 @@ impl UsageMeteringAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = ResponseContent { @@ -4092,9 +4463,17 @@ impl UsageMeteringAPI { &self, start_hr: String, params: GetUsageSNMPOptionalParams, - ) -> Result, Error> { + ) -> Result> { match self.get_usage_snmp_with_http_info(start_hr, params).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -4149,13 +4528,17 @@ impl UsageMeteringAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = ResponseContent { @@ -4172,13 +4555,20 @@ impl UsageMeteringAPI { &self, start_month: String, params: GetUsageSummaryOptionalParams, - ) -> Result, Error> - { + ) -> Result> { match self .get_usage_summary_with_http_info(start_month, params) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -4239,13 +4629,18 @@ impl UsageMeteringAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -4264,15 +4659,21 @@ impl UsageMeteringAPI { &self, start_hr: String, params: GetUsageSyntheticsOptionalParams, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self .get_usage_synthetics_with_http_info(start_hr, params) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -4329,13 +4730,18 @@ impl UsageMeteringAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -4355,14 +4761,22 @@ impl UsageMeteringAPI { start_hr: String, params: GetUsageSyntheticsAPIOptionalParams, ) -> Result< - Option, + crate::datadogV1::model::UsageSyntheticsAPIResponse, Error, > { match self .get_usage_synthetics_api_with_http_info(start_hr, params) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -4419,13 +4833,18 @@ impl UsageMeteringAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -4445,14 +4864,22 @@ impl UsageMeteringAPI { start_hr: String, params: GetUsageSyntheticsBrowserOptionalParams, ) -> Result< - Option, + crate::datadogV1::model::UsageSyntheticsBrowserResponse, Error, > { match self .get_usage_synthetics_browser_with_http_info(start_hr, params) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -4509,13 +4936,18 @@ impl UsageMeteringAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -4534,15 +4966,21 @@ impl UsageMeteringAPI { &self, start_hr: String, params: GetUsageTimeseriesOptionalParams, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self .get_usage_timeseries_with_http_info(start_hr, params) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -4599,13 +5037,18 @@ impl UsageMeteringAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -4623,11 +5066,19 @@ impl UsageMeteringAPI { &self, params: GetUsageTopAvgMetricsOptionalParams, ) -> Result< - Option, + crate::datadogV1::model::UsageTopAvgMetricsResponse, Error, > { match self.get_usage_top_avg_metrics_with_http_info(params).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -4707,13 +5158,18 @@ impl UsageMeteringAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); diff --git a/src/datadogV1/api/api_users.rs b/src/datadogV1/api/api_users.rs index e02e9e3aa..563994293 100644 --- a/src/datadogV1/api/api_users.rs +++ b/src/datadogV1/api/api_users.rs @@ -85,9 +85,17 @@ impl UsersAPI { pub async fn create_user( &self, body: crate::datadogV1::model::User, - ) -> Result, Error> { + ) -> Result> { match self.create_user_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -141,13 +149,16 @@ impl UsersAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = ResponseContent { @@ -166,9 +177,17 @@ impl UsersAPI { pub async fn disable_user( &self, user_handle: String, - ) -> Result, Error> { + ) -> Result> { match self.disable_user_with_http_info(user_handle).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -218,13 +237,18 @@ impl UsersAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = ResponseContent { @@ -240,9 +264,17 @@ impl UsersAPI { pub async fn get_user( &self, user_handle: String, - ) -> Result, Error> { + ) -> Result> { match self.get_user_with_http_info(user_handle).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -286,13 +318,16 @@ impl UsersAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = ResponseContent { @@ -307,9 +342,17 @@ impl UsersAPI { /// List all users for your organization. pub async fn list_users( &self, - ) -> Result, Error> { + ) -> Result> { match self.list_users_with_http_info().await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -352,13 +395,17 @@ impl UsersAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = ResponseContent { @@ -377,9 +424,17 @@ impl UsersAPI { &self, user_handle: String, body: crate::datadogV1::model::User, - ) -> Result, Error> { + ) -> Result> { match self.update_user_with_http_info(user_handle, body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -434,13 +489,16 @@ impl UsersAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = ResponseContent { diff --git a/src/datadogV1/api/api_webhooks_integration.rs b/src/datadogV1/api/api_webhooks_integration.rs index dedb44934..87ad4262c 100644 --- a/src/datadogV1/api/api_webhooks_integration.rs +++ b/src/datadogV1/api/api_webhooks_integration.rs @@ -114,12 +114,18 @@ impl WebhooksIntegrationAPI { pub async fn create_webhooks_integration( &self, body: crate::datadogV1::model::WebhooksIntegration, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self.create_webhooks_integration_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -172,13 +178,18 @@ impl WebhooksIntegrationAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -196,14 +207,22 @@ impl WebhooksIntegrationAPI { &self, body: crate::datadogV1::model::WebhooksIntegrationCustomVariable, ) -> Result< - Option, + crate::datadogV1::model::WebhooksIntegrationCustomVariableResponse, Error, > { match self .create_webhooks_integration_custom_variable_with_http_info(body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -256,14 +275,19 @@ impl WebhooksIntegrationAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option< + match serde_json::from_str::< crate::datadogV1::model::WebhooksIntegrationCustomVariableResponse, - > = serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + >(&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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -280,12 +304,12 @@ impl WebhooksIntegrationAPI { pub async fn delete_webhooks_integration( &self, webhook_name: String, - ) -> Result, Error> { + ) -> Result<(), Error> { match self .delete_webhooks_integration_with_http_info(webhook_name) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(_) => Ok(()), Err(err) => Err(err), } } @@ -350,12 +374,12 @@ impl WebhooksIntegrationAPI { pub async fn delete_webhooks_integration_custom_variable( &self, custom_variable_name: String, - ) -> Result, Error> { + ) -> Result<(), Error> { match self .delete_webhooks_integration_custom_variable_with_http_info(custom_variable_name) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(_) => Ok(()), Err(err) => Err(err), } } @@ -420,15 +444,21 @@ impl WebhooksIntegrationAPI { pub async fn get_webhooks_integration( &self, webhook_name: String, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self .get_webhooks_integration_with_http_info(webhook_name) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -475,13 +505,18 @@ impl WebhooksIntegrationAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -502,14 +537,22 @@ impl WebhooksIntegrationAPI { &self, custom_variable_name: String, ) -> Result< - Option, + crate::datadogV1::model::WebhooksIntegrationCustomVariableResponse, Error, > { match self .get_webhooks_integration_custom_variable_with_http_info(custom_variable_name) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -559,14 +602,19 @@ impl WebhooksIntegrationAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option< + match serde_json::from_str::< crate::datadogV1::model::WebhooksIntegrationCustomVariableResponse, - > = serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + >(&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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -584,15 +632,21 @@ impl WebhooksIntegrationAPI { &self, webhook_name: String, body: crate::datadogV1::model::WebhooksIntegrationUpdateRequest, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self .update_webhooks_integration_with_http_info(webhook_name, body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -647,13 +701,18 @@ impl WebhooksIntegrationAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -672,14 +731,22 @@ impl WebhooksIntegrationAPI { custom_variable_name: String, body: crate::datadogV1::model::WebhooksIntegrationCustomVariableUpdateRequest, ) -> Result< - Option, + crate::datadogV1::model::WebhooksIntegrationCustomVariableResponse, Error, > { match self .update_webhooks_integration_custom_variable_with_http_info(custom_variable_name, body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -734,14 +801,19 @@ impl WebhooksIntegrationAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option< + match serde_json::from_str::< crate::datadogV1::model::WebhooksIntegrationCustomVariableResponse, - > = serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + >(&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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); diff --git a/src/datadogV2/api/api_apm_retention_filters.rs b/src/datadogV2/api/api_apm_retention_filters.rs index 1ac42987b..7697270d3 100644 --- a/src/datadogV2/api/api_apm_retention_filters.rs +++ b/src/datadogV2/api/api_apm_retention_filters.rs @@ -93,11 +93,19 @@ impl APMRetentionFiltersAPI { &self, body: crate::datadogV2::model::RetentionFilterCreateRequest, ) -> Result< - Option, + crate::datadogV2::model::RetentionFilterResponse, Error, > { match self.create_apm_retention_filter_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -151,13 +159,18 @@ impl APMRetentionFiltersAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -174,12 +187,12 @@ impl APMRetentionFiltersAPI { pub async fn delete_apm_retention_filter( &self, filter_id: String, - ) -> Result, Error> { + ) -> Result<(), Error> { match self .delete_apm_retention_filter_with_http_info(filter_id) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(_) => Ok(()), Err(err) => Err(err), } } @@ -244,15 +257,21 @@ impl APMRetentionFiltersAPI { pub async fn get_apm_retention_filter( &self, filter_id: String, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self .get_apm_retention_filter_with_http_info(filter_id) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -299,13 +318,18 @@ impl APMRetentionFiltersAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -322,11 +346,19 @@ impl APMRetentionFiltersAPI { pub async fn list_apm_retention_filters( &self, ) -> Result< - Option, + crate::datadogV2::model::RetentionFiltersResponse, Error, > { match self.list_apm_retention_filters_with_http_info().await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -371,13 +403,18 @@ impl APMRetentionFiltersAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -394,12 +431,12 @@ impl APMRetentionFiltersAPI { pub async fn reorder_apm_retention_filters( &self, body: crate::datadogV2::model::ReorderRetentionFiltersRequest, - ) -> Result, Error> { + ) -> Result<(), Error> { match self .reorder_apm_retention_filters_with_http_info(body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(_) => Ok(()), Err(err) => Err(err), } } @@ -472,14 +509,22 @@ impl APMRetentionFiltersAPI { filter_id: String, body: crate::datadogV2::model::RetentionFilterUpdateRequest, ) -> Result< - Option, + crate::datadogV2::model::RetentionFilterResponse, Error, > { match self .update_apm_retention_filter_with_http_info(filter_id, body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -534,13 +579,18 @@ impl APMRetentionFiltersAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); diff --git a/src/datadogV2/api/api_audit.rs b/src/datadogV2/api/api_audit.rs index 218ccb3be..0cb351b4b 100644 --- a/src/datadogV2/api/api_audit.rs +++ b/src/datadogV2/api/api_audit.rs @@ -123,10 +123,17 @@ impl AuditAPI { pub async fn list_audit_logs( &self, params: ListAuditLogsOptionalParams, - ) -> Result, Error> - { + ) -> Result> { match self.list_audit_logs_with_http_info(params).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -210,13 +217,18 @@ impl AuditAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -238,10 +250,17 @@ impl AuditAPI { pub async fn search_audit_logs( &self, params: SearchAuditLogsOptionalParams, - ) -> Result, Error> - { + ) -> Result> { match self.search_audit_logs_with_http_info(params).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -302,13 +321,18 @@ impl AuditAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); diff --git a/src/datadogV2/api/api_authn_mappings.rs b/src/datadogV2/api/api_authn_mappings.rs index 1b147182e..3f978aa56 100644 --- a/src/datadogV2/api/api_authn_mappings.rs +++ b/src/datadogV2/api/api_authn_mappings.rs @@ -120,10 +120,17 @@ impl AuthNMappingsAPI { pub async fn create_authn_mapping( &self, body: crate::datadogV2::model::AuthNMappingCreateRequest, - ) -> Result, Error> - { + ) -> Result> { match self.create_authn_mapping_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -176,13 +183,18 @@ impl AuthNMappingsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -199,12 +211,12 @@ impl AuthNMappingsAPI { pub async fn delete_authn_mapping( &self, authn_mapping_id: String, - ) -> Result, Error> { + ) -> Result<(), Error> { match self .delete_authn_mapping_with_http_info(authn_mapping_id) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(_) => Ok(()), Err(err) => Err(err), } } @@ -269,13 +281,20 @@ impl AuthNMappingsAPI { pub async fn get_authn_mapping( &self, authn_mapping_id: String, - ) -> Result, Error> - { + ) -> Result> { match self .get_authn_mapping_with_http_info(authn_mapping_id) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -322,13 +341,18 @@ impl AuthNMappingsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -345,10 +369,17 @@ impl AuthNMappingsAPI { pub async fn list_authn_mappings( &self, params: ListAuthNMappingsOptionalParams, - ) -> Result, Error> - { + ) -> Result> { match self.list_authn_mappings_with_http_info(params).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -417,13 +448,18 @@ impl AuthNMappingsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -441,13 +477,20 @@ impl AuthNMappingsAPI { &self, authn_mapping_id: String, body: crate::datadogV2::model::AuthNMappingUpdateRequest, - ) -> Result, Error> - { + ) -> Result> { match self .update_authn_mapping_with_http_info(authn_mapping_id, body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -502,13 +545,18 @@ impl AuthNMappingsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); diff --git a/src/datadogV2/api/api_ci_visibility_pipelines.rs b/src/datadogV2/api/api_ci_visibility_pipelines.rs index 09dc785d5..9b7c85c2d 100644 --- a/src/datadogV2/api/api_ci_visibility_pipelines.rs +++ b/src/datadogV2/api/api_ci_visibility_pipelines.rs @@ -144,14 +144,22 @@ impl CIVisibilityPipelinesAPI { &self, body: crate::datadogV2::model::CIAppPipelinesAggregateRequest, ) -> Result< - Option, + crate::datadogV2::model::CIAppPipelinesAnalyticsAggregateResponse, Error, > { match self .aggregate_ci_app_pipeline_events_with_http_info(body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -204,14 +212,19 @@ impl CIVisibilityPipelinesAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option< + match serde_json::from_str::< crate::datadogV2::model::CIAppPipelinesAnalyticsAggregateResponse, - > = serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + >(&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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -231,11 +244,19 @@ impl CIVisibilityPipelinesAPI { &self, body: crate::datadogV2::model::CIAppCreatePipelineEventRequest, ) -> Result< - Option>, + std::collections::BTreeMap, Error, > { match self.create_ci_app_pipeline_event_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -287,13 +308,18 @@ impl CIVisibilityPipelinesAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option> = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -314,14 +340,22 @@ impl CIVisibilityPipelinesAPI { &self, params: ListCIAppPipelineEventsOptionalParams, ) -> Result< - Option, + crate::datadogV2::model::CIAppPipelineEventsResponse, Error, > { match self .list_ci_app_pipeline_events_with_http_info(params) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -403,13 +437,18 @@ impl CIVisibilityPipelinesAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -430,14 +469,22 @@ impl CIVisibilityPipelinesAPI { &self, params: SearchCIAppPipelineEventsOptionalParams, ) -> Result< - Option, + crate::datadogV2::model::CIAppPipelineEventsResponse, Error, > { match self .search_ci_app_pipeline_events_with_http_info(params) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -496,13 +543,18 @@ impl CIVisibilityPipelinesAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); diff --git a/src/datadogV2/api/api_ci_visibility_tests.rs b/src/datadogV2/api/api_ci_visibility_tests.rs index f8a05127a..348db85cd 100644 --- a/src/datadogV2/api/api_ci_visibility_tests.rs +++ b/src/datadogV2/api/api_ci_visibility_tests.rs @@ -126,11 +126,19 @@ impl CIVisibilityTestsAPI { &self, body: crate::datadogV2::model::CIAppTestsAggregateRequest, ) -> Result< - Option, + crate::datadogV2::model::CIAppTestsAnalyticsAggregateResponse, Error, > { match self.aggregate_ci_app_test_events_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -183,14 +191,19 @@ impl CIVisibilityTestsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option< + match serde_json::from_str::< crate::datadogV2::model::CIAppTestsAnalyticsAggregateResponse, - > = serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + >(&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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -210,12 +223,18 @@ impl CIVisibilityTestsAPI { pub async fn list_ci_app_test_events( &self, params: ListCIAppTestEventsOptionalParams, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self.list_ci_app_test_events_with_http_info(params).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -297,13 +316,18 @@ impl CIVisibilityTestsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -323,12 +347,18 @@ impl CIVisibilityTestsAPI { pub async fn search_ci_app_test_events( &self, params: SearchCIAppTestEventsOptionalParams, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self.search_ci_app_test_events_with_http_info(params).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -387,13 +417,18 @@ impl CIVisibilityTestsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); diff --git a/src/datadogV2/api/api_cloud_cost_management.rs b/src/datadogV2/api/api_cloud_cost_management.rs index 7aa86de8d..b99700e0e 100644 --- a/src/datadogV2/api/api_cloud_cost_management.rs +++ b/src/datadogV2/api/api_cloud_cost_management.rs @@ -126,12 +126,18 @@ impl CloudCostManagementAPI { pub async fn create_cost_awscur_config( &self, body: crate::datadogV2::model::AwsCURConfigPostRequest, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self.create_cost_awscur_config_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -184,13 +190,18 @@ impl CloudCostManagementAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -208,11 +219,19 @@ impl CloudCostManagementAPI { &self, body: crate::datadogV2::model::AzureUCConfigPostRequest, ) -> Result< - Option, + crate::datadogV2::model::AzureUCConfigPairsResponse, Error, > { match self.create_cost_azure_uc_configs_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -265,13 +284,18 @@ impl CloudCostManagementAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -288,12 +312,12 @@ impl CloudCostManagementAPI { pub async fn delete_cost_awscur_config( &self, cloud_account_id: String, - ) -> Result, Error> { + ) -> Result<(), Error> { match self .delete_cost_awscur_config_with_http_info(cloud_account_id) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(_) => Ok(()), Err(err) => Err(err), } } @@ -358,12 +382,12 @@ impl CloudCostManagementAPI { pub async fn delete_cost_azure_uc_config( &self, cloud_account_id: String, - ) -> Result, Error> { + ) -> Result<(), Error> { match self .delete_cost_azure_uc_config_with_http_info(cloud_account_id) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(_) => Ok(()), Err(err) => Err(err), } } @@ -427,12 +451,18 @@ impl CloudCostManagementAPI { /// Get the Cloud Cost Management activity. pub async fn get_cloud_cost_activity( &self, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self.get_cloud_cost_activity_with_http_info().await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -477,13 +507,18 @@ impl CloudCostManagementAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -501,14 +536,22 @@ impl CloudCostManagementAPI { &self, filter_management_account_id: String, ) -> Result< - Option, + crate::datadogV2::model::AWSRelatedAccountsResponse, Error, > { match self .list_aws_related_accounts_with_http_info(filter_management_account_id) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -559,13 +602,18 @@ impl CloudCostManagementAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -581,12 +629,18 @@ impl CloudCostManagementAPI { /// List the AWS CUR configs. pub async fn list_cost_awscur_configs( &self, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self.list_cost_awscur_configs_with_http_info().await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -631,13 +685,18 @@ impl CloudCostManagementAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -653,12 +712,18 @@ impl CloudCostManagementAPI { /// List the Azure configs. pub async fn list_cost_azure_uc_configs( &self, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self.list_cost_azure_uc_configs_with_http_info().await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -703,13 +768,18 @@ impl CloudCostManagementAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -727,15 +797,21 @@ impl CloudCostManagementAPI { &self, cloud_account_id: String, body: crate::datadogV2::model::AwsCURConfigPatchRequest, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self .update_cost_awscur_config_with_http_info(cloud_account_id, body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -790,13 +866,18 @@ impl CloudCostManagementAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -815,14 +896,22 @@ impl CloudCostManagementAPI { cloud_account_id: String, body: crate::datadogV2::model::AzureUCConfigPatchRequest, ) -> Result< - Option, + crate::datadogV2::model::AzureUCConfigPairsResponse, Error, > { match self .update_cost_azure_uc_configs_with_http_info(cloud_account_id, body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -877,13 +966,18 @@ impl CloudCostManagementAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); diff --git a/src/datadogV2/api/api_cloud_workload_security.rs b/src/datadogV2/api/api_cloud_workload_security.rs index d811f5db8..976ccd0d4 100644 --- a/src/datadogV2/api/api_cloud_workload_security.rs +++ b/src/datadogV2/api/api_cloud_workload_security.rs @@ -92,14 +92,22 @@ impl CloudWorkloadSecurityAPI { &self, body: crate::datadogV2::model::CloudWorkloadSecurityAgentRuleCreateRequest, ) -> Result< - Option, + crate::datadogV2::model::CloudWorkloadSecurityAgentRuleResponse, Error, > { match self .create_cloud_workload_security_agent_rule_with_http_info(body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -152,14 +160,19 @@ impl CloudWorkloadSecurityAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option< + match serde_json::from_str::< crate::datadogV2::model::CloudWorkloadSecurityAgentRuleResponse, - > = serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + >(&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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -176,12 +189,12 @@ impl CloudWorkloadSecurityAPI { pub async fn delete_cloud_workload_security_agent_rule( &self, agent_rule_id: String, - ) -> Result, Error> { + ) -> Result<(), Error> { match self .delete_cloud_workload_security_agent_rule_with_http_info(agent_rule_id) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(_) => Ok(()), Err(err) => Err(err), } } @@ -247,12 +260,20 @@ impl CloudWorkloadSecurityAPI { /// your Agents to update the policy running in your environment. pub async fn download_cloud_workload_policy_file( &self, - ) -> Result>, Error> { + ) -> Result, Error> { match self .download_cloud_workload_policy_file_with_http_info() .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -296,12 +317,16 @@ impl CloudWorkloadSecurityAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option> = serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -319,14 +344,22 @@ impl CloudWorkloadSecurityAPI { &self, agent_rule_id: String, ) -> Result< - Option, + crate::datadogV2::model::CloudWorkloadSecurityAgentRuleResponse, Error, > { match self .get_cloud_workload_security_agent_rule_with_http_info(agent_rule_id) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -373,14 +406,19 @@ impl CloudWorkloadSecurityAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option< + match serde_json::from_str::< crate::datadogV2::model::CloudWorkloadSecurityAgentRuleResponse, - > = serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + >(&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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -397,14 +435,22 @@ impl CloudWorkloadSecurityAPI { pub async fn list_cloud_workload_security_agent_rules( &self, ) -> Result< - Option, + crate::datadogV2::model::CloudWorkloadSecurityAgentRulesListResponse, Error, > { match self .list_cloud_workload_security_agent_rules_with_http_info() .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -449,14 +495,19 @@ impl CloudWorkloadSecurityAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option< + match serde_json::from_str::< crate::datadogV2::model::CloudWorkloadSecurityAgentRulesListResponse, - > = serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + >(&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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -476,14 +527,22 @@ impl CloudWorkloadSecurityAPI { agent_rule_id: String, body: crate::datadogV2::model::CloudWorkloadSecurityAgentRuleUpdateRequest, ) -> Result< - Option, + crate::datadogV2::model::CloudWorkloadSecurityAgentRuleResponse, Error, > { match self .update_cloud_workload_security_agent_rule_with_http_info(agent_rule_id, body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -539,14 +598,19 @@ impl CloudWorkloadSecurityAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option< + match serde_json::from_str::< crate::datadogV2::model::CloudWorkloadSecurityAgentRuleResponse, - > = serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + >(&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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); diff --git a/src/datadogV2/api/api_cloudflare_integration.rs b/src/datadogV2/api/api_cloudflare_integration.rs index dd6619a7a..ffccc23d5 100644 --- a/src/datadogV2/api/api_cloudflare_integration.rs +++ b/src/datadogV2/api/api_cloudflare_integration.rs @@ -86,11 +86,19 @@ impl CloudflareIntegrationAPI { &self, body: crate::datadogV2::model::CloudflareAccountCreateRequest, ) -> Result< - Option, + crate::datadogV2::model::CloudflareAccountResponse, Error, > { match self.create_cloudflare_account_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -143,13 +151,18 @@ impl CloudflareIntegrationAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -166,12 +179,12 @@ impl CloudflareIntegrationAPI { pub async fn delete_cloudflare_account( &self, account_id: String, - ) -> Result, Error> { + ) -> Result<(), Error> { match self .delete_cloudflare_account_with_http_info(account_id) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(_) => Ok(()), Err(err) => Err(err), } } @@ -236,12 +249,18 @@ impl CloudflareIntegrationAPI { pub async fn get_cloudflare_account( &self, account_id: String, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self.get_cloudflare_account_with_http_info(account_id).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -288,13 +307,18 @@ impl CloudflareIntegrationAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -311,11 +335,19 @@ impl CloudflareIntegrationAPI { pub async fn list_cloudflare_accounts( &self, ) -> Result< - Option, + crate::datadogV2::model::CloudflareAccountsResponse, Error, > { match self.list_cloudflare_accounts_with_http_info().await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -360,13 +392,18 @@ impl CloudflareIntegrationAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -385,14 +422,22 @@ impl CloudflareIntegrationAPI { account_id: String, body: crate::datadogV2::model::CloudflareAccountUpdateRequest, ) -> Result< - Option, + crate::datadogV2::model::CloudflareAccountResponse, Error, > { match self .update_cloudflare_account_with_http_info(account_id, body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -447,13 +492,18 @@ impl CloudflareIntegrationAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); diff --git a/src/datadogV2/api/api_confluent_cloud.rs b/src/datadogV2/api/api_confluent_cloud.rs index 280d27328..bfff66cf8 100644 --- a/src/datadogV2/api/api_confluent_cloud.rs +++ b/src/datadogV2/api/api_confluent_cloud.rs @@ -140,12 +140,18 @@ impl ConfluentCloudAPI { pub async fn create_confluent_account( &self, body: crate::datadogV2::model::ConfluentAccountCreateRequest, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self.create_confluent_account_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -198,13 +204,18 @@ impl ConfluentCloudAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -223,14 +234,22 @@ impl ConfluentCloudAPI { account_id: String, body: crate::datadogV2::model::ConfluentResourceRequest, ) -> Result< - Option, + crate::datadogV2::model::ConfluentResourceResponse, Error, > { match self .create_confluent_resource_with_http_info(account_id, body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -285,13 +304,18 @@ impl ConfluentCloudAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -308,12 +332,12 @@ impl ConfluentCloudAPI { pub async fn delete_confluent_account( &self, account_id: String, - ) -> Result, Error> { + ) -> Result<(), Error> { match self .delete_confluent_account_with_http_info(account_id) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(_) => Ok(()), Err(err) => Err(err), } } @@ -379,12 +403,12 @@ impl ConfluentCloudAPI { &self, account_id: String, resource_id: String, - ) -> Result, Error> { + ) -> Result<(), Error> { match self .delete_confluent_resource_with_http_info(account_id, resource_id) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(_) => Ok(()), Err(err) => Err(err), } } @@ -451,12 +475,18 @@ impl ConfluentCloudAPI { pub async fn get_confluent_account( &self, account_id: String, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self.get_confluent_account_with_http_info(account_id).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -503,13 +533,18 @@ impl ConfluentCloudAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -527,15 +562,21 @@ impl ConfluentCloudAPI { &self, account_id: String, resource_id: String, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self .get_confluent_resource_with_http_info(account_id, resource_id) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -584,13 +625,18 @@ impl ConfluentCloudAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -606,12 +652,18 @@ impl ConfluentCloudAPI { /// List Confluent accounts. pub async fn list_confluent_account( &self, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self.list_confluent_account_with_http_info().await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -656,13 +708,18 @@ impl ConfluentCloudAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -680,14 +737,22 @@ impl ConfluentCloudAPI { &self, account_id: String, ) -> Result< - Option, + crate::datadogV2::model::ConfluentResourcesResponse, Error, > { match self .list_confluent_resource_with_http_info(account_id) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -734,13 +799,18 @@ impl ConfluentCloudAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -758,15 +828,21 @@ impl ConfluentCloudAPI { &self, account_id: String, body: crate::datadogV2::model::ConfluentAccountUpdateRequest, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self .update_confluent_account_with_http_info(account_id, body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -821,13 +897,18 @@ impl ConfluentCloudAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -847,14 +928,22 @@ impl ConfluentCloudAPI { resource_id: String, body: crate::datadogV2::model::ConfluentResourceRequest, ) -> Result< - Option, + crate::datadogV2::model::ConfluentResourceResponse, Error, > { match self .update_confluent_resource_with_http_info(account_id, resource_id, body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -911,13 +1000,18 @@ impl ConfluentCloudAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); diff --git a/src/datadogV2/api/api_container_images.rs b/src/datadogV2/api/api_container_images.rs index 831b7c213..9fa6bcbae 100644 --- a/src/datadogV2/api/api_container_images.rs +++ b/src/datadogV2/api/api_container_images.rs @@ -86,12 +86,18 @@ impl ContainerImagesAPI { pub async fn list_container_images( &self, params: ListContainerImagesOptionalParams, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self.list_container_images_with_http_info(params).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -165,13 +171,18 @@ impl ContainerImagesAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); diff --git a/src/datadogV2/api/api_containers.rs b/src/datadogV2/api/api_containers.rs index d2ebd47ec..6c1bfa345 100644 --- a/src/datadogV2/api/api_containers.rs +++ b/src/datadogV2/api/api_containers.rs @@ -86,10 +86,17 @@ impl ContainersAPI { pub async fn list_containers( &self, params: ListContainersOptionalParams, - ) -> Result, Error> - { + ) -> Result> { match self.list_containers_with_http_info(params).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -163,13 +170,18 @@ impl ContainersAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); diff --git a/src/datadogV2/api/api_dashboard_lists.rs b/src/datadogV2/api/api_dashboard_lists.rs index 90648b3ab..e3ee5ed4a 100644 --- a/src/datadogV2/api/api_dashboard_lists.rs +++ b/src/datadogV2/api/api_dashboard_lists.rs @@ -75,14 +75,22 @@ impl DashboardListsAPI { dashboard_list_id: i64, body: crate::datadogV2::model::DashboardListAddItemsRequest, ) -> Result< - Option, + crate::datadogV2::model::DashboardListAddItemsResponse, Error, > { match self .create_dashboard_list_items_with_http_info(dashboard_list_id, body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -137,13 +145,18 @@ impl DashboardListsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -162,14 +175,22 @@ impl DashboardListsAPI { dashboard_list_id: i64, body: crate::datadogV2::model::DashboardListDeleteItemsRequest, ) -> Result< - Option, + crate::datadogV2::model::DashboardListDeleteItemsResponse, Error, > { match self .delete_dashboard_list_items_with_http_info(dashboard_list_id, body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -224,13 +245,18 @@ impl DashboardListsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -247,15 +273,21 @@ impl DashboardListsAPI { pub async fn get_dashboard_list_items( &self, dashboard_list_id: i64, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self .get_dashboard_list_items_with_http_info(dashboard_list_id) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -302,13 +334,18 @@ impl DashboardListsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -327,14 +364,22 @@ impl DashboardListsAPI { dashboard_list_id: i64, body: crate::datadogV2::model::DashboardListUpdateItemsRequest, ) -> Result< - Option, + crate::datadogV2::model::DashboardListUpdateItemsResponse, Error, > { match self .update_dashboard_list_items_with_http_info(dashboard_list_id, body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -389,13 +434,18 @@ impl DashboardListsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); diff --git a/src/datadogV2/api/api_dora_metrics.rs b/src/datadogV2/api/api_dora_metrics.rs index ccf4a3621..71953646d 100644 --- a/src/datadogV2/api/api_dora_metrics.rs +++ b/src/datadogV2/api/api_dora_metrics.rs @@ -56,12 +56,18 @@ impl DORAMetricsAPI { pub async fn create_dora_deployment( &self, body: crate::datadogV2::model::DORADeploymentRequest, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self.create_dora_deployment_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -124,13 +130,18 @@ impl DORAMetricsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -151,10 +162,17 @@ impl DORAMetricsAPI { pub async fn create_dora_incident( &self, body: crate::datadogV2::model::DORAIncidentRequest, - ) -> Result, Error> - { + ) -> Result> { match self.create_dora_incident_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -216,13 +234,18 @@ impl DORAMetricsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); diff --git a/src/datadogV2/api/api_downtimes.rs b/src/datadogV2/api/api_downtimes.rs index de8e0f18e..721094ef6 100644 --- a/src/datadogV2/api/api_downtimes.rs +++ b/src/datadogV2/api/api_downtimes.rs @@ -170,9 +170,9 @@ impl DowntimesAPI { pub async fn cancel_downtime( &self, downtime_id: String, - ) -> Result, Error> { + ) -> Result<(), Error> { match self.cancel_downtime_with_http_info(downtime_id).await { - Ok(response_content) => Ok(response_content.entity), + Ok(_) => Ok(()), Err(err) => Err(err), } } @@ -237,9 +237,17 @@ impl DowntimesAPI { pub async fn create_downtime( &self, body: crate::datadogV2::model::DowntimeCreateRequest, - ) -> Result, Error> { + ) -> Result> { match self.create_downtime_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -292,13 +300,17 @@ impl DowntimesAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -316,9 +328,17 @@ impl DowntimesAPI { &self, downtime_id: String, params: GetDowntimeOptionalParams, - ) -> Result, Error> { + ) -> Result> { match self.get_downtime_with_http_info(downtime_id, params).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -372,13 +392,17 @@ impl DowntimesAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = ResponseContent { @@ -394,10 +418,17 @@ impl DowntimesAPI { pub async fn list_downtimes( &self, params: ListDowntimesOptionalParams, - ) -> Result, Error> - { + ) -> Result> { match self.list_downtimes_with_http_info(params).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -466,13 +497,18 @@ impl DowntimesAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -491,14 +527,22 @@ impl DowntimesAPI { monitor_id: i64, params: ListMonitorDowntimesOptionalParams, ) -> Result< - Option, + crate::datadogV2::model::MonitorDowntimeMatchResponse, Error, > { match self .list_monitor_downtimes_with_http_info(monitor_id, params) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -559,13 +603,18 @@ impl DowntimesAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -583,9 +632,17 @@ impl DowntimesAPI { &self, downtime_id: String, body: crate::datadogV2::model::DowntimeUpdateRequest, - ) -> Result, Error> { + ) -> Result> { match self.update_downtime_with_http_info(downtime_id, body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -640,13 +697,17 @@ impl DowntimesAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); diff --git a/src/datadogV2/api/api_events.rs b/src/datadogV2/api/api_events.rs index eac5393c4..52927462d 100644 --- a/src/datadogV2/api/api_events.rs +++ b/src/datadogV2/api/api_events.rs @@ -118,9 +118,17 @@ impl EventsAPI { pub async fn list_events( &self, params: ListEventsOptionalParams, - ) -> Result, Error> { + ) -> Result> { match self.list_events_with_http_info(params).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -200,13 +208,18 @@ impl EventsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = ResponseContent { @@ -225,9 +238,17 @@ impl EventsAPI { pub async fn search_events( &self, params: SearchEventsOptionalParams, - ) -> Result, Error> { + ) -> Result> { match self.search_events_with_http_info(params).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -286,13 +307,18 @@ impl EventsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = ResponseContent { diff --git a/src/datadogV2/api/api_fastly_integration.rs b/src/datadogV2/api/api_fastly_integration.rs index 981765718..9ef07c623 100644 --- a/src/datadogV2/api/api_fastly_integration.rs +++ b/src/datadogV2/api/api_fastly_integration.rs @@ -140,12 +140,18 @@ impl FastlyIntegrationAPI { pub async fn create_fastly_account( &self, body: crate::datadogV2::model::FastlyAccountCreateRequest, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self.create_fastly_account_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -198,13 +204,18 @@ impl FastlyIntegrationAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -222,15 +233,21 @@ impl FastlyIntegrationAPI { &self, account_id: String, body: crate::datadogV2::model::FastlyServiceRequest, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self .create_fastly_service_with_http_info(account_id, body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -285,13 +302,18 @@ impl FastlyIntegrationAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -308,9 +330,9 @@ impl FastlyIntegrationAPI { pub async fn delete_fastly_account( &self, account_id: String, - ) -> Result, Error> { + ) -> Result<(), Error> { match self.delete_fastly_account_with_http_info(account_id).await { - Ok(response_content) => Ok(response_content.entity), + Ok(_) => Ok(()), Err(err) => Err(err), } } @@ -376,12 +398,12 @@ impl FastlyIntegrationAPI { &self, account_id: String, service_id: String, - ) -> Result, Error> { + ) -> Result<(), Error> { match self .delete_fastly_service_with_http_info(account_id, service_id) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(_) => Ok(()), Err(err) => Err(err), } } @@ -448,10 +470,17 @@ impl FastlyIntegrationAPI { pub async fn get_fastly_account( &self, account_id: String, - ) -> Result, Error> - { + ) -> Result> { match self.get_fastly_account_with_http_info(account_id).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -498,13 +527,18 @@ impl FastlyIntegrationAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -522,13 +556,20 @@ impl FastlyIntegrationAPI { &self, account_id: String, service_id: String, - ) -> Result, Error> - { + ) -> Result> { match self .get_fastly_service_with_http_info(account_id, service_id) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -577,13 +618,18 @@ impl FastlyIntegrationAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -599,12 +645,18 @@ impl FastlyIntegrationAPI { /// List Fastly accounts. pub async fn list_fastly_accounts( &self, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self.list_fastly_accounts_with_http_info().await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -649,13 +701,18 @@ impl FastlyIntegrationAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -672,12 +729,18 @@ impl FastlyIntegrationAPI { pub async fn list_fastly_services( &self, account_id: String, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self.list_fastly_services_with_http_info(account_id).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -724,13 +787,18 @@ impl FastlyIntegrationAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -748,15 +816,21 @@ impl FastlyIntegrationAPI { &self, account_id: String, body: crate::datadogV2::model::FastlyAccountUpdateRequest, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self .update_fastly_account_with_http_info(account_id, body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -811,13 +885,18 @@ impl FastlyIntegrationAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -836,15 +915,21 @@ impl FastlyIntegrationAPI { account_id: String, service_id: String, body: crate::datadogV2::model::FastlyServiceRequest, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self .update_fastly_service_with_http_info(account_id, service_id, body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -901,13 +986,18 @@ impl FastlyIntegrationAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); diff --git a/src/datadogV2/api/api_gcp_integration.rs b/src/datadogV2/api/api_gcp_integration.rs index 48a47d49d..bd43f30a0 100644 --- a/src/datadogV2/api/api_gcp_integration.rs +++ b/src/datadogV2/api/api_gcp_integration.rs @@ -112,11 +112,19 @@ impl GCPIntegrationAPI { &self, body: crate::datadogV2::model::GCPSTSServiceAccountCreateRequest, ) -> Result< - Option, + crate::datadogV2::model::GCPSTSServiceAccountResponse, Error, > { match self.create_gcpsts_account_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -169,13 +177,18 @@ impl GCPIntegrationAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -192,9 +205,9 @@ impl GCPIntegrationAPI { pub async fn delete_gcpsts_account( &self, account_id: String, - ) -> Result, Error> { + ) -> Result<(), Error> { match self.delete_gcpsts_account_with_http_info(account_id).await { - Ok(response_content) => Ok(response_content.entity), + Ok(_) => Ok(()), Err(err) => Err(err), } } @@ -258,12 +271,18 @@ impl GCPIntegrationAPI { /// List your Datadog-GCP STS delegate account configured in your Datadog account. pub async fn get_gcpsts_delegate( &self, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self.get_gcpsts_delegate_with_http_info().await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -308,13 +327,18 @@ impl GCPIntegrationAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -331,11 +355,19 @@ impl GCPIntegrationAPI { pub async fn list_gcpsts_accounts( &self, ) -> Result< - Option, + crate::datadogV2::model::GCPSTSServiceAccountsResponse, Error, > { match self.list_gcpsts_accounts_with_http_info().await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -380,13 +412,18 @@ impl GCPIntegrationAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -404,11 +441,19 @@ impl GCPIntegrationAPI { &self, params: MakeGCPSTSDelegateOptionalParams, ) -> Result< - Option, + crate::datadogV2::model::GCPSTSDelegateAccountResponse, Error, > { match self.make_gcpsts_delegate_with_http_info(params).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -464,13 +509,18 @@ impl GCPIntegrationAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -489,14 +539,22 @@ impl GCPIntegrationAPI { account_id: String, body: crate::datadogV2::model::GCPSTSServiceAccountUpdateRequest, ) -> Result< - Option, + crate::datadogV2::model::GCPSTSServiceAccountResponse, Error, > { match self .update_gcpsts_account_with_http_info(account_id, body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -551,13 +609,18 @@ impl GCPIntegrationAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); diff --git a/src/datadogV2/api/api_incident_services.rs b/src/datadogV2/api/api_incident_services.rs index 4f181abff..0c4c4ecf6 100644 --- a/src/datadogV2/api/api_incident_services.rs +++ b/src/datadogV2/api/api_incident_services.rs @@ -144,12 +144,18 @@ impl IncidentServicesAPI { pub async fn create_incident_service( &self, body: crate::datadogV2::model::IncidentServiceCreateRequest, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self.create_incident_service_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -210,13 +216,18 @@ impl IncidentServicesAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -233,12 +244,12 @@ impl IncidentServicesAPI { pub async fn delete_incident_service( &self, service_id: String, - ) -> Result, Error> { + ) -> Result<(), Error> { match self .delete_incident_service_with_http_info(service_id) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(_) => Ok(()), Err(err) => Err(err), } } @@ -313,15 +324,21 @@ impl IncidentServicesAPI { &self, service_id: String, params: GetIncidentServiceOptionalParams, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self .get_incident_service_with_http_info(service_id, params) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -386,13 +403,18 @@ impl IncidentServicesAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -409,12 +431,18 @@ impl IncidentServicesAPI { pub async fn list_incident_services( &self, params: ListIncidentServicesOptionalParams, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self.list_incident_services_with_http_info(params).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -491,13 +519,18 @@ impl IncidentServicesAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -515,15 +548,21 @@ impl IncidentServicesAPI { &self, service_id: String, body: crate::datadogV2::model::IncidentServiceUpdateRequest, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self .update_incident_service_with_http_info(service_id, body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -586,13 +625,18 @@ impl IncidentServicesAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); diff --git a/src/datadogV2/api/api_incident_teams.rs b/src/datadogV2/api/api_incident_teams.rs index 3cae1c7dc..fecdb3750 100644 --- a/src/datadogV2/api/api_incident_teams.rs +++ b/src/datadogV2/api/api_incident_teams.rs @@ -144,10 +144,17 @@ impl IncidentTeamsAPI { pub async fn create_incident_team( &self, body: crate::datadogV2::model::IncidentTeamCreateRequest, - ) -> Result, Error> - { + ) -> Result> { match self.create_incident_team_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -208,13 +215,18 @@ impl IncidentTeamsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -231,9 +243,9 @@ impl IncidentTeamsAPI { pub async fn delete_incident_team( &self, team_id: String, - ) -> Result, Error> { + ) -> Result<(), Error> { match self.delete_incident_team_with_http_info(team_id).await { - Ok(response_content) => Ok(response_content.entity), + Ok(_) => Ok(()), Err(err) => Err(err), } } @@ -308,10 +320,17 @@ impl IncidentTeamsAPI { &self, team_id: String, params: GetIncidentTeamOptionalParams, - ) -> Result, Error> - { + ) -> Result> { match self.get_incident_team_with_http_info(team_id, params).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -376,13 +395,18 @@ impl IncidentTeamsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -399,10 +423,17 @@ impl IncidentTeamsAPI { pub async fn list_incident_teams( &self, params: ListIncidentTeamsOptionalParams, - ) -> Result, Error> - { + ) -> Result> { match self.list_incident_teams_with_http_info(params).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -479,13 +510,18 @@ impl IncidentTeamsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -503,13 +539,20 @@ impl IncidentTeamsAPI { &self, team_id: String, body: crate::datadogV2::model::IncidentTeamUpdateRequest, - ) -> Result, Error> - { + ) -> Result> { match self .update_incident_team_with_http_info(team_id, body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -572,13 +615,18 @@ impl IncidentTeamsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); diff --git a/src/datadogV2/api/api_incidents.rs b/src/datadogV2/api/api_incidents.rs index 04ebbe713..2431d5df8 100644 --- a/src/datadogV2/api/api_incidents.rs +++ b/src/datadogV2/api/api_incidents.rs @@ -404,9 +404,17 @@ impl IncidentsAPI { pub async fn create_incident( &self, body: crate::datadogV2::model::IncidentCreateRequest, - ) -> Result, Error> { + ) -> Result> { match self.create_incident_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -467,13 +475,17 @@ impl IncidentsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -492,14 +504,22 @@ impl IncidentsAPI { incident_id: String, body: crate::datadogV2::model::IncidentIntegrationMetadataCreateRequest, ) -> Result< - Option, + crate::datadogV2::model::IncidentIntegrationMetadataResponse, Error, > { match self .create_incident_integration_with_http_info(incident_id, body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -562,13 +582,18 @@ impl IncidentsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -586,13 +611,20 @@ impl IncidentsAPI { &self, incident_id: String, body: crate::datadogV2::model::IncidentTodoCreateRequest, - ) -> Result, Error> - { + ) -> Result> { match self .create_incident_todo_with_http_info(incident_id, body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -655,13 +687,18 @@ impl IncidentsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -678,9 +715,9 @@ impl IncidentsAPI { pub async fn delete_incident( &self, incident_id: String, - ) -> Result, Error> { + ) -> Result<(), Error> { match self.delete_incident_with_http_info(incident_id).await { - Ok(response_content) => Ok(response_content.entity), + Ok(_) => Ok(()), Err(err) => Err(err), } } @@ -754,12 +791,12 @@ impl IncidentsAPI { &self, incident_id: String, integration_metadata_id: String, - ) -> Result, Error> { + ) -> Result<(), Error> { match self .delete_incident_integration_with_http_info(incident_id, integration_metadata_id) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(_) => Ok(()), Err(err) => Err(err), } } @@ -836,12 +873,12 @@ impl IncidentsAPI { &self, incident_id: String, todo_id: String, - ) -> Result, Error> { + ) -> Result<(), Error> { match self .delete_incident_todo_with_http_info(incident_id, todo_id) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(_) => Ok(()), Err(err) => Err(err), } } @@ -917,9 +954,17 @@ impl IncidentsAPI { &self, incident_id: String, params: GetIncidentOptionalParams, - ) -> Result, Error> { + ) -> Result> { match self.get_incident_with_http_info(incident_id, params).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -988,13 +1033,17 @@ impl IncidentsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = ResponseContent { @@ -1012,14 +1061,22 @@ impl IncidentsAPI { incident_id: String, integration_metadata_id: String, ) -> Result< - Option, + crate::datadogV2::model::IncidentIntegrationMetadataResponse, Error, > { match self .get_incident_integration_with_http_info(incident_id, integration_metadata_id) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -1077,13 +1134,18 @@ impl IncidentsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -1101,13 +1163,20 @@ impl IncidentsAPI { &self, incident_id: String, todo_id: String, - ) -> Result, Error> - { + ) -> Result> { match self .get_incident_todo_with_http_info(incident_id, todo_id) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -1164,13 +1233,18 @@ impl IncidentsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -1189,14 +1263,22 @@ impl IncidentsAPI { incident_id: String, params: ListIncidentAttachmentsOptionalParams, ) -> Result< - Option, + crate::datadogV2::model::IncidentAttachmentsResponse, Error, > { match self .list_incident_attachments_with_http_info(incident_id, params) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -1279,13 +1361,18 @@ impl IncidentsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -1303,14 +1390,22 @@ impl IncidentsAPI { &self, incident_id: String, ) -> Result< - Option, + crate::datadogV2::model::IncidentIntegrationMetadataListResponse, Error, > { match self .list_incident_integrations_with_http_info(incident_id) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -1365,14 +1460,19 @@ impl IncidentsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option< + match serde_json::from_str::< crate::datadogV2::model::IncidentIntegrationMetadataListResponse, - > = serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + >(&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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -1389,12 +1489,18 @@ impl IncidentsAPI { pub async fn list_incident_todos( &self, incident_id: String, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self.list_incident_todos_with_http_info(incident_id).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -1449,13 +1555,18 @@ impl IncidentsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -1472,9 +1583,17 @@ impl IncidentsAPI { pub async fn list_incidents( &self, params: ListIncidentsOptionalParams, - ) -> Result, Error> { + ) -> Result> { match self.list_incidents_with_http_info(params).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -1553,13 +1672,17 @@ impl IncidentsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -1577,10 +1700,17 @@ impl IncidentsAPI { &self, query: String, params: SearchIncidentsOptionalParams, - ) -> Result, Error> - { + ) -> Result> { match self.search_incidents_with_http_info(query, params).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -1659,13 +1789,18 @@ impl IncidentsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -1684,12 +1819,20 @@ impl IncidentsAPI { incident_id: String, body: crate::datadogV2::model::IncidentUpdateRequest, params: UpdateIncidentOptionalParams, - ) -> Result, Error> { + ) -> Result> { match self .update_incident_with_http_info(incident_id, body, params) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -1768,13 +1911,17 @@ impl IncidentsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -1794,14 +1941,22 @@ impl IncidentsAPI { body: crate::datadogV2::model::IncidentAttachmentUpdateRequest, params: UpdateIncidentAttachmentsOptionalParams, ) -> Result< - Option, + crate::datadogV2::model::IncidentAttachmentUpdateResponse, Error, > { match self .update_incident_attachments_with_http_info(incident_id, body, params) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -1880,13 +2035,18 @@ impl IncidentsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -1906,14 +2066,22 @@ impl IncidentsAPI { integration_metadata_id: String, body: crate::datadogV2::model::IncidentIntegrationMetadataPatchRequest, ) -> Result< - Option, + crate::datadogV2::model::IncidentIntegrationMetadataResponse, Error, > { match self .update_incident_integration_with_http_info(incident_id, integration_metadata_id, body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -1979,13 +2147,18 @@ impl IncidentsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -2004,13 +2177,20 @@ impl IncidentsAPI { incident_id: String, todo_id: String, body: crate::datadogV2::model::IncidentTodoPatchRequest, - ) -> Result, Error> - { + ) -> Result> { match self .update_incident_todo_with_http_info(incident_id, todo_id, body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -2075,13 +2255,18 @@ impl IncidentsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); diff --git a/src/datadogV2/api/api_ip_allowlist.rs b/src/datadogV2/api/api_ip_allowlist.rs index f18c92a76..ae2d3da41 100644 --- a/src/datadogV2/api/api_ip_allowlist.rs +++ b/src/datadogV2/api/api_ip_allowlist.rs @@ -50,10 +50,17 @@ impl IPAllowlistAPI { /// Returns the IP allowlist and its enabled or disabled state. pub async fn get_ip_allowlist( &self, - ) -> Result, Error> - { + ) -> Result> { match self.get_ip_allowlist_with_http_info().await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -98,13 +105,18 @@ impl IPAllowlistAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -121,10 +133,17 @@ impl IPAllowlistAPI { pub async fn update_ip_allowlist( &self, body: crate::datadogV2::model::IPAllowlistUpdateRequest, - ) -> Result, Error> - { + ) -> Result> { match self.update_ip_allowlist_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -177,13 +196,18 @@ impl IPAllowlistAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); diff --git a/src/datadogV2/api/api_key_management.rs b/src/datadogV2/api/api_key_management.rs index 0ea7d86c6..62f71b383 100644 --- a/src/datadogV2/api/api_key_management.rs +++ b/src/datadogV2/api/api_key_management.rs @@ -422,9 +422,17 @@ impl KeyManagementAPI { pub async fn create_api_key( &self, body: crate::datadogV2::model::APIKeyCreateRequest, - ) -> Result, Error> { + ) -> Result> { match self.create_api_key_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -475,13 +483,16 @@ impl KeyManagementAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = ResponseContent { @@ -498,14 +509,22 @@ impl KeyManagementAPI { &self, body: crate::datadogV2::model::ApplicationKeyCreateRequest, ) -> Result< - Option, + crate::datadogV2::model::ApplicationKeyResponse, Error, > { match self .create_current_user_application_key_with_http_info(body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -558,13 +577,18 @@ impl KeyManagementAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -578,12 +602,9 @@ impl KeyManagementAPI { } /// Delete an API key. - pub async fn delete_api_key( - &self, - api_key_id: String, - ) -> Result, Error> { + pub async fn delete_api_key(&self, api_key_id: String) -> Result<(), Error> { match self.delete_api_key_with_http_info(api_key_id).await { - Ok(response_content) => Ok(response_content.entity), + Ok(_) => Ok(()), Err(err) => Err(err), } } @@ -647,9 +668,9 @@ impl KeyManagementAPI { pub async fn delete_application_key( &self, app_key_id: String, - ) -> Result, Error> { + ) -> Result<(), Error> { match self.delete_application_key_with_http_info(app_key_id).await { - Ok(response_content) => Ok(response_content.entity), + Ok(_) => Ok(()), Err(err) => Err(err), } } @@ -714,12 +735,12 @@ impl KeyManagementAPI { pub async fn delete_current_user_application_key( &self, app_key_id: String, - ) -> Result, Error> { + ) -> Result<(), Error> { match self .delete_current_user_application_key_with_http_info(app_key_id) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(_) => Ok(()), Err(err) => Err(err), } } @@ -785,9 +806,17 @@ impl KeyManagementAPI { &self, api_key_id: String, params: GetAPIKeyOptionalParams, - ) -> Result, Error> { + ) -> Result> { match self.get_api_key_with_http_info(api_key_id, params).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -841,13 +870,16 @@ impl KeyManagementAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = ResponseContent { @@ -864,15 +896,21 @@ impl KeyManagementAPI { &self, app_key_id: String, params: GetApplicationKeyOptionalParams, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self .get_application_key_with_http_info(app_key_id, params) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -928,13 +966,18 @@ impl KeyManagementAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -952,14 +995,22 @@ impl KeyManagementAPI { &self, app_key_id: String, ) -> Result< - Option, + crate::datadogV2::model::ApplicationKeyResponse, Error, > { match self .get_current_user_application_key_with_http_info(app_key_id) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -1006,13 +1057,18 @@ impl KeyManagementAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -1029,9 +1085,17 @@ impl KeyManagementAPI { pub async fn list_api_keys( &self, params: ListAPIKeysOptionalParams, - ) -> Result, Error> { + ) -> Result> { match self.list_api_keys_with_http_info(params).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -1135,13 +1199,16 @@ impl KeyManagementAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = ResponseContent { @@ -1157,12 +1224,18 @@ impl KeyManagementAPI { pub async fn list_application_keys( &self, params: ListApplicationKeysOptionalParams, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self.list_application_keys_with_http_info(params).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -1246,13 +1319,18 @@ impl KeyManagementAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -1270,14 +1348,22 @@ impl KeyManagementAPI { &self, params: ListCurrentUserApplicationKeysOptionalParams, ) -> Result< - Option, + crate::datadogV2::model::ListApplicationKeysResponse, Error, > { match self .list_current_user_application_keys_with_http_info(params) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -1361,13 +1447,18 @@ impl KeyManagementAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -1385,9 +1476,17 @@ impl KeyManagementAPI { &self, api_key_id: String, body: crate::datadogV2::model::APIKeyUpdateRequest, - ) -> Result, Error> { + ) -> Result> { match self.update_api_key_with_http_info(api_key_id, body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -1440,13 +1539,16 @@ impl KeyManagementAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = ResponseContent { @@ -1463,15 +1565,21 @@ impl KeyManagementAPI { &self, app_key_id: String, body: crate::datadogV2::model::ApplicationKeyUpdateRequest, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self .update_application_key_with_http_info(app_key_id, body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -1526,13 +1634,18 @@ impl KeyManagementAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -1551,14 +1664,22 @@ impl KeyManagementAPI { app_key_id: String, body: crate::datadogV2::model::ApplicationKeyUpdateRequest, ) -> Result< - Option, + crate::datadogV2::model::ApplicationKeyResponse, Error, > { match self .update_current_user_application_key_with_http_info(app_key_id, body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -1613,13 +1734,18 @@ impl KeyManagementAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); diff --git a/src/datadogV2/api/api_logs.rs b/src/datadogV2/api/api_logs.rs index 5a9723bec..9cedfd6d8 100644 --- a/src/datadogV2/api/api_logs.rs +++ b/src/datadogV2/api/api_logs.rs @@ -185,10 +185,17 @@ impl LogsAPI { pub async fn aggregate_logs( &self, body: crate::datadogV2::model::LogsAggregateRequest, - ) -> Result, Error> - { + ) -> Result> { match self.aggregate_logs_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -241,13 +248,18 @@ impl LogsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -274,9 +286,17 @@ impl LogsAPI { pub async fn list_logs( &self, params: ListLogsOptionalParams, - ) -> Result, Error> { + ) -> Result> { match self.list_logs_with_http_info(params).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -340,13 +360,17 @@ impl LogsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = ResponseContent { @@ -372,9 +396,17 @@ impl LogsAPI { pub async fn list_logs_get( &self, params: ListLogsGetOptionalParams, - ) -> Result, Error> { + ) -> Result> { match self.list_logs_get_with_http_info(params).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -478,13 +510,17 @@ impl LogsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = ResponseContent { @@ -524,10 +560,17 @@ impl LogsAPI { &self, body: Vec, params: SubmitLogOptionalParams, - ) -> Result>, Error> - { + ) -> Result, Error> { match self.submit_log_with_http_info(body, params).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -614,13 +657,18 @@ impl LogsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option> = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = ResponseContent { diff --git a/src/datadogV2/api/api_logs_archives.rs b/src/datadogV2/api/api_logs_archives.rs index b7f03af63..b46a419ce 100644 --- a/src/datadogV2/api/api_logs_archives.rs +++ b/src/datadogV2/api/api_logs_archives.rs @@ -136,12 +136,12 @@ impl LogsArchivesAPI { &self, archive_id: String, body: crate::datadogV2::model::RelationshipToRole, - ) -> Result, Error> { + ) -> Result<(), Error> { match self .add_read_role_to_archive_with_http_info(archive_id, body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(_) => Ok(()), Err(err) => Err(err), } } @@ -214,9 +214,17 @@ impl LogsArchivesAPI { pub async fn create_logs_archive( &self, body: crate::datadogV2::model::LogsArchiveCreateRequest, - ) -> Result, Error> { + ) -> Result> { match self.create_logs_archive_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -267,13 +275,16 @@ impl LogsArchivesAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -290,9 +301,9 @@ impl LogsArchivesAPI { pub async fn delete_logs_archive( &self, archive_id: String, - ) -> Result, Error> { + ) -> Result<(), Error> { match self.delete_logs_archive_with_http_info(archive_id).await { - Ok(response_content) => Ok(response_content.entity), + Ok(_) => Ok(()), Err(err) => Err(err), } } @@ -357,9 +368,17 @@ impl LogsArchivesAPI { pub async fn get_logs_archive( &self, archive_id: String, - ) -> Result, Error> { + ) -> Result> { match self.get_logs_archive_with_http_info(archive_id).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -404,13 +423,16 @@ impl LogsArchivesAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -427,10 +449,17 @@ impl LogsArchivesAPI { /// This endpoint takes no JSON arguments. pub async fn get_logs_archive_order( &self, - ) -> Result, Error> - { + ) -> Result> { match self.get_logs_archive_order_with_http_info().await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -476,13 +505,17 @@ impl LogsArchivesAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -499,13 +532,20 @@ impl LogsArchivesAPI { pub async fn list_archive_read_roles( &self, archive_id: String, - ) -> Result, Error> - { + ) -> Result> { match self .list_archive_read_roles_with_http_info(archive_id) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -552,13 +592,16 @@ impl LogsArchivesAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -574,9 +617,17 @@ impl LogsArchivesAPI { /// Get the list of configured logs archives with their definitions. pub async fn list_logs_archives( &self, - ) -> Result, Error> { + ) -> Result> { match self.list_logs_archives_with_http_info().await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -619,13 +670,16 @@ impl LogsArchivesAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -643,12 +697,12 @@ impl LogsArchivesAPI { &self, archive_id: String, body: crate::datadogV2::model::RelationshipToRole, - ) -> Result, Error> { + ) -> Result<(), Error> { match self .remove_role_from_archive_with_http_info(archive_id, body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(_) => Ok(()), Err(err) => Err(err), } } @@ -725,12 +779,20 @@ impl LogsArchivesAPI { &self, archive_id: String, body: crate::datadogV2::model::LogsArchiveCreateRequest, - ) -> Result, Error> { + ) -> Result> { match self .update_logs_archive_with_http_info(archive_id, body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -786,13 +848,16 @@ impl LogsArchivesAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -813,10 +878,17 @@ impl LogsArchivesAPI { pub async fn update_logs_archive_order( &self, body: crate::datadogV2::model::LogsArchiveOrder, - ) -> Result, Error> - { + ) -> Result> { match self.update_logs_archive_order_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -873,13 +945,17 @@ impl LogsArchivesAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); diff --git a/src/datadogV2/api/api_logs_metrics.rs b/src/datadogV2/api/api_logs_metrics.rs index 6cd86d89a..05051d237 100644 --- a/src/datadogV2/api/api_logs_metrics.rs +++ b/src/datadogV2/api/api_logs_metrics.rs @@ -82,10 +82,17 @@ impl LogsMetricsAPI { pub async fn create_logs_metric( &self, body: crate::datadogV2::model::LogsMetricCreateRequest, - ) -> Result, Error> - { + ) -> Result> { match self.create_logs_metric_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -139,13 +146,18 @@ impl LogsMetricsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -162,9 +174,9 @@ impl LogsMetricsAPI { pub async fn delete_logs_metric( &self, metric_id: String, - ) -> Result, Error> { + ) -> Result<(), Error> { match self.delete_logs_metric_with_http_info(metric_id).await { - Ok(response_content) => Ok(response_content.entity), + Ok(_) => Ok(()), Err(err) => Err(err), } } @@ -229,10 +241,17 @@ impl LogsMetricsAPI { pub async fn get_logs_metric( &self, metric_id: String, - ) -> Result, Error> - { + ) -> Result> { match self.get_logs_metric_with_http_info(metric_id).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -279,13 +298,18 @@ impl LogsMetricsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -301,10 +325,17 @@ impl LogsMetricsAPI { /// Get the list of configured log-based metrics with their definitions. pub async fn list_logs_metrics( &self, - ) -> Result, Error> - { + ) -> Result> { match self.list_logs_metrics_with_http_info().await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -349,13 +380,18 @@ impl LogsMetricsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -374,13 +410,20 @@ impl LogsMetricsAPI { &self, metric_id: String, body: crate::datadogV2::model::LogsMetricUpdateRequest, - ) -> Result, Error> - { + ) -> Result> { match self .update_logs_metric_with_http_info(metric_id, body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -436,13 +479,18 @@ impl LogsMetricsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); diff --git a/src/datadogV2/api/api_metrics.rs b/src/datadogV2/api/api_metrics.rs index 9859cdbd8..7da69c761 100644 --- a/src/datadogV2/api/api_metrics.rs +++ b/src/datadogV2/api/api_metrics.rs @@ -340,14 +340,22 @@ impl MetricsAPI { &self, body: crate::datadogV2::model::MetricBulkTagConfigCreateRequest, ) -> Result< - Option, + crate::datadogV2::model::MetricBulkTagConfigResponse, Error, > { match self .create_bulk_tags_metrics_configuration_with_http_info(body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -406,13 +414,18 @@ impl MetricsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -435,14 +448,22 @@ impl MetricsAPI { metric_name: String, body: crate::datadogV2::model::MetricTagConfigurationCreateRequest, ) -> Result< - Option, + crate::datadogV2::model::MetricTagConfigurationResponse, Error, > { match self .create_tag_configuration_with_http_info(metric_name, body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -501,13 +522,18 @@ impl MetricsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -528,14 +554,22 @@ impl MetricsAPI { &self, body: crate::datadogV2::model::MetricBulkTagConfigDeleteRequest, ) -> Result< - Option, + crate::datadogV2::model::MetricBulkTagConfigResponse, Error, > { match self .delete_bulk_tags_metrics_configuration_with_http_info(body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -591,13 +625,18 @@ impl MetricsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -615,12 +654,12 @@ impl MetricsAPI { pub async fn delete_tag_configuration( &self, metric_name: String, - ) -> Result, Error> { + ) -> Result<(), Error> { match self .delete_tag_configuration_with_http_info(metric_name) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(_) => Ok(()), Err(err) => Err(err), } } @@ -688,14 +727,22 @@ impl MetricsAPI { metric_name: String, params: EstimateMetricsOutputSeriesOptionalParams, ) -> Result< - Option, + crate::datadogV2::model::MetricEstimateResponse, Error, > { match self .estimate_metrics_output_series_with_http_info(metric_name, params) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -771,13 +818,18 @@ impl MetricsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -796,14 +848,22 @@ impl MetricsAPI { metric_name: String, params: ListActiveMetricConfigurationsOptionalParams, ) -> Result< - Option, + crate::datadogV2::model::MetricSuggestedTagsAndAggregationsResponse, Error, > { match self .list_active_metric_configurations_with_http_info(metric_name, params) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -859,14 +919,19 @@ impl MetricsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option< + match serde_json::from_str::< crate::datadogV2::model::MetricSuggestedTagsAndAggregationsResponse, - > = serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + >(&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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -884,14 +949,22 @@ impl MetricsAPI { &self, metric_name: String, ) -> Result< - Option, + crate::datadogV2::model::MetricTagConfigurationResponse, Error, > { match self .list_tag_configuration_by_name_with_http_info(metric_name) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -938,13 +1011,18 @@ impl MetricsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -962,11 +1040,19 @@ impl MetricsAPI { &self, params: ListTagConfigurationsOptionalParams, ) -> Result< - Option, + crate::datadogV2::model::MetricsAndMetricTagConfigurationsResponse, Error, > { match self.list_tag_configurations_with_http_info(params).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -1052,14 +1138,19 @@ impl MetricsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option< + match serde_json::from_str::< crate::datadogV2::model::MetricsAndMetricTagConfigurationsResponse, - > = serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + >(&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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -1076,15 +1167,21 @@ impl MetricsAPI { pub async fn list_tags_by_metric_name( &self, metric_name: String, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self .list_tags_by_metric_name_with_http_info(metric_name) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -1131,13 +1228,18 @@ impl MetricsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -1156,15 +1258,21 @@ impl MetricsAPI { pub async fn list_volumes_by_metric_name( &self, metric_name: String, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self .list_volumes_by_metric_name_with_http_info(metric_name) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -1213,13 +1321,18 @@ impl MetricsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -1238,12 +1351,18 @@ impl MetricsAPI { pub async fn query_scalar_data( &self, body: crate::datadogV2::model::ScalarFormulaQueryRequest, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self.query_scalar_data_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -1306,13 +1425,18 @@ impl MetricsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -1331,11 +1455,19 @@ impl MetricsAPI { &self, body: crate::datadogV2::model::TimeseriesFormulaQueryRequest, ) -> Result< - Option, + crate::datadogV2::model::TimeseriesFormulaQueryResponse, Error, > { match self.query_timeseries_data_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -1397,13 +1529,18 @@ impl MetricsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -1432,10 +1569,17 @@ impl MetricsAPI { &self, body: crate::datadogV2::model::MetricPayload, params: SubmitMetricsOptionalParams, - ) -> Result, Error> - { + ) -> Result> { match self.submit_metrics_with_http_info(body, params).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -1504,13 +1648,18 @@ impl MetricsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -1533,14 +1682,22 @@ impl MetricsAPI { metric_name: String, body: crate::datadogV2::model::MetricTagConfigurationUpdateRequest, ) -> Result< - Option, + crate::datadogV2::model::MetricTagConfigurationResponse, Error, > { match self .update_tag_configuration_with_http_info(metric_name, body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -1599,13 +1756,18 @@ impl MetricsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); diff --git a/src/datadogV2/api/api_monitors.rs b/src/datadogV2/api/api_monitors.rs index d9e54c00a..b7e550501 100644 --- a/src/datadogV2/api/api_monitors.rs +++ b/src/datadogV2/api/api_monitors.rs @@ -82,11 +82,19 @@ impl MonitorsAPI { &self, body: crate::datadogV2::model::MonitorConfigPolicyCreateRequest, ) -> Result< - Option, + crate::datadogV2::model::MonitorConfigPolicyResponse, Error, > { match self.create_monitor_config_policy_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -139,13 +147,18 @@ impl MonitorsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -162,12 +175,12 @@ impl MonitorsAPI { pub async fn delete_monitor_config_policy( &self, policy_id: String, - ) -> Result, Error> { + ) -> Result<(), Error> { match self .delete_monitor_config_policy_with_http_info(policy_id) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(_) => Ok(()), Err(err) => Err(err), } } @@ -233,14 +246,22 @@ impl MonitorsAPI { &self, policy_id: String, ) -> Result< - Option, + crate::datadogV2::model::MonitorConfigPolicyResponse, Error, > { match self .get_monitor_config_policy_with_http_info(policy_id) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -287,13 +308,18 @@ impl MonitorsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -310,11 +336,19 @@ impl MonitorsAPI { pub async fn list_monitor_config_policies( &self, ) -> Result< - Option, + crate::datadogV2::model::MonitorConfigPolicyListResponse, Error, > { match self.list_monitor_config_policies_with_http_info().await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -359,13 +393,18 @@ impl MonitorsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -384,14 +423,22 @@ impl MonitorsAPI { policy_id: String, body: crate::datadogV2::model::MonitorConfigPolicyEditRequest, ) -> Result< - Option, + crate::datadogV2::model::MonitorConfigPolicyResponse, Error, > { match self .update_monitor_config_policy_with_http_info(policy_id, body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -446,13 +493,18 @@ impl MonitorsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); diff --git a/src/datadogV2/api/api_okta_integration.rs b/src/datadogV2/api/api_okta_integration.rs index 5fd77759a..91bd54b0e 100644 --- a/src/datadogV2/api/api_okta_integration.rs +++ b/src/datadogV2/api/api_okta_integration.rs @@ -85,10 +85,17 @@ impl OktaIntegrationAPI { pub async fn create_okta_account( &self, body: crate::datadogV2::model::OktaAccountRequest, - ) -> Result, Error> - { + ) -> Result> { match self.create_okta_account_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -141,13 +148,18 @@ impl OktaIntegrationAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -164,9 +176,9 @@ impl OktaIntegrationAPI { pub async fn delete_okta_account( &self, account_id: String, - ) -> Result, Error> { + ) -> Result<(), Error> { match self.delete_okta_account_with_http_info(account_id).await { - Ok(response_content) => Ok(response_content.entity), + Ok(_) => Ok(()), Err(err) => Err(err), } } @@ -231,10 +243,17 @@ impl OktaIntegrationAPI { pub async fn get_okta_account( &self, account_id: String, - ) -> Result, Error> - { + ) -> Result> { match self.get_okta_account_with_http_info(account_id).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -281,13 +300,18 @@ impl OktaIntegrationAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -303,10 +327,17 @@ impl OktaIntegrationAPI { /// List Okta accounts. pub async fn list_okta_accounts( &self, - ) -> Result, Error> - { + ) -> Result> { match self.list_okta_accounts_with_http_info().await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -351,13 +382,18 @@ impl OktaIntegrationAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -375,13 +411,20 @@ impl OktaIntegrationAPI { &self, account_id: String, body: crate::datadogV2::model::OktaAccountUpdateRequest, - ) -> Result, Error> - { + ) -> Result> { match self .update_okta_account_with_http_info(account_id, body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -436,13 +479,18 @@ impl OktaIntegrationAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); diff --git a/src/datadogV2/api/api_opsgenie_integration.rs b/src/datadogV2/api/api_opsgenie_integration.rs index c72c619cc..a45e4bd84 100644 --- a/src/datadogV2/api/api_opsgenie_integration.rs +++ b/src/datadogV2/api/api_opsgenie_integration.rs @@ -85,12 +85,18 @@ impl OpsgenieIntegrationAPI { pub async fn create_opsgenie_service( &self, body: crate::datadogV2::model::OpsgenieServiceCreateRequest, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self.create_opsgenie_service_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -143,13 +149,18 @@ impl OpsgenieIntegrationAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -166,12 +177,12 @@ impl OpsgenieIntegrationAPI { pub async fn delete_opsgenie_service( &self, integration_service_id: String, - ) -> Result, Error> { + ) -> Result<(), Error> { match self .delete_opsgenie_service_with_http_info(integration_service_id) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(_) => Ok(()), Err(err) => Err(err), } } @@ -236,15 +247,21 @@ impl OpsgenieIntegrationAPI { pub async fn get_opsgenie_service( &self, integration_service_id: String, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self .get_opsgenie_service_with_http_info(integration_service_id) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -291,13 +308,18 @@ impl OpsgenieIntegrationAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -313,12 +335,18 @@ impl OpsgenieIntegrationAPI { /// Get a list of all services from the Datadog Opsgenie integration. pub async fn list_opsgenie_services( &self, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self.list_opsgenie_services_with_http_info().await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -363,13 +391,18 @@ impl OpsgenieIntegrationAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -387,15 +420,21 @@ impl OpsgenieIntegrationAPI { &self, integration_service_id: String, body: crate::datadogV2::model::OpsgenieServiceUpdateRequest, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self .update_opsgenie_service_with_http_info(integration_service_id, body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -450,13 +489,18 @@ impl OpsgenieIntegrationAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); diff --git a/src/datadogV2/api/api_organizations.rs b/src/datadogV2/api/api_organizations.rs index e741ff6c5..c269b12bb 100644 --- a/src/datadogV2/api/api_organizations.rs +++ b/src/datadogV2/api/api_organizations.rs @@ -58,9 +58,9 @@ impl OrganizationsAPI { pub async fn upload_idp_metadata( &self, params: UploadIdPMetadataOptionalParams, - ) -> Result, Error> { + ) -> Result<(), Error> { match self.upload_idp_metadata_with_http_info(params).await { - Ok(response_content) => Ok(response_content.entity), + Ok(_) => Ok(()), Err(err) => Err(err), } } diff --git a/src/datadogV2/api/api_powerpack.rs b/src/datadogV2/api/api_powerpack.rs index 47b6b2087..bff79aa17 100644 --- a/src/datadogV2/api/api_powerpack.rs +++ b/src/datadogV2/api/api_powerpack.rs @@ -98,10 +98,17 @@ impl PowerpackAPI { pub async fn create_powerpack( &self, body: crate::datadogV2::model::Powerpack, - ) -> Result, Error> - { + ) -> Result> { match self.create_powerpack_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -154,13 +161,17 @@ impl PowerpackAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -177,9 +188,9 @@ impl PowerpackAPI { pub async fn delete_powerpack( &self, powerpack_id: String, - ) -> Result, Error> { + ) -> Result<(), Error> { match self.delete_powerpack_with_http_info(powerpack_id).await { - Ok(response_content) => Ok(response_content.entity), + Ok(_) => Ok(()), Err(err) => Err(err), } } @@ -244,9 +255,17 @@ impl PowerpackAPI { pub async fn get_powerpack( &self, powerpack_id: String, - ) -> Result, Error> { + ) -> Result> { match self.get_powerpack_with_http_info(powerpack_id).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -291,13 +310,17 @@ impl PowerpackAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = ResponseContent { @@ -313,10 +336,17 @@ impl PowerpackAPI { pub async fn list_powerpacks( &self, params: ListPowerpacksOptionalParams, - ) -> Result, Error> - { + ) -> Result> { match self.list_powerpacks_with_http_info(params).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -375,13 +405,18 @@ impl PowerpackAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -399,13 +434,20 @@ impl PowerpackAPI { &self, powerpack_id: String, body: crate::datadogV2::model::Powerpack, - ) -> Result, Error> - { + ) -> Result> { match self .update_powerpack_with_http_info(powerpack_id, body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -460,13 +502,17 @@ impl PowerpackAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); diff --git a/src/datadogV2/api/api_processes.rs b/src/datadogV2/api/api_processes.rs index b6618fbcc..5bb3cf217 100644 --- a/src/datadogV2/api/api_processes.rs +++ b/src/datadogV2/api/api_processes.rs @@ -101,10 +101,17 @@ impl ProcessesAPI { pub async fn list_processes( &self, params: ListProcessesOptionalParams, - ) -> Result, Error> - { + ) -> Result> { match self.list_processes_with_http_info(params).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -182,13 +189,18 @@ impl ProcessesAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); diff --git a/src/datadogV2/api/api_restriction_policies.rs b/src/datadogV2/api/api_restriction_policies.rs index 5ab18b5c2..5b562c1f6 100644 --- a/src/datadogV2/api/api_restriction_policies.rs +++ b/src/datadogV2/api/api_restriction_policies.rs @@ -60,12 +60,12 @@ impl RestrictionPoliciesAPI { pub async fn delete_restriction_policy( &self, resource_id: String, - ) -> Result, Error> { + ) -> Result<(), Error> { match self .delete_restriction_policy_with_http_info(resource_id) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(_) => Ok(()), Err(err) => Err(err), } } @@ -130,15 +130,21 @@ impl RestrictionPoliciesAPI { pub async fn get_restriction_policy( &self, resource_id: String, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self .get_restriction_policy_with_http_info(resource_id) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -185,13 +191,18 @@ impl RestrictionPoliciesAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -227,14 +238,22 @@ impl RestrictionPoliciesAPI { resource_id: String, body: crate::datadogV2::model::RestrictionPolicyUpdateRequest, ) -> Result< - Option, + crate::datadogV2::model::RestrictionPolicyResponse, Error, > { match self .update_restriction_policy_with_http_info(resource_id, body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -306,13 +325,18 @@ impl RestrictionPoliciesAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); diff --git a/src/datadogV2/api/api_roles.rs b/src/datadogV2/api/api_roles.rs index dad692234..e3ce90a50 100644 --- a/src/datadogV2/api/api_roles.rs +++ b/src/datadogV2/api/api_roles.rs @@ -257,13 +257,20 @@ impl RolesAPI { &self, role_id: String, body: crate::datadogV2::model::RelationshipToPermission, - ) -> Result, Error> - { + ) -> Result> { match self .add_permission_to_role_with_http_info(role_id, body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -318,13 +325,18 @@ impl RolesAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -342,9 +354,17 @@ impl RolesAPI { &self, role_id: String, body: crate::datadogV2::model::RelationshipToUser, - ) -> Result, Error> { + ) -> Result> { match self.add_user_to_role_with_http_info(role_id, body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -397,13 +417,16 @@ impl RolesAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -421,9 +444,17 @@ impl RolesAPI { &self, role_id: String, body: crate::datadogV2::model::RoleCloneRequest, - ) -> Result, Error> { + ) -> Result> { match self.clone_role_with_http_info(role_id, body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -475,13 +506,16 @@ impl RolesAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = ResponseContent { @@ -497,9 +531,17 @@ impl RolesAPI { pub async fn create_role( &self, body: crate::datadogV2::model::RoleCreateRequest, - ) -> Result, Error> { + ) -> Result> { match self.create_role_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -550,13 +592,18 @@ impl RolesAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = ResponseContent { @@ -569,9 +616,9 @@ impl RolesAPI { } /// Disables a role. - pub async fn delete_role(&self, role_id: String) -> Result, Error> { + pub async fn delete_role(&self, role_id: String) -> Result<(), Error> { match self.delete_role_with_http_info(role_id).await { - Ok(response_content) => Ok(response_content.entity), + Ok(_) => Ok(()), Err(err) => Err(err), } } @@ -635,9 +682,17 @@ impl RolesAPI { pub async fn get_role( &self, role_id: String, - ) -> Result, Error> { + ) -> Result> { match self.get_role_with_http_info(role_id).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -681,13 +736,16 @@ impl RolesAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = ResponseContent { @@ -702,10 +760,17 @@ impl RolesAPI { /// Returns a list of all permissions, including name, description, and ID. pub async fn list_permissions( &self, - ) -> Result, Error> - { + ) -> Result> { match self.list_permissions_with_http_info().await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -750,13 +815,18 @@ impl RolesAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -773,10 +843,17 @@ impl RolesAPI { pub async fn list_role_permissions( &self, role_id: String, - ) -> Result, Error> - { + ) -> Result> { match self.list_role_permissions_with_http_info(role_id).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -823,13 +900,18 @@ impl RolesAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -847,9 +929,17 @@ impl RolesAPI { &self, role_id: String, params: ListRoleUsersOptionalParams, - ) -> Result, Error> { + ) -> Result> { match self.list_role_users_with_http_info(role_id, params).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -918,13 +1008,16 @@ impl RolesAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -941,9 +1034,17 @@ impl RolesAPI { pub async fn list_roles( &self, params: ListRolesOptionalParams, - ) -> Result, Error> { + ) -> Result> { match self.list_roles_with_http_info(params).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -1015,13 +1116,16 @@ impl RolesAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = ResponseContent { @@ -1038,15 +1142,21 @@ impl RolesAPI { &self, role_id: String, body: crate::datadogV2::model::RelationshipToPermission, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self .remove_permission_from_role_with_http_info(role_id, body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -1101,13 +1211,18 @@ impl RolesAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -1125,13 +1240,20 @@ impl RolesAPI { &self, role_id: String, body: crate::datadogV2::model::RelationshipToUser, - ) -> Result, Error> - { + ) -> Result> { match self .remove_user_from_role_with_http_info(role_id, body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -1186,13 +1308,16 @@ impl RolesAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -1210,9 +1335,17 @@ impl RolesAPI { &self, role_id: String, body: crate::datadogV2::model::RoleUpdateRequest, - ) -> Result, Error> { + ) -> Result> { match self.update_role_with_http_info(role_id, body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -1265,13 +1398,18 @@ impl RolesAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = ResponseContent { diff --git a/src/datadogV2/api/api_rum.rs b/src/datadogV2/api/api_rum.rs index 2bacf73af..ec598c0c2 100644 --- a/src/datadogV2/api/api_rum.rs +++ b/src/datadogV2/api/api_rum.rs @@ -159,11 +159,19 @@ impl RUMAPI { &self, body: crate::datadogV2::model::RUMAggregateRequest, ) -> Result< - Option, + crate::datadogV2::model::RUMAnalyticsAggregateResponse, Error, > { match self.aggregate_rum_events_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -216,13 +224,18 @@ impl RUMAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -239,12 +252,18 @@ impl RUMAPI { pub async fn create_rum_application( &self, body: crate::datadogV2::model::RUMApplicationCreateRequest, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self.create_rum_application_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -297,13 +316,18 @@ impl RUMAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -320,9 +344,9 @@ impl RUMAPI { pub async fn delete_rum_application( &self, id: String, - ) -> Result, Error> { + ) -> Result<(), Error> { match self.delete_rum_application_with_http_info(id).await { - Ok(response_content) => Ok(response_content.entity), + Ok(_) => Ok(()), Err(err) => Err(err), } } @@ -387,12 +411,18 @@ impl RUMAPI { pub async fn get_rum_application( &self, id: String, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self.get_rum_application_with_http_info(id).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -439,13 +469,18 @@ impl RUMAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -461,12 +496,18 @@ impl RUMAPI { /// List all the RUM applications in your organization. pub async fn get_rum_applications( &self, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self.get_rum_applications_with_http_info().await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -511,13 +552,18 @@ impl RUMAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -539,9 +585,17 @@ impl RUMAPI { pub async fn list_rum_events( &self, params: ListRUMEventsOptionalParams, - ) -> Result, Error> { + ) -> Result> { match self.list_rum_events_with_http_info(params).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -625,13 +679,17 @@ impl RUMAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -653,10 +711,17 @@ impl RUMAPI { pub async fn search_rum_events( &self, body: crate::datadogV2::model::RUMSearchEventsRequest, - ) -> Result, Error> - { + ) -> Result> { match self.search_rum_events_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -714,13 +779,17 @@ impl RUMAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -738,12 +807,18 @@ impl RUMAPI { &self, id: String, body: crate::datadogV2::model::RUMApplicationUpdateRequest, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self.update_rum_application_with_http_info(id, body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -798,13 +873,18 @@ impl RUMAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); diff --git a/src/datadogV2/api/api_security_monitoring.rs b/src/datadogV2/api/api_security_monitoring.rs index d07407c8d..2a8e83f7c 100644 --- a/src/datadogV2/api/api_security_monitoring.rs +++ b/src/datadogV2/api/api_security_monitoring.rs @@ -438,12 +438,18 @@ impl SecurityMonitoringAPI { pub async fn create_security_filter( &self, body: crate::datadogV2::model::SecurityFilterCreateRequest, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self.create_security_filter_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -499,13 +505,18 @@ impl SecurityMonitoringAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -523,14 +534,22 @@ impl SecurityMonitoringAPI { &self, body: crate::datadogV2::model::SecurityMonitoringRuleCreatePayload, ) -> Result< - Option, + crate::datadogV2::model::SecurityMonitoringRuleResponse, Error, > { match self .create_security_monitoring_rule_with_http_info(body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -583,13 +602,18 @@ impl SecurityMonitoringAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -606,12 +630,12 @@ impl SecurityMonitoringAPI { pub async fn delete_security_filter( &self, security_filter_id: String, - ) -> Result, Error> { + ) -> Result<(), Error> { match self .delete_security_filter_with_http_info(security_filter_id) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(_) => Ok(()), Err(err) => Err(err), } } @@ -676,12 +700,12 @@ impl SecurityMonitoringAPI { pub async fn delete_security_monitoring_rule( &self, rule_id: String, - ) -> Result, Error> { + ) -> Result<(), Error> { match self .delete_security_monitoring_rule_with_http_info(rule_id) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(_) => Ok(()), Err(err) => Err(err), } } @@ -748,14 +772,22 @@ impl SecurityMonitoringAPI { signal_id: String, body: crate::datadogV2::model::SecurityMonitoringSignalAssigneeUpdateRequest, ) -> Result< - Option, + crate::datadogV2::model::SecurityMonitoringSignalTriageUpdateResponse, Error, > { match self .edit_security_monitoring_signal_assignee_with_http_info(signal_id, body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -810,14 +842,19 @@ impl SecurityMonitoringAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option< + match serde_json::from_str::< crate::datadogV2::model::SecurityMonitoringSignalTriageUpdateResponse, - > = serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + >(&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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -836,14 +873,22 @@ impl SecurityMonitoringAPI { signal_id: String, body: crate::datadogV2::model::SecurityMonitoringSignalIncidentsUpdateRequest, ) -> Result< - Option, + crate::datadogV2::model::SecurityMonitoringSignalTriageUpdateResponse, Error, > { match self .edit_security_monitoring_signal_incidents_with_http_info(signal_id, body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -898,14 +943,19 @@ impl SecurityMonitoringAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option< + match serde_json::from_str::< crate::datadogV2::model::SecurityMonitoringSignalTriageUpdateResponse, - > = serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + >(&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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -924,14 +974,22 @@ impl SecurityMonitoringAPI { signal_id: String, body: crate::datadogV2::model::SecurityMonitoringSignalStateUpdateRequest, ) -> Result< - Option, + crate::datadogV2::model::SecurityMonitoringSignalTriageUpdateResponse, Error, > { match self .edit_security_monitoring_signal_state_with_http_info(signal_id, body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -986,14 +1044,19 @@ impl SecurityMonitoringAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option< + match serde_json::from_str::< crate::datadogV2::model::SecurityMonitoringSignalTriageUpdateResponse, - > = serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + >(&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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -1011,9 +1074,17 @@ impl SecurityMonitoringAPI { &self, finding_id: String, params: GetFindingOptionalParams, - ) -> Result, Error> { + ) -> Result> { match self.get_finding_with_http_info(finding_id, params).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -1075,13 +1146,18 @@ impl SecurityMonitoringAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = ResponseContent { @@ -1100,15 +1176,21 @@ impl SecurityMonitoringAPI { pub async fn get_security_filter( &self, security_filter_id: String, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self .get_security_filter_with_http_info(security_filter_id) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -1158,13 +1240,18 @@ impl SecurityMonitoringAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -1182,14 +1269,22 @@ impl SecurityMonitoringAPI { &self, rule_id: String, ) -> Result< - Option, + crate::datadogV2::model::SecurityMonitoringRuleResponse, Error, > { match self .get_security_monitoring_rule_with_http_info(rule_id) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -1236,13 +1331,18 @@ impl SecurityMonitoringAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -1260,14 +1360,22 @@ impl SecurityMonitoringAPI { &self, signal_id: String, ) -> Result< - Option, + crate::datadogV2::model::SecurityMonitoringSignalResponse, Error, > { match self .get_security_monitoring_signal_with_http_info(signal_id) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -1314,13 +1422,18 @@ impl SecurityMonitoringAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -1367,10 +1480,17 @@ impl SecurityMonitoringAPI { pub async fn list_findings( &self, params: ListFindingsOptionalParams, - ) -> Result, Error> - { + ) -> Result> { match self.list_findings_with_http_info(params).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -1521,13 +1641,18 @@ impl SecurityMonitoringAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = ResponseContent { @@ -1542,12 +1667,18 @@ impl SecurityMonitoringAPI { /// Get the list of configured security filters with their definitions. pub async fn list_security_filters( &self, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self.list_security_filters_with_http_info().await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -1592,13 +1723,18 @@ impl SecurityMonitoringAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -1616,14 +1752,22 @@ impl SecurityMonitoringAPI { &self, params: ListSecurityMonitoringRulesOptionalParams, ) -> Result< - Option, + crate::datadogV2::model::SecurityMonitoringListRulesResponse, Error, > { match self .list_security_monitoring_rules_with_http_info(params) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -1682,13 +1826,18 @@ impl SecurityMonitoringAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -1708,14 +1857,22 @@ impl SecurityMonitoringAPI { &self, params: ListSecurityMonitoringSignalsOptionalParams, ) -> Result< - Option, + crate::datadogV2::model::SecurityMonitoringSignalsListResponse, Error, > { match self .list_security_monitoring_signals_with_http_info(params) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -1796,14 +1953,19 @@ impl SecurityMonitoringAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option< + match serde_json::from_str::< crate::datadogV2::model::SecurityMonitoringSignalsListResponse, - > = serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + >(&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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -1820,10 +1982,17 @@ impl SecurityMonitoringAPI { pub async fn mute_findings( &self, body: crate::datadogV2::model::BulkMuteFindingsRequest, - ) -> Result, Error> - { + ) -> Result> { match self.mute_findings_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -1884,13 +2053,18 @@ impl SecurityMonitoringAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = ResponseContent { @@ -1909,14 +2083,22 @@ impl SecurityMonitoringAPI { &self, params: SearchSecurityMonitoringSignalsOptionalParams, ) -> Result< - Option, + crate::datadogV2::model::SecurityMonitoringSignalsListResponse, Error, > { match self .search_security_monitoring_signals_with_http_info(params) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -1974,14 +2156,19 @@ impl SecurityMonitoringAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option< + match serde_json::from_str::< crate::datadogV2::model::SecurityMonitoringSignalsListResponse, - > = serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + >(&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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -2000,15 +2187,21 @@ impl SecurityMonitoringAPI { &self, security_filter_id: String, body: crate::datadogV2::model::SecurityFilterUpdateRequest, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self .update_security_filter_with_http_info(security_filter_id, body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -2064,13 +2257,18 @@ impl SecurityMonitoringAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -2091,14 +2289,22 @@ impl SecurityMonitoringAPI { rule_id: String, body: crate::datadogV2::model::SecurityMonitoringRuleUpdatePayload, ) -> Result< - Option, + crate::datadogV2::model::SecurityMonitoringRuleResponse, Error, > { match self .update_security_monitoring_rule_with_http_info(rule_id, body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -2155,13 +2361,18 @@ impl SecurityMonitoringAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); diff --git a/src/datadogV2/api/api_sensitive_data_scanner.rs b/src/datadogV2/api/api_sensitive_data_scanner.rs index acae2e0b9..45a6a01cb 100644 --- a/src/datadogV2/api/api_sensitive_data_scanner.rs +++ b/src/datadogV2/api/api_sensitive_data_scanner.rs @@ -129,11 +129,19 @@ impl SensitiveDataScannerAPI { &self, body: crate::datadogV2::model::SensitiveDataScannerGroupCreateRequest, ) -> Result< - Option, + crate::datadogV2::model::SensitiveDataScannerCreateGroupResponse, Error, > { match self.create_scanning_group_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -190,14 +198,19 @@ impl SensitiveDataScannerAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option< + match serde_json::from_str::< crate::datadogV2::model::SensitiveDataScannerCreateGroupResponse, - > = serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + >(&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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -219,11 +232,19 @@ impl SensitiveDataScannerAPI { &self, body: crate::datadogV2::model::SensitiveDataScannerRuleCreateRequest, ) -> Result< - Option, + crate::datadogV2::model::SensitiveDataScannerCreateRuleResponse, Error, > { match self.create_scanning_rule_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -280,14 +301,19 @@ impl SensitiveDataScannerAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option< + match serde_json::from_str::< crate::datadogV2::model::SensitiveDataScannerCreateRuleResponse, - > = serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + >(&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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -306,14 +332,22 @@ impl SensitiveDataScannerAPI { group_id: String, body: crate::datadogV2::model::SensitiveDataScannerGroupDeleteRequest, ) -> Result< - Option, + crate::datadogV2::model::SensitiveDataScannerGroupDeleteResponse, Error, > { match self .delete_scanning_group_with_http_info(group_id, body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -368,14 +402,19 @@ impl SensitiveDataScannerAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option< + match serde_json::from_str::< crate::datadogV2::model::SensitiveDataScannerGroupDeleteResponse, - > = serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + >(&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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -394,14 +433,22 @@ impl SensitiveDataScannerAPI { rule_id: String, body: crate::datadogV2::model::SensitiveDataScannerRuleDeleteRequest, ) -> Result< - Option, + crate::datadogV2::model::SensitiveDataScannerRuleDeleteResponse, Error, > { match self .delete_scanning_rule_with_http_info(rule_id, body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -456,14 +503,19 @@ impl SensitiveDataScannerAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option< + match serde_json::from_str::< crate::datadogV2::model::SensitiveDataScannerRuleDeleteResponse, - > = serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + >(&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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -480,11 +532,19 @@ impl SensitiveDataScannerAPI { pub async fn list_scanning_groups( &self, ) -> Result< - Option, + crate::datadogV2::model::SensitiveDataScannerGetConfigResponse, Error, > { match self.list_scanning_groups_with_http_info().await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -529,14 +589,19 @@ impl SensitiveDataScannerAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option< + match serde_json::from_str::< crate::datadogV2::model::SensitiveDataScannerGetConfigResponse, - > = serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + >(&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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -553,11 +618,19 @@ impl SensitiveDataScannerAPI { pub async fn list_standard_patterns( &self, ) -> Result< - Option, + crate::datadogV2::model::SensitiveDataScannerStandardPatternsResponseData, Error, > { match self.list_standard_patterns_with_http_info().await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -602,14 +675,19 @@ impl SensitiveDataScannerAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option< + match serde_json::from_str::< crate::datadogV2::model::SensitiveDataScannerStandardPatternsResponseData, - > = serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + >(&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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -627,11 +705,19 @@ impl SensitiveDataScannerAPI { &self, body: crate::datadogV2::model::SensitiveDataScannerConfigRequest, ) -> Result< - Option, + crate::datadogV2::model::SensitiveDataScannerReorderGroupsResponse, Error, > { match self.reorder_scanning_groups_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -684,14 +770,19 @@ impl SensitiveDataScannerAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option< + match serde_json::from_str::< crate::datadogV2::model::SensitiveDataScannerReorderGroupsResponse, - > = serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + >(&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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -713,14 +804,22 @@ impl SensitiveDataScannerAPI { group_id: String, body: crate::datadogV2::model::SensitiveDataScannerGroupUpdateRequest, ) -> Result< - Option, + crate::datadogV2::model::SensitiveDataScannerGroupUpdateResponse, Error, > { match self .update_scanning_group_with_http_info(group_id, body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -778,14 +877,19 @@ impl SensitiveDataScannerAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option< + match serde_json::from_str::< crate::datadogV2::model::SensitiveDataScannerGroupUpdateResponse, - > = serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + >(&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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -807,14 +911,22 @@ impl SensitiveDataScannerAPI { rule_id: String, body: crate::datadogV2::model::SensitiveDataScannerRuleUpdateRequest, ) -> Result< - Option, + crate::datadogV2::model::SensitiveDataScannerRuleUpdateResponse, Error, > { match self .update_scanning_rule_with_http_info(rule_id, body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -872,14 +984,19 @@ impl SensitiveDataScannerAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option< + match serde_json::from_str::< crate::datadogV2::model::SensitiveDataScannerRuleUpdateResponse, - > = serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + >(&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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); diff --git a/src/datadogV2/api/api_service_accounts.rs b/src/datadogV2/api/api_service_accounts.rs index 4bbaf5bb0..197d59789 100644 --- a/src/datadogV2/api/api_service_accounts.rs +++ b/src/datadogV2/api/api_service_accounts.rs @@ -147,10 +147,17 @@ impl ServiceAccountsAPI { pub async fn create_service_account( &self, body: crate::datadogV2::model::ServiceAccountCreateRequest, - ) -> Result, Error> - { + ) -> Result> { match self.create_service_account_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -203,13 +210,16 @@ impl ServiceAccountsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -228,14 +238,22 @@ impl ServiceAccountsAPI { service_account_id: String, body: crate::datadogV2::model::ApplicationKeyCreateRequest, ) -> Result< - Option, + crate::datadogV2::model::ApplicationKeyResponse, Error, > { match self .create_service_account_application_key_with_http_info(service_account_id, body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -290,13 +308,18 @@ impl ServiceAccountsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -314,12 +337,12 @@ impl ServiceAccountsAPI { &self, service_account_id: String, app_key_id: String, - ) -> Result, Error> { + ) -> Result<(), Error> { match self .delete_service_account_application_key_with_http_info(service_account_id, app_key_id) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(_) => Ok(()), Err(err) => Err(err), } } @@ -388,14 +411,22 @@ impl ServiceAccountsAPI { service_account_id: String, app_key_id: String, ) -> Result< - Option, + crate::datadogV2::model::PartialApplicationKeyResponse, Error, > { match self .get_service_account_application_key_with_http_info(service_account_id, app_key_id) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -444,13 +475,18 @@ impl ServiceAccountsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -469,14 +505,22 @@ impl ServiceAccountsAPI { service_account_id: String, params: ListServiceAccountApplicationKeysOptionalParams, ) -> Result< - Option, + crate::datadogV2::model::ListApplicationKeysResponse, Error, > { match self .list_service_account_application_keys_with_http_info(service_account_id, params) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -557,13 +601,18 @@ impl ServiceAccountsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -583,7 +632,7 @@ impl ServiceAccountsAPI { app_key_id: String, body: crate::datadogV2::model::ApplicationKeyUpdateRequest, ) -> Result< - Option, + crate::datadogV2::model::PartialApplicationKeyResponse, Error, > { match self @@ -594,7 +643,15 @@ impl ServiceAccountsAPI { ) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -651,13 +708,18 @@ impl ServiceAccountsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); diff --git a/src/datadogV2/api/api_service_definition.rs b/src/datadogV2/api/api_service_definition.rs index 658e8d6cd..6b49f9593 100644 --- a/src/datadogV2/api/api_service_definition.rs +++ b/src/datadogV2/api/api_service_definition.rs @@ -126,14 +126,22 @@ impl ServiceDefinitionAPI { &self, body: crate::datadogV2::model::ServiceDefinitionsCreateRequest, ) -> Result< - Option, + crate::datadogV2::model::ServiceDefinitionCreateResponse, Error, > { match self .create_or_update_service_definitions_with_http_info(body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -186,13 +194,18 @@ impl ServiceDefinitionAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -209,12 +222,12 @@ impl ServiceDefinitionAPI { pub async fn delete_service_definition( &self, service_name: String, - ) -> Result, Error> { + ) -> Result<(), Error> { match self .delete_service_definition_with_http_info(service_name) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(_) => Ok(()), Err(err) => Err(err), } } @@ -281,14 +294,22 @@ impl ServiceDefinitionAPI { service_name: String, params: GetServiceDefinitionOptionalParams, ) -> Result< - Option, + crate::datadogV2::model::ServiceDefinitionGetResponse, Error, > { match self .get_service_definition_with_http_info(service_name, params) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -344,13 +365,18 @@ impl ServiceDefinitionAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -368,11 +394,19 @@ impl ServiceDefinitionAPI { &self, params: ListServiceDefinitionsOptionalParams, ) -> Result< - Option, + crate::datadogV2::model::ServiceDefinitionsListResponse, Error, > { match self.list_service_definitions_with_http_info(params).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -436,13 +470,18 @@ impl ServiceDefinitionAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); diff --git a/src/datadogV2/api/api_service_scorecards.rs b/src/datadogV2/api/api_service_scorecards.rs index a94fef4ed..8ddef28f4 100644 --- a/src/datadogV2/api/api_service_scorecards.rs +++ b/src/datadogV2/api/api_service_scorecards.rs @@ -241,14 +241,22 @@ impl ServiceScorecardsAPI { &self, body: crate::datadogV2::model::OutcomesBatchRequest, ) -> Result< - Option, + crate::datadogV2::model::OutcomesBatchResponse, Error, > { match self .create_scorecard_outcomes_batch_with_http_info(body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -309,13 +317,18 @@ impl ServiceScorecardsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -332,10 +345,17 @@ impl ServiceScorecardsAPI { pub async fn create_scorecard_rule( &self, body: crate::datadogV2::model::CreateRuleRequest, - ) -> Result, Error> - { + ) -> Result> { match self.create_scorecard_rule_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -396,13 +416,18 @@ impl ServiceScorecardsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -419,9 +444,9 @@ impl ServiceScorecardsAPI { pub async fn delete_scorecard_rule( &self, rule_id: String, - ) -> Result, Error> { + ) -> Result<(), Error> { match self.delete_scorecard_rule_with_http_info(rule_id).await { - Ok(response_content) => Ok(response_content.entity), + Ok(_) => Ok(()), Err(err) => Err(err), } } @@ -494,10 +519,17 @@ impl ServiceScorecardsAPI { pub async fn list_scorecard_outcomes( &self, params: ListScorecardOutcomesOptionalParams, - ) -> Result, Error> - { + ) -> Result> { match self.list_scorecard_outcomes_with_http_info(params).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -606,13 +638,17 @@ impl ServiceScorecardsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -629,10 +665,17 @@ impl ServiceScorecardsAPI { pub async fn list_scorecard_rules( &self, params: ListScorecardRulesOptionalParams, - ) -> Result, Error> - { + ) -> Result> { match self.list_scorecard_rules_with_http_info(params).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -739,13 +782,17 @@ impl ServiceScorecardsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); diff --git a/src/datadogV2/api/api_spans.rs b/src/datadogV2/api/api_spans.rs index c3330d75b..a791c611b 100644 --- a/src/datadogV2/api/api_spans.rs +++ b/src/datadogV2/api/api_spans.rs @@ -114,10 +114,17 @@ impl SpansAPI { pub async fn aggregate_spans( &self, body: crate::datadogV2::model::SpansAggregateRequest, - ) -> Result, Error> - { + ) -> Result> { match self.aggregate_spans_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -171,13 +178,18 @@ impl SpansAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -200,9 +212,17 @@ impl SpansAPI { pub async fn list_spans( &self, body: crate::datadogV2::model::SpansListRequest, - ) -> Result, Error> { + ) -> Result> { match self.list_spans_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -259,13 +279,17 @@ impl SpansAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = ResponseContent { @@ -287,9 +311,17 @@ impl SpansAPI { pub async fn list_spans_get( &self, params: ListSpansGetOptionalParams, - ) -> Result, Error> { + ) -> Result> { match self.list_spans_get_with_http_info(params).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -372,13 +404,17 @@ impl SpansAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = ResponseContent { diff --git a/src/datadogV2/api/api_spans_metrics.rs b/src/datadogV2/api/api_spans_metrics.rs index ea96eb28d..b784c9aa1 100644 --- a/src/datadogV2/api/api_spans_metrics.rs +++ b/src/datadogV2/api/api_spans_metrics.rs @@ -82,10 +82,17 @@ impl SpansMetricsAPI { pub async fn create_spans_metric( &self, body: crate::datadogV2::model::SpansMetricCreateRequest, - ) -> Result, Error> - { + ) -> Result> { match self.create_spans_metric_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -139,13 +146,18 @@ impl SpansMetricsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -162,9 +174,9 @@ impl SpansMetricsAPI { pub async fn delete_spans_metric( &self, metric_id: String, - ) -> Result, Error> { + ) -> Result<(), Error> { match self.delete_spans_metric_with_http_info(metric_id).await { - Ok(response_content) => Ok(response_content.entity), + Ok(_) => Ok(()), Err(err) => Err(err), } } @@ -229,10 +241,17 @@ impl SpansMetricsAPI { pub async fn get_spans_metric( &self, metric_id: String, - ) -> Result, Error> - { + ) -> Result> { match self.get_spans_metric_with_http_info(metric_id).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -279,13 +298,18 @@ impl SpansMetricsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -301,10 +325,17 @@ impl SpansMetricsAPI { /// Get the list of configured span-based metrics with their definitions. pub async fn list_spans_metrics( &self, - ) -> Result, Error> - { + ) -> Result> { match self.list_spans_metrics_with_http_info().await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -349,13 +380,18 @@ impl SpansMetricsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -374,13 +410,20 @@ impl SpansMetricsAPI { &self, metric_id: String, body: crate::datadogV2::model::SpansMetricUpdateRequest, - ) -> Result, Error> - { + ) -> Result> { match self .update_spans_metric_with_http_info(metric_id, body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -436,13 +479,18 @@ impl SpansMetricsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); diff --git a/src/datadogV2/api/api_synthetics.rs b/src/datadogV2/api/api_synthetics.rs index ee10b0836..4c4751e13 100644 --- a/src/datadogV2/api/api_synthetics.rs +++ b/src/datadogV2/api/api_synthetics.rs @@ -46,11 +46,19 @@ impl SyntheticsAPI { pub async fn get_on_demand_concurrency_cap( &self, ) -> Result< - Option, + crate::datadogV2::model::OnDemandConcurrencyCapResponse, Error, > { match self.get_on_demand_concurrency_cap_with_http_info().await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -95,13 +103,18 @@ impl SyntheticsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -119,14 +132,22 @@ impl SyntheticsAPI { &self, body: crate::datadogV2::model::OnDemandConcurrencyCapAttributes, ) -> Result< - Option, + crate::datadogV2::model::OnDemandConcurrencyCapResponse, Error, > { match self .set_on_demand_concurrency_cap_with_http_info(body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -179,13 +200,18 @@ impl SyntheticsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); diff --git a/src/datadogV2/api/api_teams.rs b/src/datadogV2/api/api_teams.rs index 69fc00eda..e651f7e50 100644 --- a/src/datadogV2/api/api_teams.rs +++ b/src/datadogV2/api/api_teams.rs @@ -298,9 +298,17 @@ impl TeamsAPI { pub async fn create_team( &self, body: crate::datadogV2::model::TeamCreateRequest, - ) -> Result, Error> { + ) -> Result> { match self.create_team_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -352,13 +360,16 @@ impl TeamsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = ResponseContent { @@ -375,9 +386,17 @@ impl TeamsAPI { &self, team_id: String, body: crate::datadogV2::model::TeamLinkCreateRequest, - ) -> Result, Error> { + ) -> Result> { match self.create_team_link_with_http_info(team_id, body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -432,13 +451,17 @@ impl TeamsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -456,13 +479,20 @@ impl TeamsAPI { &self, team_id: String, body: crate::datadogV2::model::UserTeamRequest, - ) -> Result, Error> - { + ) -> Result> { match self .create_team_membership_with_http_info(team_id, body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -517,13 +547,17 @@ impl TeamsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -537,9 +571,9 @@ impl TeamsAPI { } /// Remove a team using the team's `id`. - pub async fn delete_team(&self, team_id: String) -> Result, Error> { + pub async fn delete_team(&self, team_id: String) -> Result<(), Error> { match self.delete_team_with_http_info(team_id).await { - Ok(response_content) => Ok(response_content.entity), + Ok(_) => Ok(()), Err(err) => Err(err), } } @@ -604,9 +638,9 @@ impl TeamsAPI { &self, team_id: String, link_id: String, - ) -> Result, Error> { + ) -> Result<(), Error> { match self.delete_team_link_with_http_info(team_id, link_id).await { - Ok(response_content) => Ok(response_content.entity), + Ok(_) => Ok(()), Err(err) => Err(err), } } @@ -674,12 +708,12 @@ impl TeamsAPI { &self, team_id: String, user_id: String, - ) -> Result, Error> { + ) -> Result<(), Error> { match self .delete_team_membership_with_http_info(team_id, user_id) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(_) => Ok(()), Err(err) => Err(err), } } @@ -746,9 +780,17 @@ impl TeamsAPI { pub async fn get_team( &self, team_id: String, - ) -> Result, Error> { + ) -> Result> { match self.get_team_with_http_info(team_id).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -792,13 +834,16 @@ impl TeamsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = ResponseContent { @@ -815,9 +860,17 @@ impl TeamsAPI { &self, team_id: String, link_id: String, - ) -> Result, Error> { + ) -> Result> { match self.get_team_link_with_http_info(team_id, link_id).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -864,13 +917,17 @@ impl TeamsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = ResponseContent { @@ -886,9 +943,17 @@ impl TeamsAPI { pub async fn get_team_links( &self, team_id: String, - ) -> Result, Error> { + ) -> Result> { match self.get_team_links_with_http_info(team_id).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -933,13 +998,17 @@ impl TeamsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = ResponseContent { @@ -956,13 +1025,20 @@ impl TeamsAPI { &self, team_id: String, params: GetTeamMembershipsOptionalParams, - ) -> Result, Error> - { + ) -> Result> { match self .get_team_memberships_with_http_info(team_id, params) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -1033,13 +1109,17 @@ impl TeamsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -1057,14 +1137,22 @@ impl TeamsAPI { &self, team_id: String, ) -> Result< - Option, + crate::datadogV2::model::TeamPermissionSettingsResponse, Error, > { match self .get_team_permission_settings_with_http_info(team_id) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -1111,13 +1199,18 @@ impl TeamsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -1134,10 +1227,17 @@ impl TeamsAPI { pub async fn get_user_memberships( &self, user_uuid: String, - ) -> Result, Error> - { + ) -> Result> { match self.get_user_memberships_with_http_info(user_uuid).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -1184,13 +1284,17 @@ impl TeamsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -1208,9 +1312,17 @@ impl TeamsAPI { pub async fn list_teams( &self, params: ListTeamsOptionalParams, - ) -> Result, Error> { + ) -> Result> { match self.list_teams_with_http_info(params).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -1307,13 +1419,16 @@ impl TeamsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = ResponseContent { @@ -1331,9 +1446,17 @@ impl TeamsAPI { &self, team_id: String, body: crate::datadogV2::model::TeamUpdateRequest, - ) -> Result, Error> { + ) -> Result> { match self.update_team_with_http_info(team_id, body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -1387,13 +1510,16 @@ impl TeamsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = ResponseContent { @@ -1411,12 +1537,20 @@ impl TeamsAPI { team_id: String, link_id: String, body: crate::datadogV2::model::TeamLinkCreateRequest, - ) -> Result, Error> { + ) -> Result> { match self .update_team_link_with_http_info(team_id, link_id, body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -1473,13 +1607,17 @@ impl TeamsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -1498,13 +1636,20 @@ impl TeamsAPI { team_id: String, user_id: String, body: crate::datadogV2::model::UserTeamUpdateRequest, - ) -> Result, Error> - { + ) -> Result> { match self .update_team_membership_with_http_info(team_id, user_id, body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -1561,13 +1706,17 @@ impl TeamsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -1587,14 +1736,22 @@ impl TeamsAPI { action: String, body: crate::datadogV2::model::TeamPermissionSettingUpdateRequest, ) -> Result< - Option, + crate::datadogV2::model::TeamPermissionSettingResponse, Error, > { match self .update_team_permission_setting_with_http_info(team_id, action, body) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -1651,13 +1808,18 @@ impl TeamsAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); diff --git a/src/datadogV2/api/api_usage_metering.rs b/src/datadogV2/api/api_usage_metering.rs index 249756311..bd0ec006d 100644 --- a/src/datadogV2/api/api_usage_metering.rs +++ b/src/datadogV2/api/api_usage_metering.rs @@ -385,11 +385,19 @@ impl UsageMeteringAPI { pub async fn get_active_billing_dimensions( &self, ) -> Result< - Option, + crate::datadogV2::model::ActiveBillingDimensionsResponse, Error, > { match self.get_active_billing_dimensions_with_http_info().await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -442,13 +450,18 @@ impl UsageMeteringAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -470,12 +483,20 @@ impl UsageMeteringAPI { &self, start_month: String, params: GetCostByOrgOptionalParams, - ) -> Result, Error> { + ) -> Result> { match self .get_cost_by_org_with_http_info(start_month, params) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -533,13 +554,17 @@ impl UsageMeteringAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = ResponseContent { @@ -558,10 +583,17 @@ impl UsageMeteringAPI { pub async fn get_estimated_cost_by_org( &self, params: GetEstimatedCostByOrgOptionalParams, - ) -> Result, Error> - { + ) -> Result> { match self.get_estimated_cost_by_org_with_http_info(params).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -638,13 +670,17 @@ impl UsageMeteringAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -663,15 +699,21 @@ impl UsageMeteringAPI { &self, start_month: String, params: GetHistoricalCostByOrgOptionalParams, - ) -> Result< - Option, - Error, - > { + ) -> Result> + { match self .get_historical_cost_by_org_with_http_info(start_month, params) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -733,13 +775,17 @@ impl UsageMeteringAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -758,8 +804,7 @@ impl UsageMeteringAPI { filter_timestamp_start: String, filter_product_families: String, params: GetHourlyUsageOptionalParams, - ) -> Result, Error> - { + ) -> Result> { match self .get_hourly_usage_with_http_info( filter_timestamp_start, @@ -768,7 +813,15 @@ impl UsageMeteringAPI { ) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -859,13 +912,18 @@ impl UsageMeteringAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -899,14 +957,22 @@ impl UsageMeteringAPI { fields: String, params: GetMonthlyCostAttributionOptionalParams, ) -> Result< - Option, + crate::datadogV2::model::MonthlyCostAttributionResponse, Error, > { match self .get_monthly_cost_attribution_with_http_info(start_month, end_month, fields, params) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -1007,13 +1073,18 @@ impl UsageMeteringAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -1032,10 +1103,17 @@ impl UsageMeteringAPI { pub async fn get_projected_cost( &self, params: GetProjectedCostOptionalParams, - ) -> Result, Error> - { + ) -> Result> { match self.get_projected_cost_with_http_info(params).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -1091,13 +1169,18 @@ impl UsageMeteringAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -1117,14 +1200,22 @@ impl UsageMeteringAPI { start_hr: String, params: GetUsageApplicationSecurityMonitoringOptionalParams, ) -> Result< - Option, + crate::datadogV2::model::UsageApplicationSecurityMonitoringResponse, Error, > { match self .get_usage_application_security_monitoring_with_http_info(start_hr, params) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -1181,14 +1272,19 @@ impl UsageMeteringAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option< + match serde_json::from_str::< crate::datadogV2::model::UsageApplicationSecurityMonitoringResponse, - > = serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + >(&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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -1208,14 +1304,22 @@ impl UsageMeteringAPI { start_hr: String, params: GetUsageLambdaTracedInvocationsOptionalParams, ) -> Result< - Option, + crate::datadogV2::model::UsageLambdaTracedInvocationsResponse, Error, > { match self .get_usage_lambda_traced_invocations_with_http_info(start_hr, params) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -1272,14 +1376,19 @@ impl UsageMeteringAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option< + match serde_json::from_str::< crate::datadogV2::model::UsageLambdaTracedInvocationsResponse, - > = serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + >(&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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -1299,14 +1408,22 @@ impl UsageMeteringAPI { start_hr: String, params: GetUsageObservabilityPipelinesOptionalParams, ) -> Result< - Option, + crate::datadogV2::model::UsageObservabilityPipelinesResponse, Error, > { match self .get_usage_observability_pipelines_with_http_info(start_hr, params) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -1363,13 +1480,18 @@ impl UsageMeteringAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); diff --git a/src/datadogV2/api/api_users.rs b/src/datadogV2/api/api_users.rs index acf344b73..dac84c1e2 100644 --- a/src/datadogV2/api/api_users.rs +++ b/src/datadogV2/api/api_users.rs @@ -183,9 +183,17 @@ impl UsersAPI { pub async fn create_user( &self, body: crate::datadogV2::model::UserCreateRequest, - ) -> Result, Error> { + ) -> Result> { match self.create_user_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -236,13 +244,16 @@ impl UsersAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = ResponseContent { @@ -256,12 +267,9 @@ impl UsersAPI { /// Disable a user. Can only be used with an application key belonging /// to an administrator user. - pub async fn disable_user( - &self, - user_id: String, - ) -> Result, Error> { + pub async fn disable_user(&self, user_id: String) -> Result<(), Error> { match self.disable_user_with_http_info(user_id).await { - Ok(response_content) => Ok(response_content.entity), + Ok(_) => Ok(()), Err(err) => Err(err), } } @@ -326,13 +334,20 @@ impl UsersAPI { pub async fn get_invitation( &self, user_invitation_uuid: String, - ) -> Result, Error> - { + ) -> Result> { match self .get_invitation_with_http_info(user_invitation_uuid) .await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -379,13 +394,18 @@ impl UsersAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -402,9 +422,17 @@ impl UsersAPI { pub async fn get_user( &self, user_id: String, - ) -> Result, Error> { + ) -> Result> { match self.get_user_with_http_info(user_id).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -448,13 +476,16 @@ impl UsersAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = ResponseContent { @@ -471,10 +502,17 @@ impl UsersAPI { pub async fn list_user_organizations( &self, user_id: String, - ) -> Result, Error> - { + ) -> Result> { match self.list_user_organizations_with_http_info(user_id).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -522,13 +560,16 @@ impl UsersAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -546,10 +587,17 @@ impl UsersAPI { pub async fn list_user_permissions( &self, user_id: String, - ) -> Result, Error> - { + ) -> Result> { match self.list_user_permissions_with_http_info(user_id).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -597,13 +645,18 @@ impl UsersAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -621,9 +674,17 @@ impl UsersAPI { pub async fn list_users( &self, params: ListUsersOptionalParams, - ) -> Result, Error> { + ) -> Result> { match self.list_users_with_http_info(params).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -701,13 +762,16 @@ impl UsersAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = ResponseContent { @@ -723,10 +787,17 @@ impl UsersAPI { pub async fn send_invitations( &self, body: crate::datadogV2::model::UserInvitationsRequest, - ) -> Result, Error> - { + ) -> Result> { match self.send_invitations_with_http_info(body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -779,13 +850,18 @@ impl UsersAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); @@ -804,9 +880,17 @@ impl UsersAPI { &self, user_id: String, body: crate::datadogV2::model::UserUpdateRequest, - ) -> Result, Error> { + ) -> Result> { match self.update_user_with_http_info(user_id, body).await { - Ok(response_content) => Ok(response_content.entity), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } @@ -860,13 +944,16 @@ impl UsersAPI { let local_content = local_resp.text().await?; if !local_status.is_client_error() && !local_status.is_server_error() { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); - Ok(ResponseContent { - status: local_status, - content: local_content, - entity: local_entity, - }) + 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)), + }; } else { let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = ResponseContent {