107 lines
3.7 KiB
JavaScript
107 lines
3.7 KiB
JavaScript
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
import { APIResource } from "../../resource.mjs";
|
|
import { CloudflareError } from "../../error.mjs";
|
|
export class Validate extends APIResource {
|
|
/**
|
|
* Validates destination.
|
|
*
|
|
* @example
|
|
* ```ts
|
|
* const response = await client.logpush.validate.destination({
|
|
* destination_conf: 's3://mybucket/logs?region=us-west-2',
|
|
* account_id: 'account_id',
|
|
* });
|
|
* ```
|
|
*/
|
|
destination(params, options) {
|
|
const { account_id, zone_id, ...body } = params;
|
|
if (!account_id && !zone_id) {
|
|
throw new CloudflareError('You must provide either account_id or zone_id.');
|
|
}
|
|
if (account_id && zone_id) {
|
|
throw new CloudflareError('You cannot provide both account_id and zone_id.');
|
|
}
|
|
const { accountOrZone, accountOrZoneId } = account_id ?
|
|
{
|
|
accountOrZone: 'accounts',
|
|
accountOrZoneId: account_id,
|
|
}
|
|
: {
|
|
accountOrZone: 'zones',
|
|
accountOrZoneId: zone_id,
|
|
};
|
|
return this._client.post(`/${accountOrZone}/${accountOrZoneId}/logpush/validate/destination`, {
|
|
body,
|
|
...options,
|
|
})._thenUnwrap((obj) => obj.result);
|
|
}
|
|
/**
|
|
* Checks if there is an existing job with a destination.
|
|
*
|
|
* @example
|
|
* ```ts
|
|
* const response =
|
|
* await client.logpush.validate.destinationExists({
|
|
* destination_conf: 's3://mybucket/logs?region=us-west-2',
|
|
* account_id: 'account_id',
|
|
* });
|
|
* ```
|
|
*/
|
|
destinationExists(params, options) {
|
|
const { account_id, zone_id, ...body } = params;
|
|
if (!account_id && !zone_id) {
|
|
throw new CloudflareError('You must provide either account_id or zone_id.');
|
|
}
|
|
if (account_id && zone_id) {
|
|
throw new CloudflareError('You cannot provide both account_id and zone_id.');
|
|
}
|
|
const { accountOrZone, accountOrZoneId } = account_id ?
|
|
{
|
|
accountOrZone: 'accounts',
|
|
accountOrZoneId: account_id,
|
|
}
|
|
: {
|
|
accountOrZone: 'zones',
|
|
accountOrZoneId: zone_id,
|
|
};
|
|
return this._client.post(`/${accountOrZone}/${accountOrZoneId}/logpush/validate/destination/exists`, {
|
|
body,
|
|
...options,
|
|
})._thenUnwrap((obj) => obj.result);
|
|
}
|
|
/**
|
|
* Validates logpull origin with logpull_options.
|
|
*
|
|
* @example
|
|
* ```ts
|
|
* const response = await client.logpush.validate.origin({
|
|
* logpull_options:
|
|
* 'fields=RayID,ClientIP,EdgeStartTimestamp×tamps=rfc3339',
|
|
* account_id: 'account_id',
|
|
* });
|
|
* ```
|
|
*/
|
|
origin(params, options) {
|
|
const { account_id, zone_id, ...body } = params;
|
|
if (!account_id && !zone_id) {
|
|
throw new CloudflareError('You must provide either account_id or zone_id.');
|
|
}
|
|
if (account_id && zone_id) {
|
|
throw new CloudflareError('You cannot provide both account_id and zone_id.');
|
|
}
|
|
const { accountOrZone, accountOrZoneId } = account_id ?
|
|
{
|
|
accountOrZone: 'accounts',
|
|
accountOrZoneId: account_id,
|
|
}
|
|
: {
|
|
accountOrZone: 'zones',
|
|
accountOrZoneId: zone_id,
|
|
};
|
|
return this._client.post(`/${accountOrZone}/${accountOrZoneId}/logpush/validate/origin`, {
|
|
body,
|
|
...options,
|
|
})._thenUnwrap((obj) => obj.result);
|
|
}
|
|
}
|
|
//# sourceMappingURL=validate.mjs.map
|