pub struct CloudClient { /* private fields */ }Expand description
The async client for the tiered Writ Cloud surface (see the module docs).
Construct with CloudClient::builder (explicit config) or
CloudClient::from_env (pure env resolution). The credential decides the
tier: an API key ⇒ metered, none ⇒ keyless.
Implementations§
Source§impl CloudClient
impl CloudClient
Sourcepub fn builder() -> CloudClientBuilder
pub fn builder() -> CloudClientBuilder
Start explicit configuration.
Sourcepub fn from_env() -> Result<CloudClient>
pub fn from_env() -> Result<CloudClient>
Build a client purely from the environment (WRIT_API_KEY,
WRIT_CLOUD_URL, WRIT_CLIENT_ID) and the defaults.
Sourcepub fn tier(&self) -> CloudTier
pub fn tier(&self) -> CloudTier
The tier this client will use: CloudTier::Metered when an API key is
present, else CloudTier::Keyless.
Sourcepub async fn scrape(&self, url: &str) -> Result<ScrapeResult>
pub async fn scrape(&self, url: &str) -> Result<ScrapeResult>
Scrape ONE page to clean markdown. Works on both tiers.
POST /api/crawl/scrape (metered) or /v1/keyless/scrape (keyless), body
{"url": url}.
Sourcepub async fn map(&self, url: &str, opts: &MapOptions) -> Result<MapResult>
pub async fn map(&self, url: &str, opts: &MapOptions) -> Result<MapResult>
Map a site’s URLs, ranked by an optional search. Works on both tiers.
POST /api/crawl/map (metered) or /v1/keyless/map (keyless), body
{"url": url, "search": search, "limit"?: limit}.
Sourcepub async fn crawl(&self, params: &CrawlStartParams) -> Result<CrawlJob>
pub async fn crawl(&self, params: &CrawlStartParams) -> Result<CrawlJob>
Start a whole-site crawl. METERED ONLY — requires an API key; on the
keyless tier this returns WritError::ApiKeyRequired before any network
call (use CloudClient::scrape/CloudClient::map instead).
POST /api/crawl with the CrawlStartParams body.
Sourcepub async fn crawl_status(&self, id: i64) -> Result<CrawlJob>
pub async fn crawl_status(&self, id: i64) -> Result<CrawlJob>
Poll a metered crawl’s status (requires an API key).
GET /api/crawl/{id}.
Sourcepub async fn quota(&self) -> Result<Option<KeylessQuota>>
pub async fn quota(&self) -> Result<Option<KeylessQuota>>
Remaining keyless allowance for this install (keyless tier only; None
when metered).
GET /v1/keyless/quota.
Trait Implementations§
Source§impl Clone for CloudClient
impl Clone for CloudClient
Source§fn clone(&self) -> CloudClient
fn clone(&self) -> CloudClient
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more