#[derive(Debug)]
pub struct ServiceAccountClient<'a> {
    base_client: &'a mut crate::core::base_client::BaseClient,
}
impl<'a> ServiceAccountClient<'a> {
    pub(crate) fn _new(
        base_client: &'a mut crate::core::base_client::BaseClient,
    ) -> Self {
        Self { base_client }
    }
    /// Delete a service account
    ///
    /// DELETE /service_account/{id}
    pub async fn delete(
        &mut self,
        request: super::request_types::DeleteRequest,
    ) -> crate::SdkResult<()> {
        let url = self
            .base_client
            .build_url(
                &format!(
                    "/service_account/{}", 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 all service accounts in organization
    ///
    /// GET /service_account
    pub async fn list(&mut self) -> crate::SdkResult<Vec<crate::models::User>> {
        let url = self.base_client.build_url("/service_account");
        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::User>>(response).await
    }
    /// Get service account by the ID
    ///
    /// GET /service_account/{id}
    pub async fn get(
        &mut self,
        request: super::request_types::GetRequest,
    ) -> crate::SdkResult<crate::models::User> {
        let url = self
            .base_client
            .build_url(
                &format!(
                    "/service_account/{}", 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::User>(response).await
    }
    /// Create a new service account with a set of project permissions
    ///
    /// POST /service_account
    pub async fn create(
        &mut self,
        request: super::request_types::CreateRequest,
    ) -> crate::SdkResult<crate::models::UserApiKey> {
        let url = self.base_client.build_url("/service_account");
        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::NewServiceAccount {
                    expiration: request.expiration,
                    name: request.name,
                    object_roles: request.object_roles,
                },
            );
        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::UserApiKey>(response).await
    }
}
