Skip to content

Commit 849cb9a

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add spec for Agentless GetAwsScanOptions (#869)
Co-authored-by: ci.datadog-api-spec <[email protected]>
1 parent be20633 commit 849cb9a

17 files changed

+359
-6
lines changed

.generator/schemas/v2/openapi.yaml

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46152,7 +46152,7 @@ paths:
4615246152
$ref: '#/components/responses/NotAuthorizedResponse'
4615346153
'429':
4615446154
$ref: '#/components/responses/TooManyRequestsResponse'
46155-
summary: Get AWS Scan Options
46155+
summary: List AWS Scan Options
4615646156
tags:
4615746157
- Agentless Scanning
4615846158
post:
@@ -46204,6 +46204,29 @@ paths:
4620446204
summary: Delete AWS Scan Options
4620546205
tags:
4620646206
- Agentless Scanning
46207+
get:
46208+
description: Fetches the Agentless scan options for an activated account.
46209+
operationId: GetAwsScanOptions
46210+
parameters:
46211+
- $ref: '#/components/parameters/AwsAccountId'
46212+
responses:
46213+
'200':
46214+
content:
46215+
application/json:
46216+
schema:
46217+
$ref: '#/components/schemas/AwsScanOptionsResponse'
46218+
description: OK
46219+
'400':
46220+
$ref: '#/components/responses/BadRequestResponse'
46221+
'403':
46222+
$ref: '#/components/responses/NotAuthorizedResponse'
46223+
'404':
46224+
$ref: '#/components/responses/NotFoundResponse'
46225+
'429':
46226+
$ref: '#/components/responses/TooManyRequestsResponse'
46227+
summary: Get AWS scan options
46228+
tags:
46229+
- Agentless Scanning
4620746230
patch:
4620846231
description: Update the Agentless scan options for an activated account.
4620946232
operationId: UpdateAwsScanOptions
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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+
// there is a valid "aws_scan_options" in the system
8+
let aws_scan_options_id = std::env::var("AWS_SCAN_OPTIONS_ID").unwrap();
9+
let configuration = datadog::Configuration::new();
10+
let api = AgentlessScanningAPI::with_config(configuration);
11+
let resp = api.get_aws_scan_options(aws_scan_options_id.clone()).await;
12+
if let Ok(value) = resp {
13+
println!("{:#?}", value);
14+
} else {
15+
println!("{:#?}", resp.unwrap_err());
16+
}
17+
}

examples/v2_agentless-scanning_ListAwsScanOptions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Get AWS Scan Options returns "OK" response
1+
// List AWS Scan Options returns "OK" response
22
use datadog_api_client::datadog;
33
use datadog_api_client::datadogV2::api_agentless_scanning::AgentlessScanningAPI;
44

src/datadogV2/api/api_agentless_scanning.rs

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@ pub enum GetAwsOnDemandTaskError {
4242
UnknownValue(serde_json::Value),
4343
}
4444

45+
/// GetAwsScanOptionsError is a struct for typed errors of method [`AgentlessScanningAPI::get_aws_scan_options`]
46+
#[derive(Debug, Clone, Serialize, Deserialize)]
47+
#[serde(untagged)]
48+
pub enum GetAwsScanOptionsError {
49+
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
50+
UnknownValue(serde_json::Value),
51+
}
52+
4553
/// ListAwsOnDemandTasksError is a struct for typed errors of method [`AgentlessScanningAPI::list_aws_on_demand_tasks`]
4654
#[derive(Debug, Clone, Serialize, Deserialize)]
4755
#[serde(untagged)]
@@ -641,6 +649,115 @@ impl AgentlessScanningAPI {
641649
}
642650
}
643651

