lebe-dev / zabbix-api-rs

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

Please add create_host example #8

Closed tjyang closed 9 months ago

tjyang commented 9 months ago

Hi @lebe-dev I was able to follow get_host example code to really get a host's information. Can you please add create_host example ?

[zabbix-api-rs]$ egrep -r "\/\/\/\s\*\*" src
src/client/mod.rs:    /// **Example:**
[me@rocky9t01a zabbix-api-rs]$ egrep -r "\/\/\/\s\*\*Example" src
src/client/mod.rs:    /// **Example:**
[zabbix-api-rs]$
lebe-dev commented 9 months ago

Added doc for create_host method https://github.com/lebe-dev/zabbix-api-rs/blob/792f83c88967ae588fb7ab6b210400c12c7d6240/src/client/mod.rs#L80

If you want to use dev version you should add dependency

[dependencies]
...
zabbix-api = { git = "https://github.com/lebe-dev/zabbix-api-rs.git" }
...
tjyang commented 9 months ago

Thanks, let me try it and will close upon success.

tjyang commented 9 months ago

Thanks for the create host example, I was able to see it on zabbix web GUI after creating a test01.test.net host.

Can you add error handling after host creation ? based on zabbix_api::host::create::CreateHostResponse.

lebe-dev commented 9 months ago

Why? The last instruction uses .unwrap(), test fails if any error occurs.

For example of doctest: https://doc.rust-lang.org/rust-by-example/testing/doc_testing.html#motivation-behind-documentation-tests

tjyang commented 9 months ago

Thanks for the url pointer. I now understand why no need since it is a documentation tests