/*
 * Isilon SDK
 *
 * Isilon SDK - Language bindings for the OneFS API
 *
 * OpenAPI spec version: 5
 * Contact: sdk@isilon.com
 * Generated by: https://github.com/swagger-api/swagger-codegen.git
 */

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

use futures;
use futures::Future;
use hyper;

use super::{configuration, put, query, Error};

pub struct StoragepoolApiClient<C: hyper::client::connect::Connect> {
    configuration: Rc<configuration::Configuration<C>>,
}

impl<C: hyper::client::connect::Connect> StoragepoolApiClient<C> {
    pub fn new(configuration: Rc<configuration::Configuration<C>>) -> StoragepoolApiClient<C> {
        StoragepoolApiClient {
            configuration: configuration,
        }
    }
}

pub trait StoragepoolApi {
    fn create_compatibilities_class_active_item(
        &self,
        compatibilities_class_active_item: crate::models::CompatibilitiesClassActiveItem,
        assess: bool,
    ) -> Box<
        dyn Future<
            Item = crate::models::CreateCompatibilitiesClassActiveItemResponse,
            Error = Error,
        >,
    >;
    fn create_compatibilities_ssd_active_item(
        &self,
        compatibilities_ssd_active_item: crate::models::CompatibilitiesSsdActiveItem,
        assess: bool,
    ) -> Box<
        dyn Future<
            Item = crate::models::CreateCompatibilitiesClassActiveItemResponse,
            Error = Error,
        >,
    >;
    fn create_storagepool_nodepool(
        &self,
        storagepool_nodepool: crate::models::StoragepoolNodepoolCreateParams,
    ) -> Box<dyn Future<Item = crate::models::CreateStoragepoolTierResponse, Error = Error>>;
    fn create_storagepool_tier(
        &self,
        storagepool_tier: crate::models::StoragepoolTierCreateParams,
    ) -> Box<dyn Future<Item = crate::models::CreateStoragepoolTierResponse, Error = Error>>;
    fn delete_compatibilities_class_active_by_id(
        &self,
        compatibilities_class_active_id: &str,
        assess: bool,
    ) -> Box<dyn Future<Item = (), Error = Error>>;
    fn delete_compatibilities_ssd_active_by_id(
        &self,
        compatibilities_ssd_active_id: &str,
        assess: bool,
    ) -> Box<dyn Future<Item = (), Error = Error>>;
    fn delete_storagepool_nodepool(
        &self,
        storagepool_nodepool_id: &str,
    ) -> Box<dyn Future<Item = (), Error = Error>>;
    fn delete_storagepool_nodepools(&self) -> Box<dyn Future<Item = (), Error = Error>>;
    fn delete_storagepool_tier(
        &self,
        storagepool_tier_id: &str,
    ) -> Box<dyn Future<Item = (), Error = Error>>;
    fn delete_storagepool_tiers(&self) -> Box<dyn Future<Item = (), Error = Error>>;
    fn get_compatibilities_class_active_by_id(
        &self,
        compatibilities_class_active_id: &str,
    ) -> Box<dyn Future<Item = crate::models::CompatibilitiesClassActive, Error = Error>>;
    fn get_compatibilities_class_available(
        &self,
    ) -> Box<dyn Future<Item = crate::models::CompatibilitiesClassAvailable, Error = Error>>;
    fn get_compatibilities_ssd_active_by_id(
        &self,
        compatibilities_ssd_active_id: &str,
    ) -> Box<dyn Future<Item = crate::models::CompatibilitiesSsdActive, Error = Error>>;
    fn get_compatibilities_ssd_available(
        &self,
    ) -> Box<dyn Future<Item = crate::models::CompatibilitiesSsdAvailable, Error = Error>>;
    fn get_storagepool_nodepool(
        &self,
        storagepool_nodepool_id: &str,
    ) -> Box<dyn Future<Item = crate::models::StoragepoolNodepools, Error = Error>>;
    fn get_storagepool_settings(
        &self,
    ) -> Box<dyn Future<Item = crate::models::StoragepoolSettings, Error = Error>>;
    fn get_storagepool_status(
        &self,
    ) -> Box<dyn Future<Item = crate::models::StoragepoolStatus, Error = Error>>;
    fn get_storagepool_storagepools(
        &self,
        sort: &str,
        toplevels: &str,
        dir: &str,
    ) -> Box<dyn Future<Item = crate::models::StoragepoolStoragepools, Error = Error>>;
    fn get_storagepool_suggested_protection_nid(
        &self,
        storagepool_suggested_protection_nid: &str,
    ) -> Box<dyn Future<Item = crate::models::StoragepoolSuggestedProtection, Error = Error>>;
    fn get_storagepool_tier(
        &self,
        storagepool_tier_id: &str,
    ) -> Box<dyn Future<Item = crate::models::StoragepoolTiers, Error = Error>>;
    fn get_storagepool_unprovisioned(
        &self,
    ) -> Box<dyn Future<Item = crate::models::StoragepoolUnprovisioned, Error = Error>>;
    fn list_compatibilities_class_active(
        &self,
    ) -> Box<dyn Future<Item = crate::models::CompatibilitiesClassActiveExtended, Error = Error>>;
    fn list_compatibilities_ssd_active(
        &self,
    ) -> Box<dyn Future<Item = crate::models::CompatibilitiesSsdActiveExtended, Error = Error>>;
    fn list_storagepool_nodepools(
        &self,
    ) -> Box<dyn Future<Item = crate::models::StoragepoolNodepoolsExtended, Error = Error>>;
    fn list_storagepool_tiers(
        &self,
    ) -> Box<dyn Future<Item = crate::models::StoragepoolTiersExtended, Error = Error>>;
    fn update_compatibilities_ssd_active_by_id(
        &self,
        compatibilities_ssd_active_id_params: crate::models::CompatibilitiesSsdActiveIdParams,
        compatibilities_ssd_active_id: &str,
        assess: bool,
    ) -> Box<dyn Future<Item = (), Error = Error>>;
    fn update_storagepool_nodepool(
        &self,
        storagepool_nodepool: crate::models::StoragepoolNodepool,
        storagepool_nodepool_id: &str,
    ) -> Box<dyn Future<Item = (), Error = Error>>;
    fn update_storagepool_settings(
        &self,
        storagepool_settings: crate::models::StoragepoolSettingsExtended,
    ) -> Box<dyn Future<Item = (), Error = Error>>;
    fn update_storagepool_tier(
        &self,
        storagepool_tier: crate::models::StoragepoolTier,
        storagepool_tier_id: &str,
    ) -> Box<dyn Future<Item = (), Error = Error>>;
}

