From 8cdc2bf46b041645fdb0408fa9d4b2c8be5308e8 Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Fri, 24 Oct 2025 14:51:12 +0000 Subject: [PATCH] Regenerate client from commit 31d12b4 of spec repo --- .generator/schemas/v2/openapi.yaml | 319 ++++++++++++++ ...lysis_CreateSCAResolveVulnerableSymbols.rs | 26 ++ .../v2_static-analysis_CreateSCAResult.rs | 114 +++++ src/datadog/configuration.rs | 2 + src/datadogV2/api/api_static_analysis.rs | 397 ++++++++++++++++++ src/datadogV2/api/mod.rs | 1 + src/datadogV2/mod.rs | 1 + src/datadogV2/model/mod.rs | 52 +++ ...odel_resolve_vulnerable_symbols_request.rs | 107 +++++ ...resolve_vulnerable_symbols_request_data.rs | 139 ++++++ ...nerable_symbols_request_data_attributes.rs | 103 +++++ ...ve_vulnerable_symbols_request_data_type.rs | 50 +++ ...del_resolve_vulnerable_symbols_response.rs | 108 +++++ ...esolve_vulnerable_symbols_response_data.rs | 139 ++++++ ...erable_symbols_response_data_attributes.rs | 108 +++++ ...e_vulnerable_symbols_response_data_type.rs | 50 +++ ...lve_vulnerable_symbols_response_results.rs | 127 ++++++ ...ols_response_results_vulnerable_symbols.rs | 124 ++++++ ...onse_results_vulnerable_symbols_symbols.rs | 136 ++++++ src/datadogV2/model/model_sca_request.rs | 103 +++++ src/datadogV2/model/model_sca_request_data.rs | 133 ++++++ .../model_sca_request_data_attributes.rs | 264 ++++++++++++ ...odel_sca_request_data_attributes_commit.rs | 204 +++++++++ ...uest_data_attributes_dependencies_items.rs | 273 ++++++++++++ ...utes_dependencies_items_locations_items.rs | 163 +++++++ ...ies_items_locations_items_file_position.rs | 149 +++++++ ...ndencies_items_locations_items_position.rs | 120 ++++++ ...items_reachable_symbol_properties_items.rs | 126 ++++++ ...sca_request_data_attributes_files_items.rs | 119 ++++++ ...request_data_attributes_relations_items.rs | 119 ++++++ ..._sca_request_data_attributes_repository.rs | 103 +++++ ...t_data_attributes_vulnerabilities_items.rs | 142 +++++++ ...tes_vulnerabilities_items_affects_items.rs | 104 +++++ .../model/model_sca_request_data_type.rs | 48 +++ .../features/v2/static_analysis.feature | 24 ++ tests/scenarios/features/v2/undo.json | 12 + tests/scenarios/function_mappings.rs | 69 +++ 37 files changed, 4378 insertions(+) create mode 100644 examples/v2_static-analysis_CreateSCAResolveVulnerableSymbols.rs create mode 100644 examples/v2_static-analysis_CreateSCAResult.rs create mode 100644 src/datadogV2/api/api_static_analysis.rs create mode 100644 src/datadogV2/model/model_resolve_vulnerable_symbols_request.rs create mode 100644 src/datadogV2/model/model_resolve_vulnerable_symbols_request_data.rs create mode 100644 src/datadogV2/model/model_resolve_vulnerable_symbols_request_data_attributes.rs create mode 100644 src/datadogV2/model/model_resolve_vulnerable_symbols_request_data_type.rs create mode 100644 src/datadogV2/model/model_resolve_vulnerable_symbols_response.rs create mode 100644 src/datadogV2/model/model_resolve_vulnerable_symbols_response_data.rs create mode 100644 src/datadogV2/model/model_resolve_vulnerable_symbols_response_data_attributes.rs create mode 100644 src/datadogV2/model/model_resolve_vulnerable_symbols_response_data_type.rs create mode 100644 src/datadogV2/model/model_resolve_vulnerable_symbols_response_results.rs create mode 100644 src/datadogV2/model/model_resolve_vulnerable_symbols_response_results_vulnerable_symbols.rs create mode 100644 src/datadogV2/model/model_resolve_vulnerable_symbols_response_results_vulnerable_symbols_symbols.rs create mode 100644 src/datadogV2/model/model_sca_request.rs create mode 100644 src/datadogV2/model/model_sca_request_data.rs create mode 100644 src/datadogV2/model/model_sca_request_data_attributes.rs create mode 100644 src/datadogV2/model/model_sca_request_data_attributes_commit.rs create mode 100644 src/datadogV2/model/model_sca_request_data_attributes_dependencies_items.rs create mode 100644 src/datadogV2/model/model_sca_request_data_attributes_dependencies_items_locations_items.rs create mode 100644 src/datadogV2/model/model_sca_request_data_attributes_dependencies_items_locations_items_file_position.rs create mode 100644 src/datadogV2/model/model_sca_request_data_attributes_dependencies_items_locations_items_position.rs create mode 100644 src/datadogV2/model/model_sca_request_data_attributes_dependencies_items_reachable_symbol_properties_items.rs create mode 100644 src/datadogV2/model/model_sca_request_data_attributes_files_items.rs create mode 100644 src/datadogV2/model/model_sca_request_data_attributes_relations_items.rs create mode 100644 src/datadogV2/model/model_sca_request_data_attributes_repository.rs create mode 100644 src/datadogV2/model/model_sca_request_data_attributes_vulnerabilities_items.rs create mode 100644 src/datadogV2/model/model_sca_request_data_attributes_vulnerabilities_items_affects_items.rs create mode 100644 src/datadogV2/model/model_sca_request_data_type.rs create mode 100644 tests/scenarios/features/v2/static_analysis.feature diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 2c64bbd7a..8477f0988 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -39409,6 +39409,95 @@ components: type: string x-enum-varnames: - RULESET + ResolveVulnerableSymbolsRequest: + properties: + data: + $ref: '#/components/schemas/ResolveVulnerableSymbolsRequestData' + type: object + ResolveVulnerableSymbolsRequestData: + properties: + attributes: + $ref: '#/components/schemas/ResolveVulnerableSymbolsRequestDataAttributes' + id: + type: string + type: + $ref: '#/components/schemas/ResolveVulnerableSymbolsRequestDataType' + required: + - type + type: object + ResolveVulnerableSymbolsRequestDataAttributes: + properties: + purls: + items: + type: string + type: array + type: object + ResolveVulnerableSymbolsRequestDataType: + default: resolve-vulnerable-symbols-request + enum: + - resolve-vulnerable-symbols-request + example: resolve-vulnerable-symbols-request + type: string + x-enum-varnames: + - RESOLVE_VULNERABLE_SYMBOLS_REQUEST + ResolveVulnerableSymbolsResponse: + properties: + data: + $ref: '#/components/schemas/ResolveVulnerableSymbolsResponseData' + type: object + ResolveVulnerableSymbolsResponseData: + properties: + attributes: + $ref: '#/components/schemas/ResolveVulnerableSymbolsResponseDataAttributes' + id: + type: string + type: + $ref: '#/components/schemas/ResolveVulnerableSymbolsResponseDataType' + required: + - type + type: object + ResolveVulnerableSymbolsResponseDataAttributes: + properties: + results: + items: + $ref: '#/components/schemas/ResolveVulnerableSymbolsResponseResults' + type: array + type: object + ResolveVulnerableSymbolsResponseDataType: + default: resolve-vulnerable-symbols-response + enum: + - resolve-vulnerable-symbols-response + example: resolve-vulnerable-symbols-response + type: string + x-enum-varnames: + - RESOLVE_VULNERABLE_SYMBOLS_RESPONSE + ResolveVulnerableSymbolsResponseResults: + properties: + purl: + type: string + vulnerable_symbols: + items: + $ref: '#/components/schemas/ResolveVulnerableSymbolsResponseResultsVulnerableSymbols' + type: array + type: object + ResolveVulnerableSymbolsResponseResultsVulnerableSymbols: + properties: + advisory_id: + type: string + symbols: + items: + $ref: '#/components/schemas/ResolveVulnerableSymbolsResponseResultsVulnerableSymbolsSymbols' + type: array + type: object + ResolveVulnerableSymbolsResponseResultsVulnerableSymbolsSymbols: + properties: + name: + type: string + type: + type: string + value: + type: string + type: object ResourceFilterAttributes: description: Attributes of a resource filter. example: @@ -41843,6 +41932,184 @@ components: example: report_id type: string type: object + ScaRequest: + properties: + data: + $ref: '#/components/schemas/ScaRequestData' + type: object + ScaRequestData: + properties: + attributes: + $ref: '#/components/schemas/ScaRequestDataAttributes' + id: + type: string + type: + $ref: '#/components/schemas/ScaRequestDataType' + required: + - type + type: object + ScaRequestDataAttributes: + properties: + commit: + $ref: '#/components/schemas/ScaRequestDataAttributesCommit' + dependencies: + items: + $ref: '#/components/schemas/ScaRequestDataAttributesDependenciesItems' + type: array + env: + type: string + files: + items: + $ref: '#/components/schemas/ScaRequestDataAttributesFilesItems' + type: array + relations: + items: + $ref: '#/components/schemas/ScaRequestDataAttributesRelationsItems' + type: array + repository: + $ref: '#/components/schemas/ScaRequestDataAttributesRepository' + service: + type: string + tags: + additionalProperties: + type: string + type: object + vulnerabilities: + items: + $ref: '#/components/schemas/ScaRequestDataAttributesVulnerabilitiesItems' + type: array + type: object + ScaRequestDataAttributesCommit: + properties: + author_date: + type: string + author_email: + type: string + author_name: + type: string + branch: + type: string + committer_email: + type: string + committer_name: + type: string + sha: + type: string + type: object + ScaRequestDataAttributesDependenciesItems: + properties: + exclusions: + items: + type: string + type: array + group: + type: string + is_dev: + type: boolean + is_direct: + type: boolean + language: + type: string + locations: + items: + $ref: '#/components/schemas/ScaRequestDataAttributesDependenciesItemsLocationsItems' + type: array + name: + type: string + package_manager: + type: string + purl: + type: string + reachable_symbol_properties: + items: + $ref: '#/components/schemas/ScaRequestDataAttributesDependenciesItemsReachableSymbolPropertiesItems' + type: array + version: + type: string + type: object + ScaRequestDataAttributesDependenciesItemsLocationsItems: + properties: + block: + $ref: '#/components/schemas/ScaRequestDataAttributesDependenciesItemsLocationsItemsFilePosition' + name: + $ref: '#/components/schemas/ScaRequestDataAttributesDependenciesItemsLocationsItemsFilePosition' + namespace: + $ref: '#/components/schemas/ScaRequestDataAttributesDependenciesItemsLocationsItemsFilePosition' + version: + $ref: '#/components/schemas/ScaRequestDataAttributesDependenciesItemsLocationsItemsFilePosition' + type: object + ScaRequestDataAttributesDependenciesItemsLocationsItemsFilePosition: + properties: + end: + $ref: '#/components/schemas/ScaRequestDataAttributesDependenciesItemsLocationsItemsPosition' + file_name: + type: string + start: + $ref: '#/components/schemas/ScaRequestDataAttributesDependenciesItemsLocationsItemsPosition' + type: object + ScaRequestDataAttributesDependenciesItemsLocationsItemsPosition: + properties: + col: + format: int32 + maximum: 2147483647 + type: integer + line: + format: int32 + maximum: 2147483647 + type: integer + type: object + ScaRequestDataAttributesDependenciesItemsReachableSymbolPropertiesItems: + properties: + name: + type: string + value: + type: string + type: object + ScaRequestDataAttributesFilesItems: + properties: + name: + type: string + purl: + type: string + type: object + ScaRequestDataAttributesRelationsItems: + properties: + depends_on: + items: + type: string + type: array + ref: + type: string + type: object + ScaRequestDataAttributesRepository: + properties: + url: + type: string + type: object + ScaRequestDataAttributesVulnerabilitiesItems: + properties: + affects: + items: + $ref: '#/components/schemas/ScaRequestDataAttributesVulnerabilitiesItemsAffectsItems' + type: array + bom_ref: + type: string + id: + type: string + type: object + ScaRequestDataAttributesVulnerabilitiesItemsAffectsItems: + properties: + ref: + type: string + type: object + ScaRequestDataType: + default: scarequests + enum: + - scarequests + example: scarequests + type: string + x-enum-varnames: + - SCAREQUESTS ScalarColumn: description: A single column in a scalar query response. oneOf: @@ -76995,6 +77262,56 @@ paths: cursorPath: meta.page.after limitParam: body.data.attributes.page.limit resultsPath: data + /api/v2/static-analysis-sca/dependencies: + post: + operationId: CreateSCAResult + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ScaRequest' + required: true + responses: + '200': + description: OK + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - code_analysis_read + summary: Post dependencies for analysis + tags: + - Static Analysis + x-unstable: '**Note**: This endpoint may be subject to changes.' + /api/v2/static-analysis-sca/vulnerabilities/resolve-vulnerable-symbols: + post: + operationId: CreateSCAResolveVulnerableSymbols + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ResolveVulnerableSymbolsRequest' + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/ResolveVulnerableSymbolsResponse' + description: OK + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - code_analysis_read + summary: POST request to resolve vulnerable symbols + tags: + - Static Analysis + x-unstable: '**Note**: This endpoint may be subject to changes.' /api/v2/synthetics/settings/on_demand_concurrency_cap: get: description: Get the on-demand concurrency cap. @@ -80526,6 +80843,8 @@ tags: description: Find out more at url: https://docs.datadoghq.com/tracing/metrics/metrics_namespace/ name: Spans Metrics +- description: API for static analysis + name: Static Analysis - description: "Datadog Synthetics uses simulated user requests and browser rendering to help you ensure uptime,\nidentify regional issues, and track your application performance. Datadog Synthetics tests come in\ntwo different flavors, [API tests](https://docs.datadoghq.com/synthetics/api_tests/)\nand diff --git a/examples/v2_static-analysis_CreateSCAResolveVulnerableSymbols.rs b/examples/v2_static-analysis_CreateSCAResolveVulnerableSymbols.rs new file mode 100644 index 000000000..6913d5b17 --- /dev/null +++ b/examples/v2_static-analysis_CreateSCAResolveVulnerableSymbols.rs @@ -0,0 +1,26 @@ +// POST request to resolve vulnerable symbols returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_static_analysis::StaticAnalysisAPI; +use datadog_api_client::datadogV2::model::ResolveVulnerableSymbolsRequest; +use datadog_api_client::datadogV2::model::ResolveVulnerableSymbolsRequestData; +use datadog_api_client::datadogV2::model::ResolveVulnerableSymbolsRequestDataAttributes; +use datadog_api_client::datadogV2::model::ResolveVulnerableSymbolsRequestDataType; + +#[tokio::main] +async fn main() { + let body = ResolveVulnerableSymbolsRequest::new().data( + ResolveVulnerableSymbolsRequestData::new( + ResolveVulnerableSymbolsRequestDataType::RESOLVE_VULNERABLE_SYMBOLS_REQUEST, + ) + .attributes(ResolveVulnerableSymbolsRequestDataAttributes::new().purls(vec![])), + ); + let mut configuration = datadog::Configuration::new(); + configuration.set_unstable_operation_enabled("v2.CreateSCAResolveVulnerableSymbols", true); + let api = StaticAnalysisAPI::with_config(configuration); + let resp = api.create_sca_resolve_vulnerable_symbols(body).await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_static-analysis_CreateSCAResult.rs b/examples/v2_static-analysis_CreateSCAResult.rs new file mode 100644 index 000000000..60bc8f35f --- /dev/null +++ b/examples/v2_static-analysis_CreateSCAResult.rs @@ -0,0 +1,114 @@ +// Post dependencies for analysis returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_static_analysis::StaticAnalysisAPI; +use datadog_api_client::datadogV2::model::ScaRequest; +use datadog_api_client::datadogV2::model::ScaRequestData; +use datadog_api_client::datadogV2::model::ScaRequestDataAttributes; +use datadog_api_client::datadogV2::model::ScaRequestDataAttributesCommit; +use datadog_api_client::datadogV2::model::ScaRequestDataAttributesDependenciesItems; +use datadog_api_client::datadogV2::model::ScaRequestDataAttributesDependenciesItemsLocationsItems; +use datadog_api_client::datadogV2::model::ScaRequestDataAttributesDependenciesItemsLocationsItemsFilePosition; +use datadog_api_client::datadogV2::model::ScaRequestDataAttributesDependenciesItemsLocationsItemsPosition; +use datadog_api_client::datadogV2::model::ScaRequestDataAttributesDependenciesItemsReachableSymbolPropertiesItems; +use datadog_api_client::datadogV2::model::ScaRequestDataAttributesFilesItems; +use datadog_api_client::datadogV2::model::ScaRequestDataAttributesRelationsItems; +use datadog_api_client::datadogV2::model::ScaRequestDataAttributesRepository; +use datadog_api_client::datadogV2::model::ScaRequestDataAttributesVulnerabilitiesItems; +use datadog_api_client::datadogV2::model::ScaRequestDataAttributesVulnerabilitiesItemsAffectsItems; +use datadog_api_client::datadogV2::model::ScaRequestDataType; + +#[tokio::main] +async fn main() { + let body = + ScaRequest + ::new().data( + ScaRequestData::new( + ScaRequestDataType::SCAREQUESTS, + ).attributes( + ScaRequestDataAttributes::new() + .commit(ScaRequestDataAttributesCommit::new()) + .dependencies( + vec![ + ScaRequestDataAttributesDependenciesItems::new() + .exclusions(vec![]) + .locations( + vec![ + ScaRequestDataAttributesDependenciesItemsLocationsItems::new() + .block( + ScaRequestDataAttributesDependenciesItemsLocationsItemsFilePosition + ::new() + .end( + ScaRequestDataAttributesDependenciesItemsLocationsItemsPosition + ::new(), + ) + .start( + ScaRequestDataAttributesDependenciesItemsLocationsItemsPosition + ::new(), + ), + ) + .name( + ScaRequestDataAttributesDependenciesItemsLocationsItemsFilePosition + ::new() + .end( + ScaRequestDataAttributesDependenciesItemsLocationsItemsPosition + ::new(), + ) + .start( + ScaRequestDataAttributesDependenciesItemsLocationsItemsPosition + ::new(), + ), + ) + .namespace( + ScaRequestDataAttributesDependenciesItemsLocationsItemsFilePosition + ::new() + .end( + ScaRequestDataAttributesDependenciesItemsLocationsItemsPosition + ::new(), + ) + .start( + ScaRequestDataAttributesDependenciesItemsLocationsItemsPosition + ::new(), + ), + ) + .version( + ScaRequestDataAttributesDependenciesItemsLocationsItemsFilePosition + ::new() + .end( + ScaRequestDataAttributesDependenciesItemsLocationsItemsPosition + ::new(), + ) + .start( + ScaRequestDataAttributesDependenciesItemsLocationsItemsPosition + ::new(), + ), + ) + ], + ) + .reachable_symbol_properties( + vec![ + ScaRequestDataAttributesDependenciesItemsReachableSymbolPropertiesItems::new() + ], + ) + ], + ) + .files(vec![ScaRequestDataAttributesFilesItems::new()]) + .relations(vec![ScaRequestDataAttributesRelationsItems::new().depends_on(vec![])]) + .repository(ScaRequestDataAttributesRepository::new()) + .vulnerabilities( + vec![ + ScaRequestDataAttributesVulnerabilitiesItems + ::new().affects(vec![ScaRequestDataAttributesVulnerabilitiesItemsAffectsItems::new()]) + ], + ), + ), + ); + let mut configuration = datadog::Configuration::new(); + configuration.set_unstable_operation_enabled("v2.CreateSCAResult", true); + let api = StaticAnalysisAPI::with_config(configuration); + let resp = api.create_sca_result(body).await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/src/datadog/configuration.rs b/src/datadog/configuration.rs index 612ac9304..ac51015af 100644 --- a/src/datadog/configuration.rs +++ b/src/datadog/configuration.rs @@ -233,6 +233,8 @@ impl Default for Configuration { ("v2.get_slo_report".to_owned(), false), ("v2.get_slo_report_job_status".to_owned(), false), ("v2.get_spa_recommendations".to_owned(), false), + ("v2.create_sca_resolve_vulnerable_symbols".to_owned(), false), + ("v2.create_sca_result".to_owned(), false), ("v2.add_member_team".to_owned(), false), ("v2.list_member_teams".to_owned(), false), ("v2.remove_member_team".to_owned(), false), diff --git a/src/datadogV2/api/api_static_analysis.rs b/src/datadogV2/api/api_static_analysis.rs new file mode 100644 index 000000000..3975f2370 --- /dev/null +++ b/src/datadogV2/api/api_static_analysis.rs @@ -0,0 +1,397 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use crate::datadog; +use flate2::{ + write::{GzEncoder, ZlibEncoder}, + Compression, +}; +use log::warn; +use reqwest::header::{HeaderMap, HeaderValue}; +use serde::{Deserialize, Serialize}; +use std::io::Write; + +/// CreateSCAResolveVulnerableSymbolsError is a struct for typed errors of method [`StaticAnalysisAPI::create_sca_resolve_vulnerable_symbols`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CreateSCAResolveVulnerableSymbolsError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// CreateSCAResultError is a struct for typed errors of method [`StaticAnalysisAPI::create_sca_result`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CreateSCAResultError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// API for static analysis +#[derive(Debug, Clone)] +pub struct StaticAnalysisAPI { + config: datadog::Configuration, + client: reqwest_middleware::ClientWithMiddleware, +} + +impl Default for StaticAnalysisAPI { + fn default() -> Self { + Self::with_config(datadog::Configuration::default()) + } +} + +impl StaticAnalysisAPI { + pub fn new() -> Self { + Self::default() + } + pub fn with_config(config: datadog::Configuration) -> Self { + let mut reqwest_client_builder = reqwest::Client::builder(); + + if let Some(proxy_url) = &config.proxy_url { + let proxy = reqwest::Proxy::all(proxy_url).expect("Failed to parse proxy URL"); + reqwest_client_builder = reqwest_client_builder.proxy(proxy); + } + + let mut middleware_client_builder = + reqwest_middleware::ClientBuilder::new(reqwest_client_builder.build().unwrap()); + + if config.enable_retry { + struct RetryableStatus; + impl reqwest_retry::RetryableStrategy for RetryableStatus { + fn handle( + &self, + res: &Result, + ) -> Option { + match res { + Ok(success) => reqwest_retry::default_on_request_success(success), + Err(_) => None, + } + } + } + let backoff_policy = reqwest_retry::policies::ExponentialBackoff::builder() + .build_with_max_retries(config.max_retries); + + let retry_middleware = + reqwest_retry::RetryTransientMiddleware::new_with_policy_and_strategy( + backoff_policy, + RetryableStatus, + ); + + middleware_client_builder = middleware_client_builder.with(retry_middleware); + } + + let client = middleware_client_builder.build(); + + Self { config, client } + } + + pub fn with_client_and_config( + config: datadog::Configuration, + client: reqwest_middleware::ClientWithMiddleware, + ) -> Self { + Self { config, client } + } + + pub async fn create_sca_resolve_vulnerable_symbols( + &self, + body: crate::datadogV2::model::ResolveVulnerableSymbolsRequest, + ) -> Result< + crate::datadogV2::model::ResolveVulnerableSymbolsResponse, + datadog::Error, + > { + match self + .create_sca_resolve_vulnerable_symbols_with_http_info(body) + .await + { + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } + Err(err) => Err(err), + } + } + + pub async fn create_sca_resolve_vulnerable_symbols_with_http_info( + &self, + body: crate::datadogV2::model::ResolveVulnerableSymbolsRequest, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.create_sca_resolve_vulnerable_symbols"; + if local_configuration.is_unstable_operation_enabled(operation_id) { + warn!("Using unstable operation {operation_id}"); + } else { + let local_error = datadog::UnstableOperationDisabledError { + msg: "Operation 'v2.create_sca_resolve_vulnerable_symbols' is not enabled" + .to_string(), + }; + return Err(datadog::Error::UnstableOperationDisabledError(local_error)); + } + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/static-analysis-sca/vulnerabilities/resolve-vulnerable-symbols", + local_configuration.get_operation_host(operation_id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::POST, local_uri_str.as_str()); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Content-Type", HeaderValue::from_static("application/json")); + headers.insert("Accept", HeaderValue::from_static("application/json")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + // build body parameters + let output = Vec::new(); + let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter); + if body.serialize(&mut ser).is_ok() { + if let Some(content_encoding) = headers.get("Content-Encoding") { + match content_encoding.to_str().unwrap_or_default() { + "gzip" => { + let mut enc = GzEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "deflate" => { + let mut enc = ZlibEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "zstd1" => { + let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap(); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + _ => { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + } else { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + match serde_json::from_str::( + &local_content, + ) { + Ok(e) => { + return Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: Some(e), + }) + } + Err(e) => return Err(datadog::Error::Serde(e)), + }; + } else { + let local_entity: Option = + serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + + pub async fn create_sca_result( + &self, + body: crate::datadogV2::model::ScaRequest, + ) -> Result<(), datadog::Error> { + match self.create_sca_result_with_http_info(body).await { + Ok(_) => Ok(()), + Err(err) => Err(err), + } + } + + pub async fn create_sca_result_with_http_info( + &self, + body: crate::datadogV2::model::ScaRequest, + ) -> Result, datadog::Error> { + let local_configuration = &self.config; + let operation_id = "v2.create_sca_result"; + if local_configuration.is_unstable_operation_enabled(operation_id) { + warn!("Using unstable operation {operation_id}"); + } else { + let local_error = datadog::UnstableOperationDisabledError { + msg: "Operation 'v2.create_sca_result' is not enabled".to_string(), + }; + return Err(datadog::Error::UnstableOperationDisabledError(local_error)); + } + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/static-analysis-sca/dependencies", + local_configuration.get_operation_host(operation_id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::POST, local_uri_str.as_str()); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Content-Type", HeaderValue::from_static("application/json")); + headers.insert("Accept", HeaderValue::from_static("*/*")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + // build body parameters + let output = Vec::new(); + let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter); + if body.serialize(&mut ser).is_ok() { + if let Some(content_encoding) = headers.get("Content-Encoding") { + match content_encoding.to_str().unwrap_or_default() { + "gzip" => { + let mut enc = GzEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "deflate" => { + let mut enc = ZlibEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "zstd1" => { + let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap(); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + _ => { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + } else { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: None, + }) + } else { + let local_entity: Option = + serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } +} diff --git a/src/datadogV2/api/mod.rs b/src/datadogV2/api/mod.rs index 60421ca74..4675e95e7 100644 --- a/src/datadogV2/api/mod.rs +++ b/src/datadogV2/api/mod.rs @@ -76,6 +76,7 @@ pub mod api_software_catalog; pub mod api_spa; pub mod api_spans; pub mod api_spans_metrics; +pub mod api_static_analysis; pub mod api_synthetics; pub mod api_teams; pub mod api_test_optimization; diff --git a/src/datadogV2/mod.rs b/src/datadogV2/mod.rs index e8c51e94b..17059324e 100644 --- a/src/datadogV2/mod.rs +++ b/src/datadogV2/mod.rs @@ -77,6 +77,7 @@ pub use self::api::api_software_catalog; pub use self::api::api_spa; pub use self::api::api_spans; pub use self::api::api_spans_metrics; +pub use self::api::api_static_analysis; pub use self::api::api_synthetics; pub use self::api::api_teams; pub use self::api::api_test_optimization; diff --git a/src/datadogV2/model/mod.rs b/src/datadogV2/model/mod.rs index 8a29dac6e..14eae9e72 100644 --- a/src/datadogV2/model/mod.rs +++ b/src/datadogV2/model/mod.rs @@ -6120,6 +6120,58 @@ pub mod model_spans_list_request_page; pub use self::model_spans_list_request_page::SpansListRequestPage; pub mod model_spans_list_request_type; pub use self::model_spans_list_request_type::SpansListRequestType; +pub mod model_sca_request; +pub use self::model_sca_request::ScaRequest; +pub mod model_sca_request_data; +pub use self::model_sca_request_data::ScaRequestData; +pub mod model_sca_request_data_attributes; +pub use self::model_sca_request_data_attributes::ScaRequestDataAttributes; +pub mod model_sca_request_data_attributes_commit; +pub use self::model_sca_request_data_attributes_commit::ScaRequestDataAttributesCommit; +pub mod model_sca_request_data_attributes_dependencies_items; +pub use self::model_sca_request_data_attributes_dependencies_items::ScaRequestDataAttributesDependenciesItems; +pub mod model_sca_request_data_attributes_dependencies_items_locations_items; +pub use self::model_sca_request_data_attributes_dependencies_items_locations_items::ScaRequestDataAttributesDependenciesItemsLocationsItems; +pub mod model_sca_request_data_attributes_dependencies_items_locations_items_file_position; +pub use self::model_sca_request_data_attributes_dependencies_items_locations_items_file_position::ScaRequestDataAttributesDependenciesItemsLocationsItemsFilePosition; +pub mod model_sca_request_data_attributes_dependencies_items_locations_items_position; +pub use self::model_sca_request_data_attributes_dependencies_items_locations_items_position::ScaRequestDataAttributesDependenciesItemsLocationsItemsPosition; +pub mod model_sca_request_data_attributes_dependencies_items_reachable_symbol_properties_items; +pub use self::model_sca_request_data_attributes_dependencies_items_reachable_symbol_properties_items::ScaRequestDataAttributesDependenciesItemsReachableSymbolPropertiesItems; +pub mod model_sca_request_data_attributes_files_items; +pub use self::model_sca_request_data_attributes_files_items::ScaRequestDataAttributesFilesItems; +pub mod model_sca_request_data_attributes_relations_items; +pub use self::model_sca_request_data_attributes_relations_items::ScaRequestDataAttributesRelationsItems; +pub mod model_sca_request_data_attributes_repository; +pub use self::model_sca_request_data_attributes_repository::ScaRequestDataAttributesRepository; +pub mod model_sca_request_data_attributes_vulnerabilities_items; +pub use self::model_sca_request_data_attributes_vulnerabilities_items::ScaRequestDataAttributesVulnerabilitiesItems; +pub mod model_sca_request_data_attributes_vulnerabilities_items_affects_items; +pub use self::model_sca_request_data_attributes_vulnerabilities_items_affects_items::ScaRequestDataAttributesVulnerabilitiesItemsAffectsItems; +pub mod model_sca_request_data_type; +pub use self::model_sca_request_data_type::ScaRequestDataType; +pub mod model_resolve_vulnerable_symbols_request; +pub use self::model_resolve_vulnerable_symbols_request::ResolveVulnerableSymbolsRequest; +pub mod model_resolve_vulnerable_symbols_request_data; +pub use self::model_resolve_vulnerable_symbols_request_data::ResolveVulnerableSymbolsRequestData; +pub mod model_resolve_vulnerable_symbols_request_data_attributes; +pub use self::model_resolve_vulnerable_symbols_request_data_attributes::ResolveVulnerableSymbolsRequestDataAttributes; +pub mod model_resolve_vulnerable_symbols_request_data_type; +pub use self::model_resolve_vulnerable_symbols_request_data_type::ResolveVulnerableSymbolsRequestDataType; +pub mod model_resolve_vulnerable_symbols_response; +pub use self::model_resolve_vulnerable_symbols_response::ResolveVulnerableSymbolsResponse; +pub mod model_resolve_vulnerable_symbols_response_data; +pub use self::model_resolve_vulnerable_symbols_response_data::ResolveVulnerableSymbolsResponseData; +pub mod model_resolve_vulnerable_symbols_response_data_attributes; +pub use self::model_resolve_vulnerable_symbols_response_data_attributes::ResolveVulnerableSymbolsResponseDataAttributes; +pub mod model_resolve_vulnerable_symbols_response_results; +pub use self::model_resolve_vulnerable_symbols_response_results::ResolveVulnerableSymbolsResponseResults; +pub mod model_resolve_vulnerable_symbols_response_results_vulnerable_symbols; +pub use self::model_resolve_vulnerable_symbols_response_results_vulnerable_symbols::ResolveVulnerableSymbolsResponseResultsVulnerableSymbols; +pub mod model_resolve_vulnerable_symbols_response_results_vulnerable_symbols_symbols; +pub use self::model_resolve_vulnerable_symbols_response_results_vulnerable_symbols_symbols::ResolveVulnerableSymbolsResponseResultsVulnerableSymbolsSymbols; +pub mod model_resolve_vulnerable_symbols_response_data_type; +pub use self::model_resolve_vulnerable_symbols_response_data_type::ResolveVulnerableSymbolsResponseDataType; pub mod model_on_demand_concurrency_cap_response; pub use self::model_on_demand_concurrency_cap_response::OnDemandConcurrencyCapResponse; pub mod model_on_demand_concurrency_cap; diff --git a/src/datadogV2/model/model_resolve_vulnerable_symbols_request.rs b/src/datadogV2/model/model_resolve_vulnerable_symbols_request.rs new file mode 100644 index 000000000..255a56717 --- /dev/null +++ b/src/datadogV2/model/model_resolve_vulnerable_symbols_request.rs @@ -0,0 +1,107 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct ResolveVulnerableSymbolsRequest { + #[serde(rename = "data")] + pub data: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl ResolveVulnerableSymbolsRequest { + pub fn new() -> ResolveVulnerableSymbolsRequest { + ResolveVulnerableSymbolsRequest { + data: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn data( + mut self, + value: crate::datadogV2::model::ResolveVulnerableSymbolsRequestData, + ) -> Self { + self.data = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for ResolveVulnerableSymbolsRequest { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for ResolveVulnerableSymbolsRequest { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct ResolveVulnerableSymbolsRequestVisitor; + impl<'a> Visitor<'a> for ResolveVulnerableSymbolsRequestVisitor { + type Value = ResolveVulnerableSymbolsRequest; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option = + None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + if v.is_null() { + continue; + } + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = ResolveVulnerableSymbolsRequest { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(ResolveVulnerableSymbolsRequestVisitor) + } +} diff --git a/src/datadogV2/model/model_resolve_vulnerable_symbols_request_data.rs b/src/datadogV2/model/model_resolve_vulnerable_symbols_request_data.rs new file mode 100644 index 000000000..77d11208d --- /dev/null +++ b/src/datadogV2/model/model_resolve_vulnerable_symbols_request_data.rs @@ -0,0 +1,139 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct ResolveVulnerableSymbolsRequestData { + #[serde(rename = "attributes")] + pub attributes: Option, + #[serde(rename = "id")] + pub id: Option, + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::ResolveVulnerableSymbolsRequestDataType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl ResolveVulnerableSymbolsRequestData { + pub fn new( + type_: crate::datadogV2::model::ResolveVulnerableSymbolsRequestDataType, + ) -> ResolveVulnerableSymbolsRequestData { + ResolveVulnerableSymbolsRequestData { + attributes: None, + id: None, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn attributes( + mut self, + value: crate::datadogV2::model::ResolveVulnerableSymbolsRequestDataAttributes, + ) -> Self { + self.attributes = Some(value); + self + } + + pub fn id(mut self, value: String) -> Self { + self.id = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for ResolveVulnerableSymbolsRequestData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct ResolveVulnerableSymbolsRequestDataVisitor; + impl<'a> Visitor<'a> for ResolveVulnerableSymbolsRequestDataVisitor { + type Value = ResolveVulnerableSymbolsRequestData; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut attributes: Option< + crate::datadogV2::model::ResolveVulnerableSymbolsRequestDataAttributes, + > = None; + let mut id: Option = None; + let mut type_: Option< + crate::datadogV2::model::ResolveVulnerableSymbolsRequestDataType, + > = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "attributes" => { + if v.is_null() { + continue; + } + attributes = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "id" => { + if v.is_null() { + continue; + } + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::ResolveVulnerableSymbolsRequestDataType::UnparsedObject(_type_) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = ResolveVulnerableSymbolsRequestData { + attributes, + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(ResolveVulnerableSymbolsRequestDataVisitor) + } +} diff --git a/src/datadogV2/model/model_resolve_vulnerable_symbols_request_data_attributes.rs b/src/datadogV2/model/model_resolve_vulnerable_symbols_request_data_attributes.rs new file mode 100644 index 000000000..3ccf48476 --- /dev/null +++ b/src/datadogV2/model/model_resolve_vulnerable_symbols_request_data_attributes.rs @@ -0,0 +1,103 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct ResolveVulnerableSymbolsRequestDataAttributes { + #[serde(rename = "purls")] + pub purls: Option>, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl ResolveVulnerableSymbolsRequestDataAttributes { + pub fn new() -> ResolveVulnerableSymbolsRequestDataAttributes { + ResolveVulnerableSymbolsRequestDataAttributes { + purls: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn purls(mut self, value: Vec) -> Self { + self.purls = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for ResolveVulnerableSymbolsRequestDataAttributes { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for ResolveVulnerableSymbolsRequestDataAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct ResolveVulnerableSymbolsRequestDataAttributesVisitor; + impl<'a> Visitor<'a> for ResolveVulnerableSymbolsRequestDataAttributesVisitor { + type Value = ResolveVulnerableSymbolsRequestDataAttributes; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut purls: Option> = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "purls" => { + if v.is_null() { + continue; + } + purls = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = ResolveVulnerableSymbolsRequestDataAttributes { + purls, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(ResolveVulnerableSymbolsRequestDataAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_resolve_vulnerable_symbols_request_data_type.rs b/src/datadogV2/model/model_resolve_vulnerable_symbols_request_data_type.rs new file mode 100644 index 000000000..7785d3d09 --- /dev/null +++ b/src/datadogV2/model/model_resolve_vulnerable_symbols_request_data_type.rs @@ -0,0 +1,50 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +use serde::{Deserialize, Deserializer, Serialize, Serializer}; + +#[non_exhaustive] +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum ResolveVulnerableSymbolsRequestDataType { + RESOLVE_VULNERABLE_SYMBOLS_REQUEST, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for ResolveVulnerableSymbolsRequestDataType { + fn to_string(&self) -> String { + match self { + Self::RESOLVE_VULNERABLE_SYMBOLS_REQUEST => { + String::from("resolve-vulnerable-symbols-request") + } + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for ResolveVulnerableSymbolsRequestDataType { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match self { + Self::UnparsedObject(v) => v.serialize(serializer), + _ => serializer.serialize_str(self.to_string().as_str()), + } + } +} + +impl<'de> Deserialize<'de> for ResolveVulnerableSymbolsRequestDataType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "resolve-vulnerable-symbols-request" => Self::RESOLVE_VULNERABLE_SYMBOLS_REQUEST, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_resolve_vulnerable_symbols_response.rs b/src/datadogV2/model/model_resolve_vulnerable_symbols_response.rs new file mode 100644 index 000000000..55fe0ffc5 --- /dev/null +++ b/src/datadogV2/model/model_resolve_vulnerable_symbols_response.rs @@ -0,0 +1,108 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct ResolveVulnerableSymbolsResponse { + #[serde(rename = "data")] + pub data: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl ResolveVulnerableSymbolsResponse { + pub fn new() -> ResolveVulnerableSymbolsResponse { + ResolveVulnerableSymbolsResponse { + data: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn data( + mut self, + value: crate::datadogV2::model::ResolveVulnerableSymbolsResponseData, + ) -> Self { + self.data = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for ResolveVulnerableSymbolsResponse { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for ResolveVulnerableSymbolsResponse { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct ResolveVulnerableSymbolsResponseVisitor; + impl<'a> Visitor<'a> for ResolveVulnerableSymbolsResponseVisitor { + type Value = ResolveVulnerableSymbolsResponse; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option< + crate::datadogV2::model::ResolveVulnerableSymbolsResponseData, + > = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + if v.is_null() { + continue; + } + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = ResolveVulnerableSymbolsResponse { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(ResolveVulnerableSymbolsResponseVisitor) + } +} diff --git a/src/datadogV2/model/model_resolve_vulnerable_symbols_response_data.rs b/src/datadogV2/model/model_resolve_vulnerable_symbols_response_data.rs new file mode 100644 index 000000000..cc0d3f3dd --- /dev/null +++ b/src/datadogV2/model/model_resolve_vulnerable_symbols_response_data.rs @@ -0,0 +1,139 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct ResolveVulnerableSymbolsResponseData { + #[serde(rename = "attributes")] + pub attributes: Option, + #[serde(rename = "id")] + pub id: Option, + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::ResolveVulnerableSymbolsResponseDataType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl ResolveVulnerableSymbolsResponseData { + pub fn new( + type_: crate::datadogV2::model::ResolveVulnerableSymbolsResponseDataType, + ) -> ResolveVulnerableSymbolsResponseData { + ResolveVulnerableSymbolsResponseData { + attributes: None, + id: None, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn attributes( + mut self, + value: crate::datadogV2::model::ResolveVulnerableSymbolsResponseDataAttributes, + ) -> Self { + self.attributes = Some(value); + self + } + + pub fn id(mut self, value: String) -> Self { + self.id = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for ResolveVulnerableSymbolsResponseData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct ResolveVulnerableSymbolsResponseDataVisitor; + impl<'a> Visitor<'a> for ResolveVulnerableSymbolsResponseDataVisitor { + type Value = ResolveVulnerableSymbolsResponseData; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut attributes: Option< + crate::datadogV2::model::ResolveVulnerableSymbolsResponseDataAttributes, + > = None; + let mut id: Option = None; + let mut type_: Option< + crate::datadogV2::model::ResolveVulnerableSymbolsResponseDataType, + > = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "attributes" => { + if v.is_null() { + continue; + } + attributes = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "id" => { + if v.is_null() { + continue; + } + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::ResolveVulnerableSymbolsResponseDataType::UnparsedObject(_type_) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = ResolveVulnerableSymbolsResponseData { + attributes, + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(ResolveVulnerableSymbolsResponseDataVisitor) + } +} diff --git a/src/datadogV2/model/model_resolve_vulnerable_symbols_response_data_attributes.rs b/src/datadogV2/model/model_resolve_vulnerable_symbols_response_data_attributes.rs new file mode 100644 index 000000000..ddabbd303 --- /dev/null +++ b/src/datadogV2/model/model_resolve_vulnerable_symbols_response_data_attributes.rs @@ -0,0 +1,108 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct ResolveVulnerableSymbolsResponseDataAttributes { + #[serde(rename = "results")] + pub results: Option>, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl ResolveVulnerableSymbolsResponseDataAttributes { + pub fn new() -> ResolveVulnerableSymbolsResponseDataAttributes { + ResolveVulnerableSymbolsResponseDataAttributes { + results: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn results( + mut self, + value: Vec, + ) -> Self { + self.results = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for ResolveVulnerableSymbolsResponseDataAttributes { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for ResolveVulnerableSymbolsResponseDataAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct ResolveVulnerableSymbolsResponseDataAttributesVisitor; + impl<'a> Visitor<'a> for ResolveVulnerableSymbolsResponseDataAttributesVisitor { + type Value = ResolveVulnerableSymbolsResponseDataAttributes; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut results: Option< + Vec, + > = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "results" => { + if v.is_null() { + continue; + } + results = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = ResolveVulnerableSymbolsResponseDataAttributes { + results, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(ResolveVulnerableSymbolsResponseDataAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_resolve_vulnerable_symbols_response_data_type.rs b/src/datadogV2/model/model_resolve_vulnerable_symbols_response_data_type.rs new file mode 100644 index 000000000..92be7239c --- /dev/null +++ b/src/datadogV2/model/model_resolve_vulnerable_symbols_response_data_type.rs @@ -0,0 +1,50 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +use serde::{Deserialize, Deserializer, Serialize, Serializer}; + +#[non_exhaustive] +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum ResolveVulnerableSymbolsResponseDataType { + RESOLVE_VULNERABLE_SYMBOLS_RESPONSE, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for ResolveVulnerableSymbolsResponseDataType { + fn to_string(&self) -> String { + match self { + Self::RESOLVE_VULNERABLE_SYMBOLS_RESPONSE => { + String::from("resolve-vulnerable-symbols-response") + } + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for ResolveVulnerableSymbolsResponseDataType { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match self { + Self::UnparsedObject(v) => v.serialize(serializer), + _ => serializer.serialize_str(self.to_string().as_str()), + } + } +} + +impl<'de> Deserialize<'de> for ResolveVulnerableSymbolsResponseDataType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "resolve-vulnerable-symbols-response" => Self::RESOLVE_VULNERABLE_SYMBOLS_RESPONSE, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_resolve_vulnerable_symbols_response_results.rs b/src/datadogV2/model/model_resolve_vulnerable_symbols_response_results.rs new file mode 100644 index 000000000..c260c921f --- /dev/null +++ b/src/datadogV2/model/model_resolve_vulnerable_symbols_response_results.rs @@ -0,0 +1,127 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct ResolveVulnerableSymbolsResponseResults { + #[serde(rename = "purl")] + pub purl: Option, + #[serde(rename = "vulnerable_symbols")] + pub vulnerable_symbols: Option< + Vec, + >, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl ResolveVulnerableSymbolsResponseResults { + pub fn new() -> ResolveVulnerableSymbolsResponseResults { + ResolveVulnerableSymbolsResponseResults { + purl: None, + vulnerable_symbols: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn purl(mut self, value: String) -> Self { + self.purl = Some(value); + self + } + + pub fn vulnerable_symbols( + mut self, + value: Vec< + crate::datadogV2::model::ResolveVulnerableSymbolsResponseResultsVulnerableSymbols, + >, + ) -> Self { + self.vulnerable_symbols = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for ResolveVulnerableSymbolsResponseResults { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for ResolveVulnerableSymbolsResponseResults { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct ResolveVulnerableSymbolsResponseResultsVisitor; + impl<'a> Visitor<'a> for ResolveVulnerableSymbolsResponseResultsVisitor { + type Value = ResolveVulnerableSymbolsResponseResults; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut purl: Option = None; + let mut vulnerable_symbols: Option> = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "purl" => { + if v.is_null() { + continue; + } + purl = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "vulnerable_symbols" => { + if v.is_null() { + continue; + } + vulnerable_symbols = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = ResolveVulnerableSymbolsResponseResults { + purl, + vulnerable_symbols, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(ResolveVulnerableSymbolsResponseResultsVisitor) + } +} diff --git a/src/datadogV2/model/model_resolve_vulnerable_symbols_response_results_vulnerable_symbols.rs b/src/datadogV2/model/model_resolve_vulnerable_symbols_response_results_vulnerable_symbols.rs new file mode 100644 index 000000000..3517ef78b --- /dev/null +++ b/src/datadogV2/model/model_resolve_vulnerable_symbols_response_results_vulnerable_symbols.rs @@ -0,0 +1,124 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct ResolveVulnerableSymbolsResponseResultsVulnerableSymbols { + #[serde(rename = "advisory_id")] + pub advisory_id: Option, + #[serde(rename = "symbols")] + pub symbols: Option>, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool +} + +impl ResolveVulnerableSymbolsResponseResultsVulnerableSymbols { + pub fn new() -> ResolveVulnerableSymbolsResponseResultsVulnerableSymbols { + ResolveVulnerableSymbolsResponseResultsVulnerableSymbols { + advisory_id: None, + symbols: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn advisory_id(mut self, value: String) -> Self { + self.advisory_id = Some(value); + self + } + + pub fn symbols( + mut self, + value: Vec, + ) -> Self { + self.symbols = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for ResolveVulnerableSymbolsResponseResultsVulnerableSymbols { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for ResolveVulnerableSymbolsResponseResultsVulnerableSymbols { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct ResolveVulnerableSymbolsResponseResultsVulnerableSymbolsVisitor; + impl<'a> Visitor<'a> for ResolveVulnerableSymbolsResponseResultsVulnerableSymbolsVisitor { + type Value = ResolveVulnerableSymbolsResponseResultsVulnerableSymbols; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut advisory_id: Option = None; + let mut symbols: Option> = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "advisory_id" => { + if v.is_null() { + continue; + } + advisory_id = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "symbols" => { + if v.is_null() { + continue; + } + symbols = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = ResolveVulnerableSymbolsResponseResultsVulnerableSymbols { + advisory_id, + symbols, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer + .deserialize_any(ResolveVulnerableSymbolsResponseResultsVulnerableSymbolsVisitor) + } +} diff --git a/src/datadogV2/model/model_resolve_vulnerable_symbols_response_results_vulnerable_symbols_symbols.rs b/src/datadogV2/model/model_resolve_vulnerable_symbols_response_results_vulnerable_symbols_symbols.rs new file mode 100644 index 000000000..b7bf65ce0 --- /dev/null +++ b/src/datadogV2/model/model_resolve_vulnerable_symbols_response_results_vulnerable_symbols_symbols.rs @@ -0,0 +1,136 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct ResolveVulnerableSymbolsResponseResultsVulnerableSymbolsSymbols { + #[serde(rename = "name")] + pub name: Option, + #[serde(rename = "type")] + pub type_: Option, + #[serde(rename = "value")] + pub value: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl ResolveVulnerableSymbolsResponseResultsVulnerableSymbolsSymbols { + pub fn new() -> ResolveVulnerableSymbolsResponseResultsVulnerableSymbolsSymbols { + ResolveVulnerableSymbolsResponseResultsVulnerableSymbolsSymbols { + name: None, + type_: None, + value: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn name(mut self, value: String) -> Self { + self.name = Some(value); + self + } + + pub fn type_(mut self, value: String) -> Self { + self.type_ = Some(value); + self + } + + pub fn value(mut self, value: String) -> Self { + self.value = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for ResolveVulnerableSymbolsResponseResultsVulnerableSymbolsSymbols { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for ResolveVulnerableSymbolsResponseResultsVulnerableSymbolsSymbols { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct ResolveVulnerableSymbolsResponseResultsVulnerableSymbolsSymbolsVisitor; + impl<'a> Visitor<'a> for ResolveVulnerableSymbolsResponseResultsVulnerableSymbolsSymbolsVisitor { + type Value = ResolveVulnerableSymbolsResponseResultsVulnerableSymbolsSymbols; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut name: Option = None; + let mut type_: Option = None; + let mut value: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "name" => { + if v.is_null() { + continue; + } + name = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + if v.is_null() { + continue; + } + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "value" => { + if v.is_null() { + continue; + } + value = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = ResolveVulnerableSymbolsResponseResultsVulnerableSymbolsSymbols { + name, + type_, + value, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer + .deserialize_any(ResolveVulnerableSymbolsResponseResultsVulnerableSymbolsSymbolsVisitor) + } +} diff --git a/src/datadogV2/model/model_sca_request.rs b/src/datadogV2/model/model_sca_request.rs new file mode 100644 index 000000000..58bde5083 --- /dev/null +++ b/src/datadogV2/model/model_sca_request.rs @@ -0,0 +1,103 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct ScaRequest { + #[serde(rename = "data")] + pub data: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl ScaRequest { + pub fn new() -> ScaRequest { + ScaRequest { + data: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn data(mut self, value: crate::datadogV2::model::ScaRequestData) -> Self { + self.data = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for ScaRequest { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for ScaRequest { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct ScaRequestVisitor; + impl<'a> Visitor<'a> for ScaRequestVisitor { + type Value = ScaRequest; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + if v.is_null() { + continue; + } + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = ScaRequest { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(ScaRequestVisitor) + } +} diff --git a/src/datadogV2/model/model_sca_request_data.rs b/src/datadogV2/model/model_sca_request_data.rs new file mode 100644 index 000000000..1ee08b1fd --- /dev/null +++ b/src/datadogV2/model/model_sca_request_data.rs @@ -0,0 +1,133 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct ScaRequestData { + #[serde(rename = "attributes")] + pub attributes: Option, + #[serde(rename = "id")] + pub id: Option, + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::ScaRequestDataType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl ScaRequestData { + pub fn new(type_: crate::datadogV2::model::ScaRequestDataType) -> ScaRequestData { + ScaRequestData { + attributes: None, + id: None, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn attributes(mut self, value: crate::datadogV2::model::ScaRequestDataAttributes) -> Self { + self.attributes = Some(value); + self + } + + pub fn id(mut self, value: String) -> Self { + self.id = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for ScaRequestData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct ScaRequestDataVisitor; + impl<'a> Visitor<'a> for ScaRequestDataVisitor { + type Value = ScaRequestData; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut attributes: Option = + None; + let mut id: Option = None; + let mut type_: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "attributes" => { + if v.is_null() { + continue; + } + attributes = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "id" => { + if v.is_null() { + continue; + } + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::ScaRequestDataType::UnparsedObject( + _type_, + ) => { + _unparsed = true; + } + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = ScaRequestData { + attributes, + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(ScaRequestDataVisitor) + } +} diff --git a/src/datadogV2/model/model_sca_request_data_attributes.rs b/src/datadogV2/model/model_sca_request_data_attributes.rs new file mode 100644 index 000000000..7ecf2ab29 --- /dev/null +++ b/src/datadogV2/model/model_sca_request_data_attributes.rs @@ -0,0 +1,264 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct ScaRequestDataAttributes { + #[serde(rename = "commit")] + pub commit: Option, + #[serde(rename = "dependencies")] + pub dependencies: + Option>, + #[serde(rename = "env")] + pub env: Option, + #[serde(rename = "files")] + pub files: Option>, + #[serde(rename = "relations")] + pub relations: Option>, + #[serde(rename = "repository")] + pub repository: Option, + #[serde(rename = "service")] + pub service: Option, + #[serde(rename = "tags")] + pub tags: Option>, + #[serde(rename = "vulnerabilities")] + pub vulnerabilities: + Option>, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl ScaRequestDataAttributes { + pub fn new() -> ScaRequestDataAttributes { + ScaRequestDataAttributes { + commit: None, + dependencies: None, + env: None, + files: None, + relations: None, + repository: None, + service: None, + tags: None, + vulnerabilities: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn commit( + mut self, + value: crate::datadogV2::model::ScaRequestDataAttributesCommit, + ) -> Self { + self.commit = Some(value); + self + } + + pub fn dependencies( + mut self, + value: Vec, + ) -> Self { + self.dependencies = Some(value); + self + } + + pub fn env(mut self, value: String) -> Self { + self.env = Some(value); + self + } + + pub fn files( + mut self, + value: Vec, + ) -> Self { + self.files = Some(value); + self + } + + pub fn relations( + mut self, + value: Vec, + ) -> Self { + self.relations = Some(value); + self + } + + pub fn repository( + mut self, + value: crate::datadogV2::model::ScaRequestDataAttributesRepository, + ) -> Self { + self.repository = Some(value); + self + } + + pub fn service(mut self, value: String) -> Self { + self.service = Some(value); + self + } + + pub fn tags(mut self, value: std::collections::BTreeMap) -> Self { + self.tags = Some(value); + self + } + + pub fn vulnerabilities( + mut self, + value: Vec, + ) -> Self { + self.vulnerabilities = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for ScaRequestDataAttributes { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for ScaRequestDataAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct ScaRequestDataAttributesVisitor; + impl<'a> Visitor<'a> for ScaRequestDataAttributesVisitor { + type Value = ScaRequestDataAttributes; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut commit: Option = + None; + let mut dependencies: Option< + Vec, + > = None; + let mut env: Option = None; + let mut files: Option< + Vec, + > = None; + let mut relations: Option< + Vec, + > = None; + let mut repository: Option< + crate::datadogV2::model::ScaRequestDataAttributesRepository, + > = None; + let mut service: Option = None; + let mut tags: Option> = None; + let mut vulnerabilities: Option< + Vec, + > = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "commit" => { + if v.is_null() { + continue; + } + commit = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "dependencies" => { + if v.is_null() { + continue; + } + dependencies = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "env" => { + if v.is_null() { + continue; + } + env = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "files" => { + if v.is_null() { + continue; + } + files = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "relations" => { + if v.is_null() { + continue; + } + relations = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "repository" => { + if v.is_null() { + continue; + } + repository = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "service" => { + if v.is_null() { + continue; + } + service = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "tags" => { + if v.is_null() { + continue; + } + tags = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "vulnerabilities" => { + if v.is_null() { + continue; + } + vulnerabilities = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = ScaRequestDataAttributes { + commit, + dependencies, + env, + files, + relations, + repository, + service, + tags, + vulnerabilities, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(ScaRequestDataAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_sca_request_data_attributes_commit.rs b/src/datadogV2/model/model_sca_request_data_attributes_commit.rs new file mode 100644 index 000000000..423f263c4 --- /dev/null +++ b/src/datadogV2/model/model_sca_request_data_attributes_commit.rs @@ -0,0 +1,204 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct ScaRequestDataAttributesCommit { + #[serde(rename = "author_date")] + pub author_date: Option, + #[serde(rename = "author_email")] + pub author_email: Option, + #[serde(rename = "author_name")] + pub author_name: Option, + #[serde(rename = "branch")] + pub branch: Option, + #[serde(rename = "committer_email")] + pub committer_email: Option, + #[serde(rename = "committer_name")] + pub committer_name: Option, + #[serde(rename = "sha")] + pub sha: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl ScaRequestDataAttributesCommit { + pub fn new() -> ScaRequestDataAttributesCommit { + ScaRequestDataAttributesCommit { + author_date: None, + author_email: None, + author_name: None, + branch: None, + committer_email: None, + committer_name: None, + sha: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn author_date(mut self, value: String) -> Self { + self.author_date = Some(value); + self + } + + pub fn author_email(mut self, value: String) -> Self { + self.author_email = Some(value); + self + } + + pub fn author_name(mut self, value: String) -> Self { + self.author_name = Some(value); + self + } + + pub fn branch(mut self, value: String) -> Self { + self.branch = Some(value); + self + } + + pub fn committer_email(mut self, value: String) -> Self { + self.committer_email = Some(value); + self + } + + pub fn committer_name(mut self, value: String) -> Self { + self.committer_name = Some(value); + self + } + + pub fn sha(mut self, value: String) -> Self { + self.sha = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for ScaRequestDataAttributesCommit { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for ScaRequestDataAttributesCommit { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct ScaRequestDataAttributesCommitVisitor; + impl<'a> Visitor<'a> for ScaRequestDataAttributesCommitVisitor { + type Value = ScaRequestDataAttributesCommit; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut author_date: Option = None; + let mut author_email: Option = None; + let mut author_name: Option = None; + let mut branch: Option = None; + let mut committer_email: Option = None; + let mut committer_name: Option = None; + let mut sha: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "author_date" => { + if v.is_null() { + continue; + } + author_date = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "author_email" => { + if v.is_null() { + continue; + } + author_email = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "author_name" => { + if v.is_null() { + continue; + } + author_name = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "branch" => { + if v.is_null() { + continue; + } + branch = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "committer_email" => { + if v.is_null() { + continue; + } + committer_email = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "committer_name" => { + if v.is_null() { + continue; + } + committer_name = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "sha" => { + if v.is_null() { + continue; + } + sha = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = ScaRequestDataAttributesCommit { + author_date, + author_email, + author_name, + branch, + committer_email, + committer_name, + sha, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(ScaRequestDataAttributesCommitVisitor) + } +} diff --git a/src/datadogV2/model/model_sca_request_data_attributes_dependencies_items.rs b/src/datadogV2/model/model_sca_request_data_attributes_dependencies_items.rs new file mode 100644 index 000000000..7d8f46730 --- /dev/null +++ b/src/datadogV2/model/model_sca_request_data_attributes_dependencies_items.rs @@ -0,0 +1,273 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct ScaRequestDataAttributesDependenciesItems { + #[serde(rename = "exclusions")] + pub exclusions: Option>, + #[serde(rename = "group")] + pub group: Option, + #[serde(rename = "is_dev")] + pub is_dev: Option, + #[serde(rename = "is_direct")] + pub is_direct: Option, + #[serde(rename = "language")] + pub language: Option, + #[serde(rename = "locations")] + pub locations: Option>, + #[serde(rename = "name")] + pub name: Option, + #[serde(rename = "package_manager")] + pub package_manager: Option, + #[serde(rename = "purl")] + pub purl: Option, + #[serde(rename = "reachable_symbol_properties")] + pub reachable_symbol_properties: Option>, + #[serde(rename = "version")] + pub version: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool +} + +impl ScaRequestDataAttributesDependenciesItems { + pub fn new() -> ScaRequestDataAttributesDependenciesItems { + ScaRequestDataAttributesDependenciesItems { + exclusions: None, + group: None, + is_dev: None, + is_direct: None, + language: None, + locations: None, + name: None, + package_manager: None, + purl: None, + reachable_symbol_properties: None, + version: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn exclusions(mut self, value: Vec) -> Self { + self.exclusions = Some(value); + self + } + + pub fn group(mut self, value: String) -> Self { + self.group = Some(value); + self + } + + pub fn is_dev(mut self, value: bool) -> Self { + self.is_dev = Some(value); + self + } + + pub fn is_direct(mut self, value: bool) -> Self { + self.is_direct = Some(value); + self + } + + pub fn language(mut self, value: String) -> Self { + self.language = Some(value); + self + } + + pub fn locations( + mut self, + value: Vec< + crate::datadogV2::model::ScaRequestDataAttributesDependenciesItemsLocationsItems, + >, + ) -> Self { + self.locations = Some(value); + self + } + + pub fn name(mut self, value: String) -> Self { + self.name = Some(value); + self + } + + pub fn package_manager(mut self, value: String) -> Self { + self.package_manager = Some(value); + self + } + + pub fn purl(mut self, value: String) -> Self { + self.purl = Some(value); + self + } + + pub fn reachable_symbol_properties( + mut self, + value: Vec, + ) -> Self { + self.reachable_symbol_properties = Some(value); + self + } + + pub fn version(mut self, value: String) -> Self { + self.version = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for ScaRequestDataAttributesDependenciesItems { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for ScaRequestDataAttributesDependenciesItems { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct ScaRequestDataAttributesDependenciesItemsVisitor; + impl<'a> Visitor<'a> for ScaRequestDataAttributesDependenciesItemsVisitor { + type Value = ScaRequestDataAttributesDependenciesItems; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut exclusions: Option> = None; + let mut group: Option = None; + let mut is_dev: Option = None; + let mut is_direct: Option = None; + let mut language: Option = None; + let mut locations: Option> = None; + let mut name: Option = None; + let mut package_manager: Option = None; + let mut purl: Option = None; + let mut reachable_symbol_properties: Option> = None; + let mut version: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "exclusions" => { + if v.is_null() { + continue; + } + exclusions = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "group" => { + if v.is_null() { + continue; + } + group = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "is_dev" => { + if v.is_null() { + continue; + } + is_dev = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "is_direct" => { + if v.is_null() { + continue; + } + is_direct = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "language" => { + if v.is_null() { + continue; + } + language = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "locations" => { + if v.is_null() { + continue; + } + locations = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "name" => { + if v.is_null() { + continue; + } + name = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "package_manager" => { + if v.is_null() { + continue; + } + package_manager = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "purl" => { + if v.is_null() { + continue; + } + purl = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "reachable_symbol_properties" => { + if v.is_null() { + continue; + } + reachable_symbol_properties = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "version" => { + if v.is_null() { + continue; + } + version = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = ScaRequestDataAttributesDependenciesItems { + exclusions, + group, + is_dev, + is_direct, + language, + locations, + name, + package_manager, + purl, + reachable_symbol_properties, + version, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(ScaRequestDataAttributesDependenciesItemsVisitor) + } +} diff --git a/src/datadogV2/model/model_sca_request_data_attributes_dependencies_items_locations_items.rs b/src/datadogV2/model/model_sca_request_data_attributes_dependencies_items_locations_items.rs new file mode 100644 index 000000000..f2380f2f6 --- /dev/null +++ b/src/datadogV2/model/model_sca_request_data_attributes_dependencies_items_locations_items.rs @@ -0,0 +1,163 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct ScaRequestDataAttributesDependenciesItemsLocationsItems { + #[serde(rename = "block")] + pub block: Option, + #[serde(rename = "name")] + pub name: Option, + #[serde(rename = "namespace")] + pub namespace: Option, + #[serde(rename = "version")] + pub version: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool +} + +impl ScaRequestDataAttributesDependenciesItemsLocationsItems { + pub fn new() -> ScaRequestDataAttributesDependenciesItemsLocationsItems { + ScaRequestDataAttributesDependenciesItemsLocationsItems { + block: None, + name: None, + namespace: None, + version: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn block( + mut self, + value: crate::datadogV2::model::ScaRequestDataAttributesDependenciesItemsLocationsItemsFilePosition, + ) -> Self { + self.block = Some(value); + self + } + + pub fn name( + mut self, + value: crate::datadogV2::model::ScaRequestDataAttributesDependenciesItemsLocationsItemsFilePosition, + ) -> Self { + self.name = Some(value); + self + } + + pub fn namespace( + mut self, + value: crate::datadogV2::model::ScaRequestDataAttributesDependenciesItemsLocationsItemsFilePosition, + ) -> Self { + self.namespace = Some(value); + self + } + + pub fn version( + mut self, + value: crate::datadogV2::model::ScaRequestDataAttributesDependenciesItemsLocationsItemsFilePosition, + ) -> Self { + self.version = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for ScaRequestDataAttributesDependenciesItemsLocationsItems { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for ScaRequestDataAttributesDependenciesItemsLocationsItems { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct ScaRequestDataAttributesDependenciesItemsLocationsItemsVisitor; + impl<'a> Visitor<'a> for ScaRequestDataAttributesDependenciesItemsLocationsItemsVisitor { + type Value = ScaRequestDataAttributesDependenciesItemsLocationsItems; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut block: Option = None; + let mut name: Option = None; + let mut namespace: Option = None; + let mut version: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "block" => { + if v.is_null() { + continue; + } + block = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "name" => { + if v.is_null() { + continue; + } + name = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "namespace" => { + if v.is_null() { + continue; + } + namespace = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "version" => { + if v.is_null() { + continue; + } + version = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = ScaRequestDataAttributesDependenciesItemsLocationsItems { + block, + name, + namespace, + version, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(ScaRequestDataAttributesDependenciesItemsLocationsItemsVisitor) + } +} diff --git a/src/datadogV2/model/model_sca_request_data_attributes_dependencies_items_locations_items_file_position.rs b/src/datadogV2/model/model_sca_request_data_attributes_dependencies_items_locations_items_file_position.rs new file mode 100644 index 000000000..2bccd65a7 --- /dev/null +++ b/src/datadogV2/model/model_sca_request_data_attributes_dependencies_items_locations_items_file_position.rs @@ -0,0 +1,149 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct ScaRequestDataAttributesDependenciesItemsLocationsItemsFilePosition { + #[serde(rename = "end")] + pub end: Option< + crate::datadogV2::model::ScaRequestDataAttributesDependenciesItemsLocationsItemsPosition, + >, + #[serde(rename = "file_name")] + pub file_name: Option, + #[serde(rename = "start")] + pub start: Option< + crate::datadogV2::model::ScaRequestDataAttributesDependenciesItemsLocationsItemsPosition, + >, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl ScaRequestDataAttributesDependenciesItemsLocationsItemsFilePosition { + pub fn new() -> ScaRequestDataAttributesDependenciesItemsLocationsItemsFilePosition { + ScaRequestDataAttributesDependenciesItemsLocationsItemsFilePosition { + end: None, + file_name: None, + start: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn end( + mut self, + value: crate::datadogV2::model::ScaRequestDataAttributesDependenciesItemsLocationsItemsPosition, + ) -> Self { + self.end = Some(value); + self + } + + pub fn file_name(mut self, value: String) -> Self { + self.file_name = Some(value); + self + } + + pub fn start( + mut self, + value: crate::datadogV2::model::ScaRequestDataAttributesDependenciesItemsLocationsItemsPosition, + ) -> Self { + self.start = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for ScaRequestDataAttributesDependenciesItemsLocationsItemsFilePosition { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for ScaRequestDataAttributesDependenciesItemsLocationsItemsFilePosition { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct ScaRequestDataAttributesDependenciesItemsLocationsItemsFilePositionVisitor; + impl<'a> Visitor<'a> + for ScaRequestDataAttributesDependenciesItemsLocationsItemsFilePositionVisitor + { + type Value = ScaRequestDataAttributesDependenciesItemsLocationsItemsFilePosition; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut end: Option = None; + let mut file_name: Option = None; + let mut start: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "end" => { + if v.is_null() { + continue; + } + end = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "file_name" => { + if v.is_null() { + continue; + } + file_name = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "start" => { + if v.is_null() { + continue; + } + start = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = ScaRequestDataAttributesDependenciesItemsLocationsItemsFilePosition { + end, + file_name, + start, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any( + ScaRequestDataAttributesDependenciesItemsLocationsItemsFilePositionVisitor, + ) + } +} diff --git a/src/datadogV2/model/model_sca_request_data_attributes_dependencies_items_locations_items_position.rs b/src/datadogV2/model/model_sca_request_data_attributes_dependencies_items_locations_items_position.rs new file mode 100644 index 000000000..1d8cffe18 --- /dev/null +++ b/src/datadogV2/model/model_sca_request_data_attributes_dependencies_items_locations_items_position.rs @@ -0,0 +1,120 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct ScaRequestDataAttributesDependenciesItemsLocationsItemsPosition { + #[serde(rename = "col")] + pub col: Option, + #[serde(rename = "line")] + pub line: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl ScaRequestDataAttributesDependenciesItemsLocationsItemsPosition { + pub fn new() -> ScaRequestDataAttributesDependenciesItemsLocationsItemsPosition { + ScaRequestDataAttributesDependenciesItemsLocationsItemsPosition { + col: None, + line: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn col(mut self, value: i32) -> Self { + self.col = Some(value); + self + } + + pub fn line(mut self, value: i32) -> Self { + self.line = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for ScaRequestDataAttributesDependenciesItemsLocationsItemsPosition { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for ScaRequestDataAttributesDependenciesItemsLocationsItemsPosition { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct ScaRequestDataAttributesDependenciesItemsLocationsItemsPositionVisitor; + impl<'a> Visitor<'a> for ScaRequestDataAttributesDependenciesItemsLocationsItemsPositionVisitor { + type Value = ScaRequestDataAttributesDependenciesItemsLocationsItemsPosition; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut col: Option = None; + let mut line: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "col" => { + if v.is_null() { + continue; + } + col = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "line" => { + if v.is_null() { + continue; + } + line = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = ScaRequestDataAttributesDependenciesItemsLocationsItemsPosition { + col, + line, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer + .deserialize_any(ScaRequestDataAttributesDependenciesItemsLocationsItemsPositionVisitor) + } +} diff --git a/src/datadogV2/model/model_sca_request_data_attributes_dependencies_items_reachable_symbol_properties_items.rs b/src/datadogV2/model/model_sca_request_data_attributes_dependencies_items_reachable_symbol_properties_items.rs new file mode 100644 index 000000000..25426bdb0 --- /dev/null +++ b/src/datadogV2/model/model_sca_request_data_attributes_dependencies_items_reachable_symbol_properties_items.rs @@ -0,0 +1,126 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct ScaRequestDataAttributesDependenciesItemsReachableSymbolPropertiesItems { + #[serde(rename = "name")] + pub name: Option, + #[serde(rename = "value")] + pub value: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl ScaRequestDataAttributesDependenciesItemsReachableSymbolPropertiesItems { + pub fn new() -> ScaRequestDataAttributesDependenciesItemsReachableSymbolPropertiesItems { + ScaRequestDataAttributesDependenciesItemsReachableSymbolPropertiesItems { + name: None, + value: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn name(mut self, value: String) -> Self { + self.name = Some(value); + self + } + + pub fn value(mut self, value: String) -> Self { + self.value = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for ScaRequestDataAttributesDependenciesItemsReachableSymbolPropertiesItems { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> + for ScaRequestDataAttributesDependenciesItemsReachableSymbolPropertiesItems +{ + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct ScaRequestDataAttributesDependenciesItemsReachableSymbolPropertiesItemsVisitor; + impl<'a> Visitor<'a> + for ScaRequestDataAttributesDependenciesItemsReachableSymbolPropertiesItemsVisitor + { + type Value = ScaRequestDataAttributesDependenciesItemsReachableSymbolPropertiesItems; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut name: Option = None; + let mut value: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "name" => { + if v.is_null() { + continue; + } + name = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "value" => { + if v.is_null() { + continue; + } + value = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = + ScaRequestDataAttributesDependenciesItemsReachableSymbolPropertiesItems { + name, + value, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any( + ScaRequestDataAttributesDependenciesItemsReachableSymbolPropertiesItemsVisitor, + ) + } +} diff --git a/src/datadogV2/model/model_sca_request_data_attributes_files_items.rs b/src/datadogV2/model/model_sca_request_data_attributes_files_items.rs new file mode 100644 index 000000000..b4de7322c --- /dev/null +++ b/src/datadogV2/model/model_sca_request_data_attributes_files_items.rs @@ -0,0 +1,119 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct ScaRequestDataAttributesFilesItems { + #[serde(rename = "name")] + pub name: Option, + #[serde(rename = "purl")] + pub purl: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl ScaRequestDataAttributesFilesItems { + pub fn new() -> ScaRequestDataAttributesFilesItems { + ScaRequestDataAttributesFilesItems { + name: None, + purl: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn name(mut self, value: String) -> Self { + self.name = Some(value); + self + } + + pub fn purl(mut self, value: String) -> Self { + self.purl = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for ScaRequestDataAttributesFilesItems { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for ScaRequestDataAttributesFilesItems { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct ScaRequestDataAttributesFilesItemsVisitor; + impl<'a> Visitor<'a> for ScaRequestDataAttributesFilesItemsVisitor { + type Value = ScaRequestDataAttributesFilesItems; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut name: Option = None; + let mut purl: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "name" => { + if v.is_null() { + continue; + } + name = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "purl" => { + if v.is_null() { + continue; + } + purl = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = ScaRequestDataAttributesFilesItems { + name, + purl, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(ScaRequestDataAttributesFilesItemsVisitor) + } +} diff --git a/src/datadogV2/model/model_sca_request_data_attributes_relations_items.rs b/src/datadogV2/model/model_sca_request_data_attributes_relations_items.rs new file mode 100644 index 000000000..f36b86a83 --- /dev/null +++ b/src/datadogV2/model/model_sca_request_data_attributes_relations_items.rs @@ -0,0 +1,119 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct ScaRequestDataAttributesRelationsItems { + #[serde(rename = "depends_on")] + pub depends_on: Option>, + #[serde(rename = "ref")] + pub ref_: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl ScaRequestDataAttributesRelationsItems { + pub fn new() -> ScaRequestDataAttributesRelationsItems { + ScaRequestDataAttributesRelationsItems { + depends_on: None, + ref_: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn depends_on(mut self, value: Vec) -> Self { + self.depends_on = Some(value); + self + } + + pub fn ref_(mut self, value: String) -> Self { + self.ref_ = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for ScaRequestDataAttributesRelationsItems { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for ScaRequestDataAttributesRelationsItems { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct ScaRequestDataAttributesRelationsItemsVisitor; + impl<'a> Visitor<'a> for ScaRequestDataAttributesRelationsItemsVisitor { + type Value = ScaRequestDataAttributesRelationsItems; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut depends_on: Option> = None; + let mut ref_: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "depends_on" => { + if v.is_null() { + continue; + } + depends_on = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "ref" => { + if v.is_null() { + continue; + } + ref_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = ScaRequestDataAttributesRelationsItems { + depends_on, + ref_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(ScaRequestDataAttributesRelationsItemsVisitor) + } +} diff --git a/src/datadogV2/model/model_sca_request_data_attributes_repository.rs b/src/datadogV2/model/model_sca_request_data_attributes_repository.rs new file mode 100644 index 000000000..9b420df15 --- /dev/null +++ b/src/datadogV2/model/model_sca_request_data_attributes_repository.rs @@ -0,0 +1,103 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct ScaRequestDataAttributesRepository { + #[serde(rename = "url")] + pub url: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl ScaRequestDataAttributesRepository { + pub fn new() -> ScaRequestDataAttributesRepository { + ScaRequestDataAttributesRepository { + url: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn url(mut self, value: String) -> Self { + self.url = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for ScaRequestDataAttributesRepository { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for ScaRequestDataAttributesRepository { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct ScaRequestDataAttributesRepositoryVisitor; + impl<'a> Visitor<'a> for ScaRequestDataAttributesRepositoryVisitor { + type Value = ScaRequestDataAttributesRepository; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut url: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "url" => { + if v.is_null() { + continue; + } + url = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = ScaRequestDataAttributesRepository { + url, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(ScaRequestDataAttributesRepositoryVisitor) + } +} diff --git a/src/datadogV2/model/model_sca_request_data_attributes_vulnerabilities_items.rs b/src/datadogV2/model/model_sca_request_data_attributes_vulnerabilities_items.rs new file mode 100644 index 000000000..07719bda2 --- /dev/null +++ b/src/datadogV2/model/model_sca_request_data_attributes_vulnerabilities_items.rs @@ -0,0 +1,142 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct ScaRequestDataAttributesVulnerabilitiesItems { + #[serde(rename = "affects")] + pub affects: Option< + Vec, + >, + #[serde(rename = "bom_ref")] + pub bom_ref: Option, + #[serde(rename = "id")] + pub id: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl ScaRequestDataAttributesVulnerabilitiesItems { + pub fn new() -> ScaRequestDataAttributesVulnerabilitiesItems { + ScaRequestDataAttributesVulnerabilitiesItems { + affects: None, + bom_ref: None, + id: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn affects( + mut self, + value: Vec< + crate::datadogV2::model::ScaRequestDataAttributesVulnerabilitiesItemsAffectsItems, + >, + ) -> Self { + self.affects = Some(value); + self + } + + pub fn bom_ref(mut self, value: String) -> Self { + self.bom_ref = Some(value); + self + } + + pub fn id(mut self, value: String) -> Self { + self.id = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for ScaRequestDataAttributesVulnerabilitiesItems { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for ScaRequestDataAttributesVulnerabilitiesItems { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct ScaRequestDataAttributesVulnerabilitiesItemsVisitor; + impl<'a> Visitor<'a> for ScaRequestDataAttributesVulnerabilitiesItemsVisitor { + type Value = ScaRequestDataAttributesVulnerabilitiesItems; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut affects: Option> = None; + let mut bom_ref: Option = None; + let mut id: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "affects" => { + if v.is_null() { + continue; + } + affects = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "bom_ref" => { + if v.is_null() { + continue; + } + bom_ref = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "id" => { + if v.is_null() { + continue; + } + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = ScaRequestDataAttributesVulnerabilitiesItems { + affects, + bom_ref, + id, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(ScaRequestDataAttributesVulnerabilitiesItemsVisitor) + } +} diff --git a/src/datadogV2/model/model_sca_request_data_attributes_vulnerabilities_items_affects_items.rs b/src/datadogV2/model/model_sca_request_data_attributes_vulnerabilities_items_affects_items.rs new file mode 100644 index 000000000..fe3fb9c34 --- /dev/null +++ b/src/datadogV2/model/model_sca_request_data_attributes_vulnerabilities_items_affects_items.rs @@ -0,0 +1,104 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct ScaRequestDataAttributesVulnerabilitiesItemsAffectsItems { + #[serde(rename = "ref")] + pub ref_: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl ScaRequestDataAttributesVulnerabilitiesItemsAffectsItems { + pub fn new() -> ScaRequestDataAttributesVulnerabilitiesItemsAffectsItems { + ScaRequestDataAttributesVulnerabilitiesItemsAffectsItems { + ref_: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn ref_(mut self, value: String) -> Self { + self.ref_ = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for ScaRequestDataAttributesVulnerabilitiesItemsAffectsItems { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for ScaRequestDataAttributesVulnerabilitiesItemsAffectsItems { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct ScaRequestDataAttributesVulnerabilitiesItemsAffectsItemsVisitor; + impl<'a> Visitor<'a> for ScaRequestDataAttributesVulnerabilitiesItemsAffectsItemsVisitor { + type Value = ScaRequestDataAttributesVulnerabilitiesItemsAffectsItems; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut ref_: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "ref" => { + if v.is_null() { + continue; + } + ref_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = ScaRequestDataAttributesVulnerabilitiesItemsAffectsItems { + ref_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer + .deserialize_any(ScaRequestDataAttributesVulnerabilitiesItemsAffectsItemsVisitor) + } +} diff --git a/src/datadogV2/model/model_sca_request_data_type.rs b/src/datadogV2/model/model_sca_request_data_type.rs new file mode 100644 index 000000000..bb4d0a436 --- /dev/null +++ b/src/datadogV2/model/model_sca_request_data_type.rs @@ -0,0 +1,48 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +use serde::{Deserialize, Deserializer, Serialize, Serializer}; + +#[non_exhaustive] +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum ScaRequestDataType { + SCAREQUESTS, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for ScaRequestDataType { + fn to_string(&self) -> String { + match self { + Self::SCAREQUESTS => String::from("scarequests"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for ScaRequestDataType { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match self { + Self::UnparsedObject(v) => v.serialize(serializer), + _ => serializer.serialize_str(self.to_string().as_str()), + } + } +} + +impl<'de> Deserialize<'de> for ScaRequestDataType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "scarequests" => Self::SCAREQUESTS, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/tests/scenarios/features/v2/static_analysis.feature b/tests/scenarios/features/v2/static_analysis.feature new file mode 100644 index 000000000..85bf4d83a --- /dev/null +++ b/tests/scenarios/features/v2/static_analysis.feature @@ -0,0 +1,24 @@ +@endpoint(static-analysis) @endpoint(static-analysis-v2) +Feature: Static Analysis + API for static analysis + + Background: + Given a valid "apiKeyAuth" key in the system + And a valid "appKeyAuth" key in the system + And an instance of "StaticAnalysis" API + + @generated @skip @team:DataDog/k9-vm-sca + Scenario: POST request to resolve vulnerable symbols returns "OK" response + Given operation "CreateSCAResolveVulnerableSymbols" enabled + And new "CreateSCAResolveVulnerableSymbols" request + And body with value {"data": {"attributes": {"purls": []}, "type": "resolve-vulnerable-symbols-request"}} + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:DataDog/k9-vm-sca + Scenario: Post dependencies for analysis returns "OK" response + Given operation "CreateSCAResult" enabled + And new "CreateSCAResult" request + And body with value {"data": {"attributes": {"commit": {}, "dependencies": [{"exclusions": [], "locations": [{"block": {"end": {}, "start": {}}, "name": {"end": {}, "start": {}}, "namespace": {"end": {}, "start": {}}, "version": {"end": {}, "start": {}}}], "reachable_symbol_properties": [{}]}], "files": [{}], "relations": [{"depends_on": []}], "repository": {}, "vulnerabilities": [{"affects": [{}]}]}, "type": "scarequests"}} + When the request is sent + Then the response status is 200 OK diff --git a/tests/scenarios/features/v2/undo.json b/tests/scenarios/features/v2/undo.json index bb35cea36..5f2144f5f 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -3993,6 +3993,18 @@ "type": "safe" } }, + "CreateSCAResult": { + "tag": "Static Analysis", + "undo": { + "type": "safe" + } + }, + "CreateSCAResolveVulnerableSymbols": { + "tag": "Static Analysis", + "undo": { + "type": "safe" + } + }, "GetOnDemandConcurrencyCap": { "tag": "Synthetics", "undo": { diff --git a/tests/scenarios/function_mappings.rs b/tests/scenarios/function_mappings.rs index 821ce5838..fb19d788d 100644 --- a/tests/scenarios/function_mappings.rs +++ b/tests/scenarios/function_mappings.rs @@ -144,6 +144,7 @@ pub struct ApiInstances { Option, pub v2_api_spa: Option, pub v2_api_spans: Option, + pub v2_api_static_analysis: Option, pub v2_api_synthetics: Option, pub v2_api_teams: Option, pub v2_api_incident_teams: Option, @@ -929,6 +930,14 @@ pub fn initialize_api_instance(world: &mut DatadogWorld, api: String) { world.http_client.as_ref().unwrap().clone(), )); } + "StaticAnalysis" => { + world.api_instances.v2_api_static_analysis = Some( + datadogV2::api_static_analysis::StaticAnalysisAPI::with_client_and_config( + world.config.clone(), + world.http_client.as_ref().unwrap().clone(), + ), + ); + } "Teams" => { world.api_instances.v2_api_teams = Some(datadogV2::api_teams::TeamsAPI::with_client_and_config( @@ -4075,6 +4084,13 @@ pub fn collect_function_calls(world: &mut DatadogWorld) { "v2.ListSpansWithPagination".into(), test_v2_list_spans_with_pagination, ); + world + .function_mappings + .insert("v2.CreateSCAResult".into(), test_v2_create_sca_result); + world.function_mappings.insert( + "v2.CreateSCAResolveVulnerableSymbols".into(), + test_v2_create_sca_resolve_vulnerable_symbols, + ); world.function_mappings.insert( "v2.GetOnDemandConcurrencyCap".into(), test_v2_get_on_demand_concurrency_cap, @@ -31452,6 +31468,59 @@ fn test_v2_list_spans_with_pagination( world.response.code = 200; } +fn test_v2_create_sca_result(world: &mut DatadogWorld, _parameters: &HashMap) { + let api = world + .api_instances + .v2_api_static_analysis + .as_ref() + .expect("api instance not found"); + let body = serde_json::from_value(_parameters.get("body").unwrap().clone()).unwrap(); + let response = match block_on(api.create_sca_result_with_http_info(body)) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + +fn test_v2_create_sca_resolve_vulnerable_symbols( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_static_analysis + .as_ref() + .expect("api instance not found"); + let body = serde_json::from_value(_parameters.get("body").unwrap().clone()).unwrap(); + let response = match block_on(api.create_sca_resolve_vulnerable_symbols_with_http_info(body)) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + fn test_v2_get_on_demand_concurrency_cap( world: &mut DatadogWorld, _parameters: &HashMap,