项目作者: chef-boneyard

项目描述 :
Rust API Client for the Chef Server
高级语言: Rust
项目地址: git://github.com/chef-boneyard/rs-chef-api.git
创建时间: 2015-10-29T17:06:57Z
项目社区:https://github.com/chef-boneyard/rs-chef-api

开源协议:Apache License 2.0

下载


Chef objects

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.

Usage

Models implement a version oftry_from() in the context of [serde_json]’s Value
type - which is what is returned by all requests.

  1. use chef_api::api_client::{ApiClient, Execute};
  2. use chef::models::Node;
  3. let client = ApiClient::from_credentials(None)?;
  4. let node = client.nodes().node("my_node").get()?;
  5. let node: Node = Node::try_from(node)?;
  6. println!("Node name is {}", node.name.unwrap());

Once try_from is stablised in Rust, we’ll switch to that.

Lists

Many APIs in the Chef Server return a list of items. Models will try to
convert those lists in to Iterators:

  1. use chef_api::api_client::{ApiClient, Execute};
  2. use chef::models::NodeList;
  3. let client = ApiClient::from_credentials(None)?;
  4. let nodes: NodeList = client.nodes().get()?.into();
  5. for n in nodes {
  6. println!("saw node: {}", n);
  7. }