pub struct Client { /* private fields */ }Expand description
The Commit API client. Holds configuration and a connection pool, never sessions.
Implementations§
Source§impl Client
impl Client
Sourcepub fn new(base_url: &str) -> Result<Self, Error>
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).
Sourcepub fn with_bearer(self, access_token: impl Into<String>) -> Self
pub fn with_bearer(self, access_token: impl Into<String>) -> Self
Authenticates with a Silicon Accounts access token issued to Commit
(Authorization: Bearer …).
Sourcepub fn with_proof(self, proof: impl Into<String>) -> Result<Self, Error>
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.
Sourcepub fn with_telemetry(self, _enabled: bool) -> Self
👎Deprecated since 0.6.0: Commit records no telemetry; this does nothing and can be removed
pub fn with_telemetry(self, _enabled: bool) -> Self
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.
Sourcepub 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
pub fn with_source(self, source: &'static str) -> Result<Self, Error>
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.
Sourcepub fn with_mutation(self, mutation: Mutation) -> Self
pub fn with_mutation(self, mutation: Mutation) -> Self
Attaches retry/precondition inputs to writes made through this clone.
Sourcepub fn new_idempotency_key() -> String
pub fn new_idempotency_key() -> String
A fresh random idempotency key.
Source§impl Client
Public and account endpoints.
impl Client
Public and account endpoints.
Sourcepub async fn health(&self) -> Result<Value, Error>
pub async fn health(&self) -> Result<Value, Error>
GET /healthz (public): the API process is alive.
Sourcepub async fn ready(&self) -> Result<Value, Error>
pub async fn ready(&self) -> Result<Value, Error>
GET /readyz (public): the API can serve requests.
Sourcepub async fn version(&self) -> Result<Value, Error>
pub async fn version(&self) -> Result<Value, Error>
GET /api/v1/version (public): build metadata. Sends no credentials.
Sourcepub async fn contracts(&self) -> Result<Value, Error>
pub async fn contracts(&self) -> Result<Value, Error>
GET /api/v1/contracts: the live compatibility matrix.
Sourcepub async fn accounts(&self) -> Result<Value, Error>
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.
Sourcepub async fn me(&self) -> Result<Value, Error>
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).
Sourcepub async fn silicon_allowlist(&self, silicon: &str) -> Result<Value, Error>
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).
Sourcepub async fn allow_account(
&self,
silicon: &str,
account: &str,
) -> Result<Value, Error>
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.
Sourcepub async fn disallow_account(
&self,
silicon: &str,
account: &str,
) -> Result<Value, Error>
pub async fn disallow_account( &self, silicon: &str, account: &str, ) -> Result<Value, Error>
DELETE /api/v1/silicons/{silicon}/allowed-accounts/{account}.
Sourcepub async fn email_settings(&self) -> Result<Value, Error>
pub async fn email_settings(&self) -> Result<Value, Error>
GET /api/v1/email-settings: the caller’s email delivery preferences.
Source§impl Client
Todos, notes and notification rules.
impl Client
Todos, notes and notification rules.
Sourcepub async fn list_todos(&self, query: &[(&str, &str)]) -> Result<Value, Error>
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).
Sourcepub async fn get_todo(&self, todo_id: &str) -> Result<Value, Error>
pub async fn get_todo(&self, todo_id: &str) -> Result<Value, Error>
GET /api/v1/todos/{todo_id}.
Sourcepub async fn create_todo<T: Serialize + ?Sized>(
&self,
body: &T,
) -> Result<Value, Error>
pub async fn create_todo<T: Serialize + ?Sized>( &self, body: &T, ) -> Result<Value, Error>
POST /api/v1/todos.
Sourcepub async fn update_todo<T: Serialize + ?Sized>(
&self,
todo_id: &str,
body: &T,
) -> Result<Value, Error>
pub async fn update_todo<T: Serialize + ?Sized>( &self, todo_id: &str, body: &T, ) -> Result<Value, Error>
PATCH /api/v1/todos/{todo_id}.
Sourcepub async fn delete_todo(&self, todo_id: &str) -> Result<Value, Error>
pub async fn delete_todo(&self, todo_id: &str) -> Result<Value, Error>
DELETE /api/v1/todos/{todo_id}.
Sourcepub async fn list_notes(
&self,
todo_id: &str,
query: &[(&str, &str)],
) -> Result<Value, Error>
pub async fn list_notes( &self, todo_id: &str, query: &[(&str, &str)], ) -> Result<Value, Error>
GET /api/v1/todos/{todo_id}/notes.
Sourcepub async fn add_note<T: Serialize + ?Sized>(
&self,
todo_id: &str,
body: &T,
) -> Result<Value, Error>
pub async fn add_note<T: Serialize + ?Sized>( &self, todo_id: &str, body: &T, ) -> Result<Value, Error>
POST /api/v1/todos/{todo_id}/notes.
Sourcepub async fn todo_subscription(&self, todo_id: &str) -> Result<Value, Error>
pub async fn todo_subscription(&self, todo_id: &str) -> Result<Value, Error>
GET /api/v1/todos/{todo_id}/notification-subscription.
Sourcepub async fn replace_todo_subscription<T: Serialize + ?Sized>(
&self,
todo_id: &str,
body: &T,
) -> Result<Value, Error>
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.
Sourcepub async fn notification_settings(&self) -> Result<Value, Error>
pub async fn notification_settings(&self) -> Result<Value, Error>
GET /api/v1/notification-settings: the caller’s Silicon webhook settings.
Sourcepub async fn notification_settings_of(
&self,
silicon: &str,
) -> Result<Value, Error>
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§impl Client
Projects, diaries, tasks, entries and versions.
impl Client
Projects, diaries, tasks, entries and versions.
Sourcepub async fn list_projects(
&self,
query: &[(&str, &str)],
) -> Result<Value, Error>
pub async fn list_projects( &self, query: &[(&str, &str)], ) -> Result<Value, Error>
GET /api/v1/projects (status, silicon_id, limit, cursor).
Sourcepub async fn get_project(&self, project_id: &str) -> Result<Value, Error>
pub async fn get_project(&self, project_id: &str) -> Result<Value, Error>
GET /api/v1/projects/{project_id} (id or UID).
Sourcepub async fn create_project<T: Serialize + ?Sized>(
&self,
body: &T,
) -> Result<Value, Error>
pub async fn create_project<T: Serialize + ?Sized>( &self, body: &T, ) -> Result<Value, Error>
POST /api/v1/projects.
Sourcepub async fn update_project<T: Serialize + ?Sized>(
&self,
project_id: &str,
body: &T,
) -> Result<Value, Error>
pub async fn update_project<T: Serialize + ?Sized>( &self, project_id: &str, body: &T, ) -> Result<Value, Error>
PATCH /api/v1/projects/{project_id}.
Sourcepub async fn project_diary(&self, project_id: &str) -> Result<Value, Error>
pub async fn project_diary(&self, project_id: &str) -> Result<Value, Error>
GET /api/v1/projects/{project_id}/diary.
Sourcepub async fn replace_project_diary<T: Serialize + ?Sized>(
&self,
project_id: &str,
body: &T,
) -> Result<Value, Error>
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).
Sourcepub async fn project_tasks(
&self,
project_id: &str,
query: &[(&str, &str)],
) -> Result<Value, Error>
pub async fn project_tasks( &self, project_id: &str, query: &[(&str, &str)], ) -> Result<Value, Error>
GET /api/v1/projects/{project_id}/tasks.
Sourcepub async fn project_entries(
&self,
project_id: &str,
query: &[(&str, &str)],
) -> Result<Value, Error>
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.
Sourcepub async fn create_project_task<T: Serialize + ?Sized>(
&self,
project_id: &str,
body: &T,
) -> Result<Value, Error>
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.
Sourcepub async fn update_project_task<T: Serialize + ?Sized>(
&self,
project_id: &str,
task_id: &str,
body: &T,
) -> Result<Value, Error>
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}.
Sourcepub async fn claim_project_task(
&self,
project: &str,
task: &str,
) -> Result<Value, Error>
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.
Sourcepub async fn delete_project_task(
&self,
project: &str,
task: &str,
) -> Result<Value, Error>
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.
Sourcepub async fn create_project_blocker<T: Serialize + ?Sized>(
&self,
project_id: &str,
body: &T,
) -> Result<Value, Error>
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.
Sourcepub async fn create_project_update<T: Serialize + ?Sized>(
&self,
project_id: &str,
body: &T,
) -> Result<Value, Error>
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.
Sourcepub async fn complete_project<T: Serialize + ?Sized>(
&self,
project_id: &str,
body: &T,
) -> Result<Value, Error>
pub async fn complete_project<T: Serialize + ?Sized>( &self, project_id: &str, body: &T, ) -> Result<Value, Error>
POST /api/v1/projects/{project_id}/completion.