pub struct Scoped<'c, S> { /* private fields */ }Expand description
A Client bound to a Scope. Returned by Client::org,
Client::inbox, and Client::pod; the resource methods it exposes
depend on which capability traits the scope S implements.
Implementations§
Source§impl<S: ApiKeys> Scoped<'_, S>
impl<S: ApiKeys> Scoped<'_, S>
Sourcepub async fn create_api_key(
&self,
key: CreateApiKey,
) -> Result<CreatedApiKey, Error>
pub async fn create_api_key( &self, key: CreateApiKey, ) -> Result<CreatedApiKey, Error>
POST {scope}/api-keys, mint a new API key. The full secret is in
CreatedApiKey::api_key and is shown only here; store it now.
Sourcepub async fn list_api_keys(&self, page: Page) -> Result<ApiKeyList, Error>
pub async fn list_api_keys(&self, page: Page) -> Result<ApiKeyList, Error>
GET {scope}/api-keys, one page.
Source§impl<S: Domains> Scoped<'_, S>
impl<S: Domains> Scoped<'_, S>
Sourcepub async fn create_domain(&self, domain: CreateDomain) -> Result<Domain, Error>
pub async fn create_domain(&self, domain: CreateDomain) -> Result<Domain, Error>
POST {scope}/domains, add a sending domain. The response carries the
DNS VerificationRecords to publish.
Sourcepub async fn list_domains(&self, page: Page) -> Result<DomainList, Error>
pub async fn list_domains(&self, page: Page) -> Result<DomainList, Error>
GET {scope}/domains, one page.
Sourcepub async fn list_all_domains(&self) -> Result<Vec<Domain>, Error>
pub async fn list_all_domains(&self) -> Result<Vec<Domain>, Error>
Every domain, draining pagination.
Sourcepub async fn get_domain(&self, domain_id: &str) -> Result<Domain, Error>
pub async fn get_domain(&self, domain_id: &str) -> Result<Domain, Error>
GET {scope}/domains/{domain_id}.
Sourcepub async fn update_domain(
&self,
domain_id: &str,
update: UpdateDomain,
) -> Result<Domain, Error>
pub async fn update_domain( &self, domain_id: &str, update: UpdateDomain, ) -> Result<Domain, Error>
PATCH {scope}/domains/{domain_id}, toggle feedback and subdomain
settings.
Sourcepub async fn delete_domain(&self, domain_id: &str) -> Result<(), Error>
pub async fn delete_domain(&self, domain_id: &str) -> Result<(), Error>
DELETE {scope}/domains/{domain_id}.
Sourcepub async fn verify_domain(&self, domain_id: &str) -> Result<(), Error>
pub async fn verify_domain(&self, domain_id: &str) -> Result<(), Error>
POST {scope}/domains/{domain_id}/verify, ask the API to re-check the
DNS records; poll Scoped::get_domain for the resulting status.
Source§impl<S: Drafts> Scoped<'_, S>
impl<S: Drafts> Scoped<'_, S>
Sourcepub async fn list_drafts(&self, page: Page) -> Result<DraftList, Error>
pub async fn list_drafts(&self, page: Page) -> Result<DraftList, Error>
GET {scope}/drafts, one page. Drafts are readable at every scope but
only created and sent from an Client::inbox.
Sourcepub async fn list_all_drafts(&self) -> Result<Vec<Draft>, Error>
pub async fn list_all_drafts(&self) -> Result<Vec<Draft>, Error>
Every draft, draining pagination.
Sourcepub async fn get_draft(&self, draft_id: &str) -> Result<Draft, Error>
pub async fn get_draft(&self, draft_id: &str) -> Result<Draft, Error>
GET {scope}/drafts/{draft_id}.
Sourcepub async fn get_draft_attachment(
&self,
draft_id: &str,
attachment_id: &str,
) -> Result<Attachment, Error>
pub async fn get_draft_attachment( &self, draft_id: &str, attachment_id: &str, ) -> Result<Attachment, Error>
GET {scope}/drafts/{draft_id}/attachments/{attachment_id}.
Source§impl Scoped<'_, InboxScope<'_>>
impl Scoped<'_, InboxScope<'_>>
Sourcepub async fn create_draft(&self, draft: CreateDraft) -> Result<Draft, Error>
pub async fn create_draft(&self, draft: CreateDraft) -> Result<Draft, Error>
POST /v0/inboxes/{inbox_id}/drafts, create a draft. Supply
in_reply_to to create a reply draft (with reply_all to address the
whole thread) or forward_of to create a forward draft.
Sourcepub async fn update_draft(
&self,
draft_id: &str,
update: UpdateDraft,
) -> Result<Draft, Error>
pub async fn update_draft( &self, draft_id: &str, update: UpdateDraft, ) -> Result<Draft, Error>
PATCH /v0/inboxes/{inbox_id}/drafts/{draft_id}, edit an existing draft.
Sourcepub async fn delete_draft(&self, draft_id: &str) -> Result<(), Error>
pub async fn delete_draft(&self, draft_id: &str) -> Result<(), Error>
DELETE /v0/inboxes/{inbox_id}/drafts/{draft_id}.
Sourcepub async fn send_draft(&self, draft_id: &str) -> Result<SentMessage, Error>
pub async fn send_draft(&self, draft_id: &str) -> Result<SentMessage, Error>
POST /v0/inboxes/{inbox_id}/drafts/{draft_id}/send, send a draft. The
draft is deleted after a successful send.
Source§impl Scoped<'_, InboxScope<'_>>
impl Scoped<'_, InboxScope<'_>>
Sourcepub async fn list_events(&self, page: Page) -> Result<InboxEventList, Error>
pub async fn list_events(&self, page: Page) -> Result<InboxEventList, Error>
GET /v0/inboxes/{inbox_id}/events, one page of the inbox’s audit log.
Sourcepub async fn list_all_events(&self) -> Result<Vec<InboxEvent>, Error>
pub async fn list_all_events(&self) -> Result<Vec<InboxEvent>, Error>
Every inbox event, draining pagination.
Source§impl<S: Inboxes> Scoped<'_, S>
impl<S: Inboxes> Scoped<'_, S>
Sourcepub async fn create_inbox(&self, inbox: CreateInbox) -> Result<Inbox, Error>
pub async fn create_inbox(&self, inbox: CreateInbox) -> Result<Inbox, Error>
POST {scope}/inboxes, a new agent-owned email address. At Client::org
this creates a standalone inbox; at Client::pod it creates the inbox
inside that pod. Free plans get {username}@agentmail.to; custom domains
must be verified first.
Sourcepub async fn list_inboxes(&self, page: Page) -> Result<InboxList, Error>
pub async fn list_inboxes(&self, page: Page) -> Result<InboxList, Error>
GET {scope}/inboxes, one page.
Sourcepub async fn list_all_inboxes(&self) -> Result<Vec<Inbox>, Error>
pub async fn list_all_inboxes(&self) -> Result<Vec<Inbox>, Error>
Every inbox in the scope, draining pagination.
Sourcepub async fn get_inbox(&self, inbox_id: &str) -> Result<Inbox, Error>
pub async fn get_inbox(&self, inbox_id: &str) -> Result<Inbox, Error>
GET {scope}/inboxes/{inbox_id}.
Sourcepub async fn update_inbox(
&self,
inbox_id: &str,
update: UpdateInbox,
) -> Result<Inbox, Error>
pub async fn update_inbox( &self, inbox_id: &str, update: UpdateInbox, ) -> Result<Inbox, Error>
PATCH {scope}/inboxes/{inbox_id}, update display name and/or metadata.
Source§impl<S: Lists> Scoped<'_, S>
impl<S: Lists> Scoped<'_, S>
Sourcepub async fn list_entries(
&self,
direction: ListDirection,
kind: ListKind,
page: Page,
) -> Result<ListEntries, Error>
pub async fn list_entries( &self, direction: ListDirection, kind: ListKind, page: Page, ) -> Result<ListEntries, Error>
GET {scope}/lists/{direction}/{kind}, one page of entries.
Sourcepub async fn list_all_entries(
&self,
direction: ListDirection,
kind: ListKind,
) -> Result<Vec<ListEntry>, Error>
pub async fn list_all_entries( &self, direction: ListDirection, kind: ListKind, ) -> Result<Vec<ListEntry>, Error>
Every entry in the list, draining pagination.
Sourcepub async fn create_list_entry(
&self,
direction: ListDirection,
kind: ListKind,
entry: CreateListEntry,
) -> Result<ListEntry, Error>
pub async fn create_list_entry( &self, direction: ListDirection, kind: ListKind, entry: CreateListEntry, ) -> Result<ListEntry, Error>
POST {scope}/lists/{direction}/{kind}, add an address or domain.
Sourcepub async fn get_list_entry(
&self,
direction: ListDirection,
kind: ListKind,
entry: &str,
) -> Result<ListEntry, Error>
pub async fn get_list_entry( &self, direction: ListDirection, kind: ListKind, entry: &str, ) -> Result<ListEntry, Error>
GET {scope}/lists/{direction}/{kind}/{entry}.
Sourcepub async fn delete_list_entry(
&self,
direction: ListDirection,
kind: ListKind,
entry: &str,
) -> Result<(), Error>
pub async fn delete_list_entry( &self, direction: ListDirection, kind: ListKind, entry: &str, ) -> Result<(), Error>
DELETE {scope}/lists/{direction}/{kind}/{entry}.
Source§impl Scoped<'_, InboxScope<'_>>
Messages exist only within an inbox, so these methods live on
client.inbox(id).
impl Scoped<'_, InboxScope<'_>>
Messages exist only within an inbox, so these methods live on
client.inbox(id).
Sourcepub async fn send_message(
&self,
message: SendMessage,
) -> Result<SentMessage, Error>
pub async fn send_message( &self, message: SendMessage, ) -> Result<SentMessage, Error>
POST /v0/inboxes/{inbox_id}/messages/send.
Sourcepub async fn send_text(
&self,
to: &str,
subject: &str,
text: &str,
) -> Result<SentMessage, Error>
pub async fn send_text( &self, to: &str, subject: &str, text: &str, ) -> Result<SentMessage, Error>
Send a plain-text message to a single recipient: the common case, in one
line. For anything richer (HTML, cc/bcc, attachments, labels), build a
SendMessage and call Scoped::send_message.
Sourcepub async fn list_messages(
&self,
filters: MessageListFilters,
) -> Result<MessageList, Error>
pub async fn list_messages( &self, filters: MessageListFilters, ) -> Result<MessageList, Error>
GET /v0/inboxes/{inbox_id}/messages, one page. Pass
MessageListFilters::default for the first unfiltered page.
Sourcepub async fn list_all_messages(
&self,
filters: MessageListFilters,
) -> Result<Vec<Message>, Error>
pub async fn list_all_messages( &self, filters: MessageListFilters, ) -> Result<Vec<Message>, Error>
Every message matching filters, draining pagination.
Sourcepub async fn search_messages(
&self,
query: &str,
filters: MessageListFilters,
) -> Result<MessageList, Error>
pub async fn search_messages( &self, query: &str, filters: MessageListFilters, ) -> Result<MessageList, Error>
GET /v0/inboxes/{inbox_id}/messages/search (q required).
Sourcepub async fn search_all_messages(
&self,
query: &str,
filters: MessageListFilters,
) -> Result<Vec<Message>, Error>
pub async fn search_all_messages( &self, query: &str, filters: MessageListFilters, ) -> Result<Vec<Message>, Error>
Every message matching a search, draining pagination.
Sourcepub async fn get_message(&self, message_id: &str) -> Result<Message, Error>
pub async fn get_message(&self, message_id: &str) -> Result<Message, Error>
GET /v0/inboxes/{inbox_id}/messages/{message_id}.
Sourcepub async fn update_message(
&self,
message_id: &str,
update: UpdateMessage,
) -> Result<UpdatedMessage, Error>
pub async fn update_message( &self, message_id: &str, update: UpdateMessage, ) -> Result<UpdatedMessage, Error>
PATCH /v0/inboxes/{inbox_id}/messages/{message_id}, add/remove labels
(read state is a label). Returns the id and labels after the change.
Sourcepub async fn delete_message(&self, message_id: &str) -> Result<(), Error>
pub async fn delete_message(&self, message_id: &str) -> Result<(), Error>
DELETE /v0/inboxes/{inbox_id}/messages/{message_id}.
Sourcepub async fn reply_to_message(
&self,
message_id: &str,
reply: ReplyToMessage,
) -> Result<SentMessage, Error>
pub async fn reply_to_message( &self, message_id: &str, reply: ReplyToMessage, ) -> Result<SentMessage, Error>
POST /v0/inboxes/{inbox_id}/messages/{message_id}/reply, reply to a
message (recipients derived from the parent).
Sourcepub async fn reply_all_to_message(
&self,
message_id: &str,
reply: ReplyToMessage,
) -> Result<SentMessage, Error>
pub async fn reply_all_to_message( &self, message_id: &str, reply: ReplyToMessage, ) -> Result<SentMessage, Error>
POST /v0/inboxes/{inbox_id}/messages/{message_id}/reply-all.
Sourcepub async fn forward_message(
&self,
message_id: &str,
message: SendMessage,
) -> Result<SentMessage, Error>
pub async fn forward_message( &self, message_id: &str, message: SendMessage, ) -> Result<SentMessage, Error>
POST /v0/inboxes/{inbox_id}/messages/{message_id}/forward. Reuses
SendMessage for the new recipients and any added body.
Sourcepub async fn get_raw_message(
&self,
message_id: &str,
) -> Result<RawMessage, Error>
pub async fn get_raw_message( &self, message_id: &str, ) -> Result<RawMessage, Error>
GET /v0/inboxes/{inbox_id}/messages/{message_id}/raw, a presigned URL
for the raw RFC 822 (.eml) source; fetch the bytes with
Client::download_raw.
Sourcepub async fn get_message_attachment(
&self,
message_id: &str,
attachment_id: &str,
) -> Result<Attachment, Error>
pub async fn get_message_attachment( &self, message_id: &str, attachment_id: &str, ) -> Result<Attachment, Error>
GET /v0/inboxes/{inbox_id}/messages/{message_id}/attachments/{attachment_id}.
Sourcepub async fn batch_get_messages(
&self,
message_ids: Vec<String>,
) -> Result<BatchGetMessagesResponse, Error>
pub async fn batch_get_messages( &self, message_ids: Vec<String>, ) -> Result<BatchGetMessagesResponse, Error>
POST /v0/inboxes/{inbox_id}/messages/batch-get, fetch many messages by
id in one call.
Sourcepub async fn batch_update_messages(
&self,
update: BatchUpdateMessages,
) -> Result<BatchUpdateMessagesResponse, Error>
pub async fn batch_update_messages( &self, update: BatchUpdateMessages, ) -> Result<BatchUpdateMessagesResponse, Error>
POST /v0/inboxes/{inbox_id}/messages/batch-update, apply the same label
changes to many messages at once.
Source§impl<S: Metrics> Scoped<'_, S>
impl<S: Metrics> Scoped<'_, S>
Sourcepub async fn get_metrics_events(
&self,
query: MetricsQuery,
) -> Result<MetricsEvents, Error>
pub async fn get_metrics_events( &self, query: MetricsQuery, ) -> Result<MetricsEvents, Error>
GET {scope}/metrics/events, event counts bucketed over time, keyed by
event type.
Sourcepub async fn get_metrics_usage(
&self,
query: MetricsQuery,
) -> Result<MetricsUsage, Error>
pub async fn get_metrics_usage( &self, query: MetricsQuery, ) -> Result<MetricsUsage, Error>
GET {scope}/metrics/usage, usage values bucketed over time, keyed by
usage type.
Source§impl<S: Threads> Scoped<'_, S>
impl<S: Threads> Scoped<'_, S>
Sourcepub async fn list_threads(
&self,
filters: ThreadListFilters,
) -> Result<ThreadList, Error>
pub async fn list_threads( &self, filters: ThreadListFilters, ) -> Result<ThreadList, Error>
GET {scope}/threads, one page. Pass ThreadListFilters::default for
the first unfiltered page; carry next_page_token back in for more, or
use Scoped::list_all_threads to drain every page.
Sourcepub async fn list_all_threads(
&self,
filters: ThreadListFilters,
) -> Result<Vec<Thread>, Error>
pub async fn list_all_threads( &self, filters: ThreadListFilters, ) -> Result<Vec<Thread>, Error>
Every thread matching filters, draining pagination.
Sourcepub async fn search_threads(
&self,
query: &str,
filters: ThreadListFilters,
) -> Result<ThreadList, Error>
pub async fn search_threads( &self, query: &str, filters: ThreadListFilters, ) -> Result<ThreadList, Error>
GET {scope}/threads/search, full-text search (q required); matches
come back in Thread::highlights.
Sourcepub async fn search_all_threads(
&self,
query: &str,
filters: ThreadListFilters,
) -> Result<Vec<Thread>, Error>
pub async fn search_all_threads( &self, query: &str, filters: ThreadListFilters, ) -> Result<Vec<Thread>, Error>
Every thread matching a search, draining pagination.
Sourcepub async fn get_thread(&self, thread_id: &str) -> Result<Thread, Error>
pub async fn get_thread(&self, thread_id: &str) -> Result<Thread, Error>
GET {scope}/threads/{thread_id}, the full thread with its messages.
Sourcepub async fn update_thread(
&self,
thread_id: &str,
update: UpdateThread,
) -> Result<UpdatedThread, Error>
pub async fn update_thread( &self, thread_id: &str, update: UpdateThread, ) -> Result<UpdatedThread, Error>
PATCH {scope}/threads/{thread_id}, add and/or remove labels across the
thread. Returns the thread id and its labels after the change.
Sourcepub async fn delete_thread(&self, thread_id: &str) -> Result<(), Error>
pub async fn delete_thread(&self, thread_id: &str) -> Result<(), Error>
DELETE {scope}/threads/{thread_id}.
Sourcepub async fn get_thread_attachment(
&self,
thread_id: &str,
attachment_id: &str,
) -> Result<Attachment, Error>
pub async fn get_thread_attachment( &self, thread_id: &str, attachment_id: &str, ) -> Result<Attachment, Error>
GET {scope}/threads/{thread_id}/attachments/{attachment_id}, the
attachment metadata with a short-lived download_url; fetch the bytes
with Client::download_attachment.
Source§impl<S: Webhooks> Scoped<'_, S>
impl<S: Webhooks> Scoped<'_, S>
Sourcepub async fn create_webhook(
&self,
webhook: CreateWebhook,
) -> Result<Webhook, Error>
pub async fn create_webhook( &self, webhook: CreateWebhook, ) -> Result<Webhook, Error>
POST {scope}/webhooks, subscribe an HTTPS endpoint to events (e.g.
message.received). The response carries the signing secret exactly
once; store it. Inbox and pod scopes ignore inbox_ids/pod_ids (the
scope already targets the delivery); set those only at Client::org.
Sourcepub async fn list_webhooks(&self, page: Page) -> Result<WebhookList, Error>
pub async fn list_webhooks(&self, page: Page) -> Result<WebhookList, Error>
GET {scope}/webhooks, one page.
Sourcepub async fn list_all_webhooks(&self) -> Result<Vec<Webhook>, Error>
pub async fn list_all_webhooks(&self) -> Result<Vec<Webhook>, Error>
Every webhook, draining pagination.
Sourcepub async fn get_webhook(&self, webhook_id: &str) -> Result<Webhook, Error>
pub async fn get_webhook(&self, webhook_id: &str) -> Result<Webhook, Error>
GET {scope}/webhooks/{webhook_id}.
Sourcepub async fn update_webhook(
&self,
webhook_id: &str,
update: UpdateWebhook,
) -> Result<Webhook, Error>
pub async fn update_webhook( &self, webhook_id: &str, update: UpdateWebhook, ) -> Result<Webhook, Error>
PATCH {scope}/webhooks/{webhook_id}, edit event types and inbox/pod
targeting (see UpdateWebhook).