cloudflare
Version:
The official TypeScript library for the Cloudflare API
247 lines (213 loc) • 5.79 kB
text/typescript
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from '../../../core/resource';
import { APIPromise } from '../../../core/api-promise';
import { RequestOptions } from '../../../internal/request-options';
import { path } from '../../../internal/utils/path';
export class BaseCatchAlls extends APIResource {
static override readonly _key: readonly ['emailRouting', 'rules', 'catchAlls'] = Object.freeze([
'emailRouting',
'rules',
'catchAlls',
] as const);
/**
* Enable or disable catch-all routing rule, or change action to forward to a
* specific destination address. Forward actions require exactly one verified
* destination address.
*
* @example
* ```ts
* const catchAll =
* await client.emailRouting.rules.catchAlls.update({
* zone_id: '023e105f4ecef8ad9ca31a8372d0c353',
* actions: [{ type: 'forward' }],
* matchers: [{ type: 'all' }],
* });
* ```
*/
update(params: CatchAllUpdateParams, options?: RequestOptions): APIPromise<CatchAllUpdateResponse> {
const { zone_id, ...body } = params;
return (
this._client.put(path`/zones/${zone_id}/email/routing/rules/catch_all`, {
body,
...options,
}) as APIPromise<{ result: CatchAllUpdateResponse }>
)._thenUnwrap((obj) => obj.result);
}
/**
* Get information on the default catch-all routing rule.
*
* @example
* ```ts
* const catchAll =
* await client.emailRouting.rules.catchAlls.get({
* zone_id: '023e105f4ecef8ad9ca31a8372d0c353',
* });
* ```
*/
get(params: CatchAllGetParams, options?: RequestOptions): APIPromise<CatchAllGetResponse> {
const { zone_id } = params;
return (
this._client.get(path`/zones/${zone_id}/email/routing/rules/catch_all`, options) as APIPromise<{
result: CatchAllGetResponse;
}>
)._thenUnwrap((obj) => obj.result);
}
}
export class CatchAlls extends BaseCatchAlls {}
/**
* Action for the catch-all routing rule.
*/
export interface CatchAllAction {
/**
* Type of action for catch-all rule.
*/
type: 'drop' | 'forward' | 'worker';
/**
* List of values for the action. Currently limited to a single value.
*/
value?: Array<string>;
}
/**
* Action for the catch-all routing rule.
*/
export interface CatchAllActionParam {
/**
* Type of action for catch-all rule.
*/
type: 'drop' | 'forward' | 'worker';
/**
* List of values for the action. Currently limited to a single value.
*/
value?: Array<string>;
}
/**
* Matcher for catch-all routing rule.
*/
export interface CatchAllMatcher {
/**
* Type of matcher. Default is 'all'.
*/
type: 'all';
}
/**
* Matcher for catch-all routing rule.
*/
export interface CatchAllMatcherParam {
/**
* Type of matcher. Default is 'all'.
*/
type: 'all';
}
export interface CatchAllUpdateResponse {
/**
* Routing rule identifier.
*/
id?: string;
/**
* List actions for the catch-all routing rule.
*/
actions?: Array<CatchAllAction>;
/**
* Routing rule status.
*/
enabled?: true | false;
/**
* List of matchers for the catch-all routing rule.
*/
matchers?: Array<CatchAllMatcher>;
/**
* Routing rule name.
*/
name?: string;
/**
* Who manages the rule. `api` covers dashboard, generic API, and Terraform;
* `wrangler` means the rule is managed by a Worker's wrangler.jsonc. Defaults to
* `api` when omitted on write.
*/
source?: 'api' | 'wrangler';
/**
* @deprecated Routing rule tag. (Deprecated, replaced by routing rule identifier)
*/
tag?: string;
}
export interface CatchAllGetResponse {
/**
* Routing rule identifier.
*/
id?: string;
/**
* List actions for the catch-all routing rule.
*/
actions?: Array<CatchAllAction>;
/**
* Routing rule status.
*/
enabled?: true | false;
/**
* List of matchers for the catch-all routing rule.
*/
matchers?: Array<CatchAllMatcher>;
/**
* Routing rule name.
*/
name?: string;
/**
* Who manages the rule. `api` covers dashboard, generic API, and Terraform;
* `wrangler` means the rule is managed by a Worker's wrangler.jsonc. Defaults to
* `api` when omitted on write.
*/
source?: 'api' | 'wrangler';
/**
* @deprecated Routing rule tag. (Deprecated, replaced by routing rule identifier)
*/
tag?: string;
}
export interface CatchAllUpdateParams {
/**
* Path param: Identifier.
*/
zone_id: string;
/**
* Body param: List actions for the catch-all routing rule.
*/
actions: Array<CatchAllActionParam>;
/**
* Body param: List of matchers for the catch-all routing rule.
*/
matchers: Array<CatchAllMatcherParam>;
/**
* Body param: Routing rule status.
*/
enabled?: true | false;
/**
* Body param: Routing rule name.
*/
name?: string;
/**
* Body param: Public tag (script_tag) of the Worker that owns this rule. Required
* when `source` is `wrangler`.
*/
owner_worker_tag?: string;
/**
* Body param: Who manages the rule. `api` covers dashboard, generic API, and
* Terraform; `wrangler` means the rule is managed by a Worker's wrangler.jsonc.
* Defaults to `api` when omitted on write.
*/
source?: 'api' | 'wrangler';
}
export interface CatchAllGetParams {
/**
* Identifier.
*/
zone_id: string;
}
export declare namespace CatchAlls {
export {
type CatchAllAction as CatchAllAction,
type CatchAllMatcher as CatchAllMatcher,
type CatchAllUpdateResponse as CatchAllUpdateResponse,
type CatchAllGetResponse as CatchAllGetResponse,
type CatchAllUpdateParams as CatchAllUpdateParams,
type CatchAllGetParams as CatchAllGetParams,
};
}