lebe-dev / zabbix-api-rs

Zabbix API for Rust
MIT License
4 stars 2 forks source link

Q: What is syntax for specify attributes for CreateHostReqest ? #11

Closed tjyang closed 7 months ago

tjyang commented 8 months ago

@lebe-dev Would you please provide an example of passing interface attributes using vec![] ?

lebe-dev commented 8 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
}
tjyang commented 8 months ago

Thanks for CustomCreateHostRequest hint. Would you please provide and complete rust code example on specifying interfaces parameters ?

``

lebe-dev commented 8 months ago

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>
  ...
}
tjyang commented 8 months ago

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.

tjyang commented 7 months ago

I am closing this ticket for. I decided to use different approach to do CRUD opts with zabbix API. Thanks.