1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
 * Open Service Broker API
 *
 * The Open Service Broker API defines an HTTP(S) interface between Platforms and Service Brokers.
 *
 * The version of the OpenAPI document: master - might contain changes that are not yet released
 * Contact: open-service-broker-api@googlegroups.com
 * Generated by: https://openapi-generator.tech
 */

use std::rc::Rc;
use std::borrow::Borrow;

use reqwest;

use super::{Error, configuration};

pub struct CatalogApiClient {
    configuration: Rc<configuration::Configuration>,
}

impl CatalogApiClient {
    pub fn new(configuration: Rc<configuration::Configuration>) -> CatalogApiClient {
        CatalogApiClient {
            configuration: configuration,
        }
    }
}

pub trait CatalogApi {
    fn catalog_get(&self, x_broker_api_version: &str) -> Result<crate::models::Catalog, Error>;
}

impl CatalogApi for CatalogApiClient {
    fn catalog_get(&self, x_broker_api_version: &str) -> Result<crate::models::Catalog, Error> {
        let configuration: &configuration::Configuration = self.configuration.borrow();
        let client = &configuration.client;

        let uri_str = format!("{}/v2/catalog", configuration.base_path);
        let mut req_builder = client.get(uri_str.as_str());

        if let Some(ref user_agent) = configuration.user_agent {
            req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
        }
        req_builder = req_builder.header("X-Broker-API-Version", x_broker_api_version.to_string());
        if let Some(ref auth_conf) = configuration.basic_auth {
            req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
        };

        // send request
        let req = req_builder.build()?;

        Ok(client.execute(req)?.error_for_status()?.json()?)
    }

}