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
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
/*
 * 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 ServiceBindingsApiClient {
    configuration: Rc<configuration::Configuration>,
}

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

pub trait ServiceBindingsApi {
    fn service_binding_binding(&self, x_broker_api_version: &str, instance_id: &str, binding_id: &str, service_binding_request: crate::models::ServiceBindingRequest, x_broker_api_originating_identity: &str, accepts_incomplete: bool) -> Result<crate::models::ServiceBindingResponse, Error>;
    fn service_binding_get(&self, x_broker_api_version: &str, instance_id: &str, binding_id: &str, x_broker_api_originating_identity: &str, service_id: &str, plan_id: &str) -> Result<crate::models::ServiceBindingResource, Error>;
    fn service_binding_last_operation_get(&self, x_broker_api_version: &str, instance_id: &str, binding_id: &str, service_id: &str, plan_id: &str, operation: &str) -> Result<crate::models::LastOperationResource, Error>;
    fn service_binding_unbinding(&self, x_broker_api_version: &str, instance_id: &str, binding_id: &str, service_id: &str, plan_id: &str, x_broker_api_originating_identity: &str, accepts_incomplete: bool) -> Result<serde_json::Value, Error>;
}

impl ServiceBindingsApi for ServiceBindingsApiClient {
    fn service_binding_binding(&self, x_broker_api_version: &str, instance_id: &str, binding_id: &str, service_binding_request: crate::models::ServiceBindingRequest, x_broker_api_originating_identity: &str, accepts_incomplete: bool) -> Result<crate::models::ServiceBindingResponse, Error> {
        let configuration: &configuration::Configuration = self.configuration.borrow();
        let client = &configuration.client;

        let uri_str = format!("{}/v2/service_instances/{instance_id}/service_bindings/{binding_id}", configuration.base_path, instance_id=crate::apis::urlencode(instance_id), binding_id=crate::apis::urlencode(binding_id));
        let mut req_builder = client.put(uri_str.as_str());

        req_builder = req_builder.query(&[("accepts_incomplete", &accepts_incomplete.to_string())]);
        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());
        req_builder = req_builder.header("X-Broker-API-Originating-Identity", x_broker_api_originating_identity.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());
        };
        req_builder = req_builder.json(&service_binding_request);

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

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

    fn service_binding_get(&self, x_broker_api_version: &str, instance_id: &str, binding_id: &str, x_broker_api_originating_identity: &str, service_id: &str, plan_id: &str) -> Result<crate::models::ServiceBindingResource, Error> {
        let configuration: &configuration::Configuration = self.configuration.borrow();
        let client = &configuration.client;

        let uri_str = format!("{}/v2/service_instances/{instance_id}/service_bindings/{binding_id}", configuration.base_path, instance_id=crate::apis::urlencode(instance_id), binding_id=crate::apis::urlencode(binding_id));
        let mut req_builder = client.get(uri_str.as_str());

        req_builder = req_builder.query(&[("service_id", &service_id.to_string())]);
        req_builder = req_builder.query(&[("plan_id", &plan_id.to_string())]);
        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());
        req_builder = req_builder.header("X-Broker-API-Originating-Identity", x_broker_api_originating_identity.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()?)
    }

    fn service_binding_last_operation_get(&self, x_broker_api_version: &str, instance_id: &str, binding_id: &str, service_id: &str, plan_id: &str, operation: &str) -> Result<crate::models::LastOperationResource, Error> {
        let configuration: &configuration::Configuration = self.configuration.borrow();
        let client = &configuration.client;

        let uri_str = format!("{}/v2/service_instances/{instance_id}/service_bindings/{binding_id}/last_operation", configuration.base_path, instance_id=crate::apis::urlencode(instance_id), binding_id=crate::apis::urlencode(binding_id));
        let mut req_builder = client.get(uri_str.as_str());

        req_builder = req_builder.query(&[("service_id", &service_id.to_string())]);
        req_builder = req_builder.query(&[("plan_id", &plan_id.to_string())]);
        req_builder = req_builder.query(&[("operation", &operation.to_string())]);
        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()?)
    }

    fn service_binding_unbinding(&self, x_broker_api_version: &str, instance_id: &str, binding_id: &str, service_id: &str, plan_id: &str, x_broker_api_originating_identity: &str, accepts_incomplete: bool) -> Result<serde_json::Value, Error> {
        let configuration: &configuration::Configuration = self.configuration.borrow();
        let client = &configuration.client;

        let uri_str = format!("{}/v2/service_instances/{instance_id}/service_bindings/{binding_id}", configuration.base_path, instance_id=crate::apis::urlencode(instance_id), binding_id=crate::apis::urlencode(binding_id));
        let mut req_builder = client.delete(uri_str.as_str());

        req_builder = req_builder.query(&[("service_id", &service_id.to_string())]);
        req_builder = req_builder.query(&[("plan_id", &plan_id.to_string())]);
        req_builder = req_builder.query(&[("accepts_incomplete", &accepts_incomplete.to_string())]);
        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());
        req_builder = req_builder.header("X-Broker-API-Originating-Identity", x_broker_api_originating_identity.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()?)
    }

}