| Crates.io | chef |
| lib.rs | chef |
| version | 0.1.0 |
| created_at | 2017-12-21 15:22:32.833919+00 |
| updated_at | 2017-12-21 15:22:32.833919+00 |
| description | Models for Chef Server objects |
| homepage | |
| repository | https://github.com/chef/rs-chef-api |
| max_upload_size | |
| id | 43841 |
| size | 24,431 |
This library depends upon chef_api for most functionality, but
provides a set of models for common Chef objects, such as nodes, roles
and environments.
Models implement a version oftry_from() in the context of [serde_json]'s Value
type - which is what is returned by all requests.
use chef_api::api_client::{ApiClient, Execute};
use chef::models::Node;
let client = ApiClient::from_credentials(None)?;
let node = client.nodes().node("my_node").get()?;
let node: Node = Node::try_from(node)?;
println!("Node name is {}", node.name.unwrap());
Once try_from is stablised in Rust, we'll switch to that.
Many APIs in the Chef Server return a list of items. Models will try to
convert those lists in to Iterators:
use chef_api::api_client::{ApiClient, Execute};
use chef::models::NodeList;
let client = ApiClient::from_credentials(None)?;
let nodes: NodeList = client.nodes().get()?.into();
for n in nodes {
println!("saw node: {}", n);
}