/**
 * Cloudflare RULES API
 *
 * Generated from Cloudflare TypeScript SDK.
 * DO NOT EDIT - regenerate with: bun scripts/generate.ts --service rules
 */
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 GetListRequest = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    listId: Schema.String.pipe(T.HttpPath("listId")),
    accountId: Schema.String.pipe(T.HttpPath("account_id")),
}).pipe(T.Http({
    method: "GET",
    path: "/accounts/{account_id}/rules/lists/{listId}",
}));
export const GetListResponse = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    id: Schema.String,
    createdOn: Schema.String,
    kind: Schema.Literals(["ip", "redirect", "hostname", "asn"]),
    modifiedOn: Schema.String,
    name: Schema.String,
    numItems: Schema.Number,
    numReferencingFilters: Schema.Number,
    description: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
})
    .pipe(Schema.encodeKeys({
    id: "id",
    createdOn: "created_on",
    kind: "kind",
    modifiedOn: "modified_on",
    name: "name",
    numItems: "num_items",
    numReferencingFilters: "num_referencing_filters",
    description: "description",
}))
    .pipe(T.ResponsePath("result"));
export const getList = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: GetListRequest,
    output: GetListResponse,
    errors: [],
}));
export const ListListsRequest = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    accountId: Schema.String.pipe(T.HttpPath("account_id")),
}).pipe(T.Http({ method: "GET", path: "/accounts/{account_id}/rules/lists" }));
export const ListListsResponse = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    result: Schema.Array(Schema.Struct({
        id: Schema.String,
        createdOn: Schema.String,
        kind: Schema.Literals(["ip", "redirect", "hostname", "asn"]),
        modifiedOn: Schema.String,
        name: Schema.String,
        numItems: Schema.Number,
        numReferencingFilters: Schema.Number,
        description: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
    }).pipe(Schema.encodeKeys({
        id: "id",
        createdOn: "created_on",
        kind: "kind",
        modifiedOn: "modified_on",
        name: "name",
        numItems: "num_items",
        numReferencingFilters: "num_referencing_filters",
        description: "description",
    }))),
});
export const listLists = /*@__PURE__*/ /*#__PURE__*/ API.makePaginated(() => ({
    input: ListListsRequest,
    output: ListListsResponse,
    errors: [],
    pagination: {
        mode: "single",
        items: "result",
    },
}));
export const CreateListRequest = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    accountId: Schema.String.pipe(T.HttpPath("account_id")),
    kind: Schema.Literals(["ip", "redirect", "hostname", "asn"]),
    name: Schema.String,
    description: Schema.optional(Schema.String),
}).pipe(T.Http({ method: "POST", path: "/accounts/{account_id}/rules/lists" }));
export const CreateListResponse = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    id: Schema.String,
    createdOn: Schema.String,
    kind: Schema.Literals(["ip", "redirect", "hostname", "asn"]),
    modifiedOn: Schema.String,
    name: Schema.String,
    numItems: Schema.Number,
    numReferencingFilters: Schema.Number,
    description: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
})
    .pipe(Schema.encodeKeys({
    id: "id",
    createdOn: "created_on",
    kind: "kind",
    modifiedOn: "modified_on",
    name: "name",
    numItems: "num_items",
    numReferencingFilters: "num_referencing_filters",
    description: "description",
}))
    .pipe(T.ResponsePath("result"));
export const createList = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: CreateListRequest,
    output: CreateListResponse,
    errors: [],
}));
export const UpdateListRequest = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    listId: Schema.String.pipe(T.HttpPath("listId")),
    accountId: Schema.String.pipe(T.HttpPath("account_id")),
    description: Schema.optional(Schema.String),
}).pipe(T.Http({
    method: "PUT",
    path: "/accounts/{account_id}/rules/lists/{listId}",
}));
export const UpdateListResponse = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    id: Schema.String,
    createdOn: Schema.String,
    kind: Schema.Literals(["ip", "redirect", "hostname", "asn"]),
    modifiedOn: Schema.String,
    name: Schema.String,
    numItems: Schema.Number,
    numReferencingFilters: Schema.Number,
    description: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
})
    .pipe(Schema.encodeKeys({
    id: "id",
    createdOn: "created_on",
    kind: "kind",
    modifiedOn: "modified_on",
    name: "name",
    numItems: "num_items",
    numReferencingFilters: "num_referencing_filters",
    description: "description",
}))
    .pipe(T.ResponsePath("result"));
