#[derive(Debug)]
pub struct ApiLinkClient<'a> {
    base_client: &'a mut crate::core::base_client::BaseClient,
}
impl<'a> ApiLinkClient<'a> {
    pub(crate) fn _new(
        base_client: &'a mut crate::core::base_client::BaseClient,
    ) -> Self {
        Self { base_client }
    }
    pub fn group(
        &mut self,
    ) -> crate::resources::api_link::group::resource_client::GroupClient {
        crate::resources::api_link::group::resource_client::GroupClient::_new(
            self.base_client,
        )
    }
    /// Removes an API link
    ///
    /// DELETE /api_link/{id}
    pub async fn delete(
        &mut self,
        request: super::request_types::DeleteRequest,
    ) -> crate::SdkResult<()> {
        let url = self
            .base_client
            .build_url(
                &format!(
                    "/api_link/{}", crate ::core::params::format_string_param(& request
                    .id)
                ),
            );
        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 API links for doc version
    ///
    /// GET /api_link
    pub async fn list(
        &mut self,
        request: super::request_types::ListRequest,
    ) -> crate::SdkResult<Vec<crate::models::ApiLink>> {
        let url = self.base_client.build_url("/api_link");
        let mut builder = reqwest::Client::default().get(&url);
        let mut queries = crate::core::params::QueryParams::default();
        queries
            .add(
                "doc_name",
                &request.doc_name,
                crate::core::params::QueryStyle::Form,
                true,
            );
        queries
            .add(
                "doc_version",
                &request.doc_version,
                crate::core::params::QueryStyle::Form,
                true,
            );
        builder = builder.query(&queries.params);
        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::ApiLink>>(response)
            .await
    }
    /// Retrieve single API link
    ///
    /// GET /api_link/{id}
    pub async fn get(
        &mut self,
        request: super::request_types::GetRequest,
    ) -> crate::SdkResult<crate::models::ApiLink> {
        let url = self
            .base_client
            .build_url(
                &format!(
                    "/api_link/{}", crate ::core::params::format_string_param(& request
                    .id)
                ),
            );
        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::ApiLink>(response).await
    }
    /// Updates an API link
    ///
    /// PATCH /api_link/{id}
    pub async fn patch(
        &mut self,
        request: super::request_types::PatchRequest,
    ) -> crate::SdkResult<crate::models::ApiLink> {
        let url = self
            .base_client
            .build_url(
                &format!(
                    "/api_link/{}", crate ::core::params::format_string_param(& request
                    .id)
                ),
            );
        let mut builder = reqwest::Client::default().patch(&url);
        builder = builder.header("x-sideko-sdk-language", "rust");
        builder = builder.header("content-type", "application/json");
        builder = builder
            .json(
                &crate::models::UpdateApiLink {
                    api_version: request.api_version,
                    build_request_enabled: request.build_request_enabled,
                    include_mock_server: request.include_mock_server,
                    nav_label: request.nav_label,
                    policy: request.policy,
                    slug: request.slug,
                },
            );
        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::ApiLink>(response).await
    }
    /// Links API Version to Documentation project version with a specified update policy
    ///
    /// POST /api_link
    pub async fn create(
        &mut self,
        request: super::request_types::CreateRequest,
    ) -> crate::SdkResult<crate::models::ApiLink> {
        let url = self.base_client.build_url("/api_link");
        let mut builder = reqwest::Client::default().post(&url);
        builder = builder.header("x-sideko-sdk-language", "rust");
        builder = builder.header("content-type", "application/json");
        builder = builder
            .json(
                &crate::models::NewApiLink {
                    build_request_enabled: request.build_request_enabled,
                    include_mock_server: request.include_mock_server,
                    doc_version_id: request.doc_version_id,
                    group_id: request.group_id,
                    nav_label: request.nav_label,
                    policy: request.policy,
                    slug: request.slug,
                },
            );
        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::ApiLink>(response).await
    }
    /// Reorder API links and groups
    ///
    /// POST /api_link/reorder
    pub async fn reorder(
        &mut self,
        request: super::request_types::ReorderRequest,
    ) -> crate::SdkResult<crate::models::ApiReorder> {
        let url = self.base_client.build_url("/api_link/reorder");
        let mut builder = reqwest::Client::default().post(&url);
        builder = builder.header("x-sideko-sdk-language", "rust");
        builder = builder.header("content-type", "application/json");
        builder = builder
            .json(
                &crate::models::ApiReorder {
                    doc_version_id: request.doc_version_id,
                    groups: request.groups,
                    links: request.links,
                },
            );
        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::ApiReorder>(response).await
    }
}
