Skip to main content

Client

Struct Client 

Source
pub struct Client { /* private fields */ }
Expand description

The Commit API client. Holds configuration and a connection pool, never sessions.

Implementations§

Source§

impl Client

Source

pub fn new(base_url: &str) -> Result<Self, Error>

Accepts the API origin, or the origin followed by /api/v1 or /api/v1/. Plain http:// is accepted only for this machine (localhost, 127.0.0.1, ::1).

Source

pub fn with_bearer(self, access_token: impl Into<String>) -> Self

Authenticates with a Silicon Accounts access token issued to Commit (Authorization: Bearer …).

Source

pub fn with_proof(self, proof: impl Into<String>) -> Result<Self, Error>

Authenticates as another app acting for an account, with a User verification proof (Authorization: Proof sap_…) issued for Commit with the scopes of the actions you call (each route’s action id, e.g. commit.todos.list). Commit must allow your app for those scopes.

Source

pub fn with_telemetry(self, _enabled: bool) -> Self

👎Deprecated since 0.6.0:

Commit records no telemetry; this does nothing and can be removed

Does nothing. Commit records no telemetry, so there is nothing to turn on or off.

Source

pub fn with_source(self, source: &'static str) -> Result<Self, Error>

👎Deprecated since 0.6.0:

Commit records no request diagnostics; this does nothing and can be removed

Does nothing. The source only named the interface in request diagnostics, which Commit no longer records. A value other than cli, browser, daemon or rust-client is still refused.

Source

pub fn with_mutation(self, mutation: Mutation) -> Self

Attaches retry/precondition inputs to writes made through this clone.

Source

pub fn base_url(&self) -> &Url

The /api/v1/ base every request goes to.

Source

pub fn new_idempotency_key() -> String

A fresh random idempotency key.

Source§

impl Client

Public and account endpoints.

Source

pub async fn health(&self) -> Result<Value, Error>

GET /healthz (public): the API process is alive.

Source

pub async fn ready(&self) -> Result<Value, Error>

GET /readyz (public): the API can serve requests.

Source

pub async fn version(&self) -> Result<Value, Error>

GET /api/v1/version (public): build metadata. Sends no credentials.

Source

pub async fn contracts(&self) -> Result<Value, Error>

GET /api/v1/contracts: the live compatibility matrix.

Source

pub async fn accounts(&self) -> Result<Value, Error>

GET /api/v1/accounts (public): how to sign in to Commit (app id, Silicon Accounts URLs, the scopes Commit honours). Sends no credentials.

Source

pub async fn me(&self) -> Result<Value, Error>

GET /api/v1/me: the caller as Commit sees it (uuid, id, kind, name, photo, shared email, custodian or Silicons, and via_app for proofs).

Source

pub async fn silicon_allowlist(&self, silicon: &str) -> Result<Value, Error>

GET /api/v1/silicons/{silicon}/allowed-accounts: the accounts a Silicon accepts todos and project invitations from besides its custodian and the custodian’s other Silicons (read by the Silicon or its custodian).

Source

pub async fn allow_account( &self, silicon: &str, account: &str, ) -> Result<Value, Error>

PUT /api/v1/silicons/{silicon}/allowed-accounts/{account}: lets account reach the Silicon.

Source

pub async fn disallow_account( &self, silicon: &str, account: &str, ) -> Result<Value, Error>

DELETE /api/v1/silicons/{silicon}/allowed-accounts/{account}.

Source

pub async fn email_settings(&self) -> Result<Value, Error>

GET /api/v1/email-settings: the caller’s email delivery preferences.

Source

pub async fn set_email_settings(&self, body: &Value) -> Result<Value, Error>

PUT /api/v1/email-settings: replaces the address and the subscribed events.

Source

pub async fn report(&self, body: &Value) -> Result<Value, Error>

POST /api/v1/reports: a bug report for Commit’s maintainers (keep the mutation across retries).

Source§

impl Client

Todos, notes and notification rules.

Source

pub async fn list_todos(&self, query: &[(&str, &str)]) -> Result<Value, Error>

GET /api/v1/todos (view, status, assigned_to, assigned_by, created_from, created_to, limit, cursor).

Source

pub async fn get_todo(&self, todo_id: &str) -> Result<Value, Error>

GET /api/v1/todos/{todo_id}.

Source

pub async fn create_todo<T: Serialize + ?Sized>( &self, body: &T, ) -> Result<Value, Error>

POST /api/v1/todos.

Source

pub async fn update_todo<T: Serialize + ?Sized>( &self, todo_id: &str, body: &T, ) -> Result<Value, Error>

PATCH /api/v1/todos/{todo_id}.

Source

pub async fn delete_todo(&self, todo_id: &str) -> Result<Value, Error>

DELETE /api/v1/todos/{todo_id}.

Source

pub async fn list_notes( &self, todo_id: &str, query: &[(&str, &str)], ) -> Result<Value, Error>

GET /api/v1/todos/{todo_id}/notes.

Source

pub async fn add_note<T: Serialize + ?Sized>( &self, todo_id: &str, body: &T, ) -> Result<Value, Error>

POST /api/v1/todos/{todo_id}/notes.

Source

pub async fn todo_subscription(&self, todo_id: &str) -> Result<Value, Error>

GET /api/v1/todos/{todo_id}/notification-subscription.

Source

pub async fn replace_todo_subscription<T: Serialize + ?Sized>( &self, todo_id: &str, body: &T, ) -> Result<Value, Error>

PUT /api/v1/todos/{todo_id}/notification-subscription.

Source

pub async fn notification_settings(&self) -> Result<Value, Error>

GET /api/v1/notification-settings: the caller’s Silicon webhook settings.

Source

pub async fn notification_settings_of( &self, silicon: &str, ) -> Result<Value, Error>

GET /api/v1/notification-settings?silicon=si:…: a Silicon’s settings, read by the Silicon or its custodian.

Source

pub async fn update_notification_settings<T: Serialize + ?Sized>( &self, body: &T, ) -> Result<Value, Error>

PUT /api/v1/notification-settings.

Source

pub async fn update_notification_settings_of<T: Serialize + ?Sized>( &self, silicon: &str, body: &T, ) -> Result<Value, Error>

PUT /api/v1/notification-settings?silicon=si:…: replaces a Silicon’s settings as the Silicon or its custodian.

Source§

impl Client

Projects, diaries, tasks, entries and versions.

Source

pub async fn list_projects( &self, query: &[(&str, &str)], ) -> Result<Value, Error>

GET /api/v1/projects (status, silicon_id, limit, cursor).

Source

pub async fn get_project(&self, project_id: &str) -> Result<Value, Error>

GET /api/v1/projects/{project_id} (id or UID).

Source

pub async fn create_project<T: Serialize + ?Sized>( &self, body: &T, ) -> Result<Value, Error>

POST /api/v1/projects.

Source

pub async fn update_project<T: Serialize + ?Sized>( &self, project_id: &str, body: &T, ) -> Result<Value, Error>

PATCH /api/v1/projects/{project_id}.

Source

pub async fn project_diary(&self, project_id: &str) -> Result<Value, Error>

GET /api/v1/projects/{project_id}/diary.

Source

pub async fn replace_project_diary<T: Serialize + ?Sized>( &self, project_id: &str, body: &T, ) -> Result<Value, Error>

PUT /api/v1/projects/{project_id}/diary (send If-Match).

Source

pub async fn project_tasks( &self, project_id: &str, query: &[(&str, &str)], ) -> Result<Value, Error>

GET /api/v1/projects/{project_id}/tasks.

Source

pub async fn project_entries( &self, project_id: &str, query: &[(&str, &str)], ) -> Result<Value, Error>

GET /api/v1/projects/{project_id}/entries: blockers, updates and completion.

Source

pub async fn create_project_task<T: Serialize + ?Sized>( &self, project_id: &str, body: &T, ) -> Result<Value, Error>

POST /api/v1/projects/{project_id}/tasks.

Source

pub async fn update_project_task<T: Serialize + ?Sized>( &self, project_id: &str, task_id: &str, body: &T, ) -> Result<Value, Error>

PATCH /api/v1/projects/{project_id}/tasks/{task_id}.

Source

pub async fn claim_project_task( &self, project: &str, task: &str, ) -> Result<Value, Error>

POST /api/v1/projects/{project}/tasks/{task}/claim: takes an unassigned task atomically.

Source

pub async fn delete_project_task( &self, project: &str, task: &str, ) -> Result<Value, Error>

DELETE /api/v1/projects/{project}/tasks/{task}: removes a task subtree and its linked todos.

Source

pub async fn create_project_blocker<T: Serialize + ?Sized>( &self, project_id: &str, body: &T, ) -> Result<Value, Error>

POST /api/v1/projects/{project_id}/blockers.

Source

pub async fn create_project_update<T: Serialize + ?Sized>( &self, project_id: &str, body: &T, ) -> Result<Value, Error>

POST /api/v1/projects/{project_id}/updates.

Source

pub async fn complete_project<T: Serialize + ?Sized>( &self, project_id: &str, body: &T, ) -> Result<Value, Error>

POST /api/v1/projects/{project_id}/completion.

Source

pub async fn project_versions( &self, project: &str, query: &[(&str, &str)], ) -> Result<Value, Error>

GET /api/v1/projects/{project}/versions (before, limit): newest first.

Source

pub async fn project_version( &self, project: &str, version: i64, ) -> Result<Value, Error>

GET /api/v1/projects/{project}/versions/{version}: one retained snapshot.

Trait Implementations§

Source§

impl Clone for Client

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Client

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more