export const updateList = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: UpdateListRequest,
    output: UpdateListResponse,
    errors: [],
}));
export const DeleteListRequest = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    listId: Schema.String.pipe(T.HttpPath("listId")),
    accountId: Schema.String.pipe(T.HttpPath("account_id")),
}).pipe(T.Http({
    method: "DELETE",
    path: "/accounts/{account_id}/rules/lists/{listId}",
}));
export const DeleteListResponse = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    id: Schema.String,
}).pipe(T.ResponsePath("result"));
export const deleteList = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: DeleteListRequest,
    output: DeleteListResponse,
    errors: [],
}));
export const GetListBulkOperationRequest = 
/*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    operationId: Schema.String.pipe(T.HttpPath("operationId")),
    accountId: Schema.String.pipe(T.HttpPath("account_id")),
}).pipe(T.Http({
    method: "GET",
    path: "/accounts/{account_id}/rules/lists/bulk_operations/{operationId}",
}));
export const GetListBulkOperationResponse = 
/*@__PURE__*/ /*#__PURE__*/ Schema.Union([
    Schema.Struct({
        id: Schema.String,
        completed: Schema.String,
        error: Schema.String,
        status: Schema.Literal("failed"),
    }),
    Schema.Struct({
        id: Schema.String,
        completed: Schema.String,
        status: Schema.Literal("completed"),
    }),
    Schema.Struct({
        id: Schema.String,
        status: Schema.Literals(["pending", "running"]),
    }),
]).pipe(T.ResponsePath("result"));
export const getListBulkOperation = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: GetListBulkOperationRequest,
    output: GetListBulkOperationResponse,
    errors: [],
}));
export const GetListItemRequest = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    listId: Schema.String.pipe(T.HttpPath("listId")),
    itemId: Schema.String.pipe(T.HttpPath("itemId")),
    accountId: Schema.String.pipe(T.HttpPath("account_id")),
}).pipe(T.Http({
    method: "GET",
    path: "/accounts/{account_id}/rules/lists/{listId}/items/{itemId}",
}));
export const GetListItemResponse = /*@__PURE__*/ /*#__PURE__*/ Schema.Union([
    Schema.Struct({
        id: Schema.String,
        createdOn: Schema.String,
        ip: Schema.String,
        modifiedOn: Schema.String,
        comment: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
    }).pipe(Schema.encodeKeys({
        id: "id",
        createdOn: "created_on",
        ip: "ip",
        modifiedOn: "modified_on",
        comment: "comment",
    })),
    Schema.Struct({
        id: Schema.String,
        createdOn: Schema.String,
        hostname: Schema.Struct({
            urlHostname: Schema.String,
            excludeExactHostname: Schema.optional(Schema.Union([Schema.Boolean, Schema.Null])),
        }).pipe(Schema.encodeKeys({
            urlHostname: "url_hostname",
            excludeExactHostname: "exclude_exact_hostname",
        })),
        modifiedOn: Schema.String,
        comment: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
    }).pipe(Schema.encodeKeys({
        id: "id",
        createdOn: "created_on",
        hostname: "hostname",
        modifiedOn: "modified_on",
        comment: "comment",
    })),
    Schema.Struct({
        id: Schema.String,
        createdOn: Schema.String,
        modifiedOn: Schema.String,
        redirect: Schema.Struct({
            sourceUrl: Schema.String,
            targetUrl: Schema.String,
            includeSubdomains: Schema.optional(Schema.Union([Schema.Boolean, Schema.Null])),
            preservePathSuffix: Schema.optional(Schema.Union([Schema.Boolean, Schema.Null])),
            preserveQueryString: Schema.optional(Schema.Union([Schema.Boolean, Schema.Null])),
            statusCode: Schema.optional(Schema.Union([
                Schema.Literals(["301", "302", "307", "308"]),
                Schema.Null,
            ])),
            subpathMatching: Schema.optional(Schema.Union([Schema.Boolean, Schema.Null])),
        }).pipe(Schema.encodeKeys({
            sourceUrl: "source_url",
            targetUrl: "target_url",
            includeSubdomains: "include_subdomains",
            preservePathSuffix: "preserve_path_suffix",
            preserveQueryString: "preserve_query_string",
            statusCode: "status_code",
            subpathMatching: "subpath_matching",
        })),
        comment: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
    }).pipe(Schema.encodeKeys({
        id: "id",
        createdOn: "created_on",
        modifiedOn: "modified_on",
        redirect: "redirect",
        comment: "comment",
    })),
    Schema.Struct({
        id: Schema.String,
        asn: Schema.Number,
        createdOn: Schema.String,
        modifiedOn: Schema.String,
        comment: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
    }).pipe(Schema.encodeKeys({
        id: "id",
        asn: "asn",
        createdOn: "created_on",
        modifiedOn: "modified_on",
        comment: "comment",
    })),
]).pipe(T.ResponsePath("result"));
export const getListItem = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: GetListItemRequest,
    output: GetListItemResponse,
    errors: [],
}));
export const ListListItemsRequest = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    listId: Schema.String.pipe(T.HttpPath("listId")),
    accountId: Schema.String.pipe(T.HttpPath("account_id")),
    cursor: Schema.optional(Schema.String).pipe(T.HttpQuery("cursor")),
    perPage: Schema.optional(Schema.Number).pipe(T.HttpQuery("per_page")),
    search: Schema.optional(Schema.String).pipe(T.HttpQuery("search")),
}).pipe(T.Http({
    method: "GET",
    path: "/accounts/{account_id}/rules/lists/{listId}/items",
}));
export const ListListItemsResponse = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    result: Schema.Array(Schema.Union([
        Schema.Struct({
            id: Schema.String,
            createdOn: Schema.String,
            ip: Schema.String,
            modifiedOn: Schema.String,
            comment: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
        }).pipe(Schema.encodeKeys({
            id: "id",
            createdOn: "created_on",
            ip: "ip",
            modifiedOn: "modified_on",
            comment: "comment",
        })),
        Schema.Struct({
            id: Schema.String,
            createdOn: Schema.String,
            hostname: Schema.Struct({
                urlHostname: Schema.String,
                excludeExactHostname: Schema.optional(Schema.Union([Schema.Boolean, Schema.Null])),
            }).pipe(Schema.encodeKeys({
                urlHostname: "url_hostname",
                excludeExactHostname: "exclude_exact_hostname",
            })),
            modifiedOn: Schema.String,
            comment: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
        }).pipe(Schema.encodeKeys({
            id: "id",
            createdOn: "created_on",
            hostname: "hostname",
            modifiedOn: "modified_on",
            comment: "comment",
        })),
        Schema.Struct({
            id: Schema.String,
            createdOn: Schema.String,
            modifiedOn: Schema.String,
            redirect: Schema.Struct({
                sourceUrl: Schema.String,
                targetUrl: Schema.String,
                includeSubdomains: Schema.optional(Schema.Union([Schema.Boolean, Schema.Null])),
                preservePathSuffix: Schema.optional(Schema.Union([Schema.Boolean, Schema.Null])),
                preserveQueryString: Schema.optional(Schema.Union([Schema.Boolean, Schema.Null])),
                statusCode: Schema.optional(Schema.Union([
                    Schema.Literals(["301", "302", "307", "308"]),
                    Schema.Null,
                ])),
                subpathMatching: Schema.optional(Schema.Union([Schema.Boolean, Schema.Null])),
            }).pipe(Schema.encodeKeys({
                sourceUrl: "source_url",
                targetUrl: "target_url",
                includeSubdomains: "include_subdomains",
                preservePathSuffix: "preserve_path_suffix",
                preserveQueryString: "preserve_query_string",
                statusCode: "status_code",
                subpathMatching: "subpath_matching",
            })),
            comment: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
        }).pipe(Schema.encodeKeys({
            id: "id",
            createdOn: "created_on",
            modifiedOn: "modified_on",
            redirect: "redirect",
            comment: "comment",
        })),
        Schema.Struct({
            id: Schema.String,
            asn: Schema.Number,
            createdOn: Schema.String,
            modifiedOn: Schema.String,
            comment: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
        }).pipe(Schema.encodeKeys({
            id: "id",
            asn: "asn",
            createdOn: "created_on",
            modifiedOn: "modified_on",
            comment: "comment",
        })),
    ])),
    resultInfo: Schema.optional(Schema.Union([
        Schema.Struct({
            cursors: Schema.optional(Schema.Union([
                Schema.Struct({
                    after: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
                }),
                Schema.Null,
            ])),
        }),
        Schema.Null,
    ])),
}).pipe(Schema.encodeKeys({ result: "result", resultInfo: "result_info" }));
export const listListItems = /*@__PURE__*/ /*#__PURE__*/ API.makePaginated(() => ({
    input: ListListItemsRequest,
    output: ListListItemsResponse,
    errors: [],
    pagination: {
        mode: "cursor",
        inputToken: "cursor",
        outputToken: "resultInfo.cursors.after",
        items: "result",
    },
}));
export const CreateListItemRequest = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    listId: Schema.String.pipe(T.HttpPath("listId")),
    accountId: Schema.String.pipe(T.HttpPath("account_id")),
    body: Schema.Array(Schema.Union([
        Schema.Struct({
            ip: Schema.String,
            comment: Schema.optional(Schema.String),
        }),
        Schema.Struct({
            redirect: Schema.Struct({
                sourceUrl: Schema.String,
                targetUrl: Schema.String,
                includeSubdomains: Schema.optional(Schema.Boolean),
                preservePathSuffix: Schema.optional(Schema.Boolean),
                preserveQueryString: Schema.optional(Schema.Boolean),
                statusCode: Schema.optional(Schema.Literals(["301", "302", "307", "308"])),
                subpathMatching: Schema.optional(Schema.Boolean),
            }).pipe(Schema.encodeKeys({
                sourceUrl: "source_url",
                targetUrl: "target_url",
                includeSubdomains: "include_subdomains",
                preservePathSuffix: "preserve_path_suffix",
                preserveQueryString: "preserve_query_string",
                statusCode: "status_code",
                subpathMatching: "subpath_matching",
            })),
            comment: Schema.optional(Schema.String),
        }),
        Schema.Struct({
            hostname: Schema.Struct({
                urlHostname: Schema.String,
                excludeExactHostname: Schema.optional(Schema.Boolean),
            }).pipe(Schema.encodeKeys({
                urlHostname: "url_hostname",
                excludeExactHostname: "exclude_exact_hostname",
            })),
            comment: Schema.optional(Schema.String),
        }),
        Schema.Struct({
            asn: Schema.Number,
            comment: Schema.optional(Schema.String),
        }),
    ])).pipe(T.HttpBody()),
}).pipe(T.Http({
    method: "POST",
    path: "/accounts/{account_id}/rules/lists/{listId}/items",
}));
export const CreateListItemResponse = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    operationId: Schema.String,
})
    .pipe(Schema.encodeKeys({ operationId: "operation_id" }))
    .pipe(T.ResponsePath("result"));
