Files
outline/src/models/user.rs
T
henning dec8face54 Add Outline API client library foundation
Implements a first vertical slice of the Outline RPC API (auth, documents,
collections, users) covering the structural patterns used across the whole
API: single object, paginated list, tree, create/update, delete, search.
Chosen as the basis for future CLI and GUI clients built on top of this crate.

- Handwritten client (not codegen) against the vendored OpenAPI spec, since
  Outline's API is uniformly POST /api/<resource>.<action> with JSON bodies
  and inline/anonymous schemas that generators handle poorly
- Async (reqwest + tokio) Client, cheaply cloneable, no &mut self methods
- thiserror-based Error with ErrorKind classification and boxed API error
  context; forward-compatible models (unknown fields ignored, unknown
  string-enum values preserved via a catch-all variant) since the API is
  unversioned and self-hosted instances vary in age
- Pagination via Page<T>/Paginator with next_page/collect_all/into_stream
- wiremock-based test suite plus a spec-coverage test guarding against typos
  in RPC method names
2026-07-30 13:00:09 +02:00

57 lines
1.7 KiB
Rust

use serde::{Deserialize, Serialize};
use super::common::{Id, Timestamp, UnknownVariant};
/// A member of an Outline workspace.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
#[non_exhaustive]
pub struct User {
/// Unique identifier for the user.
pub id: Id,
/// The user's display name.
pub name: String,
/// The URL of the user's avatar image, if any.
#[serde(default)]
pub avatar_url: Option<String>,
/// A color representing the user, used for avatars without an image.
#[serde(default)]
pub color: Option<String>,
/// The user's email address.
#[serde(default)]
pub email: Option<String>,
/// The user's role within the workspace.
#[serde(default)]
pub role: Option<UserRole>,
/// Whether the user has been suspended.
#[serde(default)]
pub is_suspended: bool,
/// The last time this user made an API request.
#[serde(default)]
pub last_active_at: Option<Timestamp>,
/// The date and time this user first signed in or was invited.
#[serde(default)]
pub created_at: Option<Timestamp>,
/// The date and time this user was last updated.
#[serde(default)]
pub updated_at: Option<Timestamp>,
}
/// A user's role within a workspace.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
#[non_exhaustive]
pub enum UserRole {
/// Full administrative access.
Admin,
/// A regular workspace member.
Member,
/// Read-only access to shared content.
Viewer,
/// External guest access.
Guest,
/// A value not recognized by this version of the crate.
#[serde(untagged)]
Unknown(UnknownVariant),
}