zabbix_api/host/
model.rs

1use serde::{Deserialize, Serialize};
2use serde_with::skip_serializing_none;
3use std::cmp::PartialEq;
4use std::str::FromStr;
5
6#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
7pub enum HostStatus {
8    #[serde(rename = "0")]
9    Enabled,
10    #[serde(rename = "1")]
11    Disabled,
12}
13
14impl FromStr for HostStatus {
15    type Err = ();
16
17    fn from_str(s: &str) -> Result<Self, Self::Err> {
18        match s {
19            "0" => Ok(HostStatus::Enabled),
20            "1" => Ok(HostStatus::Disabled),
21            _ => Err(()),
22        }
23    }
24}
25
26/// API Object: https://www.zabbix.com/documentation/6.0/en/manual/api/reference/host/object
27#[derive(Deserialize, PartialEq, Clone, Debug)]
28pub struct ZabbixHost {
29    #[serde(rename = "hostid")]
30    pub host_id: String,
31    pub host: String,
32    pub status: HostStatus,
33}
34
35// API Object: https://www.zabbix.com/documentation/6.0/en/manual/api/reference/host/object#host-tag
36#[derive(Serialize, Deserialize, PartialEq, Clone, Debug)]
37pub struct ZabbixHostTag {
38    pub tag: String,
39    pub value: String,
40}
41
42/// API Object: https://www.zabbix.com/documentation/6.0/en/manual/api/reference/hostinterface/object
43#[derive(Serialize, Deserialize, PartialEq, Clone, Debug)]
44pub struct ZabbixHostInterface {
45    pub r#type: u8,
46    pub main: u8,
47    pub ip: String,
48    pub dns: String,
49    pub port: String,
50    #[serde(rename = "useip")]
51    pub use_ip: u8,
52}
53
54/// API Object: https://www.zabbix.com/documentation/6.0/en/manual/api/reference/host/object#host-inventory
55#[skip_serializing_none]
56#[derive(Serialize, Deserialize, PartialEq, Clone, Debug, Default)]
57pub struct ZabbixHostInventory {
58    #[serde(rename = "type")]
59    pub r#type: Option<String>,
60    pub type_full: Option<String>,
61    pub name: Option<String>,
62    pub alias: Option<String>,
63    pub os: Option<String>,
64    pub os_full: Option<String>,
65    pub os_short: Option<String>,
66    pub serialno_a: Option<String>,
67    pub serialno_b: Option<String>,
68    pub tag: Option<String>,
69    pub asset_tag: Option<String>,
70    pub macaddress_a: Option<String>,
71    pub macaddress_b: Option<String>,
72    pub hardware: Option<String>,
73    pub hardware_full: Option<String>,
74    pub software: Option<String>,
75    pub software_full: Option<String>,
76    pub software_app_a: Option<String>,
77    pub software_app_b: Option<String>,
78    pub software_app_c: Option<String>,
79    pub software_app_d: Option<String>,
80    pub software_app_e: Option<String>,
81    pub contact: Option<String>,
82    pub location: Option<String>,
83    pub location_lat: Option<String>,
84    pub location_lon: Option<String>,
85    pub notes: Option<String>,
86    pub chassis: Option<String>,
87    pub model: Option<String>,
88    pub hw_arch: Option<String>,
89    pub vendor: Option<String>,
90    pub contract_number: Option<String>,
91    pub installer_name: Option<String>,
92    pub deployment_status: Option<String>,
93    pub url_a: Option<String>,
94    pub url_b: Option<String>,
95    pub url_c: Option<String>,
96    pub host_networks: Option<String>,
97    pub host_netmask: Option<String>,
98    pub host_router: Option<String>,
99    pub oob_ip: Option<String>,
100    pub oob_netmask: Option<String>,
101    pub oob_router: Option<String>,
102    pub date_hw_purchase: Option<String>,
103    pub date_hw_install: Option<String>,
104    pub date_hw_expiry: Option<String>,
105    pub date_hw_decomm: Option<String>,
106    pub site_address_a: Option<String>,
107    pub site_address_b: Option<String>,
108    pub site_address_c: Option<String>,
109    pub site_city: Option<String>,
110    pub site_state: Option<String>,
111    pub site_country: Option<String>,
112    pub site_zip: Option<String>,
113    pub site_rack: Option<String>,
114    pub site_notes: Option<String>,
115    pub poc_1_name: Option<String>,
116    pub poc_1_email: Option<String>,
117    pub poc_1_phone_a: Option<String>,
118    pub poc_1_phone_b: Option<String>,
119    pub poc_1_cell: Option<String>,
120    pub poc_1_screen: Option<String>,
121    pub poc_1_notes: Option<String>,
122    pub poc_2_name: Option<String>,
123    pub poc_2_email: Option<String>,
124    pub poc_2_phone_a: Option<String>,
125    pub poc_2_phone_b: Option<String>,
126    pub poc_2_cell: Option<String>,
127    pub poc_2_screen: Option<String>,
128    pub poc_2_notes: Option<String>,
129}
130
131impl ZabbixHostInventory {
132    pub fn builder() -> ZabbixHostInventoryBuilder {
133        ZabbixHostInventoryBuilder::default()
134    }
135}
136
137#[derive(Default)]
138pub struct ZabbixHostInventoryBuilder {
139    inner: ZabbixHostInventory,
140}
141
142impl ZabbixHostInventoryBuilder {
143    pub fn r#type(mut self, value: impl ToString) -> Self {
144        self.inner.r#type = Some(value.to_string());
145        self
146    }
147
148    pub fn type_full(mut self, value: impl ToString) -> Self {
149        self.inner.type_full = Some(value.to_string());
150        self
151    }
152
153    pub fn name(mut self, value: impl ToString) -> Self {
154        self.inner.name = Some(value.to_string());
155        self
156    }
157
158    pub fn alias(mut self, value: impl ToString) -> Self {
159        self.inner.alias = Some(value.to_string());
160        self
161    }
162
163    pub fn os(mut self, value: impl ToString) -> Self {
164        self.inner.os = Some(value.to_string());
165        self
166    }
167
168    pub fn os_full(mut self, value: impl ToString) -> Self {
169        self.inner.os_full = Some(value.to_string());
170        self
171    }
172
173    pub fn os_short(mut self, value: impl ToString) -> Self {
174        self.inner.os_short = Some(value.to_string());
175        self
176    }
177
178    pub fn serialno_a(mut self, value: impl ToString) -> Self {
179        self.inner.serialno_a = Some(value.to_string());
180        self
181    }
182
183    pub fn serialno_b(mut self, value: impl ToString) -> Self {
184        self.inner.serialno_b = Some(value.to_string());
185        self
186    }
187
188    pub fn tag(mut self, value: impl ToString) -> Self {
189        self.inner.tag = Some(value.to_string());
190        self
191    }
192
193    pub fn asset_tag(mut self, value: impl ToString) -> Self {
194        self.inner.asset_tag = Some(value.to_string());
195        self
196    }
197
198    pub fn macaddress_a(mut self, value: impl ToString) -> Self {
199        self.inner.macaddress_a = Some(value.to_string());
200        self
201    }
202
203    pub fn macaddress_b(mut self, value: impl ToString) -> Self {
204        self.inner.macaddress_b = Some(value.to_string());
205        self
206    }
207
208    pub fn hardware(mut self, value: impl ToString) -> Self {
209        self.inner.hardware = Some(value.to_string());
210        self
211    }
212
213    pub fn hardware_full(mut self, value: impl ToString) -> Self {
214        self.inner.hardware_full = Some(value.to_string());
215        self
216    }
217
218    pub fn software(mut self, value: impl ToString) -> Self {
219        self.inner.software = Some(value.to_string());
220        self
221    }
222
223    pub fn software_full(mut self, value: impl ToString) -> Self {
224        self.inner.software_full = Some(value.to_string());
225        self
226    }
227
228    pub fn software_app_a(mut self, value: impl ToString) -> Self {
229        self.inner.software_app_a = Some(value.to_string());
230        self
231    }
232
233    pub fn software_app_b(mut self, value: impl ToString) -> Self {
234        self.inner.software_app_b = Some(value.to_string());
235        self
236    }
237
238    pub fn software_app_c(mut self, value: impl ToString) -> Self {
239        self.inner.software_app_c = Some(value.to_string());
240        self
241    }
242
243    pub fn software_app_d(mut self, value: impl ToString) -> Self {
244        self.inner.software_app_d = Some(value.to_string());
245        self
246    }
247
248    pub fn software_app_e(mut self, value: impl ToString) -> Self {
249        self.inner.software_app_e = Some(value.to_string());
250        self
251    }
252
253    pub fn contact(mut self, value: impl ToString) -> Self {
254        self.inner.contact = Some(value.to_string());
255        self
256    }
257
258    pub fn location(mut self, value: impl ToString) -> Self {
259        self.inner.location = Some(value.to_string());
260        self
261    }
262
263    pub fn location_lat(mut self, value: impl ToString) -> Self {
264        self.inner.location_lat = Some(value.to_string());
265        self
266    }
267
268    pub fn location_lon(mut self, value: impl ToString) -> Self {
269        self.inner.location_lon = Some(value.to_string());
270        self
271    }
272
273    pub fn notes(mut self, value: impl ToString) -> Self {
274        self.inner.notes = Some(value.to_string());
275        self
276    }
277
278    pub fn chassis(mut self, value: impl ToString) -> Self {
279        self.inner.chassis = Some(value.to_string());
280        self
281    }
282
283    pub fn model(mut self, value: impl ToString) -> Self {
284        self.inner.model = Some(value.to_string());
285        self
286    }
287
288    pub fn hw_arch(mut self, value: impl ToString) -> Self {
289        self.inner.hw_arch = Some(value.to_string());
290        self
291    }
292
293    pub fn vendor(mut self, value: impl ToString) -> Self {
294        self.inner.vendor = Some(value.to_string());
295        self
296    }
297
298    pub fn contract_number(mut self, value: impl ToString) -> Self {
299        self.inner.contract_number = Some(value.to_string());
300        self
301    }
302
303    pub fn installer_name(mut self, value: impl ToString) -> Self {
304        self.inner.installer_name = Some(value.to_string());
305        self
306    }
307
308    pub fn deployment_status(mut self, value: impl ToString) -> Self {
309        self.inner.deployment_status = Some(value.to_string());
310        self
311    }
312
313    pub fn url_a(mut self, value: impl ToString) -> Self {
314        self.inner.url_a = Some(value.to_string());
315        self
316    }
317
318    pub fn url_b(mut self, value: impl ToString) -> Self {
319        self.inner.url_b = Some(value.to_string());
320        self
321    }
322
323    pub fn url_c(mut self, value: impl ToString) -> Self {
324        self.inner.url_c = Some(value.to_string());
325        self
326    }
327
328    pub fn host_networks(mut self, value: impl ToString) -> Self {
329        self.inner.host_networks = Some(value.to_string());
330        self
331    }
332
333    pub fn host_netmask(mut self, value: impl ToString) -> Self {
334        self.inner.host_netmask = Some(value.to_string());
335        self
336    }
337
338    pub fn host_router(mut self, value: impl ToString) -> Self {
339        self.inner.host_router = Some(value.to_string());
340        self
341    }
342
343    pub fn oob_ip(mut self, value: impl ToString) -> Self {
344        self.inner.oob_ip = Some(value.to_string());
345        self
346    }
347
348    pub fn oob_netmask(mut self, value: impl ToString) -> Self {
349        self.inner.oob_netmask = Some(value.to_string());
350        self
351    }
352
353    pub fn oob_router(mut self, value: impl ToString) -> Self {
354        self.inner.oob_router = Some(value.to_string());
355        self
356    }
357
358    pub fn date_hw_purchase(mut self, value: impl ToString) -> Self {
359        self.inner.date_hw_purchase = Some(value.to_string());
360        self
361    }
362
363    pub fn date_hw_install(mut self, value: impl ToString) -> Self {
364        self.inner.date_hw_install = Some(value.to_string());
365        self
366    }
367
368    pub fn date_hw_expiry(mut self, value: impl ToString) -> Self {
369        self.inner.date_hw_expiry = Some(value.to_string());
370        self
371    }
372
373    pub fn date_hw_decomm(mut self, value: impl ToString) -> Self {
374        self.inner.date_hw_decomm = Some(value.to_string());
375        self
376    }
377
378    pub fn site_address_a(mut self, value: impl ToString) -> Self {
379        self.inner.site_address_a = Some(value.to_string());
380        self
381    }
382
383    pub fn site_address_b(mut self, value: impl ToString) -> Self {
384        self.inner.site_address_b = Some(value.to_string());
385        self
386    }
387
388    pub fn site_address_c(mut self, value: impl ToString) -> Self {
389        self.inner.site_address_c = Some(value.to_string());
390        self
391    }
392
393    pub fn site_city(mut self, value: impl ToString) -> Self {
394        self.inner.site_city = Some(value.to_string());
395        self
396    }
397
398    pub fn site_state(mut self, value: impl ToString) -> Self {
399        self.inner.site_state = Some(value.to_string());
400        self
401    }
402
403    pub fn site_country(mut self, value: impl ToString) -> Self {
404        self.inner.site_country = Some(value.to_string());
405        self
406    }
407
408    pub fn site_zip(mut self, value: impl ToString) -> Self {
409        self.inner.site_zip = Some(value.to_string());
410        self
411    }
412
413    pub fn site_rack(mut self, value: impl ToString) -> Self {
414        self.inner.site_rack = Some(value.to_string());
415        self
416    }
417
418    pub fn site_notes(mut self, value: impl ToString) -> Self {
419        self.inner.site_notes = Some(value.to_string());
420        self
421    }
422
423    pub fn poc_1_name(mut self, value: impl ToString) -> Self {
424        self.inner.poc_1_name = Some(value.to_string());
425        self
426    }
427
428    pub fn poc_1_email(mut self, value: impl ToString) -> Self {
429        self.inner.poc_1_email = Some(value.to_string());
430        self
431    }
432
433    pub fn poc_1_phone_a(mut self, value: impl ToString) -> Self {
434        self.inner.poc_1_phone_a = Some(value.to_string());
435        self
436    }
437
438    pub fn poc_1_phone_b(mut self, value: impl ToString) -> Self {
439        self.inner.poc_1_phone_b = Some(value.to_string());
440        self
441    }
442
443    pub fn poc_1_cell(mut self, value: impl ToString) -> Self {
444        self.inner.poc_1_cell = Some(value.to_string());
445        self
446    }
447
448    pub fn poc_1_screen(mut self, value: impl ToString) -> Self {
449        self.inner.poc_1_screen = Some(value.to_string());
450        self
451    }
452
453    pub fn poc_1_notes(mut self, value: impl ToString) -> Self {
454        self.inner.poc_1_notes = Some(value.to_string());
455        self
456    }
457
458    pub fn poc_2_name(mut self, value: impl ToString) -> Self {
459        self.inner.poc_2_name = Some(value.to_string());
460        self
461    }
462
463    pub fn poc_2_email(mut self, value: impl ToString) -> Self {
464        self.inner.poc_2_email = Some(value.to_string());
465        self
466    }
467
468    pub fn poc_2_phone_a(mut self, value: impl ToString) -> Self {
469        self.inner.poc_2_phone_a = Some(value.to_string());
470        self
471    }
472
473    pub fn poc_2_phone_b(mut self, value: impl ToString) -> Self {
474        self.inner.poc_2_phone_b = Some(value.to_string());
475        self
476    }
477
478    pub fn poc_2_cell(mut self, value: impl ToString) -> Self {
479        self.inner.poc_2_cell = Some(value.to_string());
480        self
481    }
482
483    pub fn poc_2_screen(mut self, value: impl ToString) -> Self {
484        self.inner.poc_2_screen = Some(value.to_string());
485        self
486    }
487
488    pub fn poc_2_notes(mut self, value: impl ToString) -> Self {
489        self.inner.poc_2_notes = Some(value.to_string());
490        self
491    }
492
493    pub fn build(self) -> ZabbixHostInventory {
494        self.inner
495    }
496}