Skip to content

Commit 21acc9a

Browse files
author
ci.datadog-api-spec
committed
Regenerate client from commit e2cc2df0 of spec repo
1 parent 9407a13 commit 21acc9a

16 files changed

+849
-6
lines changed

.apigentools-info

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
"spec_versions": {
55
"v1": {
66
"apigentools_version": "1.6.6",
7-
"regenerated": "2024-12-18 19:23:38.680515",
8-
"spec_repo_commit": "3f22290a"
7+
"regenerated": "2024-12-19 11:45:54.928880",
8+
"spec_repo_commit": "e2cc2df0"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.6",
12-
"regenerated": "2024-12-18 19:23:38.695560",
13-
"spec_repo_commit": "3f22290a"
12+
"regenerated": "2024-12-19 11:45:54.945568",
13+
"spec_repo_commit": "e2cc2df0"
1414
}
1515
}
1616
}

.generator/schemas/v2/openapi.yaml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2615,6 +2615,57 @@ components:
26152615
$ref: '#/components/schemas/AwsCURConfig'
26162616
type: array
26172617
type: object
2618+
AwsScanOptionsAttributes:
2619+
description: Attributes for the AWS scan options.
2620+
properties:
2621+
lambda:
2622+
description: Indicates if scanning of Lambda functions is enabled.
2623+
example: true
2624+
type: boolean
2625+
sensitive_data:
2626+
description: Indicates if scanning for sensitive data is enabled.
2627+
example: false
2628+
type: boolean
2629+
vuln_containers_os:
2630+
description: Indicates if scanning for vulnerabilities in containers is
2631+
enabled.
2632+
example: true
2633+
type: boolean
2634+
vuln_host_os:
2635+
description: Indicates if scanning for vulnerabilities in hosts is enabled.
2636+
example: true
2637+
type: boolean
2638+
type: object
2639+
AwsScanOptionsData:
2640+
description: Single AWS Scan Options entry.
2641+
properties:
2642+
attributes:
2643+
$ref: '#/components/schemas/AwsScanOptionsAttributes'
2644+
id:
2645+
description: The ID of the AWS account.
2646+
example: '184366314700'
2647+
type: string
2648+
type:
2649+
$ref: '#/components/schemas/AwsScanOptionsType'
2650+
type: object
2651+
AwsScanOptionsResponse:
2652+
description: Response object that includes a list of AWS scan options.
2653+
properties:
2654+
data:
2655+
description: A list of AWS scan options.
2656+
items:
2657+
$ref: '#/components/schemas/AwsScanOptionsData'
2658+
type: array
2659+
type: object
2660+
AwsScanOptionsType:
2661+
default: aws_scan_options
2662+
description: The type of the resource. The value should always be `aws_scan_options`.
2663+
enum:
2664+
- aws_scan_options
2665+
example: aws_scan_options
2666+
type: string
2667+
x-enum-varnames:
2668+
- AWS_SCAN_OPTIONS
26182669
AzureUCConfig:
26192670
description: Azure config.
26202671
properties:
@@ -29269,6 +29320,24 @@ info:
2926929320
version: '1.0'
2927029321
openapi: 3.0.0
2927129322
paths:
29323+
/api/v2/agentless_scanning/accounts/aws:
29324+
get:
29325+
description: Fetches the scan options configured for AWS accounts.
29326+
operationId: ListAwsScanOptions
29327+
responses:
29328+
'200':
29329+
content:
29330+
application/json:
29331+
schema:
29332+
$ref: '#/components/schemas/AwsScanOptionsResponse'
29333+
description: OK
29334+
'403':
29335+
$ref: '#/components/responses/NotAuthorizedResponse'
29336+
'429':
29337+
$ref: '#/components/responses/TooManyRequestsResponse'
29338+
summary: Get AWS Scan Options
29339+
tags:
29340+
- Agentless Scanning
2927229341
/api/v2/api_keys:
2927329342
get:
2927429343
description: List all API keys available for your account.
@@ -46531,6 +46600,11 @@ tags:
4653146600
externalDocs:
4653246601
url: https://docs.datadoghq.com/integrations/amazon_web_services/#log-collection
4653346602
name: AWS Logs Integration
46603+
- description: "Datadog Agentless Scanning provides visibility into risks and vulnerabilities\nwithin
46604+
your hosts, running containers, and serverless functions\u2014all without\nrequiring
46605+
teams to install Agents on every host or where Agents cannot be installed.\nGo
46606+
to https://www.datadoghq.com/blog/agentless-scanning/ to learn more"
46607+
name: Agentless Scanning
4653446608
- description: Deploy and disable apps in App Builder.
4653546609
name: App Deployment
4653646610
- description: Create, read, update, and delete apps in App Builder.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Get AWS Scan Options returns "OK" response
2+
use datadog_api_client::datadog;
3+
use datadog_api_client::datadogV2::api_agentless_scanning::AgentlessScanningAPI;
4+
5+
#[tokio::main]
6+
async fn main() {
7+
let configuration = datadog::Configuration::new();
8+
let api = AgentlessScanningAPI::with_config(configuration);
9+
let resp = api.list_aws_scan_options().await;
10+
if let Ok(value) = resp {
11+
println!("{:#?}", value);
12+
} else {
13+
println!("{:#?}", resp.unwrap_err());
14+
}
15+
}
Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
2+
// This product includes software developed at Datadog (https://www.datadoghq.com/).
3+
// Copyright 2019-Present Datadog, Inc.
4+
use crate::datadog;
5+
use reqwest::header::{HeaderMap, HeaderValue};
6+
use serde::{Deserialize, Serialize};
7+
8+
/// ListAwsScanOptionsError is a struct for typed errors of method [`AgentlessScanningAPI::list_aws_scan_options`]
9+
#[derive(Debug, Clone, Serialize, Deserialize)]
10+
#[serde(untagged)]
11+
pub enum ListAwsScanOptionsError {
12+
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
13+
UnknownValue(serde_json::Value),
14+
}
15+
16+
/// Datadog Agentless Scanning provides visibility into risks and vulnerabilities
17+
/// within your hosts, running containers, and serverless functions—all without
18+
/// requiring teams to install Agents on every host or where Agents cannot be installed.
19+
/// Go to <https://www.datadoghq.com/blog/agentless-scanning/> to learn more
20+
#[derive(Debug, Clone)]
21+
pub struct AgentlessScanningAPI {
22+
config: datadog::Configuration,
23+
client: reqwest_middleware::ClientWithMiddleware,
24+
}
25+
26+
impl Default for AgentlessScanningAPI {
27+
fn default() -> Self {
28+
Self::with_config(datadog::Configuration::default())
29+
}
30+
}
31+
32+
impl AgentlessScanningAPI {
33+
pub fn new() -> Self {
34+
Self::default()
35+
}
36+
pub fn with_config(config: datadog::Configuration) -> Self {
37+
let mut reqwest_client_builder = reqwest::Client::builder();
38+
39+
if let Some(proxy_url) = &config.proxy_url {
40+
let proxy = reqwest::Proxy::all(proxy_url).expect("Failed to parse proxy URL");
41+
reqwest_client_builder = reqwest_client_builder.proxy(proxy);
42+
}
43+
44+
let mut middleware_client_builder =
45+
reqwest_middleware::ClientBuilder::new(reqwest_client_builder.build().unwrap());
46+
47+
if config.enable_retry {
48+
struct RetryableStatus;
49+
impl reqwest_retry::RetryableStrategy for RetryableStatus {
50+
fn handle(
51+
&self,
52+
res: &Result<reqwest::Response, reqwest_middleware::Error>,
53+
) -> Option<reqwest_retry::Retryable> {
54+
match res {
55+
Ok(success) => reqwest_retry::default_on_request_success(success),
56+
Err(_) => None,
57+
}
58+
}
59+
}
60+
let backoff_policy = reqwest_retry::policies::ExponentialBackoff::builder()
61+
.build_with_max_retries(config.max_retries);
62+
63+
let retry_middleware =
64+
reqwest_retry::RetryTransientMiddleware::new_with_policy_and_strategy(
65+
backoff_policy,
66+
RetryableStatus,
67+
);
68+
69+
middleware_client_builder = middleware_client_builder.with(retry_middleware);
70+
}
71+
72+
let client = middleware_client_builder.build();
73+
74+
Self { config, client }
75+
}
76+
77+
pub fn with_client_and_config(
78+
config: datadog::Configuration,
79+
client: reqwest_middleware::ClientWithMiddleware,
80+
) -> Self {
81+
Self { config, client }
82+
}
83+
84+
/// Fetches the scan options configured for AWS accounts.
85+
pub async fn list_aws_scan_options(
86+
&self,
87+
) -> Result<
88+
crate::datadogV2::model::AwsScanOptionsResponse,
89+
datadog::Error<ListAwsScanOptionsError>,
90+
> {
91+
match self.list_aws_scan_options_with_http_info().await {
92+
Ok(response_content) => {
93+
if let Some(e) = response_content.entity {
94+
Ok(e)
95+
} else {
96+
Err(datadog::Error::Serde(serde::de::Error::custom(
97+
"response content was None",
98+
)))
99+
}
100+
}
101+
Err(err) => Err(err),
102+
}
103+
}
104+
105+
/// Fetches the scan options configured for AWS accounts.
106+
pub async fn list_aws_scan_options_with_http_info(
107+
&self,
108+
) -> Result<
109+
datadog::ResponseContent<crate::datadogV2::model::AwsScanOptionsResponse>,
110+
datadog::Error<ListAwsScanOptionsError>,
111+
> {
112+
let local_configuration = &self.config;
113+
let operation_id = "v2.list_aws_scan_options";
114+
115+
let local_client = &self.client;
116+
117+
let local_uri_str = format!(
118+
"{}/api/v2/agentless_scanning/accounts/aws",
119+
local_configuration.get_operation_host(operation_id)
120+
);
121+
let mut local_req_builder =
122+
local_client.request(reqwest::Method::GET, local_uri_str.as_str());
123+
124+
// build headers
125+
let mut headers = HeaderMap::new();
126+
headers.insert("Accept", HeaderValue::from_static("application/json"));
127+
128+
// build user agent
129+
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
130+
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
131+
Err(e) => {
132+
log::warn!("Failed to parse user agent header: {e}, falling back to default");
133+
headers.insert(
134+
reqwest::header::USER_AGENT,
135+
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
136+
)
137+
}
138+
};
139+
140+
// build auth
141+
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
142+
headers.insert(
143+
"DD-API-KEY",
144+
HeaderValue::from_str(local_key.key.as_str())
145+
.expect("failed to parse DD-API-KEY header"),
146+
);
147+
};
148+
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
149+
headers.insert(
150+
"DD-APPLICATION-KEY",
151+
HeaderValue::from_str(local_key.key.as_str())
152+
.expect("failed to parse DD-APPLICATION-KEY header"),
153+
);
154+
};
155+
156+
local_req_builder = local_req_builder.headers(headers);
157+
let local_req = local_req_builder.build()?;
158+
log::debug!("request content: {:?}", local_req.body());
159+
let local_resp = local_client.execute(local_req).await?;
160+
161+
let local_status = local_resp.status();
162+
let local_content = local_resp.text().await?;
163+
log::debug!("response content: {}", local_content);
164+
165+
if !local_status.is_client_error() && !local_status.is_server_error() {
166+
match serde_json::from_str::<crate::datadogV2::model::AwsScanOptionsResponse>(
167+
&local_content,
168+
) {
169+
Ok(e) => {
170+
return Ok(datadog::ResponseContent {
171+
status: local_status,
172+
content: local_content,
173+
entity: Some(e),
174+
})
175+
}
176+
Err(e) => return Err(datadog::Error::Serde(e)),
177+
};
178+
} else {
179+
let local_entity: Option<ListAwsScanOptionsError> =
180+
serde_json::from_str(&local_content).ok();
181+
let local_error = datadog::ResponseContent {
182+
status: local_status,
183+
content: local_content,
184+
entity: local_entity,
185+
};
186+
Err(datadog::Error::ResponseError(local_error))
187+
}
188+
}
189+
}

