/**
 * Cloudflare EMAIL-ROUTING API
 *
 * Generated from Cloudflare TypeScript SDK.
 * DO NOT EDIT - regenerate with: bun scripts/generate.ts --service email-routing
 */
import * as Schema from "effect/Schema";
import * as API from "../client/api.js";
import * as T from "../traits.js";
import {} from "../errors.js";
export const GetAddressRequest = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    destinationAddressIdentifier: Schema.String.pipe(T.HttpPath("destinationAddressIdentifier")),
    accountId: Schema.String.pipe(T.HttpPath("account_id")),
}).pipe(T.Http({
    method: "GET",
    path: "/accounts/{account_id}/email/routing/addresses/{destinationAddressIdentifier}",
}));
export const GetAddressResponse = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    id: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
    created: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
    email: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
    modified: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
    tag: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
    verified: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
}).pipe(T.ResponsePath("result"));
export const getAddress = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: GetAddressRequest,
    output: GetAddressResponse,
    errors: [],
}));
export const ListAddressesRequest = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    accountId: Schema.String.pipe(T.HttpPath("account_id")),
    page: Schema.optional(Schema.Number).pipe(T.HttpQuery("page")),
    perPage: Schema.optional(Schema.Number).pipe(T.HttpQuery("per_page")),
    direction: Schema.optional(Schema.Literals(["asc", "desc"])).pipe(T.HttpQuery("direction")),
    verified: Schema.optional(Schema.Literals([true, false])).pipe(T.HttpQuery("verified")),
}).pipe(T.Http({
    method: "GET",
    path: "/accounts/{account_id}/email/routing/addresses",
}));
export const ListAddressesResponse = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    result: Schema.Array(Schema.Struct({
        id: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
        created: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
        email: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
        modified: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
        tag: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
        verified: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
    })),
    resultInfo: Schema.optional(Schema.Union([
        Schema.Struct({
            count: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
            page: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
            perPage: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
            totalCount: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
        }).pipe(Schema.encodeKeys({
            count: "count",
            page: "page",
            perPage: "per_page",
            totalCount: "total_count",
        })),
        Schema.Null,
    ])),
}).pipe(Schema.encodeKeys({ result: "result", resultInfo: "result_info" }));
export const listAddresses = /*@__PURE__*/ /*#__PURE__*/ API.makePaginated(() => ({
    input: ListAddressesRequest,
    output: ListAddressesResponse,
    errors: [],
    pagination: {
        mode: "page",
        inputToken: "page",
        outputToken: "resultInfo.page",
        items: "result",
        pageSize: "perPage",
    },
}));
export const CreateAddressRequest = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    accountId: Schema.String.pipe(T.HttpPath("account_id")),
    email: Schema.String,
}).pipe(T.Http({
    method: "POST",
    path: "/accounts/{account_id}/email/routing/addresses",
}));
export const CreateAddressResponse = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    id: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
    created: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
    email: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
    modified: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
    tag: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
    verified: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
}).pipe(T.ResponsePath("result"));
export const createAddress = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: CreateAddressRequest,
    output: CreateAddressResponse,
    errors: [],
}));
export const DeleteAddressRequest = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    destinationAddressIdentifier: Schema.String.pipe(T.HttpPath("destinationAddressIdentifier")),
    accountId: Schema.String.pipe(T.HttpPath("account_id")),
}).pipe(T.Http({
    method: "DELETE",
    path: "/accounts/{account_id}/email/routing/addresses/{destinationAddressIdentifier}",
}));
export const DeleteAddressResponse = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    id: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
    created: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
    email: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
    modified: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
    tag: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
    verified: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
}).pipe(T.ResponsePath("result"));
export const deleteAddress = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: DeleteAddressRequest,
    output: DeleteAddressResponse,
    errors: [],
}));
export const GetDnsRequest = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    zoneId: Schema.String.pipe(T.HttpPath("zone_id")),
    subdomain: Schema.optional(Schema.String).pipe(T.HttpQuery("subdomain")),
}).pipe(T.Http({ method: "GET", path: "/zones/{zone_id}/email/routing/dns" }));
export const GetDnsResponse = /*@__PURE__*/ /*#__PURE__*/ Schema.Union([
    Schema.Struct({
        errors: Schema.Array(Schema.Struct({
            code: Schema.Number,
            message: Schema.String,
            documentationUrl: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
            source: Schema.optional(Schema.Union([
                Schema.Struct({
                    pointer: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
                }),
                Schema.Null,
            ])),
        }).pipe(Schema.encodeKeys({
            code: "code",
            message: "message",
            documentationUrl: "documentation_url",
            source: "source",
        }))),
        messages: Schema.Array(Schema.Struct({
            code: Schema.Number,
            message: Schema.String,
            documentationUrl: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
            source: Schema.optional(Schema.Union([
                Schema.Struct({
                    pointer: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
                }),
                Schema.Null,
            ])),
        }).pipe(Schema.encodeKeys({
            code: "code",
            message: "message",
            documentationUrl: "documentation_url",
            source: "source",
        }))),
        success: Schema.Literal(true),
        result: Schema.optional(Schema.Union([
            Schema.Struct({
                errors: Schema.optional(Schema.Union([
                    Schema.Array(Schema.Struct({
                        code: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
                        missing: Schema.optional(Schema.Union([
                            Schema.Struct({
                                content: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
                                name: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
                                priority: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                                ttl: Schema.optional(Schema.Union([
                                    Schema.Union([Schema.Number, Schema.Literal("1")]),
                                    Schema.Null,
                                ])),
                                type: Schema.optional(Schema.Union([
                                    Schema.Literals([
                                        "A",
                                        "AAAA",
                                        "CNAME",
                                        "HTTPS",
                                        "TXT",
                                        "SRV",
                                        "LOC",
                                        "MX",
                                        "NS",
                                        "CERT",
                                        "DNSKEY",
                                        "DS",
                                        "NAPTR",
                                        "SMIMEA",
                                        "SSHFP",
                                        "SVCB",
                                        "TLSA",
                                        "URI",
                                    ]),
                                    Schema.Null,
                                ])),
                            }),
                            Schema.Null,
                        ])),
                    })),
                    Schema.Null,
                ])),
                record: Schema.optional(Schema.Union([
                    Schema.Array(Schema.Struct({
                        content: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
                        name: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
                        priority: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                        ttl: Schema.optional(Schema.Union([
                            Schema.Union([Schema.Number, Schema.Literal("1")]),
                            Schema.Null,
                        ])),
                        type: Schema.optional(Schema.Union([
                            Schema.Literals([
                                "A",
                                "AAAA",
                                "CNAME",
                                "HTTPS",
                                "TXT",
                                "SRV",
                                "LOC",
                                "MX",
                                "NS",
                                "CERT",
                                "DNSKEY",
                                "DS",
                                "NAPTR",
                                "SMIMEA",
                                "SSHFP",
                                "SVCB",
                                "TLSA",
                                "URI",
                            ]),
                            Schema.Null,
                        ])),
                    })),
                    Schema.Null,
                ])),
            }),
            Schema.Null,
        ])),
        resultInfo: Schema.optional(Schema.Union([
            Schema.Struct({
                count: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                page: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                perPage: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                totalCount: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
            }).pipe(Schema.encodeKeys({
                count: "count",
                page: "page",
                perPage: "per_page",
                totalCount: "total_count",
            })),
            Schema.Null,
        ])),
    }).pipe(Schema.encodeKeys({
        errors: "errors",
        messages: "messages",
        success: "success",
        result: "result",
        resultInfo: "result_info",
    })),
    Schema.Struct({
        errors: Schema.Array(Schema.Struct({
            code: Schema.Number,
            message: Schema.String,
            documentationUrl: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
            source: Schema.optional(Schema.Union([
                Schema.Struct({
                    pointer: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
                }),
                Schema.Null,
            ])),
        }).pipe(Schema.encodeKeys({
            code: "code",
            message: "message",
            documentationUrl: "documentation_url",
            source: "source",
        }))),
        messages: Schema.Array(Schema.Struct({
            code: Schema.Number,
            message: Schema.String,
            documentationUrl: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
            source: Schema.optional(Schema.Union([
                Schema.Struct({
                    pointer: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
                }),
                Schema.Null,
            ])),
        }).pipe(Schema.encodeKeys({
            code: "code",
            message: "message",
            documentationUrl: "documentation_url",
            source: "source",
        }))),
        success: Schema.Literal(true),
        result: Schema.optional(Schema.Union([
            Schema.Array(Schema.Struct({
                content: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
                name: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
                priority: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                ttl: Schema.optional(Schema.Union([
                    Schema.Union([Schema.Number, Schema.Literal("1")]),
                    Schema.Null,
                ])),
                type: Schema.optional(Schema.Union([
                    Schema.Literals([
                        "A",
                        "AAAA",
                        "CNAME",
                        "HTTPS",
                        "TXT",
                        "SRV",
                        "LOC",
                        "MX",
                        "NS",
                        "CERT",
                        "DNSKEY",
                        "DS",
                        "NAPTR",
                        "SMIMEA",
                        "SSHFP",
                        "SVCB",
                        "TLSA",
                        "URI",
                    ]),
                    Schema.Null,
                ])),
            })),
            Schema.Null,
        ])),
        resultInfo: Schema.optional(Schema.Union([
            Schema.Struct({
                count: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                page: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                perPage: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                totalCount: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
            }).pipe(Schema.encodeKeys({
                count: "count",
                page: "page",
                perPage: "per_page",
                totalCount: "total_count",
            })),
            Schema.Null,
        ])),
    }).pipe(Schema.encodeKeys({
        errors: "errors",
        messages: "messages",
        success: "success",
        result: "result",
        resultInfo: "result_info",
    })),
]);
export const getDns = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: GetDnsRequest,
    output: GetDnsResponse,
    errors: [],
}));
export const CreateDnsRequest = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    zoneId: Schema.String.pipe(T.HttpPath("zone_id")),
    name: Schema.optional(Schema.String),
}).pipe(T.Http({ method: "POST", path: "/zones/{zone_id}/email/routing/dns" }));
export const CreateDnsResponse = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    id: Schema.String,
    enabled: Schema.Literals([true, false]),
    name: Schema.String,
    created: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
    modified: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
    skipWizard: Schema.optional(Schema.Union([Schema.Literals([true, false]), Schema.Null])),
    status: Schema.optional(Schema.Union([
        Schema.Literals([
            "ready",
            "unconfigured",
            "misconfigured",
            "misconfigured/locked",
            "unlocked",
        ]),
        Schema.Null,
    ])),
    tag: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
})
    .pipe(Schema.encodeKeys({
    id: "id",
    enabled: "enabled",
    name: "name",
    created: "created",
    modified: "modified",
    skipWizard: "skip_wizard",
    status: "status",
    tag: "tag",
}))
    .pipe(T.ResponsePath("result"));
