attackerkb_api_rs/v1/
query.rs

1use crate::pagination::default_size;
2use chrono::NaiveDate;
3use derive_builder::Builder;
4use serde::{Deserialize, Serialize};
5use uuid::Uuid;
6
7#[derive(Debug, Serialize, Deserialize, PartialEq, Clone, Builder)]
8#[builder(setter(into), default)]
9#[serde(rename_all = "camelCase")]
10pub struct TopicsParameters {
11  /// The UUID of a specific topic to return.
12  /// Example: c0f010fe-da9c-4aa6-b898-c57d483df51b
13  pub id: Option<Uuid>,
14  /// The UUID of a contributor.
15  /// Example: c28a806c-84c7-44bf-95d3-1241475de5bf
16  pub editor_id: Option<Uuid>,
17  /// Text to query the name attribute. A substring match is performed
18  /// Example: bluekeep
19  pub name: Option<String>,
20  /// Return all topics that were created on the given date.
21  /// Example: 2019-07-04
22  pub created: Option<NaiveDate>,
23  /// Return all topics that were created after the given date.
24  /// Example: 2019-07-04
25  pub created_after: Option<NaiveDate>,
26  /// Return all topics that were created before the given date.
27  /// Example: 2019-07-04
28  pub created_before: Option<NaiveDate>,
29  /// Return all topics that were last edited on the given date.
30  /// Example: 2019-07-04
31  pub revision_date: Option<NaiveDate>,
32  /// Return all topics that were last edited after the given date.
33  /// Example: 2019-07-04
34  pub revised_after: Option<NaiveDate>,
35  /// Return all topics that were last edited before the given date.
36  /// Example: 2019-07-04
37  pub revised_before: Option<NaiveDate>,
38  /// Return all topics that were disclosed on the given date.
39  /// Example: 2019-07-04
40  pub disclosure_date: Option<NaiveDate>,
41  /// Text to query the document attribute. A substring match is performed
42  /// Example : RDP
43  pub document: Option<String>,
44  /// Text to query the metadata attribute. A substring match is performed
45  /// Example : metasploit
46  pub metadata: Option<String>,
47  /// Return all topics that are featured.
48  pub featured: Option<bool>,
49  /// Return all topics where the rapid7Analysis was created on the given date.
50  /// Example: 2019-07-04
51  pub rapid7_analysis_created: Option<NaiveDate>,
52  /// Return all topics where the rapid7Analysis was created after the given date.
53  /// Example: 2019-07-04
54  pub rapid7_analysis_created_after: Option<NaiveDate>,
55  /// Return all topics where the rapid7Analysis was created before the given date.
56  /// Example: 2019-07-04
57  pub rapid7_analysis_created_before: Option<NaiveDate>,
58  /// Return all topics where the rapid7Analysis was last edited on the given date.
59  /// Example: 2019-07-04
60  pub rapid7_analysis_revision_date: Option<NaiveDate>,
61  /// Return all topics where the rapid7Analysis was last edited after the given date.
62  /// Example: 2019-07-04
63  pub rapid7_analysis_revised_after: Option<NaiveDate>,
64  /// Return all topics where the rapid7Analysis was last edited before the given date.
65  /// Example: 2019-07-04
66  pub rapid7_analysis_revised_before: Option<NaiveDate>,
67  /// Return all topics that have content that matches the query string q.
68  /// Example : eternal blue
69  pub q: Option<String>,
70  /// Pagination page number.
71  /// Default value : 0
72  #[serde(default)]
73  pub page: i32,
74  /// The number of topics returned per page.
75  /// Default value : 10
76  #[serde(default = "default_size")]
77  pub size: i32,
78  pub sort: Option<String>,
79  pub expand: Option<String>,
80}
81
82impl Default for TopicsParameters {
83  fn default() -> Self {
84    Self {
85      id: None,
86      editor_id: None,
87      name: None,
88      created: None,
89      created_after: None,
90      created_before: None,
91      revision_date: None,
92      revised_after: None,
93      revised_before: None,
94      disclosure_date: None,
95      document: None,
96      metadata: None,
97      featured: None,
98      rapid7_analysis_created: None,
99      rapid7_analysis_created_after: None,
100      rapid7_analysis_created_before: None,
101      rapid7_analysis_revision_date: None,
102      rapid7_analysis_revised_after: None,
103      rapid7_analysis_revised_before: None,
104      q: None,
105      page: 0,
106      size: 10,
107      sort: None,
108      expand: None,
109    }
110  }
111}
112
113#[derive(Debug, Serialize, Deserialize, PartialEq, Clone, Builder)]
114#[builder(setter(into), default)]
115#[serde(rename_all = "camelCase")]
116pub struct AssessmentsParameters {
117  /// The UUID of a specific assessment to return.
118  /// Example: c0f010fe-da9c-4aa6-b898-c57d483df51b
119  pub id: Option<Uuid>,
120  /// The UUID of a contributor.
121  /// Example: c28a806c-84c7-44bf-95d3-1241475de5bf
122  pub editor_id: Option<Uuid>,
123  /// The UUID of the topic this assessment was based on.
124  /// Example: c28a806c-84c7-44bf-95d3-1241475de5bf
125  pub topic_id: Option<Uuid>,
126  /// Return all assessments that were created on the given date.
127  /// Example: 2019-07-04
128  pub created: Option<NaiveDate>,
129  /// Return all assessments that were created after the given date.
130  /// Example: 2019-07-04
131  pub created_after: Option<NaiveDate>,
132  /// Return all assessments that were created before the given date.
133  /// Example: 2019-07-04
134  pub created_before: Option<NaiveDate>,
135  /// Return all assessments that were last edited on the given date.
136  /// Example: 2019-07-04
137  pub revision_date: Option<NaiveDate>,
138  /// Return all assessments that were last edited after the given date.
139  /// Example: 2019-07-04
140  pub revised_after: Option<NaiveDate>,
141  /// Return all assessments that were last edited before the given date.
142  /// Example: 2019-07-04
143  pub revised_before: Option<NaiveDate>,
144  /// Return all topics that were disclosed on the given date.
145  /// Example: 2019-07-04
146  pub document: Option<String>,
147  /// Return all assessments with this score.
148  pub score: Option<i32>,
149  /// Text to query the metadata attribute. A substring match is performed
150  /// Example : metasploit
151  pub metadata: Option<String>,
152  /// Return all assessments that have content that matches the query string q.
153  pub q: Option<String>,
154  /// Pagination page number.
155  /// Default value : 0
156  #[serde(default)]
157  pub page: i32,
158  /// The number of topics returned per page.
159  /// Default value : 10
160  #[serde(default = "default_size")]
161  pub size: i32,
162  /// Sort by assessment attribute. This parameter takes the form attribute:order.
163  /// attribute: id, editorId, created, revisionDate, document, score, metadata
164  /// order: asc (ascending), desc (descending)
165  /// Each attribute is sorted by its respective type.
166  pub sort: Option<String>,
167  /// Comma separated list of related objects to fully expand in the returned result. Only the id of related objects will be included if this parameter is not specified.
168  pub expand: Option<String>,
169}
170
171impl Default for AssessmentsParameters {
172  fn default() -> Self {
173    Self {
174      id: None,
175      editor_id: None,
176      topic_id: None,
177      created: None,
178      created_after: None,
179      created_before: None,
180      revision_date: None,
181      revised_after: None,
182      revised_before: None,
183      document: None,
184      score: None,
185      metadata: None,
186      q: None,
187      page: 0,
188      size: 10,
189      sort: None,
190      expand: None,
191    }
192  }
193}
194
195#[derive(Debug, Serialize, Deserialize, PartialEq, Clone, Builder)]
196#[builder(setter(into), default)]
197#[serde(rename_all = "camelCase")]
198pub struct ContributorsParameters {
199  /// The UUID of a specific contributor to return.
200  /// Example: c0f010fe-da9c-4aa6-b898-c57d483df51b
201  pub id: Option<Uuid>,
202  /// Return contributors with the matching username.
203  /// Example: c28a806c-84c7-44bf-95d3-1241475de5bf
204  pub username: Option<String>,
205  /// Return all contributors where avatar matches the given value.
206  /// Example: c28a806c-84c7-44bf-95d3-1241475de5bf
207  pub avatar: Option<Uuid>,
208  /// Return all contributors that were created on the given date.
209  /// Example: 2019-07-04
210  pub created: Option<NaiveDate>,
211  /// Return all contributors that were created after the given date.
212  /// Example: 2019-07-04
213  pub created_after: Option<NaiveDate>,
214  /// Return all contributors that were created before the given date.
215  /// Example: 2019-07-04
216  pub created_before: Option<NaiveDate>,
217  /// Return all contributors with this score.
218  pub score: Option<i32>,
219  /// Return all contributors that have usernames that match the query string q.
220  pub q: Option<String>,
221  /// Pagination page number.
222  /// Default value : 0
223  #[serde(default)]
224  pub page: i32,
225  /// The number of topics returned per page.
226  /// Default value : 10
227  #[serde(default = "default_size")]
228  pub size: i32,
229  /// Sort by contributor attribute. This parameter takes the form attribute:order.
230  /// attribute: id, username, avatar, created, score.
231  /// order: asc (ascending), desc (descending)
232  /// Each attribute is sorted by its respective type.
233  pub sort: Option<String>,
234}
235
236impl Default for ContributorsParameters {
237  fn default() -> Self {
238    Self {
239      id: None,
240      username: None,
241      avatar: None,
242      created: None,
243      created_after: None,
244      created_before: None,
245      score: None,
246      q: None,
247      page: 0,
248      size: 10,
249      sort: None,
250    }
251  }
252}