src/datadogV2/api/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// This product includes software developed at Datadog (https://www.datadoghq.com/).
33
// Copyright 2019-Present Datadog, Inc.
44

5+
pub mod api_agentless_scanning;
56
pub mod api_api_management;
67
pub mod api_apm_retention_filters;
78
pub mod api_app_deployment;

src/datadogV2/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// Copyright 2019-Present Datadog, Inc.
44

55
pub mod api;
6+
pub use self::api::api_agentless_scanning;
67
pub use self::api::api_api_management;
78
pub use self::api::api_apm_retention_filters;
89
pub use self::api::api_app_deployment;

src/datadogV2/model/mod.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22
// This product includes software developed at Datadog (https://www.datadoghq.com/).
33
// Copyright 2019-Present Datadog, Inc.
44

5+
pub mod model_aws_scan_options_response;
6+
pub use self::model_aws_scan_options_response::AwsScanOptionsResponse;
7+
pub mod model_aws_scan_options_data;
8+
pub use self::model_aws_scan_options_data::AwsScanOptionsData;
9+
pub mod model_aws_scan_options_attributes;
10+
pub use self::model_aws_scan_options_attributes::AwsScanOptionsAttributes;
11+
pub mod model_aws_scan_options_type;
12+
pub use self::model_aws_scan_options_type::AwsScanOptionsType;
13+
pub mod model_api_error_response;
14+
pub use self::model_api_error_response::APIErrorResponse;
515
pub mod model_api_keys_sort;
616
pub use self::model_api_keys_sort::APIKeysSort;
717
pub mod model_api_keys_response;
@@ -58,8 +68,6 @@ pub mod model_api_keys_response_meta;
5868
pub use self::model_api_keys_response_meta::APIKeysResponseMeta;
5969
pub mod model_api_keys_response_meta_page;
6070
pub use self::model_api_keys_response_meta_page::APIKeysResponseMetaPage;
61-
pub mod model_api_error_response;
62-
pub use self::model_api_error_response::APIErrorResponse;
6371
pub mod model_api_key_create_request;
6472
pub use self::model_api_key_create_request::APIKeyCreateRequest;
6573
pub mod model_api_key_create_data;

0 commit comments

Comments
 (0)