Closed tjyang closed 7 months ago
Zabbix API is huge and dynamic (hello from php world), so, I can't implement all possible fields for request struct based on Zabbix API object :) I've implemented just what i needed. But api client methods allows you to implement any structure you want.
Just don't use current CreateHostRequest and implement your own request struct. The only one requirement - your struct should have Serialize
:
#[derive(Serialize)]
struct CustomCreateHostRequest {
// any fields you want
}
Thanks for CustomCreateHostRequest hint. Would you please provide and complete rust code example on specifying interfaces parameters ?
let request = CustomCreateHostRequest {
host: host_name,
groups: vec![host_group],
interfaces: vec![
"type",
1,
"main",
1,
"useip",
1,
"ip",
"192.168.3.1",
"dns",
"",
"port",
"10050",
],
tags: vec![],
templates: vec![],
macros: vec![],
inventory_mode: 0,
inventory: Default::default(),
};
``
I would implement struct ZabbixInterface with fields you need - https://www.zabbix.com/documentation/6.0/en/manual/api/reference/hostinterface/object
Then implement something like this:
#[derive(Serialize)]
struct CreateHostRequest {
...
pub interfaces: Vec<ZabbixInterface>
...
}
Sorry Rust beginner here. I failed to understand. This will be a good beginner home work I guest ;) I have to study on how to use serialize syntax and example.
I am closing this ticket for. I decided to use different approach to do CRUD opts with zabbix API. Thanks.
@lebe-dev Would you please provide an example of passing interface attributes using vec![] ?