agentmail-rs 0.4.1

Unofficial typed Rust client for AgentMail (agentmail.to), the email API for agents.
Documentation
use serde::{Deserialize, Serialize};

/// Request body for `create_webhook`.
#[derive(Clone, Debug, Default, Serialize)]
pub struct CreateWebhook {
    /// HTTPS endpoint to deliver events to.
    pub url: String,
    /// e.g. `["message.received"]`.
    pub event_types: Vec<String>,
    /// Limit delivery to these inboxes; empty means all.
    #[serde(skip_serializing_if = "Vec::is_empty")]
    pub inbox_ids: Vec<String>,
    /// Limit delivery to these pods; empty means all.
    #[serde(skip_serializing_if = "Vec::is_empty")]
    pub pod_ids: Vec<String>,
    /// Your own idempotency/reference id for this webhook.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub client_id: Option<String>,
    /// Extra headers to send with every delivery.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub headers: Option<serde_json::Value>,
}

/// Request body for `update_webhook`. Every field is optional; leave
/// a field empty to keep it unchanged. Inbox and pod targeting is edited by
/// delta (add/remove lists) rather than by replacing the whole set.
#[derive(Clone, Debug, Default, Serialize)]
pub struct UpdateWebhook {
    /// Replace the subscribed event types.
    #[serde(skip_serializing_if = "Vec::is_empty")]
    pub event_types: Vec<String>,
    /// Pause (`false`) or resume (`true`) delivery.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub enabled: Option<bool>,
    /// Inboxes to add to the subscription.
    #[serde(skip_serializing_if = "Vec::is_empty")]
    pub add_inbox_ids: Vec<String>,
    /// Inboxes to remove from the subscription.
    #[serde(skip_serializing_if = "Vec::is_empty")]
    pub remove_inbox_ids: Vec<String>,
    /// Pods to add to the subscription.
    #[serde(skip_serializing_if = "Vec::is_empty")]
    pub add_pod_ids: Vec<String>,
    /// Pods to remove from the subscription.
    #[serde(skip_serializing_if = "Vec::is_empty")]
    pub remove_pod_ids: Vec<String>,
}
/// A webhook subscription, as the API returns it.
#[derive(Clone, Debug, Deserialize)]
pub struct Webhook {
    /// Unique id, used to delete the subscription.
    pub webhook_id: String,
    /// The subscribed HTTPS endpoint.
    pub url: String,
    /// Signing secret, returned once, on creation.
    #[serde(default)]
    pub secret: Option<String>,
    /// Subscribed event types.
    #[serde(default)]
    pub event_types: Vec<String>,
    /// Inboxes the subscription is limited to; empty means all.
    #[serde(default)]
    pub inbox_ids: Vec<String>,
    /// Pods the subscription is limited to; empty means all.
    #[serde(default)]
    pub pod_ids: Vec<String>,
    /// The pod this webhook is scoped to, when created on a pod handle.
    #[serde(default)]
    pub pod_id: Option<String>,
    /// The inbox this webhook is scoped to, when created on an inbox handle.
    #[serde(default)]
    pub inbox_id: Option<String>,
    /// Whether the subscription currently delivers.
    pub enabled: bool,
    /// Your own reference id, echoed back if set on creation.
    #[serde(default)]
    pub client_id: Option<String>,
    /// Timestamp the subscription was last updated (RFC 3339).
    #[serde(default)]
    pub updated_at: Option<String>,
    /// Timestamp the subscription was created (RFC 3339).
    #[serde(default)]
    pub created_at: Option<String>,
}
/// One page of webhooks from `list_webhooks_page`.
#[derive(Clone, Debug, Deserialize)]
pub struct WebhookList {
    /// Total webhooks in the account (not just this page).
    pub count: u64,
    /// This page of webhooks.
    #[serde(default)]
    pub webhooks: Vec<Webhook>,
    /// Cursor for the next page; `None` on the last page.
    #[serde(default)]
    pub next_page_token: Option<String>,
}

/// Body for `update_webhook_headers`: headers to set or replace, plus names
/// to remove. Applied to every delivery of that webhook.
#[derive(Clone, Debug, Default, Serialize)]
pub struct UpdateWebhookHeaders {
    /// Headers to set or overwrite, sent verbatim with each delivery.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub headers: Option<serde_json::Value>,
    /// Header names to delete from the subscription.
    #[serde(skip_serializing_if = "Vec::is_empty")]
    pub remove_headers: Vec<String>,
}

/// The header names configured on a webhook, from `get_webhook_headers`
/// (values are never returned).
#[derive(Clone, Debug, Deserialize)]
pub struct WebhookHeaderNames {
    /// The configured header names.
    pub header_names: Vec<String>,
}