impl<C: hyper::client::connect::Connect + 'static> StoragepoolApi for StoragepoolApiClient<C> {
    fn create_compatibilities_class_active_item(
        &self,
        compatibilities_class_active_item: crate::models::CompatibilitiesClassActiveItem,
        assess: bool,
    ) -> Box<
        dyn Future<
            Item = crate::models::CreateCompatibilitiesClassActiveItemResponse,
            Error = Error,
        >,
    > {
        let q = ::url::form_urlencoded::Serializer::new(String::new())
            .append_pair("assess", &assess.to_string())
            .finish();
        let uri_str = format!(
            "{}/platform/1/storagepool/compatibilities/class/active?{}",
            self.configuration.base_path, q
        );
        query(
            self.configuration.borrow(),
            &uri_str,
            &compatibilities_class_active_item,
            hyper::Method::POST,
        )
    }

    fn create_compatibilities_ssd_active_item(
        &self,
        compatibilities_ssd_active_item: crate::models::CompatibilitiesSsdActiveItem,
        assess: bool,
    ) -> Box<
        dyn Future<
            Item = crate::models::CreateCompatibilitiesClassActiveItemResponse,
            Error = Error,
        >,
    > {
        let q = ::url::form_urlencoded::Serializer::new(String::new())
            .append_pair("assess", &assess.to_string())
            .finish();
        let uri_str = format!(
            "{}/platform/3/storagepool/compatibilities/ssd/active?{}",
            self.configuration.base_path, q
        );
        query(
            self.configuration.borrow(),
            &uri_str,
            &compatibilities_ssd_active_item,
            hyper::Method::POST,
        )
    }

    fn create_storagepool_nodepool(
        &self,
        storagepool_nodepool: crate::models::StoragepoolNodepoolCreateParams,
    ) -> Box<dyn Future<Item = crate::models::CreateStoragepoolTierResponse, Error = Error>> {
        let uri_str = format!(
            "{}/platform/3/storagepool/nodepools",
            self.configuration.base_path
        );
        query(
            self.configuration.borrow(),
            &uri_str,
            &storagepool_nodepool,
            hyper::Method::POST,
        )
    }

    fn create_storagepool_tier(
        &self,
        storagepool_tier: crate::models::StoragepoolTierCreateParams,
    ) -> Box<dyn Future<Item = crate::models::CreateStoragepoolTierResponse, Error = Error>> {
        let uri_str = format!(
            "{}/platform/1/storagepool/tiers",
            self.configuration.base_path
        );
        query(
            self.configuration.borrow(),
            &uri_str,
            &storagepool_tier,
            hyper::Method::POST,
        )
    }

    fn delete_compatibilities_class_active_by_id(
        &self,
        compatibilities_class_active_id: &str,
        assess: bool,
    ) -> Box<dyn Future<Item = (), Error = Error>> {
        let q = ::url::form_urlencoded::Serializer::new(String::new())
            .append_pair("assess", &assess.to_string())
            .finish();
        let uri_str = format!("{}/platform/1/storagepool/compatibilities/class/active/{CompatibilitiesClassActiveId}?{}", self.configuration.base_path, q, CompatibilitiesClassActiveId=compatibilities_class_active_id);
        query(
            self.configuration.borrow(),
            &uri_str,
            &"",
            hyper::Method::DELETE,
        )
    }

    fn delete_compatibilities_ssd_active_by_id(
        &self,
        compatibilities_ssd_active_id: &str,
        assess: bool,
    ) -> Box<dyn Future<Item = (), Error = Error>> {
        let q = ::url::form_urlencoded::Serializer::new(String::new())
            .append_pair("assess", &assess.to_string())
            .finish();
        let uri_str = format!(
            "{}/platform/3/storagepool/compatibilities/ssd/active/{CompatibilitiesSsdActiveId}?{}",
            self.configuration.base_path,
            q,
            CompatibilitiesSsdActiveId = compatibilities_ssd_active_id
        );
        query(
            self.configuration.borrow(),
            &uri_str,
            &"",
            hyper::Method::DELETE,
        )
    }

    fn delete_storagepool_nodepool(
        &self,
        storagepool_nodepool_id: &str,
    ) -> Box<dyn Future<Item = (), Error = Error>> {
        let uri_str = format!(
            "{}/platform/3/storagepool/nodepools/{StoragepoolNodepoolId}",
            self.configuration.base_path,
            StoragepoolNodepoolId = storagepool_nodepool_id
        );
        query(
            self.configuration.borrow(),
            &uri_str,
            &"",
            hyper::Method::DELETE,
        )
    }

    fn delete_storagepool_nodepools(&self) -> Box<dyn Future<Item = (), Error = Error>> {
        let uri_str = format!(
            "{}/platform/3/storagepool/nodepools",
            self.configuration.base_path
        );
        query(
            self.configuration.borrow(),
            &uri_str,
            &"",
            hyper::Method::DELETE,
        )
    }

    fn delete_storagepool_tier(
        &self,
        storagepool_tier_id: &str,
    ) -> Box<dyn Future<Item = (), Error = Error>> {
        let uri_str = format!(
            "{}/platform/1/storagepool/tiers/{StoragepoolTierId}",
            self.configuration.base_path,
            StoragepoolTierId = storagepool_tier_id
        );
        query(
            self.configuration.borrow(),
            &uri_str,
            &"",
            hyper::Method::DELETE,
        )
    }

    fn delete_storagepool_tiers(&self) -> Box<dyn Future<Item = (), Error = Error>> {
        let uri_str = format!(
            "{}/platform/1/storagepool/tiers",
            self.configuration.base_path
        );
        query(
            self.configuration.borrow(),
            &uri_str,
            &"",
            hyper::Method::DELETE,
        )
    }

    fn get_compatibilities_class_active_by_id(
        &self,
        compatibilities_class_active_id: &str,
    ) -> Box<dyn Future<Item = crate::models::CompatibilitiesClassActive, Error = Error>> {
        let uri_str = format!(
            "{}/platform/1/storagepool/compatibilities/class/active/{CompatibilitiesClassActiveId}",
            self.configuration.base_path,
            CompatibilitiesClassActiveId = compatibilities_class_active_id
        );
        query(
            self.configuration.borrow(),
            &uri_str,
            &"",
            hyper::Method::GET,
        )
    }

    fn get_compatibilities_class_available(
        &self,
    ) -> Box<dyn Future<Item = crate::models::CompatibilitiesClassAvailable, Error = Error>> {
        let uri_str = format!(
            "{}/platform/1/storagepool/compatibilities/class/available",
            self.configuration.base_path
        );
        query(
            self.configuration.borrow(),
            &uri_str,
            &"",
            hyper::Method::GET,
        )
    }

    fn get_compatibilities_ssd_active_by_id(
        &self,
        compatibilities_ssd_active_id: &str,
    ) -> Box<dyn Future<Item = crate::models::CompatibilitiesSsdActive, Error = Error>> {
        let uri_str = format!(
            "{}/platform/3/storagepool/compatibilities/ssd/active/{CompatibilitiesSsdActiveId}",
            self.configuration.base_path,
            CompatibilitiesSsdActiveId = compatibilities_ssd_active_id
        );
        query(
            self.configuration.borrow(),
            &uri_str,
            &"",
            hyper::Method::GET,
        )
    }

    fn get_compatibilities_ssd_available(
        &self,
    ) -> Box<dyn Future<Item = crate::models::CompatibilitiesSsdAvailable, Error = Error>> {
        let uri_str = format!(
            "{}/platform/1/storagepool/compatibilities/ssd/available",
            self.configuration.base_path
        );
        query(
            self.configuration.borrow(),
            &uri_str,
            &"",
            hyper::Method::GET,
        )
    }

    fn get_storagepool_nodepool(
        &self,
        storagepool_nodepool_id: &str,
    ) -> Box<dyn Future<Item = crate::models::StoragepoolNodepools, Error = Error>> {
        let uri_str = format!(
            "{}/platform/3/storagepool/nodepools/{StoragepoolNodepoolId}",
            self.configuration.base_path,
            StoragepoolNodepoolId = storagepool_nodepool_id
        );
        query(
            self.configuration.borrow(),
            &uri_str,
            &"",
            hyper::Method::GET,
        )
    }

    fn get_storagepool_settings(
        &self,
    ) -> Box<dyn Future<Item = crate::models::StoragepoolSettings, Error = Error>> {
        let uri_str = format!(
            "{}/platform/5/storagepool/settings",
            self.configuration.base_path
        );
        query(
            self.configuration.borrow(),
            &uri_str,
            &"",
            hyper::Method::GET,
        )
    }

    fn get_storagepool_status(
        &self,
    ) -> Box<dyn Future<Item = crate::models::StoragepoolStatus, Error = Error>> {
        let uri_str = format!(
            "{}/platform/1/storagepool/status",
            self.configuration.base_path
        );
        query(
            self.configuration.borrow(),
            &uri_str,
            &"",
            hyper::Method::GET,
        )
    }

    fn get_storagepool_storagepools(
        &self,
        sort: &str,
        toplevels: &str,
        dir: &str,
    ) -> Box<dyn Future<Item = crate::models::StoragepoolStoragepools, Error = Error>> {
        let q = ::url::form_urlencoded::Serializer::new(String::new())
            .append_pair("sort", &sort.to_string())
            .append_pair("toplevels", &toplevels.to_string())
            .append_pair("dir", &dir.to_string())
            .finish();
        let uri_str = format!(
            "{}/platform/3/storagepool/storagepools?{}",
            self.configuration.base_path, q
        );
        query(
            self.configuration.borrow(),
            &uri_str,
            &"",
            hyper::Method::GET,
        )
    }

    fn get_storagepool_suggested_protection_nid(
        &self,
        storagepool_suggested_protection_nid: &str,
    ) -> Box<dyn Future<Item = crate::models::StoragepoolSuggestedProtection, Error = Error>> {
        let uri_str = format!(
            "{}/platform/3/storagepool/suggested-protection/{StoragepoolSuggestedProtectionNid}",
            self.configuration.base_path,
            StoragepoolSuggestedProtectionNid = storagepool_suggested_protection_nid
        );
        query(
            self.configuration.borrow(),
            &uri_str,
            &"",
            hyper::Method::GET,
        )
    }

    fn get_storagepool_tier(
        &self,
        storagepool_tier_id: &str,
    ) -> Box<dyn Future<Item = crate::models::StoragepoolTiers, Error = Error>> {
        let uri_str = format!(
            "{}/platform/1/storagepool/tiers/{StoragepoolTierId}",
            self.configuration.base_path,
            StoragepoolTierId = storagepool_tier_id
        );
        query(
            self.configuration.borrow(),
            &uri_str,
            &"",
            hyper::Method::GET,
        )
    }

    fn get_storagepool_unprovisioned(
        &self,
    ) -> Box<dyn Future<Item = crate::models::StoragepoolUnprovisioned, Error = Error>> {
        let uri_str = format!(
            "{}/platform/1/storagepool/unprovisioned",
            self.configuration.base_path
        );
        query(
            self.configuration.borrow(),
            &uri_str,
            &"",
            hyper::Method::GET,
        )
    }

    fn list_compatibilities_class_active(
        &self,
    ) -> Box<dyn Future<Item = crate::models::CompatibilitiesClassActiveExtended, Error = Error>>
    {
        let uri_str = format!(
            "{}/platform/1/storagepool/compatibilities/class/active",
            self.configuration.base_path
        );
        query(
            self.configuration.borrow(),
            &uri_str,
            &"",
            hyper::Method::GET,
        )
    }

    fn list_compatibilities_ssd_active(
        &self,
    ) -> Box<dyn Future<Item = crate::models::CompatibilitiesSsdActiveExtended, Error = Error>>
    {
        let uri_str = format!(
            "{}/platform/3/storagepool/compatibilities/ssd/active",
            self.configuration.base_path
        );
        query(
            self.configuration.borrow(),
            &uri_str,
            &"",
            hyper::Method::GET,
        )
    }

    fn list_storagepool_nodepools(
        &self,
    ) -> Box<dyn Future<Item = crate::models::StoragepoolNodepoolsExtended, Error = Error>> {
        let uri_str = format!(
            "{}/platform/3/storagepool/nodepools",
            self.configuration.base_path
        );
        query(
            self.configuration.borrow(),
            &uri_str,
            &"",
            hyper::Method::GET,
        )
    }

    fn list_storagepool_tiers(
        &self,
    ) -> Box<dyn Future<Item = crate::models::StoragepoolTiersExtended, Error = Error>> {
        let uri_str = format!(
            "{}/platform/1/storagepool/tiers",
            self.configuration.base_path
        );
        query(
            self.configuration.borrow(),
            &uri_str,
            &"",
            hyper::Method::GET,
        )
    }

    fn update_compatibilities_ssd_active_by_id(
        &self,
        compatibilities_ssd_active_id_params: crate::models::CompatibilitiesSsdActiveIdParams,
        compatibilities_ssd_active_id: &str,
        assess: bool,
    ) -> Box<dyn Future<Item = (), Error = Error>> {
        let q = ::url::form_urlencoded::Serializer::new(String::new())
            .append_pair("assess", &assess.to_string())
            .finish();
        let uri_str = format!(
            "{}/platform/3/storagepool/compatibilities/ssd/active/{CompatibilitiesSsdActiveId}?{}",
            self.configuration.base_path,
            q,
            CompatibilitiesSsdActiveId = compatibilities_ssd_active_id
        );
        put(
            self.configuration.borrow(),
            &uri_str,
            &compatibilities_ssd_active_id_params,
        )
    }

    fn update_storagepool_nodepool(
        &self,
        storagepool_nodepool: crate::models::StoragepoolNodepool,
        storagepool_nodepool_id: &str,
    ) -> Box<dyn Future<Item = (), Error = Error>> {
        let uri_str = format!(
            "{}/platform/3/storagepool/nodepools/{StoragepoolNodepoolId}",
            self.configuration.base_path,
            StoragepoolNodepoolId = storagepool_nodepool_id
        );
        put(self.configuration.borrow(), &uri_str, &storagepool_nodepool)
    }

    fn update_storagepool_settings(
        &self,
        storagepool_settings: crate::models::StoragepoolSettingsExtended,
    ) -> Box<dyn Future<Item = (), Error = Error>> {
        let uri_str = format!(
            "{}/platform/5/storagepool/settings",
            self.configuration.base_path
        );
        put(self.configuration.borrow(), &uri_str, &storagepool_settings)
    }

    fn update_storagepool_tier(
        &self,
        storagepool_tier: crate::models::StoragepoolTier,
        storagepool_tier_id: &str,
    ) -> Box<dyn Future<Item = (), Error = Error>> {
        let uri_str = format!(
            "{}/platform/1/storagepool/tiers/{StoragepoolTierId}",
            self.configuration.base_path,
            StoragepoolTierId = storagepool_tier_id
        );
        put(self.configuration.borrow(), &uri_str, &storagepool_tier)
    }
}
