/**
 * Cloudflare R2-DATA-CATALOG API
 *
 * Generated from Cloudflare TypeScript SDK.
 * DO NOT EDIT - regenerate with: bun scripts/generate.ts --service r2-data-catalog
 */
import * as Schema from "effect/Schema";
import * as API from "../client/api.js";
import * as T from "../traits.js";
import {} from "../errors.js";
// =============================================================================
// Errors
// =============================================================================
export class InvalidCredential extends Schema.TaggedErrorClass()("InvalidCredential", { code: Schema.Number, message: Schema.String }) {
}
T.applyErrorMatchers(InvalidCredential, [{ code: 30004 }, { code: 30005 }]);
export class InvalidRoute extends Schema.TaggedErrorClass()("InvalidRoute", { code: Schema.Number, message: Schema.String }) {
}
T.applyErrorMatchers(InvalidRoute, [{ code: 7003 }]);
export class NoSuchBucket extends Schema.TaggedErrorClass()("NoSuchBucket", { code: Schema.Number, message: Schema.String }) {
}
T.applyErrorMatchers(NoSuchBucket, [{ code: 10006 }]);
export class TableNotFound extends Schema.TaggedErrorClass()("TableNotFound", { code: Schema.Number, message: Schema.String }) {
}
T.applyErrorMatchers(TableNotFound, [{ code: 10001 }, { code: 40403 }]);
export class WarehouseInactive extends Schema.TaggedErrorClass()("WarehouseInactive", { code: Schema.Number, message: Schema.String }) {
}
T.applyErrorMatchers(WarehouseInactive, [{ code: 40402 }]);
export class WarehouseNotFound extends Schema.TaggedErrorClass()("WarehouseNotFound", { code: Schema.Number, message: Schema.String }) {
}
T.applyErrorMatchers(WarehouseNotFound, [{ code: 40401 }]);
export const CreateCredentialRequest = 
/*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    bucketName: Schema.String.pipe(T.HttpPath("bucketName")),
    accountId: Schema.String.pipe(T.HttpPath("account_id")),
    token: Schema.String,
}).pipe(T.Http({
    method: "POST",
    path: "/accounts/{account_id}/r2-catalog/{bucketName}/credential",
}));
export const CreateCredentialResponse = 
/*@__PURE__*/ /*#__PURE__*/ Schema.Unknown.pipe(T.ResponsePath("result"));
export const createCredential = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: CreateCredentialRequest,
    output: CreateCredentialResponse,
    errors: [InvalidRoute, InvalidCredential],
}));
export const GetMaintenanceConfigRequest = 
/*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    bucketName: Schema.String.pipe(T.HttpPath("bucketName")),
    accountId: Schema.String.pipe(T.HttpPath("account_id")),
}).pipe(T.Http({
    method: "GET",
    path: "/accounts/{account_id}/r2-catalog/{bucketName}/maintenance-configs",
}));
export const GetMaintenanceConfigResponse = 
/*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    credentialStatus: Schema.Literals(["present", "absent"]),
    maintenanceConfig: Schema.Struct({
        compaction: Schema.optional(Schema.Union([
            Schema.Struct({
                state: Schema.Literals(["enabled", "disabled"]),
                targetSizeMb: Schema.Literals(["64", "128", "256", "512"]),
            }).pipe(Schema.encodeKeys({
                state: "state",
                targetSizeMb: "target_size_mb",
            })),
            Schema.Null,
        ])),
        snapshotExpiration: Schema.optional(Schema.Union([
            Schema.Struct({
                maxSnapshotAge: Schema.String,
                minSnapshotsToKeep: Schema.Number,
                state: Schema.Literals(["enabled", "disabled"]),
            }).pipe(Schema.encodeKeys({
                maxSnapshotAge: "max_snapshot_age",
                minSnapshotsToKeep: "min_snapshots_to_keep",
                state: "state",
            })),
            Schema.Null,
        ])),
    }).pipe(Schema.encodeKeys({
        compaction: "compaction",
        snapshotExpiration: "snapshot_expiration",
    })),
})
    .pipe(Schema.encodeKeys({
    credentialStatus: "credential_status",
    maintenanceConfig: "maintenance_config",
}))
    .pipe(T.ResponsePath("result"));
export const getMaintenanceConfig = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: GetMaintenanceConfigRequest,
    output: GetMaintenanceConfigResponse,
    errors: [InvalidRoute, WarehouseInactive, WarehouseNotFound],
}));
export const UpdateMaintenanceConfigRequest = 
/*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    bucketName: Schema.String.pipe(T.HttpPath("bucketName")),
    accountId: Schema.String.pipe(T.HttpPath("account_id")),
    compaction: Schema.optional(Schema.Struct({
        state: Schema.optional(Schema.Literals(["enabled", "disabled"])),
        targetSizeMb: Schema.optional(Schema.Literals(["64", "128", "256", "512"])),
    }).pipe(Schema.encodeKeys({ state: "state", targetSizeMb: "target_size_mb" }))),
    snapshotExpiration: Schema.optional(Schema.Struct({
        maxSnapshotAge: Schema.optional(Schema.String),
        minSnapshotsToKeep: Schema.optional(Schema.Number),
        state: Schema.optional(Schema.Literals(["enabled", "disabled"])),
    }).pipe(Schema.encodeKeys({
        maxSnapshotAge: "max_snapshot_age",
        minSnapshotsToKeep: "min_snapshots_to_keep",
        state: "state",
    }))),
}).pipe(Schema.encodeKeys({
    compaction: "compaction",
    snapshotExpiration: "snapshot_expiration",
}), T.Http({
    method: "POST",
    path: "/accounts/{account_id}/r2-catalog/{bucketName}/maintenance-configs",
}));
export const UpdateMaintenanceConfigResponse = 
/*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    compaction: Schema.optional(Schema.Union([
        Schema.Struct({
            state: Schema.Literals(["enabled", "disabled"]),
            targetSizeMb: Schema.Literals(["64", "128", "256", "512"]),
        }).pipe(Schema.encodeKeys({ state: "state", targetSizeMb: "target_size_mb" })),
        Schema.Null,
    ])),
    snapshotExpiration: Schema.optional(Schema.Union([
        Schema.Struct({
            maxSnapshotAge: Schema.String,
            minSnapshotsToKeep: Schema.Number,
            state: Schema.Literals(["enabled", "disabled"]),
        }).pipe(Schema.encodeKeys({
            maxSnapshotAge: "max_snapshot_age",
            minSnapshotsToKeep: "min_snapshots_to_keep",
            state: "state",
        })),
        Schema.Null,
    ])),
})
    .pipe(Schema.encodeKeys({
    compaction: "compaction",
    snapshotExpiration: "snapshot_expiration",
}))
    .pipe(T.ResponsePath("result"));
export const updateMaintenanceConfig = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: UpdateMaintenanceConfigRequest,
    output: UpdateMaintenanceConfigResponse,
    errors: [InvalidRoute, WarehouseInactive],
}));
export const ListNamespacesRequest = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    bucketName: Schema.String.pipe(T.HttpPath("bucketName")),
    accountId: Schema.String.pipe(T.HttpPath("account_id")),
    pageSize: Schema.optional(Schema.Number).pipe(T.HttpQuery("page_size")),
    pageToken: Schema.optional(Schema.String).pipe(T.HttpQuery("page_token")),
    parent: Schema.optional(Schema.String).pipe(T.HttpQuery("parent")),
    returnDetails: Schema.optional(Schema.Boolean).pipe(T.HttpQuery("return_details")),
    returnUuids: Schema.optional(Schema.Boolean).pipe(T.HttpQuery("return_uuids")),
}).pipe(T.Http({
    method: "GET",
    path: "/accounts/{account_id}/r2-catalog/{bucketName}/namespaces",
}));
export const ListNamespacesResponse = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    namespaces: Schema.Array(Schema.Array(Schema.String)),
    details: Schema.optional(Schema.Union([
        Schema.Array(Schema.Struct({
            namespace: Schema.Array(Schema.String),
            namespaceUuid: Schema.String,
            createdAt: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
            updatedAt: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
        }).pipe(Schema.encodeKeys({
            namespace: "namespace",
            namespaceUuid: "namespace_uuid",
            createdAt: "created_at",
            updatedAt: "updated_at",
        }))),
        Schema.Null,
    ])),
    namespaceUuids: Schema.optional(Schema.Union([Schema.Array(Schema.String), Schema.Null])),
    nextPageToken: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
})
    .pipe(Schema.encodeKeys({
    namespaces: "namespaces",
    details: "details",
    namespaceUuids: "namespace_uuids",
    nextPageToken: "next_page_token",
}))
    .pipe(T.ResponsePath("result"));
export const listNamespaces = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: ListNamespacesRequest,
    output: ListNamespacesResponse,
    errors: [InvalidRoute, WarehouseInactive, WarehouseNotFound],
}));
export const ListNamespaceTablesRequest = 
/*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    bucketName: Schema.String.pipe(T.HttpPath("bucketName")),
    namespace: Schema.String.pipe(T.HttpPath("namespace")),
    accountId: Schema.String.pipe(T.HttpPath("account_id")),
    pageSize: Schema.optional(Schema.Number).pipe(T.HttpQuery("page_size")),
    pageToken: Schema.optional(Schema.String).pipe(T.HttpQuery("page_token")),
    returnDetails: Schema.optional(Schema.Boolean).pipe(T.HttpQuery("return_details")),
    returnUuids: Schema.optional(Schema.Boolean).pipe(T.HttpQuery("return_uuids")),
}).pipe(T.Http({
    method: "GET",
    path: "/accounts/{account_id}/r2-catalog/{bucketName}/namespaces/{namespace}/tables",
}));
export const ListNamespaceTablesResponse = 
/*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    identifiers: Schema.Array(Schema.Struct({
        name: Schema.String,
        namespace: Schema.Array(Schema.String),
    })),
    details: Schema.optional(Schema.Union([
        Schema.Array(Schema.Struct({
            identifier: Schema.Struct({
                name: Schema.String,
                namespace: Schema.Array(Schema.String),
            }),
            tableUuid: Schema.String,
            createdAt: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
            location: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
            metadataLocation: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
            updatedAt: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
        }).pipe(Schema.encodeKeys({
            identifier: "identifier",
            tableUuid: "table_uuid",
            createdAt: "created_at",
            location: "location",
            metadataLocation: "metadata_location",
            updatedAt: "updated_at",
        }))),
        Schema.Null,
    ])),
    nextPageToken: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
    tableUuids: Schema.optional(Schema.Union([Schema.Array(Schema.String), Schema.Null])),
})
    .pipe(Schema.encodeKeys({
    identifiers: "identifiers",
    details: "details",
    nextPageToken: "next_page_token",
    tableUuids: "table_uuids",
}))
    .pipe(T.ResponsePath("result"));
export const listNamespaceTables = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: ListNamespaceTablesRequest,
    output: ListNamespaceTablesResponse,
    errors: [InvalidRoute, WarehouseInactive],
}));
export const GetNamespaceTableMaintenanceConfigRequest = 
/*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    bucketName: Schema.String.pipe(T.HttpPath("bucketName")),
    namespace: Schema.String.pipe(T.HttpPath("namespace")),
    tableName: Schema.String.pipe(T.HttpPath("tableName")),
    accountId: Schema.String.pipe(T.HttpPath("account_id")),
}).pipe(T.Http({
    method: "GET",
    path: "/accounts/{account_id}/r2-catalog/{bucketName}/namespaces/{namespace}/tables/{tableName}/maintenance-configs",
}));
export const GetNamespaceTableMaintenanceConfigResponse = 
/*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    maintenanceConfig: Schema.Struct({
        compaction: Schema.optional(Schema.Union([
            Schema.Struct({
                state: Schema.Literals(["enabled", "disabled"]),
                targetSizeMb: Schema.Literals(["64", "128", "256", "512"]),
            }).pipe(Schema.encodeKeys({
                state: "state",
                targetSizeMb: "target_size_mb",
            })),
            Schema.Null,
        ])),
        snapshotExpiration: Schema.optional(Schema.Union([
            Schema.Struct({
                maxSnapshotAge: Schema.String,
                minSnapshotsToKeep: Schema.Number,
                state: Schema.Literals(["enabled", "disabled"]),
            }).pipe(Schema.encodeKeys({
                maxSnapshotAge: "max_snapshot_age",
                minSnapshotsToKeep: "min_snapshots_to_keep",
                state: "state",
            })),
            Schema.Null,
        ])),
    }).pipe(Schema.encodeKeys({
        compaction: "compaction",
        snapshotExpiration: "snapshot_expiration",
    })),
})
    .pipe(Schema.encodeKeys({ maintenanceConfig: "maintenance_config" }))
    .pipe(T.ResponsePath("result"));
export const getNamespaceTableMaintenanceConfig = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: GetNamespaceTableMaintenanceConfigRequest,
    output: GetNamespaceTableMaintenanceConfigResponse,
    errors: [TableNotFound, InvalidRoute, WarehouseInactive],
}));
export const UpdateNamespaceTableMaintenanceConfigRequest = 
/*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    bucketName: Schema.String.pipe(T.HttpPath("bucketName")),
    namespace: Schema.String.pipe(T.HttpPath("namespace")),
    tableName: Schema.String.pipe(T.HttpPath("tableName")),
    accountId: Schema.String.pipe(T.HttpPath("account_id")),
    compaction: Schema.optional(Schema.Struct({
        state: Schema.optional(Schema.Literals(["enabled", "disabled"])),
        targetSizeMb: Schema.optional(Schema.Literals(["64", "128", "256", "512"])),
    }).pipe(Schema.encodeKeys({ state: "state", targetSizeMb: "target_size_mb" }))),
    snapshotExpiration: Schema.optional(Schema.Struct({
        maxSnapshotAge: Schema.optional(Schema.String),
        minSnapshotsToKeep: Schema.optional(Schema.Number),
        state: Schema.optional(Schema.Literals(["enabled", "disabled"])),
    }).pipe(Schema.encodeKeys({
        maxSnapshotAge: "max_snapshot_age",
        minSnapshotsToKeep: "min_snapshots_to_keep",
        state: "state",
    }))),
}).pipe(Schema.encodeKeys({
    compaction: "compaction",
    snapshotExpiration: "snapshot_expiration",
}), T.Http({
    method: "POST",
    path: "/accounts/{account_id}/r2-catalog/{bucketName}/namespaces/{namespace}/tables/{tableName}/maintenance-configs",
}));
export const UpdateNamespaceTableMaintenanceConfigResponse = 
/*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    compaction: Schema.optional(Schema.Union([
        Schema.Struct({
            state: Schema.Literals(["enabled", "disabled"]),
            targetSizeMb: Schema.Literals(["64", "128", "256", "512"]),
        }).pipe(Schema.encodeKeys({ state: "state", targetSizeMb: "target_size_mb" })),
        Schema.Null,
    ])),
    snapshotExpiration: Schema.optional(Schema.Union([
        Schema.Struct({
            maxSnapshotAge: Schema.String,
            minSnapshotsToKeep: Schema.Number,
            state: Schema.Literals(["enabled", "disabled"]),
        }).pipe(Schema.encodeKeys({
            maxSnapshotAge: "max_snapshot_age",
            minSnapshotsToKeep: "min_snapshots_to_keep",
            state: "state",
        })),
        Schema.Null,
    ])),
})
    .pipe(Schema.encodeKeys({
    compaction: "compaction",
    snapshotExpiration: "snapshot_expiration",
}))
    .pipe(T.ResponsePath("result"));
export const updateNamespaceTableMaintenanceConfig = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: UpdateNamespaceTableMaintenanceConfigRequest,
    output: UpdateNamespaceTableMaintenanceConfigResponse,
    errors: [TableNotFound, InvalidRoute, WarehouseInactive],
}));
export const GetR2DataCatalogRequest = 
/*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    bucketName: Schema.String.pipe(T.HttpPath("bucketName")),
    accountId: Schema.String.pipe(T.HttpPath("account_id")),
}).pipe(T.Http({
    method: "GET",
    path: "/accounts/{account_id}/r2-catalog/{bucketName}",
}));
export const GetR2DataCatalogResponse = 
/*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    id: Schema.String,
    bucket: Schema.String,
    name: Schema.String,
    status: Schema.Literals(["active", "inactive"]),
    credentialStatus: Schema.optional(Schema.Union([
        Schema.Literal("present"),
        Schema.Literal("absent"),
        Schema.Null,
    ])),
    maintenanceConfig: Schema.optional(Schema.Union([
        Schema.Struct({
            compaction: Schema.optional(Schema.Union([
                Schema.Struct({
                    state: Schema.Literals(["enabled", "disabled"]),
                    targetSizeMb: Schema.Literals(["64", "128", "256", "512"]),
                }).pipe(Schema.encodeKeys({
                    state: "state",
                    targetSizeMb: "target_size_mb",
                })),
                Schema.Null,
            ])),
            snapshotExpiration: Schema.optional(Schema.Union([
                Schema.Struct({
                    maxSnapshotAge: Schema.String,
                    minSnapshotsToKeep: Schema.Number,
                    state: Schema.Literals(["enabled", "disabled"]),
                }).pipe(Schema.encodeKeys({
                    maxSnapshotAge: "max_snapshot_age",
                    minSnapshotsToKeep: "min_snapshots_to_keep",
                    state: "state",
                })),
                Schema.Null,
            ])),
        }).pipe(Schema.encodeKeys({
            compaction: "compaction",
            snapshotExpiration: "snapshot_expiration",
        })),
        Schema.Null,
    ])),
})
    .pipe(Schema.encodeKeys({
    id: "id",
    bucket: "bucket",
    name: "name",
    status: "status",
    credentialStatus: "credential_status",
    maintenanceConfig: "maintenance_config",
}))
    .pipe(T.ResponsePath("result"));
export const getR2DataCatalog = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: GetR2DataCatalogRequest,
    output: GetR2DataCatalogResponse,
    errors: [NoSuchBucket, InvalidRoute],
}));
export const ListR2DataCatalogsRequest = 
/*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    accountId: Schema.String.pipe(T.HttpPath("account_id")),
}).pipe(T.Http({ method: "GET", path: "/accounts/{account_id}/r2-catalog" }));
export const ListR2DataCatalogsResponse = 
/*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    warehouses: Schema.Array(Schema.Struct({
        id: Schema.String,
        bucket: Schema.String,
        name: Schema.String,
        status: Schema.Literals(["active", "inactive"]),
        credentialStatus: Schema.optional(Schema.Union([
            Schema.Literal("present"),
            Schema.Literal("absent"),
            Schema.Null,
        ])),
        maintenanceConfig: Schema.optional(Schema.Union([
            Schema.Struct({
                compaction: Schema.optional(Schema.Union([
                    Schema.Struct({
                        state: Schema.Literals(["enabled", "disabled"]),
                        targetSizeMb: Schema.Literals(["64", "128", "256", "512"]),
                    }).pipe(Schema.encodeKeys({
                        state: "state",
                        targetSizeMb: "target_size_mb",
                    })),
                    Schema.Null,
                ])),
                snapshotExpiration: Schema.optional(Schema.Union([
                    Schema.Struct({
                        maxSnapshotAge: Schema.String,
                        minSnapshotsToKeep: Schema.Number,
                        state: Schema.Literals(["enabled", "disabled"]),
                    }).pipe(Schema.encodeKeys({
                        maxSnapshotAge: "max_snapshot_age",
                        minSnapshotsToKeep: "min_snapshots_to_keep",
                        state: "state",
                    })),
                    Schema.Null,
                ])),
            }).pipe(Schema.encodeKeys({
                compaction: "compaction",
                snapshotExpiration: "snapshot_expiration",
            })),
            Schema.Null,
        ])),
    }).pipe(Schema.encodeKeys({
        id: "id",
        bucket: "bucket",
        name: "name",
        status: "status",
        credentialStatus: "credential_status",
        maintenanceConfig: "maintenance_config",
    }))),
}).pipe(T.ResponsePath("result"));
export const listR2DataCatalogs = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: ListR2DataCatalogsRequest,
    output: ListR2DataCatalogsResponse,
    errors: [InvalidRoute],
}));
export const EnableR2DataCatalogRequest = 
/*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    bucketName: Schema.String.pipe(T.HttpPath("bucketName")),
    accountId: Schema.String.pipe(T.HttpPath("account_id")),
}).pipe(T.Http({
    method: "POST",
    path: "/accounts/{account_id}/r2-catalog/{bucketName}/enable",
}));
export const EnableR2DataCatalogResponse = 
/*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    id: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
    name: Schema.String,
}).pipe(T.ResponsePath("result"));
export const enableR2DataCatalog = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: EnableR2DataCatalogRequest,
    output: EnableR2DataCatalogResponse,
    errors: [NoSuchBucket, InvalidRoute],
}));
export const DisableR2DataCatalogRequest = 
/*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    bucketName: Schema.String.pipe(T.HttpPath("bucketName")),
    accountId: Schema.String.pipe(T.HttpPath("account_id")),
}).pipe(T.Http({
    method: "POST",
    path: "/accounts/{account_id}/r2-catalog/{bucketName}/disable",
}));
export const DisableR2DataCatalogResponse = 
/*@__PURE__*/ /*#__PURE__*/ Schema.Unknown;
export const disableR2DataCatalog = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: DisableR2DataCatalogRequest,
    output: DisableR2DataCatalogResponse,
    errors: [NoSuchBucket, InvalidRoute],
}));
//# sourceMappingURL=r2-data-catalog.js.map