elastic_hyper 0.3.1

A lightweight implementation of the Elasticsearch API based on Hyper.
Documentation
use hyper::client::Client;
#[allow(unused_imports)]
use hyper::client::Body;
use hyper::client::response::Response;
use hyper::error::Result;

use ::RequestParams;

/// http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-rollover-index.html
pub fn post_alias<'a,
              I: Into<Body<'a>>>(client: &'a mut Client,
                                 req: &'a RequestParams, alias: &'a str,
                                 body: I) -> Result<Response>{
    let url_qry = &req.get_url_qry();
    let base = &req.base_url;
    let mut url_fmtd =
        String::with_capacity(base.len() + 1 + 10 + alias.len() +
                                  url_qry.len());
    url_fmtd.push_str(base);
    url_fmtd.push_str("/");
    url_fmtd.push_str(alias);
    url_fmtd.push_str("/_rollover");
    url_fmtd.push_str(url_qry);
    let res =
        client.post(&url_fmtd).headers(req.headers.to_owned()).body(body.into());
    res.send()
}

/// http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-rollover-index.html
pub fn post_alias_new_index<'a,
                        I: Into<Body<'a>>>(client: &'a mut Client,
                                           req: &'a RequestParams,
                                           alias: &'a str, new_index: &'a str,
                                           body: I) -> Result<Response>{
    let url_qry = &req.get_url_qry();
    let base = &req.base_url;
    let mut url_fmtd =
        String::with_capacity(base.len() + 1 + 11 + alias.len() +
                                  new_index.len() + url_qry.len());
    url_fmtd.push_str(base);
    url_fmtd.push_str("/");
    url_fmtd.push_str(alias);
    url_fmtd.push_str("/_rollover/");
    url_fmtd.push_str(new_index);
    url_fmtd.push_str(url_qry);
    let res =
        client.post(&url_fmtd).headers(req.headers.to_owned()).body(body.into());
    res.send()
}