export const createListItem = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: CreateListItemRequest,
    output: CreateListItemResponse,
    errors: [],
}));
export const UpdateListItemRequest = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    listId: Schema.String.pipe(T.HttpPath("listId")),
    accountId: Schema.String.pipe(T.HttpPath("account_id")),
    body: Schema.Array(Schema.Union([
        Schema.Struct({
            ip: Schema.String,
            comment: Schema.optional(Schema.String),
        }),
        Schema.Struct({
            redirect: Schema.Struct({
                sourceUrl: Schema.String,
                targetUrl: Schema.String,
                includeSubdomains: Schema.optional(Schema.Boolean),
                preservePathSuffix: Schema.optional(Schema.Boolean),
                preserveQueryString: Schema.optional(Schema.Boolean),
                statusCode: Schema.optional(Schema.Literals(["301", "302", "307", "308"])),
                subpathMatching: Schema.optional(Schema.Boolean),
            }).pipe(Schema.encodeKeys({
                sourceUrl: "source_url",
                targetUrl: "target_url",
                includeSubdomains: "include_subdomains",
                preservePathSuffix: "preserve_path_suffix",
                preserveQueryString: "preserve_query_string",
                statusCode: "status_code",
                subpathMatching: "subpath_matching",
            })),
            comment: Schema.optional(Schema.String),
        }),
        Schema.Struct({
            hostname: Schema.Struct({
                urlHostname: Schema.String,
                excludeExactHostname: Schema.optional(Schema.Boolean),
            }).pipe(Schema.encodeKeys({
                urlHostname: "url_hostname",
                excludeExactHostname: "exclude_exact_hostname",
            })),
            comment: Schema.optional(Schema.String),
        }),
        Schema.Struct({
            asn: Schema.Number,
            comment: Schema.optional(Schema.String),
        }),
    ])).pipe(T.HttpBody()),
}).pipe(T.Http({
    method: "PUT",
    path: "/accounts/{account_id}/rules/lists/{listId}/items",
}));
export const UpdateListItemResponse = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    operationId: Schema.String,
})
    .pipe(Schema.encodeKeys({ operationId: "operation_id" }))
    .pipe(T.ResponsePath("result"));
export const updateListItem = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: UpdateListItemRequest,
    output: UpdateListItemResponse,
    errors: [],
}));
export const DeleteListItemRequest = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    listId: Schema.String.pipe(T.HttpPath("listId")),
    accountId: Schema.String.pipe(T.HttpPath("account_id")),
    items: Schema.optional(Schema.Array(Schema.Struct({
        id: Schema.String,
    }))),
}).pipe(T.Http({
    method: "DELETE",
    path: "/accounts/{account_id}/rules/lists/{listId}/items",
}));
export const DeleteListItemResponse = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    operationId: Schema.String,
})
    .pipe(Schema.encodeKeys({ operationId: "operation_id" }))
    .pipe(T.ResponsePath("result"));
export const deleteListItem = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: DeleteListItemRequest,
    output: DeleteListItemResponse,
    errors: [],
}));
//# sourceMappingURL=rules.js.map