652+
/// Fetches the Agentless scan options for an activated account.
653+
pub async fn get_aws_scan_options(
654+
&self,
655+
account_id: String,
656+
) -> Result<
657+
crate::datadogV2::model::AwsScanOptionsResponse,
658+
datadog::Error<GetAwsScanOptionsError>,
659+
> {
660+
match self.get_aws_scan_options_with_http_info(account_id).await {
661+
Ok(response_content) => {
662+
if let Some(e) = response_content.entity {
663+
Ok(e)
664+
} else {
665+
Err(datadog::Error::Serde(serde::de::Error::custom(
666+
"response content was None",
667+
)))
668+
}
669+
}
670+
Err(err) => Err(err),
671+
}
672+
}
673+
674+
/// Fetches the Agentless scan options for an activated account.
675+
pub async fn get_aws_scan_options_with_http_info(
676+
&self,
677+
account_id: String,
678+
) -> Result<
679+
datadog::ResponseContent<crate::datadogV2::model::AwsScanOptionsResponse>,
680+
datadog::Error<GetAwsScanOptionsError>,
681+
> {
682+
let local_configuration = &self.config;
683+
let operation_id = "v2.get_aws_scan_options";
684+
685+
let local_client = &self.client;
686+
687+
let local_uri_str = format!(
688+
"{}/api/v2/agentless_scanning/accounts/aws/{account_id}",
689+
local_configuration.get_operation_host(operation_id),
690+
account_id = datadog::urlencode(account_id)
691+
);
692+
let mut local_req_builder =
693+
local_client.request(reqwest::Method::GET, local_uri_str.as_str());
694+
695+
// build headers
696+
let mut headers = HeaderMap::new();
697+
headers.insert("Accept", HeaderValue::from_static("application/json"));
698+
699+
// build user agent
700+
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
701+
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
702+
Err(e) => {
703+
log::warn!("Failed to parse user agent header: {e}, falling back to default");
704+
headers.insert(
705+
reqwest::header::USER_AGENT,
706+
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
707+
)
708+
}
709+
};
710+
711+
// build auth
712+
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
713+
headers.insert(
714+
"DD-API-KEY",
715+
HeaderValue::from_str(local_key.key.as_str())
716+
.expect("failed to parse DD-API-KEY header"),
717+
);
718+
};
719+
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
720+
headers.insert(
721+
"DD-APPLICATION-KEY",
722+
HeaderValue::from_str(local_key.key.as_str())
723+
.expect("failed to parse DD-APPLICATION-KEY header"),
724+
);
725+
};
726+
727+
local_req_builder = local_req_builder.headers(headers);
728+
let local_req = local_req_builder.build()?;
729+
log::debug!("request content: {:?}", local_req.body());
730+
let local_resp = local_client.execute(local_req).await?;
731+
732+
let local_status = local_resp.status();
733+
let local_content = local_resp.text().await?;
734+
log::debug!("response content: {}", local_content);
735+
736+
if !local_status.is_client_error() && !local_status.is_server_error() {
737+
match serde_json::from_str::<crate::datadogV2::model::AwsScanOptionsResponse>(
738+
&local_content,
739+
) {
740+
Ok(e) => {
741+
return Ok(datadog::ResponseContent {
742+
status: local_status,
743+
content: local_content,
744+
entity: Some(e),
745+
})
746+
}
747+
Err(e) => return Err(datadog::Error::Serde(e)),
748+
};
749+
} else {
750+
let local_entity: Option<GetAwsScanOptionsError> =
751+
serde_json::from_str(&local_content).ok();
752+
let local_error = datadog::ResponseContent {
753+
status: local_status,
754+
content: local_content,
755+
entity: local_entity,
756+
};
757+
Err(datadog::Error::ResponseError(local_error))
758+
}
759+
}
760+
644761
/// Fetches the most recent 1000 AWS on demand tasks.
645762
pub async fn list_aws_on_demand_tasks(
646763
&self,

tests/scenarios/cassettes/v2/agentless_scanning/Get-AWS-Scan-Options-returns-OK-response.frozen

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2025-08-27T13:04:35.618Z
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"http_interactions": [
3+
{
4+
"request": {
5+
"body": "",
6+
"headers": {
7+
"Accept": [
8+
"application/json"
9+
]
10+
},
11+
"method": "get",
12+
"uri": "https://api.datadoghq.com/api/v2/agentless_scanning/accounts/aws/not-an-account-id"
13+
},
14+
"response": {
15+
"body": {
16+
"string": "{\"errors\":[{\"title\":\"Generic Error\",\"detail\":\"missing or invalid url parameter 'accountId', expected 12 digit format '123456789012'\"}]}",
17+
"encoding": null
18+
},
19+
"headers": {
20+
"Content-Type": [
21+
"application/vnd.api+json"
22+
]
23+
},
24+
"status": {
25+
"code": 400,
26+
"message": "Bad Request"
27+
}
28+
},
29+
"recorded_at": "Wed, 27 Aug 2025 13:04:35 GMT"
30+
}
31+
],
32+
"recorded_with": "VCR 6.0.0"
33+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2025-08-27T01:14:07.103Z
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"http_interactions": [
3+
{
4+
"request": {
5+
"body": "",
6+
"headers": {
7+
"Accept": [
8+
"application/json"
9+
]
10+
},
11+
"method": "get",
12+
"uri": "https://api.datadoghq.com/api/v2/agentless_scanning/accounts/aws/404404404404"
13+
},
14+
"response": {
15+
"body": {
16+
"string": "{\"errors\":[{\"status\":\"404\",\"detail\":\"no aws scan options found for subscription 404404404404\"}]}",
17+
"encoding": null
18+
},
19+
"headers": {
20+
"Content-Type": [
21+
"application/vnd.api+json"
22+
]
23+
},
24+
"status": {
25+
"code": 404,
26+
"message": "Not Found"
27+
}
28+
},
29+
"recorded_at": "Wed, 27 Aug 2025 01:14:07 GMT"
30+
}
31+
],
32+
"recorded_with": "VCR 6.0.0"
33+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2025-08-27T01:14:24.197Z

0 commit comments

Comments
 (0)