export const createDns = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: CreateDnsRequest,
    output: CreateDnsResponse,
    errors: [],
}));
export const PatchDnsRequest = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    zoneId: Schema.String.pipe(T.HttpPath("zone_id")),
    name: Schema.optional(Schema.String),
}).pipe(T.Http({ method: "PATCH", path: "/zones/{zone_id}/email/routing/dns" }));
export const PatchDnsResponse = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    id: Schema.String,
    enabled: Schema.Literals([true, false]),
    name: Schema.String,
    created: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
    modified: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
    skipWizard: Schema.optional(Schema.Union([Schema.Literals([true, false]), Schema.Null])),
    status: Schema.optional(Schema.Union([
        Schema.Literals([
            "ready",
            "unconfigured",
            "misconfigured",
            "misconfigured/locked",
            "unlocked",
        ]),
        Schema.Null,
    ])),
    tag: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
})
    .pipe(Schema.encodeKeys({
    id: "id",
    enabled: "enabled",
    name: "name",
    created: "created",
    modified: "modified",
    skipWizard: "skip_wizard",
    status: "status",
    tag: "tag",
}))
    .pipe(T.ResponsePath("result"));
export const patchDns = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: PatchDnsRequest,
    output: PatchDnsResponse,
    errors: [],
}));
export const DeleteDnsRequest = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    zoneId: Schema.String.pipe(T.HttpPath("zone_id")),
}).pipe(T.Http({ method: "DELETE", path: "/zones/{zone_id}/email/routing/dns" }));
export const DeleteDnsResponse = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    result: Schema.Array(Schema.Struct({
        content: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
        name: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
        priority: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
        ttl: Schema.optional(Schema.Union([
            Schema.Union([Schema.Number, Schema.Literal("1")]),
            Schema.Null,
        ])),
        type: Schema.optional(Schema.Union([
            Schema.Literals([
                "A",
                "AAAA",
                "CNAME",
                "HTTPS",
                "TXT",
                "SRV",
                "LOC",
                "MX",
                "NS",
                "CERT",
                "DNSKEY",
                "DS",
                "NAPTR",
                "SMIMEA",
                "SSHFP",
                "SVCB",
                "TLSA",
                "URI",
            ]),
            Schema.Null,
        ])),
    })),
});
export const deleteDns = /*@__PURE__*/ /*#__PURE__*/ API.makePaginated(() => ({
    input: DeleteDnsRequest,
    output: DeleteDnsResponse,
    errors: [],
    pagination: {
        mode: "single",
        items: "result",
    },
}));
export const GetEmailRoutingRequest = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    zoneId: Schema.String.pipe(T.HttpPath("zone_id")),
}).pipe(T.Http({ method: "GET", path: "/zones/{zone_id}/email/routing" }));
export const GetEmailRoutingResponse = 
/*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    id: Schema.String,
    enabled: Schema.Literals([true, false]),
    name: Schema.String,
    created: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
    modified: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
    skipWizard: Schema.optional(Schema.Union([Schema.Literals([true, false]), Schema.Null])),
    status: Schema.optional(Schema.Union([
        Schema.Literals([
            "ready",
            "unconfigured",
            "misconfigured",
            "misconfigured/locked",
            "unlocked",
        ]),
        Schema.Null,
    ])),
    tag: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
})
    .pipe(Schema.encodeKeys({
    id: "id",
    enabled: "enabled",
    name: "name",
    created: "created",
    modified: "modified",
    skipWizard: "skip_wizard",
    status: "status",
    tag: "tag",
}))
    .pipe(T.ResponsePath("result"));
export const getEmailRouting = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: GetEmailRoutingRequest,
    output: GetEmailRoutingResponse,
    errors: [],
}));
export const EnableEmailRoutingRequest = 
/*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    zoneId: Schema.String.pipe(T.HttpPath("zone_id")),
    body: Schema.Unknown.pipe(T.HttpBody()),
}).pipe(T.Http({ method: "POST", path: "/zones/{zone_id}/email/routing/enable" }));
export const EnableEmailRoutingResponse = 
/*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    id: Schema.String,
    enabled: Schema.Literals([true, false]),
    name: Schema.String,
    created: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
    modified: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
    skipWizard: Schema.optional(Schema.Union([Schema.Literals([true, false]), Schema.Null])),
    status: Schema.optional(Schema.Union([
        Schema.Literals([
            "ready",
            "unconfigured",
            "misconfigured",
            "misconfigured/locked",
            "unlocked",
        ]),
        Schema.Null,
    ])),
    tag: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
})
    .pipe(Schema.encodeKeys({
    id: "id",
    enabled: "enabled",
    name: "name",
    created: "created",
    modified: "modified",
    skipWizard: "skip_wizard",
    status: "status",
    tag: "tag",
}))
    .pipe(T.ResponsePath("result"));
export const enableEmailRouting = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: EnableEmailRoutingRequest,
    output: EnableEmailRoutingResponse,
    errors: [],
}));
export const DisableEmailRoutingRequest = 
/*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    zoneId: Schema.String.pipe(T.HttpPath("zone_id")),
    body: Schema.Unknown.pipe(T.HttpBody()),
}).pipe(T.Http({ method: "POST", path: "/zones/{zone_id}/email/routing/disable" }));
export const DisableEmailRoutingResponse = 
/*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    id: Schema.String,
    enabled: Schema.Literals([true, false]),
    name: Schema.String,
    created: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
    modified: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
    skipWizard: Schema.optional(Schema.Union([Schema.Literals([true, false]), Schema.Null])),
    status: Schema.optional(Schema.Union([
        Schema.Literals([
            "ready",
            "unconfigured",
            "misconfigured",
            "misconfigured/locked",
            "unlocked",
        ]),
        Schema.Null,
    ])),
    tag: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
})
    .pipe(Schema.encodeKeys({
    id: "id",
    enabled: "enabled",
    name: "name",
    created: "created",
    modified: "modified",
    skipWizard: "skip_wizard",
    status: "status",
    tag: "tag",
}))
    .pipe(T.ResponsePath("result"));
export const disableEmailRouting = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: DisableEmailRoutingRequest,
    output: DisableEmailRoutingResponse,
    errors: [],
}));
export const GetRuleRequest = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    ruleIdentifier: Schema.String.pipe(T.HttpPath("ruleIdentifier")),
    zoneId: Schema.String.pipe(T.HttpPath("zone_id")),
}).pipe(T.Http({
    method: "GET",
    path: "/zones/{zone_id}/email/routing/rules/{ruleIdentifier}",
}));
export const GetRuleResponse = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    id: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
    actions: Schema.optional(Schema.Union([
        Schema.Array(Schema.Struct({
            type: Schema.Literals(["drop", "forward", "worker"]),
            value: Schema.optional(Schema.Union([Schema.Array(Schema.String), Schema.Null])),
        })),
        Schema.Null,
    ])),
    enabled: Schema.optional(Schema.Union([Schema.Literals([true, false]), Schema.Null])),
    matchers: Schema.optional(Schema.Union([
        Schema.Array(Schema.Struct({
            type: Schema.Literals(["all", "literal"]),
            field: Schema.optional(Schema.Union([Schema.Literal("to"), Schema.Null])),
            value: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
        })),
        Schema.Null,
    ])),
    name: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
    priority: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
    tag: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
}).pipe(T.ResponsePath("result"));
export const getRule = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: GetRuleRequest,
    output: GetRuleResponse,
    errors: [],
}));
export const ListRulesRequest = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    zoneId: Schema.String.pipe(T.HttpPath("zone_id")),
    page: Schema.optional(Schema.Number).pipe(T.HttpQuery("page")),
    perPage: Schema.optional(Schema.Number).pipe(T.HttpQuery("per_page")),
    enabled: Schema.optional(Schema.Literals([true, false])).pipe(T.HttpQuery("enabled")),
}).pipe(T.Http({ method: "GET", path: "/zones/{zone_id}/email/routing/rules" }));
export const ListRulesResponse = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    result: Schema.Array(Schema.Struct({
        id: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
        actions: Schema.optional(Schema.Union([
            Schema.Array(Schema.Struct({
                type: Schema.Literals(["drop", "forward", "worker"]),
                value: Schema.optional(Schema.Union([Schema.Array(Schema.String), Schema.Null])),
            })),
            Schema.Null,
        ])),
        enabled: Schema.optional(Schema.Union([Schema.Literals([true, false]), Schema.Null])),
        matchers: Schema.optional(Schema.Union([
            Schema.Array(Schema.Struct({
                type: Schema.Literals(["all", "literal"]),
                field: Schema.optional(Schema.Union([Schema.Literal("to"), Schema.Null])),
                value: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
            })),
            Schema.Null,
        ])),
        name: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
        priority: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
        tag: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
    })),
    resultInfo: Schema.optional(Schema.Union([
        Schema.Struct({
            count: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
            page: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
            perPage: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
            totalCount: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
        }).pipe(Schema.encodeKeys({
            count: "count",
            page: "page",
            perPage: "per_page",
            totalCount: "total_count",
        })),
        Schema.Null,
    ])),
}).pipe(Schema.encodeKeys({ result: "result", resultInfo: "result_info" }));
export const listRules = /*@__PURE__*/ /*#__PURE__*/ API.makePaginated(() => ({
    input: ListRulesRequest,
    output: ListRulesResponse,
    errors: [],
    pagination: {
        mode: "page",
        inputToken: "page",
        outputToken: "resultInfo.page",
        items: "result",
        pageSize: "perPage",
    },
}));
export const CreateRuleRequest = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    zoneId: Schema.String.pipe(T.HttpPath("zone_id")),
    actions: Schema.Array(Schema.Struct({
        type: Schema.Literals(["drop", "forward", "worker"]),
        value: Schema.optional(Schema.Array(Schema.String)),
    })),
    matchers: Schema.Array(Schema.Struct({
        type: Schema.Literals(["all", "literal"]),
        field: Schema.optional(Schema.Literal("to")),
        value: Schema.optional(Schema.String),
    })),
    enabled: Schema.optional(Schema.Literals([true, false])),
    name: Schema.optional(Schema.String),
    priority: Schema.optional(Schema.Number),
}).pipe(T.Http({ method: "POST", path: "/zones/{zone_id}/email/routing/rules" }));
export const CreateRuleResponse = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    id: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
    actions: Schema.optional(Schema.Union([
        Schema.Array(Schema.Struct({
            type: Schema.Literals(["drop", "forward", "worker"]),
            value: Schema.optional(Schema.Union([Schema.Array(Schema.String), Schema.Null])),
        })),
        Schema.Null,
    ])),
    enabled: Schema.optional(Schema.Union([Schema.Literals([true, false]), Schema.Null])),
    matchers: Schema.optional(Schema.Union([
        Schema.Array(Schema.Struct({
            type: Schema.Literals(["all", "literal"]),
            field: Schema.optional(Schema.Union([Schema.Literal("to"), Schema.Null])),
            value: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
        })),
        Schema.Null,
    ])),
    name: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
    priority: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
    tag: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
}).pipe(T.ResponsePath("result"));
export const createRule = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: CreateRuleRequest,
    output: CreateRuleResponse,
    errors: [],
}));
export const UpdateRuleRequest = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    ruleIdentifier: Schema.String.pipe(T.HttpPath("ruleIdentifier")),
    zoneId: Schema.String.pipe(T.HttpPath("zone_id")),
    actions: Schema.Array(Schema.Struct({
        type: Schema.Literals(["drop", "forward", "worker"]),
        value: Schema.optional(Schema.Array(Schema.String)),
    })),
    matchers: Schema.Array(Schema.Struct({
        type: Schema.Literals(["all", "literal"]),
        field: Schema.optional(Schema.Literal("to")),
        value: Schema.optional(Schema.String),
    })),
    enabled: Schema.optional(Schema.Literals([true, false])),
    name: Schema.optional(Schema.String),
    priority: Schema.optional(Schema.Number),
}).pipe(T.Http({
    method: "PUT",
    path: "/zones/{zone_id}/email/routing/rules/{ruleIdentifier}",
}));
export const UpdateRuleResponse = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    id: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
    actions: Schema.optional(Schema.Union([
        Schema.Array(Schema.Struct({
            type: Schema.Literals(["drop", "forward", "worker"]),
            value: Schema.optional(Schema.Union([Schema.Array(Schema.String), Schema.Null])),
        })),
        Schema.Null,
    ])),
    enabled: Schema.optional(Schema.Union([Schema.Literals([true, false]), Schema.Null])),
    matchers: Schema.optional(Schema.Union([
        Schema.Array(Schema.Struct({
            type: Schema.Literals(["all", "literal"]),
            field: Schema.optional(Schema.Union([Schema.Literal("to"), Schema.Null])),
            value: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
        })),
        Schema.Null,
    ])),
    name: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
    priority: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
    tag: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
}).pipe(T.ResponsePath("result"));
export const updateRule = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: UpdateRuleRequest,
    output: UpdateRuleResponse,
    errors: [],
}));
export const DeleteRuleRequest = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    ruleIdentifier: Schema.String.pipe(T.HttpPath("ruleIdentifier")),
    zoneId: Schema.String.pipe(T.HttpPath("zone_id")),
}).pipe(T.Http({
    method: "DELETE",
    path: "/zones/{zone_id}/email/routing/rules/{ruleIdentifier}",
}));
export const DeleteRuleResponse = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    id: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
    actions: Schema.optional(Schema.Union([
        Schema.Array(Schema.Struct({
            type: Schema.Literals(["drop", "forward", "worker"]),
            value: Schema.optional(Schema.Union([Schema.Array(Schema.String), Schema.Null])),
        })),
        Schema.Null,
    ])),
    enabled: Schema.optional(Schema.Union([Schema.Literals([true, false]), Schema.Null])),
    matchers: Schema.optional(Schema.Union([
        Schema.Array(Schema.Struct({
            type: Schema.Literals(["all", "literal"]),
            field: Schema.optional(Schema.Union([Schema.Literal("to"), Schema.Null])),
            value: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
        })),
        Schema.Null,
    ])),
    name: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
    priority: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
    tag: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
}).pipe(T.ResponsePath("result"));
export const deleteRule = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: DeleteRuleRequest,
    output: DeleteRuleResponse,
    errors: [],
}));
export const GetRuleCatchAllRequest = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    zoneId: Schema.String.pipe(T.HttpPath("zone_id")),
}).pipe(T.Http({
    method: "GET",
    path: "/zones/{zone_id}/email/routing/rules/catch_all",
}));
export const GetRuleCatchAllResponse = 
/*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    id: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
    actions: Schema.optional(Schema.Union([
        Schema.Array(Schema.Struct({
            type: Schema.Literals(["drop", "forward", "worker"]),
            value: Schema.optional(Schema.Union([Schema.Array(Schema.String), Schema.Null])),
        })),
        Schema.Null,
    ])),
    enabled: Schema.optional(Schema.Union([Schema.Literals([true, false]), Schema.Null])),
    matchers: Schema.optional(Schema.Union([
        Schema.Array(Schema.Struct({
            type: Schema.Literal("all"),
        })),
        Schema.Null,
    ])),
    name: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
    tag: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
}).pipe(T.ResponsePath("result"));
export const getRuleCatchAll = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: GetRuleCatchAllRequest,
    output: GetRuleCatchAllResponse,
    errors: [],
}));
export const PutRuleCatchAllRequest = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    zoneId: Schema.String.pipe(T.HttpPath("zone_id")),
    actions: Schema.Array(Schema.Struct({
        type: Schema.Literals(["drop", "forward", "worker"]),
        value: Schema.optional(Schema.Array(Schema.String)),
    })),
    matchers: Schema.Array(Schema.Struct({
        type: Schema.Literal("all"),
    })),
    enabled: Schema.optional(Schema.Literals([true, false])),
    name: Schema.optional(Schema.String),
}).pipe(T.Http({
    method: "PUT",
    path: "/zones/{zone_id}/email/routing/rules/catch_all",
}));
export const PutRuleCatchAllResponse = 
/*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    id: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
    actions: Schema.optional(Schema.Union([
        Schema.Array(Schema.Struct({
            type: Schema.Literals(["drop", "forward", "worker"]),
            value: Schema.optional(Schema.Union([Schema.Array(Schema.String), Schema.Null])),
        })),
        Schema.Null,
    ])),
    enabled: Schema.optional(Schema.Union([Schema.Literals([true, false]), Schema.Null])),
    matchers: Schema.optional(Schema.Union([
        Schema.Array(Schema.Struct({
            type: Schema.Literal("all"),
        })),
        Schema.Null,
    ])),
    name: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
    tag: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
}).pipe(T.ResponsePath("result"));
export const putRuleCatchAll = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: PutRuleCatchAllRequest,
    output: PutRuleCatchAllResponse,
    errors: [],
}));
//# sourceMappingURL=email-routing.js.map