rusty_falcon/apis/
container_packages_api.rs

1/*
2 * CrowdStrike API Specification
3 *
4 * Use this API specification as a reference for the API endpoints you can use to interact with your Falcon environment. These endpoints support authentication via OAuth2 and interact with detections and network containment. For detailed usage guides and examples, see our [documentation inside the Falcon console](https://falcon.crowdstrike.com/support/documentation).     To use the APIs described below, combine the base URL with the path shown for each API endpoint. For commercial cloud customers, your base URL is `https://api.crowdstrike.com`.    Each API endpoint requires authorization via an OAuth2 token. Your first API request should retrieve an OAuth2 token using the `oauth2/token` endpoint, such as `https://api.crowdstrike.com/oauth2/token`. For subsequent requests, include the OAuth2 token in an HTTP authorization header. Tokens expire after 30 minutes, after which you should make a new token request to continue making API requests.
5 *
6 * The version of the OpenAPI document: rolling
7 *
8 * Generated by: https://openapi-generator.tech
9 */
10
11use reqwest;
12
13use super::{configuration, Error};
14use crate::{apis::ResponseContent, models};
15
16/// struct for typed errors of method [`read_packages_by_fixable_vuln_count`]
17#[derive(Debug, Clone, Serialize, Deserialize)]
18#[serde(untagged)]
19pub enum ReadPackagesByFixableVulnCountError {
20    Status403(models::MsaPeriodReplyMetaOnly),
21    Status429(models::MsaPeriodReplyMetaOnly),
22    Status500(models::CorePeriodEntitiesResponse),
23    UnknownValue(serde_json::Value),
24}
25
26/// struct for typed errors of method [`read_packages_by_vuln_count`]
27#[derive(Debug, Clone, Serialize, Deserialize)]
28#[serde(untagged)]
29pub enum ReadPackagesByVulnCountError {
30    Status403(models::MsaPeriodReplyMetaOnly),
31    Status429(models::MsaPeriodReplyMetaOnly),
32    Status500(models::CorePeriodEntitiesResponse),
33    UnknownValue(serde_json::Value),
34}
35
36/// struct for typed errors of method [`read_packages_combined`]
37#[derive(Debug, Clone, Serialize, Deserialize)]
38#[serde(untagged)]
39pub enum ReadPackagesCombinedError {
40    Status403(models::MsaPeriodReplyMetaOnly),
41    Status429(models::MsaPeriodReplyMetaOnly),
42    Status500(models::CorePeriodEntitiesResponse),
43    UnknownValue(serde_json::Value),
44}
45
46/// struct for typed errors of method [`read_packages_combined_export`]
47#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum ReadPackagesCombinedExportError {
50    Status403(models::MsaPeriodReplyMetaOnly),
51    Status429(models::MsaPeriodReplyMetaOnly),
52    Status500(models::CorePeriodEntitiesResponse),
53    UnknownValue(serde_json::Value),
54}
55
56/// struct for typed errors of method [`read_packages_count_by_zero_day`]
57#[derive(Debug, Clone, Serialize, Deserialize)]
58#[serde(untagged)]
59pub enum ReadPackagesCountByZeroDayError {
60    Status403(models::MsaPeriodReplyMetaOnly),
61    Status429(models::MsaPeriodReplyMetaOnly),
62    Status500(models::CorePeriodEntitiesResponse),
63    UnknownValue(serde_json::Value),
64}
65
66pub async fn read_packages_by_fixable_vuln_count(
67    configuration: &configuration::Configuration,
68    filter: Option<&str>,
69    limit: Option<i32>,
70    offset: Option<i32>,
71) -> Result<models::PackagesPeriodApiPackagesByVulnCount, Error<ReadPackagesByFixableVulnCountError>>
72{
73    let local_var_configuration = configuration;
74
75    let local_var_client = &local_var_configuration.client;
76
77    let local_var_uri_str = format!(
78        "{}/container-security/combined/packages/app-by-fixable-vulnerability-count/v1",
79        local_var_configuration.base_path
80    );
81    let mut local_var_req_builder =
82        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
83
84    if let Some(ref local_var_str) = filter {
85        local_var_req_builder =
86            local_var_req_builder.query(&[("filter", &local_var_str.to_string())]);
87    }
88    if let Some(ref local_var_str) = limit {
89        local_var_req_builder =
90            local_var_req_builder.query(&[("limit", &local_var_str.to_string())]);
91    }
92    if let Some(ref local_var_str) = offset {
93        local_var_req_builder =
94            local_var_req_builder.query(&[("offset", &local_var_str.to_string())]);
95    }
96    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
97        local_var_req_builder =
98            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
99    }
100    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
101        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
102    };
103
104    let local_var_req = local_var_req_builder.build()?;
105    let local_var_resp = local_var_client.execute(local_var_req).await?;
106
107    let local_var_status = local_var_resp.status();
108    let local_var_content = local_var_resp.text().await?;
109
110    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
111        serde_json::from_str(&local_var_content).map_err(Error::from)
112    } else {
113        let local_var_entity: Option<ReadPackagesByFixableVulnCountError> =
114            serde_json::from_str(&local_var_content).ok();
115        let local_var_error = ResponseContent {
116            status: local_var_status,
117            content: local_var_content,
118            entity: local_var_entity,
119        };
120        Err(Error::ResponseError(local_var_error))
121    }
122}
123
124pub async fn read_packages_by_vuln_count(
125    configuration: &configuration::Configuration,
126    filter: Option<&str>,
127    limit: Option<i32>,
128    offset: Option<i32>,
129) -> Result<models::PackagesPeriodApiPackagesByVulnCount, Error<ReadPackagesByVulnCountError>> {
130    let local_var_configuration = configuration;
131
132    let local_var_client = &local_var_configuration.client;
133
134    let local_var_uri_str = format!(
135        "{}/container-security/combined/packages/by-vulnerability-count/v1",
136        local_var_configuration.base_path
137    );
138    let mut local_var_req_builder =
139        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
140
141    if let Some(ref local_var_str) = filter {
142        local_var_req_builder =
143            local_var_req_builder.query(&[("filter", &local_var_str.to_string())]);
144    }
145    if let Some(ref local_var_str) = limit {
146        local_var_req_builder =
147            local_var_req_builder.query(&[("limit", &local_var_str.to_string())]);
148    }
149    if let Some(ref local_var_str) = offset {
150        local_var_req_builder =
151            local_var_req_builder.query(&[("offset", &local_var_str.to_string())]);
152    }
153    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
154        local_var_req_builder =
155            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
156    }
157    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
158        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
159    };
160
161    let local_var_req = local_var_req_builder.build()?;
162    let local_var_resp = local_var_client.execute(local_var_req).await?;
163
164    let local_var_status = local_var_resp.status();
165    let local_var_content = local_var_resp.text().await?;
166
167    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
168        serde_json::from_str(&local_var_content).map_err(Error::from)
169    } else {
170        let local_var_entity: Option<ReadPackagesByVulnCountError> =
171            serde_json::from_str(&local_var_content).ok();
172        let local_var_error = ResponseContent {
173            status: local_var_status,
174            content: local_var_content,
175            entity: local_var_entity,
176        };
177        Err(Error::ResponseError(local_var_error))
178    }
179}
180
181pub async fn read_packages_combined(
182    configuration: &configuration::Configuration,
183    filter: Option<&str>,
184    only_zero_day_affected: Option<bool>,
185    limit: Option<i32>,
186    offset: Option<i32>,
187    sort: Option<&str>,
188) -> Result<models::PackagesPeriodApiCombinedPackage, Error<ReadPackagesCombinedError>> {
189    let local_var_configuration = configuration;
190
191    let local_var_client = &local_var_configuration.client;
192
193    let local_var_uri_str = format!(
194        "{}/container-security/combined/packages/v1",
195        local_var_configuration.base_path
196    );
197    let mut local_var_req_builder =
198        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
199
200    if let Some(ref local_var_str) = filter {
201        local_var_req_builder =
202            local_var_req_builder.query(&[("filter", &local_var_str.to_string())]);
203    }
204    if let Some(ref local_var_str) = only_zero_day_affected {
205        local_var_req_builder =
206            local_var_req_builder.query(&[("only_zero_day_affected", &local_var_str.to_string())]);
207    }
208    if let Some(ref local_var_str) = limit {
209        local_var_req_builder =
210            local_var_req_builder.query(&[("limit", &local_var_str.to_string())]);
211    }
212    if let Some(ref local_var_str) = offset {
213        local_var_req_builder =
214            local_var_req_builder.query(&[("offset", &local_var_str.to_string())]);
215    }
216    if let Some(ref local_var_str) = sort {
217        local_var_req_builder =
218            local_var_req_builder.query(&[("sort", &local_var_str.to_string())]);
219    }
220    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
221        local_var_req_builder =
222            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
223    }
224    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
225        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
226    };
227
228    let local_var_req = local_var_req_builder.build()?;
229    let local_var_resp = local_var_client.execute(local_var_req).await?;
230
231    let local_var_status = local_var_resp.status();
232    let local_var_content = local_var_resp.text().await?;
233
234    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
235        serde_json::from_str(&local_var_content).map_err(Error::from)
236    } else {
237        let local_var_entity: Option<ReadPackagesCombinedError> =
238            serde_json::from_str(&local_var_content).ok();
239        let local_var_error = ResponseContent {
240            status: local_var_status,
241            content: local_var_content,
242            entity: local_var_entity,
243        };
244        Err(Error::ResponseError(local_var_error))
245    }
246}
247
248pub async fn read_packages_combined_export(
249    configuration: &configuration::Configuration,
250    filter: Option<&str>,
251    only_zero_day_affected: Option<bool>,
252    limit: Option<i32>,
253    offset: Option<i32>,
254    sort: Option<&str>,
255) -> Result<models::PackagesPeriodApiCombinedPackageExport, Error<ReadPackagesCombinedExportError>>
256{
257    let local_var_configuration = configuration;
258
259    let local_var_client = &local_var_configuration.client;
260
261    let local_var_uri_str = format!(
262        "{}/container-security/combined/packages/export/v1",
263        local_var_configuration.base_path
264    );
265    let mut local_var_req_builder =
266        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
267
268    if let Some(ref local_var_str) = filter {
269        local_var_req_builder =
270            local_var_req_builder.query(&[("filter", &local_var_str.to_string())]);
271    }
272    if let Some(ref local_var_str) = only_zero_day_affected {
273        local_var_req_builder =
274            local_var_req_builder.query(&[("only_zero_day_affected", &local_var_str.to_string())]);
275    }
276    if let Some(ref local_var_str) = limit {
277        local_var_req_builder =
278            local_var_req_builder.query(&[("limit", &local_var_str.to_string())]);
279    }
280    if let Some(ref local_var_str) = offset {
281        local_var_req_builder =
282            local_var_req_builder.query(&[("offset", &local_var_str.to_string())]);
283    }
284    if let Some(ref local_var_str) = sort {
285        local_var_req_builder =
286            local_var_req_builder.query(&[("sort", &local_var_str.to_string())]);
287    }
288    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
289        local_var_req_builder =
290            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
291    }
292    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
293        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
294    };
295
296    let local_var_req = local_var_req_builder.build()?;
297    let local_var_resp = local_var_client.execute(local_var_req).await?;
298
299    let local_var_status = local_var_resp.status();
300    let local_var_content = local_var_resp.text().await?;
301
302    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
303        serde_json::from_str(&local_var_content).map_err(Error::from)
304    } else {
305        let local_var_entity: Option<ReadPackagesCombinedExportError> =
306            serde_json::from_str(&local_var_content).ok();
307        let local_var_error = ResponseContent {
308            status: local_var_status,
309            content: local_var_content,
310            entity: local_var_entity,
311        };
312        Err(Error::ResponseError(local_var_error))
313    }
314}
315
316pub async fn read_packages_count_by_zero_day(
317    configuration: &configuration::Configuration,
318    filter: Option<&str>,
319) -> Result<models::CommonPeriodCountResponse, Error<ReadPackagesCountByZeroDayError>> {
320    let local_var_configuration = configuration;
321
322    let local_var_client = &local_var_configuration.client;
323
324    let local_var_uri_str = format!(
325        "{}/container-security/aggregates/packages/count-by-zero-day/v1",
326        local_var_configuration.base_path
327    );
328    let mut local_var_req_builder =
329        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
330
331    if let Some(ref local_var_str) = filter {
332        local_var_req_builder =
333            local_var_req_builder.query(&[("filter", &local_var_str.to_string())]);
334    }
335    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
336        local_var_req_builder =
337            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
338    }
339    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
340        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
341    };
342
343    let local_var_req = local_var_req_builder.build()?;
344    let local_var_resp = local_var_client.execute(local_var_req).await?;
345
346    let local_var_status = local_var_resp.status();
347    let local_var_content = local_var_resp.text().await?;
348
349    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
350        serde_json::from_str(&local_var_content).map_err(Error::from)
351    } else {
352        let local_var_entity: Option<ReadPackagesCountByZeroDayError> =
353            serde_json::from_str(&local_var_content).ok();
354        let local_var_error = ResponseContent {
355            status: local_var_status,
356            content: local_var_content,
357            entity: local_var_entity,
358        };
359        Err(Error::ResponseError(local_var_error))
360    }
361}