#[derive(Debug)]
pub struct RoleClient<'a> {
    base_client: &'a mut crate::core::base_client::BaseClient,
}
impl<'a> RoleClient<'a> {
    pub(crate) fn _new(
        base_client: &'a mut crate::core::base_client::BaseClient,
    ) -> Self {
        Self { base_client }
    }
    /// Delete role and all associated permissions
    ///
    /// DELETE /role/{id}
    pub async fn delete(
        &mut self,
        request: super::request_types::DeleteRequest,
    ) -> crate::SdkResult<()> {
        let url = self
            .base_client
            .build_url(
                &format!(
                    "/role/{}", 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 roles
    ///
    /// GET /role
    pub async fn list(
        &mut self,
        request: super::request_types::ListRequest,
    ) -> crate::SdkResult<Vec<crate::models::Role>> {
        let url = self.base_client.build_url("/role");
        let mut builder = reqwest::Client::default().get(&url);
        let mut queries = crate::core::params::QueryParams::default();
        queries
            .add_option(
                "object_id",
                &request.object_id,
                crate::core::params::QueryStyle::Form,
                true,
            );
        queries
            .add_option(
                "object_type",
                &request.object_type,
                crate::core::params::QueryStyle::Form,
                true,
            );
        queries
            .add_option(
                "user_id",
                &request.user_id,
                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::Role>>(response).await
    }
    /// Create a new role
    ///
    /// POST /role
    pub async fn create(
        &mut self,
        request: super::request_types::CreateRequest,
    ) -> crate::SdkResult<crate::models::Role> {
        let url = self.base_client.build_url("/role");
        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::NewRole {
                    object_id: request.object_id,
                    object_type: request.object_type,
                    role_definition_id: request.role_definition_id,
                    user_id: request.user_id,
                },
            );
        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::Role>(response).await
    }
}
