use crate::api::*;
use crate::{ApiError, ClientConfig, HttpClient, QueryBuilder, RequestOptions};
use reqwest::Method;
pub struct SsOsClient {
pub http_client: HttpClient,
}
impl SsOsClient {
pub fn new(config: ClientConfig) -> Result<Self, ApiError> {
Ok(Self {
http_client: HttpClient::new(config.clone())?,
})
}
pub async fn list_all_ss_os(
&self,
request: &ListAllSsOsQueryRequest,
options: Option<RequestOptions>,
) -> Result<GetSSOResponse, ApiError> {
self.http_client
.execute_request(
Method::GET,
"sso",
None,
QueryBuilder::new()
.int("page", request.page.clone())
.int("limit", request.limit.clone())
.string("search", request.search.clone())
.build(),
options,
)
.await
}
pub async fn create_an_sso(
&self,
request: &PostSSORequest,
options: Option<RequestOptions>,
) -> Result<PostSSOResponse, ApiError> {
self.http_client
.execute_request(
Method::POST,
"sso",
Some(serde_json::to_value(request).unwrap_or_default()),
None,
options,
)
.await
}
pub async fn get_an_sso(
&self,
id: &String,
options: Option<RequestOptions>,
) -> Result<GetSsoIdResponse, ApiError> {
self.http_client
.execute_request(Method::GET, &format!("sso/{}", id), None, None, options)
.await
}
pub async fn delete_an_sso(
&self,
id: &String,
options: Option<RequestOptions>,
) -> Result<DeleteSsoIdResponse, ApiError> {
self.http_client
.execute_request(Method::DELETE, &format!("sso/{}", id), None, None, options)
.await
}
pub async fn update_an_sso(
&self,
id: &String,
request: &PatchSsoIdRequest,
options: Option<RequestOptions>,
) -> Result<PatchSsoIdResponse, ApiError> {
self.http_client
.execute_request(
Method::PATCH,
&format!("sso/{}", id),
Some(serde_json::to_value(request).unwrap_or_default()),
None,
options,
)
.await
}
}