pub struct Users<'a> { /* private fields */ }Expand description
The caller’s own user account, from Client::users.
Needs a personal key: a zone key has no user and gets
ErrorCode::Forbidden.
Implementations§
Source§impl<'a> Users<'a>
impl<'a> Users<'a>
Sourcepub async fn get(&self, user: &str) -> Result<User>
pub async fn get(&self, user: &str) -> Result<User>
One user, by uuid or email. A non-Admin can read only their own account; this is also how to learn your own uuid (Core has no “who am I” route yet).
GET /api/v1/users/:ref
§Errors
ErrorCode::NotFoundif there is no such user.ErrorCode::Forbiddenfor another user’s account, or with a zone key.
§Examples
let me = client.users().get("ana@example.com").await?;
println!("my uuid is {}", me.uuid);Sourcepub async fn create_api_key(&self, uuid: Uuid) -> Result<Secret>
pub async fn create_api_key(&self, uuid: Uuid) -> Result<Secret>
Issues a new personal key (du_…) and returns it. Core shows the key only in this
response and keeps just its hash, so store it now. A previous personal key stops
working immediately, also for this client: build a new client with the new key.
POST /api/v1/users/:uuid/api-key
§Errors
ErrorCode::Forbidden for another user’s account, or
with a zone key.
§Examples
let me = client.users().get("ana@example.com").await?;
let key = client.users().create_api_key(me.uuid).await?;
// From here on, only a client built with `key` works; Core never returns it again.
println!("{}", key.expose());Sourcepub async fn revoke_api_key(&self, uuid: Uuid) -> Result<User>
pub async fn revoke_api_key(&self, uuid: Uuid) -> Result<User>
Revokes the user’s personal key; the account then has none
(User::has_api_key is false). If it is the key this client uses, the client
stops working.
DELETE /api/v1/users/:uuid/api-key
§Errors
ErrorCode::Forbidden for another user’s account, or
with a zone key.