uptrakit_openapi_client/
oauth_clients.rs1use crate::Result;
4use crate::UptrakitClient;
5use crate::types_impl::oauth::{
6 DcrRegistrationRequest, DcrRegistrationResponse, OAuthClientResponse,
7};
8use crate::types_impl::pagination::{PaginatedResponse, PaginationParams};
9
10impl UptrakitClient {
11 pub async fn list_clients(
13 &self,
14 params: &PaginationParams,
15 ) -> Result<PaginatedResponse<OAuthClientResponse>> {
16 self.get_with_query(crate::paths::oauth::CLIENTS, params)
17 .await
18 }
19
20 pub async fn manual_register_client(
25 &self,
26 req: &DcrRegistrationRequest,
27 ) -> Result<DcrRegistrationResponse> {
28 self.post_json(crate::paths::oauth::CLIENTS, req).await
29 }
30
31 pub async fn revoke_client(&self, client_id: &str) -> Result<()> {
33 self.delete(&crate::paths::oauth::client_by_id(client_id))
34 .await
35 }
36
37 pub async fn trust_client(&self, client_id: &str) -> Result<()> {
39 self.post_empty_no_content(&crate::paths::oauth::client_trust(client_id))
40 .await
41 }
42}
43
44#[cfg(test)]
45mod tests {
46 #[test]
47 fn client_by_id_encodes_url_shaped_ids() {
48 let path = crate::paths::oauth::client_by_id("https://example.com/client.json");
49 let rest = path
50 .strip_prefix("/api/oauth/clients/")
51 .expect("path must start with the clients prefix");
52 assert!(
53 !rest.contains('/'),
54 "encoded id must be a single path segment: {path}"
55 );
56 }
57}