// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from 'cloudflaredev/resource';
import { isRequestOptions } from 'cloudflaredev/core';
import * as RulesAPI from 'cloudflaredev/resources/email-routing/rules/rules';
import * as CatchAllsAPI from 'cloudflaredev/resources/email-routing/rules/catch-alls';
import { V4PagePaginationArray } from 'cloudflaredev/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`, EmailRoutingRulesV4PagePaginationArray, { 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 EmailRoutingRulesV4PagePaginationArray extends V4PagePaginationArray {
}
(function (Rules) {
    Rules.EmailRoutingRulesV4PagePaginationArray = RulesAPI.EmailRoutingRulesV4PagePaginationArray;
    Rules.CatchAlls = CatchAllsAPI.CatchAlls;
})(Rules || (Rules = {}));
//# sourceMappingURL=rules.mjs.map