cloudflare
Version:
The official TypeScript library for the Cloudflare API
68 lines • 2.4 kB
JavaScript
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from "../../core/resource.mjs";
import { path } from "../../internal/utils/path.mjs";
export var BaseCrawl = /* @__PURE__ */ (() => {
class BaseCrawl extends APIResource {
/**
* Starts a crawl job for the provided URL and its children. Check available
* options like `gotoOptions` and `waitFor*` to control page load behaviour.
*
* @example
* ```ts
* const crawl = await client.browserRendering.crawl.create({
* account_id: 'account_id',
* url: 'https://example.com',
* });
* ```
*/
create(params, options) {
const { account_id, cacheTTL, ...body } = params;
return this._client.post(path `/accounts/${account_id}/browser-rendering/crawl`, {
query: { cacheTTL },
body,
...options,
})._thenUnwrap((obj) => obj.result);
}
/**
* Cancels an ongoing crawl job by setting its status to cancelled and stopping all
* queued URLs.
*
* @example
* ```ts
* const crawl = await client.browserRendering.crawl.delete(
* 'job_id',
* { account_id: 'account_id' },
* );
* ```
*/
delete(jobID, params, options) {
const { account_id } = params;
return this._client.delete(path `/accounts/${account_id}/browser-rendering/crawl/${jobID}`, options)._thenUnwrap((obj) => obj.result);
}
/**
* Returns the result of a crawl job.
*
* @example
* ```ts
* const crawl = await client.browserRendering.crawl.get('x', {
* account_id: 'account_id',
* });
* ```
*/
get(jobID, params, options) {
const { account_id, ...query } = params;
return this._client.get(path `/accounts/${account_id}/browser-rendering/crawl/${jobID}`, {
query,
...options,
})._thenUnwrap((obj) => obj.result);
}
}
BaseCrawl._key = Object.freeze([
'browserRendering',
'crawl',
]);
return BaseCrawl;
})();
export class Crawl extends BaseCrawl {
}
//# sourceMappingURL=crawl.mjs.map