1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
use crate::{
types::{Acr, AcrUpdate, AssetByUuidReq, AssetsMove, AssetsMoveDef, AssetsReq},
Tenable,
};
use std::borrow::Cow;
/// Provides methods for the `Asset` Type.
pub trait AssetReq {
/// Lists up to 5,000 assets.
///
/// **Note:** You can use the `assets_export` endpoint to export data for all
/// assets.
///
/// # Permission
///
/// Requires BASIC [16] user permissions.
///
/// # Example
///
/// ```no_run
/// use std::convert::Infallible;
/// use tenable::{requests::AssetReq, Error, Response, Tenable, types::Assets};
/// let tenable = Tenable::new(
/// "0000000000000000000000000000000000000000000000000000000000000000",
/// "0000000000000000000000000000000000000000000000000000000000000000",
/// );
/// let req = tenable.assets();
/// let _assets: Assets = Tenable::request(req, |_| {
/// Result::<Response, Error<Infallible>>::Ok(todo!("Define a method to send http requests"))
/// })
/// .expect("Unable to list assets");
/// ```
fn assets(&self) -> AssetsReq<'_>;
/// Returns details of the specified asset.
///
/// # Permission
///
/// Requires BASIC [16] user permissions.
///
/// # Example
///
/// ```no_run
/// use std::convert::Infallible;
/// use tenable::{requests::AssetReq, Error, Response, Tenable, types::AssetByUuid};
/// let tenable = Tenable::new(
/// "0000000000000000000000000000000000000000000000000000000000000000",
/// "0000000000000000000000000000000000000000000000000000000000000000",
/// );
/// let req = tenable.asset_by_uuid("00000000-0000-0000-0000-000000000000");
/// let _asset: AssetByUuid = Tenable::request(req, |_| {
/// Result::<Response, Error<Infallible>>::Ok(todo!("Define a method to send http requests"))
/// })
/// .expect("Unable to fetch asset")
/// .expect("Asset not found");
/// ```
fn asset_by_uuid<'a, I: Into<Cow<'a, str>>>(&'a self, asset_uuid: I) -> AssetByUuidReq<'a>;
/// Overwrites the Tenable-provided Asset Criticality Rating (ACR) for the specified
/// assets. Tenable assigns an ACR to each asset on your network to represent the
/// asset's relative risk as an integer from 1 to 10. For more information about ACR,
/// see Lumin metrics in the Tenable.io Vulnerability Management User Guide.
///
/// You must have a Lumin license to update the ACR for assets in your organization.
///
/// # Permission
///
/// Requires ADMINISTRATOR [64] user permissions.
///
/// # Example
///
/// ```no_run
/// use std::convert::Infallible;
/// use tenable::{requests::AssetReq, types::Acr, Error, Response, Tenable};
/// let tenable = Tenable::new(
/// "0000000000000000000000000000000000000000000000000000000000000000",
/// "0000000000000000000000000000000000000000000000000000000000000000",
/// );
/// let req = tenable.acr_update(vec![Acr {
/// acr_score: 0,
/// asset: Vec::new(),
/// ..Acr::default()
/// }]);
/// Tenable::request(req, |_| {
/// Result::<Response, Error<Infallible>>::Ok(todo!("Define a method to send http requests"))
/// })
/// .expect("Unable to update acr");
/// ```
fn acr_update<'a, I: Into<Cow<'a, [Acr]>>>(&'a self, acrs: I) -> AcrUpdate<'a>;
/// Moves assets from the specified network to another network. You can use this endpoint to move
/// assets from the default network to a user-defined network, from a user-defined network to the
/// default network, and from one user-defined network to another user-defined network. This request
/// creates an asynchronous job in Tenable.io.
///
/// For information about the assets move workflow and payload examples, see Bulk Asset Operations.
///
/// Requires ADMINISTRATOR [64] user permissions.
///
/// # Example
///
/// ```no_run
/// use std::convert::Infallible;
/// use tenable::{requests::AssetReq, Error, Response, Tenable, types::{AssetsMoveDef, MovedAssets}};
/// let tenable = Tenable::new(
/// "0000000000000000000000000000000000000000000000000000000000000000",
/// "0000000000000000000000000000000000000000000000000000000000000000",
/// );
/// let req = tenable.assets_move(AssetsMoveDef {
/// source: "00000000-0000-0000-0000-000000000000".into(),
/// destination: "00000000-0000-0000-0000-000000000001".into(),
/// targets: "172.204.81.57-172.204.81.69".into()
/// });
/// let _move_info: MovedAssets = Tenable::request(req, |_| {
/// Result::<Response, Error<Infallible>>::Ok(todo!("Define a method to send http requests"))
/// })
/// .expect("Unable to move assets")
/// .expect("Networks not found");
/// ```
fn assets_move<'a, I: Into<Cow<'a, AssetsMoveDef>>>(
&'a self,
assets_move_def: I,
) -> AssetsMove<'a>;
}
impl AssetReq for Tenable<'_> {
#[inline]
fn assets(&self) -> AssetsReq<'_> {
AssetsReq { tenable: self }
}
#[inline]
fn asset_by_uuid<'a, I: Into<Cow<'a, str>>>(&'a self, asset_uuid: I) -> AssetByUuidReq<'a> {
AssetByUuidReq {
tenable: self,
asset_uuid: asset_uuid.into(),
}
}
#[inline]
fn acr_update<'a, I: Into<Cow<'a, [Acr]>>>(&'a self, acrs: I) -> AcrUpdate<'a> {
AcrUpdate {
tenable: self,
acrs: acrs.into(),
}
}
#[inline]
fn assets_move<'a, I: Into<Cow<'a, AssetsMoveDef>>>(
&'a self,
assets_move_def: I,
) -> AssetsMove<'a> {
AssetsMove {
tenable: self,
assets_move_def: assets_move_def.into(),
}
}
}