// File generated from our OpenAPI spec by Stainless.
import { APIResource } from 'cloudflare/resource';
import { isRequestOptions } from 'cloudflare/core';
import * as RulesAPI from 'cloudflare/resources/email-routing/routing/rules/rules';
import * as CatchAllsAPI from 'cloudflare/resources/email-routing/routing/rules/catch-alls';
import { V4PagePaginationArray } from 'cloudflare/pagination';
export class Rules extends APIResource {
    constructor() {
        super(...arguments);
        this.catchAlls = new CatchAllsAPI.CatchAlls(this._client);
    }
    /**
     * Rules consist of a set of criteria for matching emails (such as an email being
     * sent to a specific custom email address) plus a set of actions to take on the
     * email (like forwarding it to a specific destination address).
     */
    create(zoneIdentifier, body, options) {
        return this._client.post(`/zones/${zoneIdentifier}/email/routing/rules`, {
            body,
            ...options,
        })._thenUnwrap((obj) => obj.result);
    }
    /**
     * Update actions and matches, or enable/disable specific routing rules.
     */
    update(zoneIdentifier, ruleIdentifier, body, options) {
        return this._client.put(`/zones/${zoneIdentifier}/email/routing/rules/${ruleIdentifier}`, {
            body,
            ...options,
        })._thenUnwrap((obj) => obj.result);
    }
    list(zoneIdentifier, query = {}, options) {
        if (isRequestOptions(query)) {
            return this.list(zoneIdentifier, {}, query);
        }
        return this._client.getAPIList(`/zones/${zoneIdentifier}/email/routing/rules`, RuleListResponsesV4PagePaginationArray, { query, ...options });
    }
    /**
     * Delete a specific routing rule.
     */
    delete(zoneIdentifier, ruleIdentifier, options) {
        return this._client.delete(`/zones/${zoneIdentifier}/email/routing/rules/${ruleIdentifier}`, options)._thenUnwrap((obj) => obj.result);
    }
    /**
     * Get information for a specific routing rule already created.
     */
    get(zoneIdentifier, ruleIdentifier, options) {
        return this._client.get(`/zones/${zoneIdentifier}/email/routing/rules/${ruleIdentifier}`, options)._thenUnwrap((obj) => obj.result);
    }
}
export class RuleListResponsesV4PagePaginationArray extends V4PagePaginationArray {
}
(function (Rules) {
    Rules.RuleListResponsesV4PagePaginationArray = RulesAPI.RuleListResponsesV4PagePaginationArray;
    Rules.CatchAlls = CatchAllsAPI.CatchAlls;
})(Rules || (Rules = {}));
//# sourceMappingURL=rules.mjs.map