1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
// @generated by tools/gen_management.py from management-registry.json and
// openapi.json. DO NOT EDIT -- your changes will be overwritten. Regenerate
// with `tools/gen_management.py`; CI verifies the committed output is current.
//! The `scim_tokens` management namespace (CONTRACT §27.1).
//!
//! Bearer tokens for the SCIM 2.0 provisioning endpoint.
#![allow(clippy::too_many_arguments)]
use uuid::Uuid;
use crate::AxiamError;
use crate::client::AxiamClient;
use crate::management::models;
use crate::management::request::{Call, Verb};
use crate::management::scope::Scope;
/// The `scim_tokens` namespace handle.
///
/// Bearer tokens for the SCIM 2.0 provisioning endpoint.
///
/// Acquiring one performs no I/O and allocates nothing meaningful (§27.2 rule
/// 1); it borrows the client and cannot outlive it.
#[derive(Clone, Copy)]
pub struct ScimTokens<'c> {
pub(crate) client: &'c AxiamClient,
pub(crate) scope: Scope,
}
impl std::fmt::Debug for ScimTokens<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("ScimTokens")
.field("scope", &self.scope)
.finish()
}
}
impl<'c> ScimTokens<'c> {
pub(crate) fn new(client: &'c AxiamClient) -> Self {
Self {
client,
scope: Scope::default(),
}
}
/// `GET /api/v1/scim-tokens`
pub async fn list(&self) -> Result<Vec<models::ScimTokenResponse>, AxiamError> {
let query: Vec<(&'static str, String)> = Vec::new();
let call = Call {
operation: "scim_tokens.list",
verb: Verb::Get,
path_template: "/api/v1/scim-tokens",
path: "/api/v1/scim-tokens".to_string(),
query: &query,
};
self.client
.management_send::<_, Vec<models::ScimTokenResponse>>(call, None::<&()>)
.await
}
/// `POST /api/v1/scim-tokens`
/// **Returns secret material, once.** `provisioning_token` is returned by
/// this call and by no other; no later `get` will return it again. Discarding
/// the result destroys the credential (§27.5 rule 3).
/// Not retried on failure (§27.4 rule 8): every write on this surface is
/// issued exactly once, including the ones that look idempotent.
pub async fn create(
&self,
body: &models::CreateScimTokenRequest,
) -> Result<models::CreateScimTokenResponse, AxiamError> {
let query: Vec<(&'static str, String)> = Vec::new();
let call = Call {
operation: "scim_tokens.create",
verb: Verb::Post,
path_template: "/api/v1/scim-tokens",
path: "/api/v1/scim-tokens".to_string(),
query: &query,
};
let wire: models::CreateScimTokenResponseWire =
self.client.management_send(call, Some(body)).await?;
Ok(models::CreateScimTokenResponse::from(wire))
}
/// `DELETE /api/v1/scim-tokens/{id}`
/// Not retried on failure (§27.4 rule 8): every write on this surface is
/// issued exactly once, including the ones that look idempotent.
pub async fn revoke(&self, id: Uuid) -> Result<(), AxiamError> {
let query: Vec<(&'static str, String)> = Vec::new();
let call = Call {
operation: "scim_tokens.revoke",
verb: Verb::Delete,
path_template: "/api/v1/scim-tokens/{id}",
path: format!("/api/v1/scim-tokens/{id}"),
query: &query,
};
self.client
.management_send_no_content(call, None::<&()>)
.await
}
}