#[derive(Debug)]
pub struct SpecClient<'a> {
    base_client: &'a mut crate::core::base_client::BaseClient,
}
impl<'a> SpecClient<'a> {
    pub(crate) fn _new(
        base_client: &'a mut crate::core::base_client::BaseClient,
    ) -> Self {
        Self { base_client }
    }
    /// Delete an API Specification and it's associated metadata
    ///
    /// DELETE /api/{api_name}/spec/{api_version}
    pub async fn delete(
        &mut self,
        request: super::request_types::DeleteRequest,
    ) -> crate::SdkResult<()> {
        let url = self
            .base_client
            .build_url(
                &format!(
                    "/api/{}/spec/{}", crate ::core::params::format_string_param(&
                    request.api_name), crate ::core::params::format_string_param(&
                    request.api_version)
                ),
            );
        let mut builder = reqwest::Client::default().delete(&url);
        builder = builder.header("x-sideko-sdk-language", "rust");
        builder = self
            .base_client
            .apply_auths_to_builder(builder, &["ApiKeyAuth", "CookieAuth"])
            .await?;
        let response = builder.send().await?;
        self.base_client.error_for_status("DELETE", response).await?;
        Ok(())
    }
    /// List specs of a collection
    ///
    /// GET /api/{api_name}/spec
    pub async fn list(
        &mut self,
        request: super::request_types::ListRequest,
    ) -> crate::SdkResult<Vec<crate::models::ApiSpec>> {
        let url = self
            .base_client
            .build_url(
                &format!(
                    "/api/{}/spec", crate ::core::params::format_string_param(& request
                    .api_name)
                ),
            );
        let mut builder = reqwest::Client::default().get(&url);
        builder = builder.header("x-sideko-sdk-language", "rust");
        builder = self
            .base_client
            .apply_auths_to_builder(builder, &["ApiKeyAuth", "CookieAuth"])
            .await?;
        let mut response = builder.send().await?;
        response = self.base_client.error_for_status("GET", response).await?;
        crate::core::response::process_json::<Vec<crate::models::ApiSpec>>(response)
            .await
    }
    /// Get API specification metadata
    ///
    /// GET /api/{api_name}/spec/{api_version}
    pub async fn get(
        &mut self,
        request: super::request_types::GetRequest,
    ) -> crate::SdkResult<crate::models::ApiSpec> {
        let url = self
            .base_client
            .build_url(
                &format!(
                    "/api/{}/spec/{}", crate ::core::params::format_string_param(&
                    request.api_name), crate ::core::params::format_string_param(&
                    request.api_version)
                ),
            );
        let mut builder = reqwest::Client::default().get(&url);
        builder = builder.header("x-sideko-sdk-language", "rust");
        builder = self
            .base_client
            .apply_auths_to_builder(builder, &["ApiKeyAuth", "CookieAuth"])
            .await?;
        let mut response = builder.send().await?;
        response = self.base_client.error_for_status("GET", response).await?;
        crate::core::response::process_json::<crate::models::ApiSpec>(response).await
    }
    /// Get OpenAPI specification
    ///
    /// GET /api/{api_name}/spec/{api_version}/openapi
    pub async fn get_openapi(
        &mut self,
        request: super::request_types::GetOpenapiRequest,
    ) -> crate::SdkResult<crate::models::OpenApi> {
        let url = self
            .base_client
            .build_url(
                &format!(
                    "/api/{}/spec/{}/openapi", crate
                    ::core::params::format_string_param(& request.api_name), crate
                    ::core::params::format_string_param(& request.api_version)
                ),
            );
        let mut builder = reqwest::Client::default().get(&url);
        builder = builder.header("x-sideko-sdk-language", "rust");
        builder = self
            .base_client
            .apply_auths_to_builder(builder, &["ApiKeyAuth", "CookieAuth"])
            .await?;
        let mut response = builder.send().await?;
        response = self.base_client.error_for_status("GET", response).await?;
        crate::core::response::process_json::<crate::models::OpenApi>(response).await
    }
    /// Get Stats about the specification
    ///
    /// GET /api/{api_name}/spec/{api_version}/stats
    pub async fn get_stats(
        &mut self,
        request: super::request_types::GetStatsRequest,
    ) -> crate::SdkResult<crate::models::ApiSpecStats> {
        let url = self
            .base_client
            .build_url(
                &format!(
                    "/api/{}/spec/{}/stats", crate ::core::params::format_string_param(&
                    request.api_name), crate ::core::params::format_string_param(&
                    request.api_version)
                ),
            );
        let mut builder = reqwest::Client::default().get(&url);
        builder = builder.header("x-sideko-sdk-language", "rust");
        builder = self
            .base_client
            .apply_auths_to_builder(builder, &["ApiKeyAuth", "CookieAuth"])
            .await?;
        let mut response = builder.send().await?;
        response = self.base_client.error_for_status("GET", response).await?;
        crate::core::response::process_json::<crate::models::ApiSpecStats>(response)
            .await
    }
    /// Update an API Specification and/or metadata
    ///
    /// PATCH /api/{api_name}/spec/{api_version}
    pub async fn patch(
        &mut self,
        request: super::request_types::PatchRequest,
    ) -> crate::SdkResult<crate::models::ApiSpec> {
        let url = self
            .base_client
            .build_url(
                &format!(
                    "/api/{}/spec/{}", crate ::core::params::format_string_param(&
                    request.api_name), crate ::core::params::format_string_param(&
                    request.api_version)
                ),
            );
        let mut builder = reqwest::Client::default().patch(&url);
        builder = builder.header("x-sideko-sdk-language", "rust");
        let mut form_data = reqwest::multipart::Form::new();
        if let Some(val) = &request.allow_lint_errors {
            form_data = form_data
                .part(
                    "allow_lint_errors",
                    reqwest::multipart::Part::text(
                        crate::core::params::format_string_param(&val),
                    ),
                );
        }
        if let Some(val) = &request.mock_server_enabled {
            form_data = form_data
                .part(
                    "mock_server_enabled",
                    reqwest::multipart::Part::text(
                        crate::core::params::format_string_param(&val),
                    ),
                );
        }
        if let Some(val) = &request.notes {
            form_data = form_data
                .part(
                    "notes",
                    reqwest::multipart::Part::text(
                        crate::core::params::format_string_param(&val),
                    ),
                );
        }
        if let Some(val) = &request.openapi {
            form_data = form_data.part("openapi", reqwest::multipart::Part::from(val));
        }
        if let Some(val) = &request.version {
            form_data = form_data
                .part(
                    "version",
                    reqwest::multipart::Part::text(
                        crate::core::params::format_string_param(&val),
                    ),
                );
        }
        builder = builder.multipart(form_data);
        builder = self
            .base_client
            .apply_auths_to_builder(builder, &["ApiKeyAuth", "CookieAuth"])
            .await?;
        let mut response = builder.send().await?;
        response = self.base_client.error_for_status("PATCH", response).await?;
        crate::core::response::process_json::<crate::models::ApiSpec>(response).await
    }
    /// Add a new API specification
    ///
    /// POST /api/{api_name}/spec
    pub async fn create(
        &mut self,
        request: super::request_types::CreateRequest,
    ) -> crate::SdkResult<crate::models::ApiSpec> {
        let url = self
            .base_client
            .build_url(
                &format!(
                    "/api/{}/spec", crate ::core::params::format_string_param(& request
                    .api_name)
                ),
            );
        let mut builder = reqwest::Client::default().post(&url);
        builder = builder.header("x-sideko-sdk-language", "rust");
        let mut form_data = reqwest::multipart::Form::new();
        if let Some(val) = &request.allow_lint_errors {
            form_data = form_data
                .part(
                    "allow_lint_errors",
                    reqwest::multipart::Part::text(
                        crate::core::params::format_string_param(&val),
                    ),
                );
        }
        if let Some(val) = &request.mock_server_enabled {
            form_data = form_data
                .part(
                    "mock_server_enabled",
                    reqwest::multipart::Part::text(
                        crate::core::params::format_string_param(&val),
                    ),
                );
        }
        if let Some(val) = &request.notes {
            form_data = form_data
                .part(
                    "notes",
                    reqwest::multipart::Part::text(
                        crate::core::params::format_string_param(&val),
                    ),
                );
        }
        form_data = form_data
            .part("openapi", reqwest::multipart::Part::from(&request.openapi));
        form_data = form_data
            .part(
                "version",
                reqwest::multipart::Part::text(
                    crate::core::params::format_string_param(&request.version),
                ),
            );
        builder = builder.multipart(form_data);
        builder = self
            .base_client
            .apply_auths_to_builder(builder, &["ApiKeyAuth", "CookieAuth"])
            .await?;
        let mut response = builder.send().await?;
        response = self.base_client.error_for_status("POST", response).await?;
        crate::core::response::process_json::<crate::models::ApiSpec>(response).await
    }
}
