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
79 lines
2.5 KiB
Rust
79 lines
2.5 KiB
Rust
use serde::{Deserialize, Serialize};
|
|
|
|
use super::common::Id;
|
|
use super::user::{User, UserRole};
|
|
|
|
/// The payload returned by `auth.info`: the current API actor and their workspace.
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
#[non_exhaustive]
|
|
pub struct AuthInfo {
|
|
/// The user associated with the current API key or access token.
|
|
pub user: User,
|
|
/// The workspace the user belongs to.
|
|
pub team: Team,
|
|
}
|
|
|
|
/// An Outline workspace (formerly "team").
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
#[serde(rename_all = "camelCase")]
|
|
#[non_exhaustive]
|
|
pub struct Team {
|
|
/// Unique identifier for the workspace.
|
|
pub id: Id,
|
|
/// The name of the workspace.
|
|
pub name: String,
|
|
/// A short description of the workspace.
|
|
#[serde(default)]
|
|
pub description: Option<String>,
|
|
/// The URL of the workspace's avatar image, if any.
|
|
#[serde(default)]
|
|
pub avatar_url: Option<String>,
|
|
/// Whether this workspace has share links globally enabled.
|
|
#[serde(default)]
|
|
pub sharing: bool,
|
|
/// The default role assigned to new members.
|
|
#[serde(default)]
|
|
pub default_user_role: Option<UserRole>,
|
|
/// The fully qualified URL at which this workspace can be accessed.
|
|
#[serde(default)]
|
|
pub url: Option<String>,
|
|
/// The subdomain at which this workspace can be accessed.
|
|
#[serde(default)]
|
|
pub subdomain: Option<String>,
|
|
}
|
|
|
|
/// Authentication configuration for an Outline instance (`auth.config`).
|
|
///
|
|
/// This endpoint requires no authentication and is useful for discovering
|
|
/// available sign-in methods before a client has credentials.
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
#[serde(rename_all = "camelCase")]
|
|
#[non_exhaustive]
|
|
pub struct AuthConfig {
|
|
/// The name of the workspace.
|
|
#[serde(default)]
|
|
pub name: Option<String>,
|
|
/// The hostname at which this workspace can be accessed.
|
|
#[serde(default)]
|
|
pub hostname: Option<String>,
|
|
/// Available single sign-on services.
|
|
#[serde(default)]
|
|
pub services: Vec<AuthService>,
|
|
}
|
|
|
|
/// A single sign-on service available for authentication.
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
#[serde(rename_all = "camelCase")]
|
|
#[non_exhaustive]
|
|
pub struct AuthService {
|
|
/// The service identifier, e.g. `"slack"`.
|
|
#[serde(default)]
|
|
pub id: Option<String>,
|
|
/// The human-readable service name, e.g. `"Slack"`.
|
|
#[serde(default)]
|
|
pub name: Option<String>,
|
|
/// The URL to redirect to in order to authenticate with this service.
|
|
#[serde(default)]
|
|
pub auth_url: Option<String>,
|
|
}
|