All Downloads are FREE. Search and download functionalities are using the official Maven repository.
Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
rust.hyper.api.mustache Maven / Gradle / Ivy
{{>partial_header}}
use std::rc::Rc;
use std::borrow::Borrow;
use std::pin::Pin;
#[allow(unused_imports)]
use std::option::Option;
use hyper;
use futures::Future;
use super::{Error, configuration};
use super::request as __internal_request;
pub struct {{{classname}}}Client
where C: Clone + std::marker::Send + Sync + 'static {
configuration: Rc>,
}
impl {{{classname}}}Client
where C: Clone + std::marker::Send + Sync {
pub fn new(configuration: Rc>) -> {{{classname}}}Client {
{{{classname}}}Client {
configuration,
}
}
}
pub trait {{{classname}}} {
{{#operations}}
{{#operation}}
fn {{{operationId}}}(&self, {{#allParams}}{{{paramName}}}: {{^required}}Option<{{/required}}{{#required}}{{#isNullable}}Option<{{/isNullable}}{{/required}}{{#isString}}{{^isUuid}}&str{{/isUuid}}{{/isString}}{{#isUuid}}&str{{/isUuid}}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}crate::models::{{/isContainer}}{{/isPrimitiveType}}{{{dataType}}}{{/isUuid}}{{/isString}}{{^required}}>{{/required}}{{#required}}{{#isNullable}}>{{/isNullable}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}) -> Pin>>>;
{{/operation}}
{{/operations}}
}
impl{{{classname}}} for {{{classname}}}Client
where C: Clone + std::marker::Send + Sync {
{{#operations}}
{{#operation}}
#[allow(unused_mut)]
fn {{{operationId}}}(&self, {{#allParams}}{{{paramName}}}: {{^required}}Option<{{/required}}{{#required}}{{#isNullable}}Option<{{/isNullable}}{{/required}}{{#isString}}{{^isUuid}}&str{{/isUuid}}{{/isString}}{{#isUuid}}&str{{/isUuid}}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}crate::models::{{/isContainer}}{{/isPrimitiveType}}{{{dataType}}}{{/isUuid}}{{/isString}}{{^required}}>{{/required}}{{#required}}{{#isNullable}}>{{/isNullable}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}) -> Pin>>> {
let mut req = __internal_request::Request::new(hyper::Method::{{{httpMethod.toUpperCase}}}, "{{{path}}}".to_string())
{{#hasAuthMethods}}
{{#authMethods}}
{{#isApiKey}}
.with_auth(__internal_request::Auth::ApiKey(__internal_request::ApiKey{
in_header: {{#isKeyInHeader}}true{{/isKeyInHeader}}{{^isKeyInHeader}}false{{/isKeyInHeader}},
in_query: {{#isKeyInQuery}}true{{/isKeyInQuery}}{{^isKeyInQuery}}false{{/isKeyInQuery}},
param_name: "{{{keyParamName}}}".to_owned(),
}))
{{/isApiKey}}
{{#isBasic}}
.with_auth(__internal_request::Auth::Basic)
{{/isBasic}}
{{#isOAuth}}
.with_auth(__internal_request::Auth::Oauth)
{{/isOAuth}}
{{/authMethods}}
{{/hasAuthMethods}}
;
{{#queryParams}}
{{#required}}
{{^isNullable}}
req = req.with_query_param("{{{baseName}}}".to_string(), {{{paramName}}}{{#isArray}}.join(","){{/isArray}}.to_string());
{{/isNullable}}
{{#isNullable}}
match {{{paramName}}} {
Some(param_value) => { req = req.with_query_param("{{{baseName}}}".to_string(), param_value{{#isArray}}.join(","){{/isArray}}.to_string()); },
None => { req = req.with_query_param("{{{baseName}}}".to_string(), "".to_string()); },
}
{{/isNullable}}
{{/required}}
{{^required}}
if let Some(ref s) = {{{paramName}}} {
let query_value = {{#isArray}}s.iter().map(|s| s.to_string()).collect::>().join(","){{/isArray}}{{^isArray}}s.to_string(){{/isArray}};
req = req.with_query_param("{{{baseName}}}".to_string(), query_value);
}
{{/required}}
{{/queryParams}}
{{#pathParams}}
{{#required}}
{{^isNullable}}
req = req.with_path_param("{{{baseName}}}".to_string(), {{{paramName}}}{{#isArray}}.join(","){{/isArray}}.to_string());
{{/isNullable}}
{{#isNullable}}
match {{{paramName}}} {
Some(param_value) => { req = req.with_path_param("{{{baseName}}}".to_string(), param_value{{#isArray}}.join(","){{/isArray}}.to_string()); },
None => { req = req.with_path_param("{{{baseName}}}".to_string(), "".to_string()); },
}
{{/isNullable}}
{{/required}}
{{^required}}
if let Some(param_value) = {{{paramName}}} {
req = req.with_path_param("{{{baseName}}}".to_string(), param_value{{#isArray}}.join(","){{/isArray}}.to_string());
}
{{/required}}
{{/pathParams}}
{{#hasHeaderParams}}
{{#headerParams}}
{{#required}}
{{^isNullable}}
req = req.with_header_param("{{{baseName}}}".to_string(), {{{paramName}}}{{#isArray}}.join(","){{/isArray}}.to_string());
{{/isNullable}}
{{#isNullable}}
match {{{paramName}}} {
Some(param_value) => { req = req.with_header_param("{{{baseName}}}".to_string(), param_value{{#isArray}}.join(","){{/isArray}}.to_string()); },
None => { req = req.with_header_param("{{{baseName}}}".to_string(), "".to_string()); },
}
{{/isNullable}}
{{/required}}
{{^required}}
if let Some(param_value) = {{{paramName}}} {
req = req.with_header_param("{{{baseName}}}".to_string(), param_value{{#isArray}}.join(","){{/isArray}}.to_string());
}
{{/required}}
{{/headerParams}}
{{/hasHeaderParams}}
{{#hasFormParams}}
{{#formParams}}
{{#isFile}}
{{#required}}
{{^isNullable}}
req = req.with_form_param("{{{baseName}}}".to_string(), unimplemented!());
{{/isNullable}}
{{#isNullable}}
match {{{paramName}}} {
Some(param_value) => { req = req.with_form_param("{{{baseName}}}".to_string(), unimplemented!()); },
None => { req = req.with_form_param("{{{baseName}}}".to_string(), unimplemented!()); },
}
{{/isNullable}}
{{/required}}
{{^required}}
if let Some(param_value) = {{{paramName}}} {
req = req.with_form_param("{{{baseName}}}".to_string(), unimplemented!());
}
{{/required}}
{{/isFile}}
{{^isFile}}
{{#required}}
{{^isNullable}}
req = req.with_form_param("{{{baseName}}}".to_string(), {{{paramName}}}{{#isArray}}.join(","){{/isArray}}.to_string());
{{/isNullable}}
{{#isNullable}}
match {{{paramName}}} {
Some(param_value) => { req = req.with_form_param("{{{baseName}}}".to_string(), param_value{{#isArray}}.join(","){{/isArray}}.to_string()); },
None => { req = req.with_form_param("{{{baseName}}}".to_string(), "".to_string()); },
}
{{/isNullable}}
{{/required}}
{{^required}}
if let Some(param_value) = {{{paramName}}} {
req = req.with_form_param("{{{baseName}}}".to_string(), param_value{{#isArray}}.join(","){{/isArray}}.to_string());
}
{{/required}}
{{/isFile}}
{{/formParams}}
{{/hasFormParams}}
{{#hasBodyParam}}
{{#bodyParams}}
req = req.with_body_param({{{paramName}}});
{{/bodyParams}}
{{/hasBodyParam}}
{{^returnType}}
req = req.returns_nothing();
{{/returnType}}
req.execute(self.configuration.borrow())
}
{{/operation}}
{{/operations}}
}