// This file is auto-generated by @hey-api/openapi-ts

import { type DefaultError, type MutationOptions, queryOptions } from '@tanstack/solid-query';

import { client } from '../client.gen';
import { type Options, serenDbAddIpAllowList, serenDbAssignProjectVpcEndpoint, serenDbAssignProjectVpcEndpointById, serenDbConnectionUri, serenDbCreateBranch, serenDbCreateBranchProtection, serenDbCreateDatabase, serenDbCreateEndpoint, serenDbCreateProject, serenDbCreatePublication, serenDbCreateReplicationSlot, serenDbCreateRole, serenDbDeleteBranch, serenDbDeleteBranchProtection, serenDbDeleteDatabase, serenDbDeleteEndpoint, serenDbDeleteProject, serenDbDeleteProjectEndpoint, serenDbDeletePublication, serenDbDeleteReplicationSlot, serenDbDeleteRole, serenDbGetBranch, serenDbGetBranchCount, serenDbGetBranchDetails, serenDbGetBranchProtection, serenDbGetConnectionString, serenDbGetDatabase, serenDbGetEndpointHealth, serenDbGetEndpointMetrics, serenDbGetEndpointStatus, serenDbGetLsnByTimestamp, serenDbGetOperation, serenDbGetProject, serenDbGetProjectConsumption, serenDbGetProjectSize, serenDbGetReplicationSettings, serenDbGetTimestampByLsn, serenDbListBranches, serenDbListBranchProtectionRules, serenDbListDatabases, serenDbListEndpoints, serenDbListIpAllowList, serenDbListOperations, serenDbListProjectDatabases, serenDbListProjectEndpoints, serenDbListProjects, serenDbListProjectVpcEndpoints, serenDbListProjectVpcEndpointsAlias, serenDbListPublications, serenDbListReplicationSlots, serenDbListRoles, serenDbQuery, serenDbRemoveIpAllowList, serenDbRemoveProjectVpcEndpoint, serenDbRemoveProjectVpcEndpointByVpcId, serenDbRenameBranch, serenDbResetBranch, serenDbResetIpAllowList, serenDbResetRolePassword, serenDbRestartEndpoint, serenDbRestoreBranch, serenDbRevealRolePassword, serenDbSetBranchArchived, serenDbSetBranchExpiration, serenDbSetDefaultBranch, serenDbSetDefaultBranchAlias, serenDbStartEndpoint, serenDbStartProjectEndpoint, serenDbStopEndpoint, serenDbSuspendProjectEndpoint, serenDbUpdateBranchProtection, serenDbUpdateDatabase, serenDbUpdateEndpoint, serenDbUpdateProject, serenDbUpdateProjectEndpoint, serenDbUpdatePublication, serenDbUpdateReplicationSettings } from '../sdk.gen';
import type { SerenDbAddIpAllowListData, SerenDbAddIpAllowListResponse, SerenDbAssignProjectVpcEndpointByIdData, SerenDbAssignProjectVpcEndpointByIdResponse, SerenDbAssignProjectVpcEndpointData, SerenDbAssignProjectVpcEndpointResponse, SerenDbConnectionUriData, SerenDbConnectionUriResponse, SerenDbCreateBranchData, SerenDbCreateBranchProtectionData, SerenDbCreateBranchProtectionResponse, SerenDbCreateBranchResponse, SerenDbCreateDatabaseData, SerenDbCreateDatabaseResponse, SerenDbCreateEndpointData, SerenDbCreateEndpointResponse, SerenDbCreateProjectData, SerenDbCreateProjectResponse, SerenDbCreatePublicationData, SerenDbCreatePublicationResponse, SerenDbCreateReplicationSlotData, SerenDbCreateReplicationSlotResponse, SerenDbCreateRoleData, SerenDbCreateRoleResponse, SerenDbDeleteBranchData, SerenDbDeleteBranchProtectionData, SerenDbDeleteBranchProtectionResponse, SerenDbDeleteBranchResponse, SerenDbDeleteDatabaseData, SerenDbDeleteDatabaseResponse, SerenDbDeleteEndpointData, SerenDbDeleteEndpointResponse, SerenDbDeleteProjectData, SerenDbDeleteProjectEndpointData, SerenDbDeleteProjectEndpointResponse, SerenDbDeleteProjectResponse, SerenDbDeletePublicationData, SerenDbDeletePublicationResponse, SerenDbDeleteReplicationSlotData, SerenDbDeleteReplicationSlotResponse, SerenDbDeleteRoleData, SerenDbDeleteRoleResponse, SerenDbGetBranchCountData, SerenDbGetBranchCountResponse, SerenDbGetBranchData, SerenDbGetBranchDetailsData, SerenDbGetBranchDetailsResponse, SerenDbGetBranchProtectionData, SerenDbGetBranchProtectionResponse, SerenDbGetBranchResponse, SerenDbGetConnectionStringData, SerenDbGetConnectionStringResponse, SerenDbGetDatabaseData, SerenDbGetDatabaseResponse, SerenDbGetEndpointHealthData, SerenDbGetEndpointHealthResponse, SerenDbGetEndpointMetricsData, SerenDbGetEndpointMetricsResponse, SerenDbGetEndpointStatusData, SerenDbGetEndpointStatusResponse, SerenDbGetLsnByTimestampData, SerenDbGetLsnByTimestampResponse, SerenDbGetOperationData, SerenDbGetOperationResponse, SerenDbGetProjectConsumptionData, SerenDbGetProjectConsumptionResponse, SerenDbGetProjectData, SerenDbGetProjectResponse, SerenDbGetProjectSizeData, SerenDbGetProjectSizeResponse, SerenDbGetReplicationSettingsData, SerenDbGetReplicationSettingsResponse, SerenDbGetTimestampByLsnData, SerenDbGetTimestampByLsnResponse, SerenDbListBranchesData, SerenDbListBranchesResponse, SerenDbListBranchProtectionRulesData, SerenDbListBranchProtectionRulesResponse, SerenDbListDatabasesData, SerenDbListDatabasesResponse, SerenDbListEndpointsData, SerenDbListEndpointsResponse, SerenDbListIpAllowListData, SerenDbListIpAllowListResponse, SerenDbListOperationsData, SerenDbListOperationsResponse, SerenDbListProjectDatabasesData, SerenDbListProjectDatabasesResponse, SerenDbListProjectEndpointsData, SerenDbListProjectEndpointsResponse, SerenDbListProjectsData, SerenDbListProjectsResponse, SerenDbListProjectVpcEndpointsAliasData, SerenDbListProjectVpcEndpointsAliasResponse, SerenDbListProjectVpcEndpointsData, SerenDbListProjectVpcEndpointsResponse, SerenDbListPublicationsData, SerenDbListPublicationsResponse, SerenDbListReplicationSlotsData, SerenDbListReplicationSlotsResponse, SerenDbListRolesData, SerenDbListRolesResponse, SerenDbQueryData, SerenDbQueryResponse, SerenDbRemoveIpAllowListData, SerenDbRemoveIpAllowListResponse, SerenDbRemoveProjectVpcEndpointByVpcIdData, SerenDbRemoveProjectVpcEndpointByVpcIdResponse, SerenDbRemoveProjectVpcEndpointData, SerenDbRemoveProjectVpcEndpointResponse, SerenDbRenameBranchData, SerenDbRenameBranchResponse, SerenDbResetBranchData, SerenDbResetBranchResponse, SerenDbResetIpAllowListData, SerenDbResetIpAllowListResponse, SerenDbResetRolePasswordData, SerenDbResetRolePasswordResponse, SerenDbRestartEndpointData, SerenDbRestartEndpointResponse, SerenDbRestoreBranchData, SerenDbRestoreBranchResponse, SerenDbRevealRolePasswordData, SerenDbRevealRolePasswordResponse, SerenDbSetBranchArchivedData, SerenDbSetBranchArchivedResponse, SerenDbSetBranchExpirationData, SerenDbSetBranchExpirationResponse, SerenDbSetDefaultBranchAliasData, SerenDbSetDefaultBranchAliasResponse, SerenDbSetDefaultBranchData, SerenDbSetDefaultBranchResponse, SerenDbStartEndpointData, SerenDbStartEndpointResponse, SerenDbStartProjectEndpointData, SerenDbStartProjectEndpointResponse, SerenDbStopEndpointData, SerenDbStopEndpointResponse, SerenDbSuspendProjectEndpointData, SerenDbSuspendProjectEndpointResponse, SerenDbUpdateBranchProtectionData, SerenDbUpdateBranchProtectionResponse, SerenDbUpdateDatabaseData, SerenDbUpdateDatabaseResponse, SerenDbUpdateEndpointData, SerenDbUpdateEndpointResponse, SerenDbUpdateProjectData, SerenDbUpdateProjectEndpointData, SerenDbUpdateProjectEndpointResponse, SerenDbUpdateProjectResponse, SerenDbUpdatePublicationData, SerenDbUpdatePublicationResponse, SerenDbUpdateReplicationSettingsData, SerenDbUpdateReplicationSettingsResponse } from '../types.gen';

export type QueryKey<TOptions extends Options> = [
    Pick<TOptions, 'baseUrl' | 'body' | 'headers' | 'path' | 'query'> & {
        _id: string;
        _infinite?: boolean;
        tags?: ReadonlyArray<string>;
    }
];

const createQueryKey = <TOptions extends Options>(id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray<string>): [
    QueryKey<TOptions>[0]
] => {
    const params: QueryKey<TOptions>[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? client).getConfig().baseUrl } as QueryKey<TOptions>[0];
    if (infinite) {
        params._infinite = infinite;
    }
    if (tags) {
        params.tags = tags;
    }
    if (options?.body) {
        params.body = options.body;
    }
    if (options?.headers) {
        params.headers = options.headers;
    }
    if (options?.path) {
        params.path = options.path;
    }
    if (options?.query) {
        params.query = options.query;
    }
    return [params];
};

export const serenDbListProjectsQueryKey = (options?: Options<SerenDbListProjectsData>) => createQueryKey('serenDbListProjects', options);

/**
 * List all projects in the organization.
 */
export const serenDbListProjectsOptions = (options?: Options<SerenDbListProjectsData>) => queryOptions<SerenDbListProjectsResponse, DefaultError, SerenDbListProjectsResponse, ReturnType<typeof serenDbListProjectsQueryKey>>({
    queryFn: async ({ queryKey, signal }) => {
        const { data } = await serenDbListProjects({
            ...options,
            ...queryKey[0],
            signal,
            throwOnError: true
        });
        return data;
    },
    queryKey: serenDbListProjectsQueryKey(options)
});

/**
 * Create a new SerenDB project.
 */
export const serenDbCreateProjectMutation = (options?: Partial<Options<SerenDbCreateProjectData>>): MutationOptions<SerenDbCreateProjectResponse, DefaultError, Options<SerenDbCreateProjectData>> => {
    const mutationOptions: MutationOptions<SerenDbCreateProjectResponse, DefaultError, Options<SerenDbCreateProjectData>> = {
        mutationFn: async (fnOptions) => {
            const { data } = await serenDbCreateProject({
                ...options,
                ...fnOptions,
                throwOnError: true
            });
            return data;
        }
    };
    return mutationOptions;
};

/**
 * Delete a project.
 */
export const serenDbDeleteProjectMutation = (options?: Partial<Options<SerenDbDeleteProjectData>>): MutationOptions<SerenDbDeleteProjectResponse, DefaultError, Options<SerenDbDeleteProjectData>> => {
    const mutationOptions: MutationOptions<SerenDbDeleteProjectResponse, DefaultError, Options<SerenDbDeleteProjectData>> = {
        mutationFn: async (fnOptions) => {
            const { data } = await serenDbDeleteProject({
                ...options,
                ...fnOptions,
                throwOnError: true
            });
            return data;
        }
    };
    return mutationOptions;
};

export const serenDbGetProjectQueryKey = (options: Options<SerenDbGetProjectData>) => createQueryKey('serenDbGetProject', options);

/**
 * Get a project by ID.
 */
export const serenDbGetProjectOptions = (options: Options<SerenDbGetProjectData>) => queryOptions<SerenDbGetProjectResponse, DefaultError, SerenDbGetProjectResponse, ReturnType<typeof serenDbGetProjectQueryKey>>({
    queryFn: async ({ queryKey, signal }) => {
        const { data } = await serenDbGetProject({
            ...options,
            ...queryKey[0],
            signal,
            throwOnError: true
        });
        return data;
    },
    queryKey: serenDbGetProjectQueryKey(options)
});

/**
 * Update a project.
 */
export const serenDbUpdateProjectMutation = (options?: Partial<Options<SerenDbUpdateProjectData>>): MutationOptions<SerenDbUpdateProjectResponse, DefaultError, Options<SerenDbUpdateProjectData>> => {
    const mutationOptions: MutationOptions<SerenDbUpdateProjectResponse, DefaultError, Options<SerenDbUpdateProjectData>> = {
        mutationFn: async (fnOptions) => {
            const { data } = await serenDbUpdateProject({
                ...options,
                ...fnOptions,
                throwOnError: true
            });
            return data;
        }
    };
    return mutationOptions;
};

export const serenDbListBranchProtectionRulesQueryKey = (options: Options<SerenDbListBranchProtectionRulesData>) => createQueryKey('serenDbListBranchProtectionRules', options);

/**
 * List branch protection rules for a project.
 */
export const serenDbListBranchProtectionRulesOptions = (options: Options<SerenDbListBranchProtectionRulesData>) => queryOptions<SerenDbListBranchProtectionRulesResponse, DefaultError, SerenDbListBranchProtectionRulesResponse, ReturnType<typeof serenDbListBranchProtectionRulesQueryKey>>({
    queryFn: async ({ queryKey, signal }) => {
        const { data } = await serenDbListBranchProtectionRules({
            ...options,
            ...queryKey[0],
            signal,
            throwOnError: true
        });
        return data;
    },
    queryKey: serenDbListBranchProtectionRulesQueryKey(options)
});

export const serenDbListBranchesQueryKey = (options: Options<SerenDbListBranchesData>) => createQueryKey('serenDbListBranches', options);

/**
 * List all branches in a project.
 */
export const serenDbListBranchesOptions = (options: Options<SerenDbListBranchesData>) => queryOptions<SerenDbListBranchesResponse, DefaultError, SerenDbListBranchesResponse, ReturnType<typeof serenDbListBranchesQueryKey>>({
    queryFn: async ({ queryKey, signal }) => {
        const { data } = await serenDbListBranches({
            ...options,
            ...queryKey[0],
            signal,
            throwOnError: true
        });
        return data;
    },
    queryKey: serenDbListBranchesQueryKey(options)
});

/**
 * Create a new branch in a project.
 */
export const serenDbCreateBranchMutation = (options?: Partial<Options<SerenDbCreateBranchData>>): MutationOptions<SerenDbCreateBranchResponse, DefaultError, Options<SerenDbCreateBranchData>> => {
    const mutationOptions: MutationOptions<SerenDbCreateBranchResponse, DefaultError, Options<SerenDbCreateBranchData>> = {
        mutationFn: async (fnOptions) => {
            const { data } = await serenDbCreateBranch({
                ...options,
                ...fnOptions,
                throwOnError: true
            });
            return data;
        }
    };
    return mutationOptions;
};

export const serenDbGetBranchCountQueryKey = (options: Options<SerenDbGetBranchCountData>) => createQueryKey('serenDbGetBranchCount', options);

/**
 * Get branch count for a project.
 */
export const serenDbGetBranchCountOptions = (options: Options<SerenDbGetBranchCountData>) => queryOptions<SerenDbGetBranchCountResponse, DefaultError, SerenDbGetBranchCountResponse, ReturnType<typeof serenDbGetBranchCountQueryKey>>({
    queryFn: async ({ queryKey, signal }) => {
        const { data } = await serenDbGetBranchCount({
            ...options,
            ...queryKey[0],
            signal,
            throwOnError: true
        });
        return data;
    },
    queryKey: serenDbGetBranchCountQueryKey(options)
});

/**
 * Delete a branch.
 */
export const serenDbDeleteBranchMutation = (options?: Partial<Options<SerenDbDeleteBranchData>>): MutationOptions<SerenDbDeleteBranchResponse, DefaultError, Options<SerenDbDeleteBranchData>> => {
    const mutationOptions: MutationOptions<SerenDbDeleteBranchResponse, DefaultError, Options<SerenDbDeleteBranchData>> = {
        mutationFn: async (fnOptions) => {
            const { data } = await serenDbDeleteBranch({
                ...options,
                ...fnOptions,
                throwOnError: true
            });
            return data;
        }
    };
    return mutationOptions;
};

export const serenDbGetBranchQueryKey = (options: Options<SerenDbGetBranchData>) => createQueryKey('serenDbGetBranch', options);

/**
 * Get a specific branch.
 */
export const serenDbGetBranchOptions = (options: Options<SerenDbGetBranchData>) => queryOptions<SerenDbGetBranchResponse, DefaultError, SerenDbGetBranchResponse, ReturnType<typeof serenDbGetBranchQueryKey>>({
    queryFn: async ({ queryKey, signal }) => {
        const { data } = await serenDbGetBranch({
            ...options,
            ...queryKey[0],
            signal,
            throwOnError: true
        });
        return data;
    },
    queryKey: serenDbGetBranchQueryKey(options)
});

/**
 * Rename a branch.
 */
export const serenDbRenameBranchMutation = (options?: Partial<Options<SerenDbRenameBranchData>>): MutationOptions<SerenDbRenameBranchResponse, DefaultError, Options<SerenDbRenameBranchData>> => {
    const mutationOptions: MutationOptions<SerenDbRenameBranchResponse, DefaultError, Options<SerenDbRenameBranchData>> = {
        mutationFn: async (fnOptions) => {
            const { data } = await serenDbRenameBranch({
                ...options,
                ...fnOptions,
                throwOnError: true
            });
            return data;
        }
    };
    return mutationOptions;
};

/**
 * Set a branch archived state.
 */
export const serenDbSetBranchArchivedMutation = (options?: Partial<Options<SerenDbSetBranchArchivedData>>): MutationOptions<SerenDbSetBranchArchivedResponse, DefaultError, Options<SerenDbSetBranchArchivedData>> => {
    const mutationOptions: MutationOptions<SerenDbSetBranchArchivedResponse, DefaultError, Options<SerenDbSetBranchArchivedData>> = {
        mutationFn: async (fnOptions) => {
            const { data } = await serenDbSetBranchArchived({
                ...options,
                ...fnOptions,
                throwOnError: true
            });
            return data;
        }
    };
    return mutationOptions;
};

export const serenDbGetConnectionStringQueryKey = (options: Options<SerenDbGetConnectionStringData>) => createQueryKey('serenDbGetConnectionString', options);

/**
 * Get a branch connection string.
 */
export const serenDbGetConnectionStringOptions = (options: Options<SerenDbGetConnectionStringData>) => queryOptions<SerenDbGetConnectionStringResponse, DefaultError, SerenDbGetConnectionStringResponse, ReturnType<typeof serenDbGetConnectionStringQueryKey>>({
    queryFn: async ({ queryKey, signal }) => {
        const { data } = await serenDbGetConnectionString({
            ...options,
            ...queryKey[0],
            signal,
            throwOnError: true
        });
        return data;
    },
    queryKey: serenDbGetConnectionStringQueryKey(options)
});

export const serenDbListDatabasesQueryKey = (options: Options<SerenDbListDatabasesData>) => createQueryKey('serenDbListDatabases', options);

/**
 * List all databases on a branch.
 */
export const serenDbListDatabasesOptions = (options: Options<SerenDbListDatabasesData>) => queryOptions<SerenDbListDatabasesResponse, DefaultError, SerenDbListDatabasesResponse, ReturnType<typeof serenDbListDatabasesQueryKey>>({
    queryFn: async ({ queryKey, signal }) => {
        const { data } = await serenDbListDatabases({
            ...options,
            ...queryKey[0],
            signal,
            throwOnError: true
        });
        return data;
    },
    queryKey: serenDbListDatabasesQueryKey(options)
});

/**
 * Create a new database on a branch.
 */
export const serenDbCreateDatabaseMutation = (options?: Partial<Options<SerenDbCreateDatabaseData>>): MutationOptions<SerenDbCreateDatabaseResponse, DefaultError, Options<SerenDbCreateDatabaseData>> => {
    const mutationOptions: MutationOptions<SerenDbCreateDatabaseResponse, DefaultError, Options<SerenDbCreateDatabaseData>> = {
        mutationFn: async (fnOptions) => {
            const { data } = await serenDbCreateDatabase({
                ...options,
                ...fnOptions,
                throwOnError: true
            });
            return data;
        }
    };
    return mutationOptions;
};

/**
 * Delete a database.
 */
export const serenDbDeleteDatabaseMutation = (options?: Partial<Options<SerenDbDeleteDatabaseData>>): MutationOptions<SerenDbDeleteDatabaseResponse, DefaultError, Options<SerenDbDeleteDatabaseData>> => {
    const mutationOptions: MutationOptions<SerenDbDeleteDatabaseResponse, DefaultError, Options<SerenDbDeleteDatabaseData>> = {
        mutationFn: async (fnOptions) => {
            const { data } = await serenDbDeleteDatabase({
                ...options,
                ...fnOptions,
                throwOnError: true
            });
            return data;
        }
    };
    return mutationOptions;
};

export const serenDbGetDatabaseQueryKey = (options: Options<SerenDbGetDatabaseData>) => createQueryKey('serenDbGetDatabase', options);

/**
 * Get a specific database.
 */
export const serenDbGetDatabaseOptions = (options: Options<SerenDbGetDatabaseData>) => queryOptions<SerenDbGetDatabaseResponse, DefaultError, SerenDbGetDatabaseResponse, ReturnType<typeof serenDbGetDatabaseQueryKey>>({
    queryFn: async ({ queryKey, signal }) => {
        const { data } = await serenDbGetDatabase({
            ...options,
            ...queryKey[0],
            signal,
            throwOnError: true
        });
        return data;
    },
    queryKey: serenDbGetDatabaseQueryKey(options)
});

/**
 * Update a database (change owner).
 */
export const serenDbUpdateDatabaseMutation = (options?: Partial<Options<SerenDbUpdateDatabaseData>>): MutationOptions<SerenDbUpdateDatabaseResponse, DefaultError, Options<SerenDbUpdateDatabaseData>> => {
    const mutationOptions: MutationOptions<SerenDbUpdateDatabaseResponse, DefaultError, Options<SerenDbUpdateDatabaseData>> = {
        mutationFn: async (fnOptions) => {
            const { data } = await serenDbUpdateDatabase({
                ...options,
                ...fnOptions,
                throwOnError: true
            });
            return data;
        }
    };
    return mutationOptions;
};

export const serenDbGetBranchDetailsQueryKey = (options: Options<SerenDbGetBranchDetailsData>) => createQueryKey('serenDbGetBranchDetails', options);

/**
 * Get branch details.
 */
export const serenDbGetBranchDetailsOptions = (options: Options<SerenDbGetBranchDetailsData>) => queryOptions<SerenDbGetBranchDetailsResponse, DefaultError, SerenDbGetBranchDetailsResponse, ReturnType<typeof serenDbGetBranchDetailsQueryKey>>({
    queryFn: async ({ queryKey, signal }) => {
        const { data } = await serenDbGetBranchDetails({
            ...options,
            ...queryKey[0],
            signal,
            throwOnError: true
        });
        return data;
    },
    queryKey: serenDbGetBranchDetailsQueryKey(options)
});

export const serenDbListEndpointsQueryKey = (options: Options<SerenDbListEndpointsData>) => createQueryKey('serenDbListEndpoints', options);

/**
 * List all endpoints on a branch.
 */
export const serenDbListEndpointsOptions = (options: Options<SerenDbListEndpointsData>) => queryOptions<SerenDbListEndpointsResponse, DefaultError, SerenDbListEndpointsResponse, ReturnType<typeof serenDbListEndpointsQueryKey>>({
    queryFn: async ({ queryKey, signal }) => {
        const { data } = await serenDbListEndpoints({
            ...options,
            ...queryKey[0],
            signal,
            throwOnError: true
        });
        return data;
    },
    queryKey: serenDbListEndpointsQueryKey(options)
});

/**
 * Create a new compute endpoint on a branch.
 */
export const serenDbCreateEndpointMutation = (options?: Partial<Options<SerenDbCreateEndpointData>>): MutationOptions<SerenDbCreateEndpointResponse, DefaultError, Options<SerenDbCreateEndpointData>> => {
    const mutationOptions: MutationOptions<SerenDbCreateEndpointResponse, DefaultError, Options<SerenDbCreateEndpointData>> = {
        mutationFn: async (fnOptions) => {
            const { data } = await serenDbCreateEndpoint({
                ...options,
                ...fnOptions,
                throwOnError: true
            });
            return data;
        }
    };
    return mutationOptions;
};

/**
 * Delete an endpoint.
 */
export const serenDbDeleteEndpointMutation = (options?: Partial<Options<SerenDbDeleteEndpointData>>): MutationOptions<SerenDbDeleteEndpointResponse, DefaultError, Options<SerenDbDeleteEndpointData>> => {
    const mutationOptions: MutationOptions<SerenDbDeleteEndpointResponse, DefaultError, Options<SerenDbDeleteEndpointData>> = {
        mutationFn: async (fnOptions) => {
            const { data } = await serenDbDeleteEndpoint({
                ...options,
                ...fnOptions,
                throwOnError: true
            });
            return data;
        }
    };
    return mutationOptions;
};

/**
 * Update an endpoint's settings.
 */
export const serenDbUpdateEndpointMutation = (options?: Partial<Options<SerenDbUpdateEndpointData>>): MutationOptions<SerenDbUpdateEndpointResponse, DefaultError, Options<SerenDbUpdateEndpointData>> => {
    const mutationOptions: MutationOptions<SerenDbUpdateEndpointResponse, DefaultError, Options<SerenDbUpdateEndpointData>> = {
        mutationFn: async (fnOptions) => {
            const { data } = await serenDbUpdateEndpoint({
                ...options,
                ...fnOptions,
                throwOnError: true
            });
            return data;
        }
    };
    return mutationOptions;
};

export const serenDbGetEndpointHealthQueryKey = (options: Options<SerenDbGetEndpointHealthData>) => createQueryKey('serenDbGetEndpointHealth', options);

/**
 * Get endpoint health.
 */
export const serenDbGetEndpointHealthOptions = (options: Options<SerenDbGetEndpointHealthData>) => queryOptions<SerenDbGetEndpointHealthResponse, DefaultError, SerenDbGetEndpointHealthResponse, ReturnType<typeof serenDbGetEndpointHealthQueryKey>>({
    queryFn: async ({ queryKey, signal }) => {
        const { data } = await serenDbGetEndpointHealth({
            ...options,
            ...queryKey[0],
            signal,
            throwOnError: true
        });
        return data;
    },
    queryKey: serenDbGetEndpointHealthQueryKey(options)
});

export const serenDbGetEndpointMetricsQueryKey = (options: Options<SerenDbGetEndpointMetricsData>) => createQueryKey('serenDbGetEndpointMetrics', options);

/**
 * Get endpoint metrics.
 */
export const serenDbGetEndpointMetricsOptions = (options: Options<SerenDbGetEndpointMetricsData>) => queryOptions<SerenDbGetEndpointMetricsResponse, DefaultError, SerenDbGetEndpointMetricsResponse, ReturnType<typeof serenDbGetEndpointMetricsQueryKey>>({
    queryFn: async ({ queryKey, signal }) => {
        const { data } = await serenDbGetEndpointMetrics({
            ...options,
            ...queryKey[0],
            signal,
            throwOnError: true
        });
        return data;
    },
    queryKey: serenDbGetEndpointMetricsQueryKey(options)
});

/**
 * Start a suspended endpoint.
 */
export const serenDbStartEndpointMutation = (options?: Partial<Options<SerenDbStartEndpointData>>): MutationOptions<SerenDbStartEndpointResponse, DefaultError, Options<SerenDbStartEndpointData>> => {
    const mutationOptions: MutationOptions<SerenDbStartEndpointResponse, DefaultError, Options<SerenDbStartEndpointData>> = {
        mutationFn: async (fnOptions) => {
            const { data } = await serenDbStartEndpoint({
                ...options,
                ...fnOptions,
                throwOnError: true
            });
            return data;
        }
    };
    return mutationOptions;
};

export const serenDbGetEndpointStatusQueryKey = (options: Options<SerenDbGetEndpointStatusData>) => createQueryKey('serenDbGetEndpointStatus', options);

/**
 * Get endpoint status.
 */
export const serenDbGetEndpointStatusOptions = (options: Options<SerenDbGetEndpointStatusData>) => queryOptions<SerenDbGetEndpointStatusResponse, DefaultError, SerenDbGetEndpointStatusResponse, ReturnType<typeof serenDbGetEndpointStatusQueryKey>>({
    queryFn: async ({ queryKey, signal }) => {
        const { data } = await serenDbGetEndpointStatus({
            ...options,
            ...queryKey[0],
            signal,
            throwOnError: true
        });
        return data;
    },
    queryKey: serenDbGetEndpointStatusQueryKey(options)
});

/**
 * Stop (suspend) an endpoint.
 */
export const serenDbStopEndpointMutation = (options?: Partial<Options<SerenDbStopEndpointData>>): MutationOptions<SerenDbStopEndpointResponse, DefaultError, Options<SerenDbStopEndpointData>> => {
    const mutationOptions: MutationOptions<SerenDbStopEndpointResponse, DefaultError, Options<SerenDbStopEndpointData>> = {
        mutationFn: async (fnOptions) => {
            const { data } = await serenDbStopEndpoint({
                ...options,
                ...fnOptions,
                throwOnError: true
            });
            return data;
        }
    };
    return mutationOptions;
};

/**
 * Set branch expiration.
 */
export const serenDbSetBranchExpirationMutation = (options?: Partial<Options<SerenDbSetBranchExpirationData>>): MutationOptions<SerenDbSetBranchExpirationResponse, DefaultError, Options<SerenDbSetBranchExpirationData>> => {
    const mutationOptions: MutationOptions<SerenDbSetBranchExpirationResponse, DefaultError, Options<SerenDbSetBranchExpirationData>> = {
        mutationFn: async (fnOptions) => {
            const { data } = await serenDbSetBranchExpiration({
                ...options,
                ...fnOptions,
                throwOnError: true
            });
            return data;
        }
    };
    return mutationOptions;
};

export const serenDbGetLsnByTimestampQueryKey = (options: Options<SerenDbGetLsnByTimestampData>) => createQueryKey('serenDbGetLsnByTimestamp', options);

/**
 * Get LSN by timestamp for a branch.
 */
export const serenDbGetLsnByTimestampOptions = (options: Options<SerenDbGetLsnByTimestampData>) => queryOptions<SerenDbGetLsnByTimestampResponse, DefaultError, SerenDbGetLsnByTimestampResponse, ReturnType<typeof serenDbGetLsnByTimestampQueryKey>>({
    queryFn: async ({ queryKey, signal }) => {
        const { data } = await serenDbGetLsnByTimestamp({
            ...options,
            ...queryKey[0],
            signal,
            throwOnError: true
        });
        return data;
    },
    queryKey: serenDbGetLsnByTimestampQueryKey(options)
});

/**
 * Delete branch protection rule for a branch.
 */
export const serenDbDeleteBranchProtectionMutation = (options?: Partial<Options<SerenDbDeleteBranchProtectionData>>): MutationOptions<SerenDbDeleteBranchProtectionResponse, DefaultError, Options<SerenDbDeleteBranchProtectionData>> => {
    const mutationOptions: MutationOptions<SerenDbDeleteBranchProtectionResponse, DefaultError, Options<SerenDbDeleteBranchProtectionData>> = {
        mutationFn: async (fnOptions) => {
            const { data } = await serenDbDeleteBranchProtection({
                ...options,
                ...fnOptions,
                throwOnError: true
            });
            return data;
        }
    };
    return mutationOptions;
};

export const serenDbGetBranchProtectionQueryKey = (options: Options<SerenDbGetBranchProtectionData>) => createQueryKey('serenDbGetBranchProtection', options);

/**
 * Get branch protection rule for a branch.
 */
export const serenDbGetBranchProtectionOptions = (options: Options<SerenDbGetBranchProtectionData>) => queryOptions<SerenDbGetBranchProtectionResponse, DefaultError, SerenDbGetBranchProtectionResponse, ReturnType<typeof serenDbGetBranchProtectionQueryKey>>({
    queryFn: async ({ queryKey, signal }) => {
        const { data } = await serenDbGetBranchProtection({
            ...options,
            ...queryKey[0],
            signal,
            throwOnError: true
        });
        return data;
    },
    queryKey: serenDbGetBranchProtectionQueryKey(options)
});

/**
 * Update branch protection rule for a branch.
 */
export const serenDbUpdateBranchProtectionMutation = (options?: Partial<Options<SerenDbUpdateBranchProtectionData>>): MutationOptions<SerenDbUpdateBranchProtectionResponse, DefaultError, Options<SerenDbUpdateBranchProtectionData>> => {
    const mutationOptions: MutationOptions<SerenDbUpdateBranchProtectionResponse, DefaultError, Options<SerenDbUpdateBranchProtectionData>> = {
        mutationFn: async (fnOptions) => {
            const { data } = await serenDbUpdateBranchProtection({
                ...options,
                ...fnOptions,
                throwOnError: true
            });
            return data;
        }
    };
    return mutationOptions;
};

/**
 * Create branch protection rule for a branch.
 */
export const serenDbCreateBranchProtectionMutation = (options?: Partial<Options<SerenDbCreateBranchProtectionData>>): MutationOptions<SerenDbCreateBranchProtectionResponse, DefaultError, Options<SerenDbCreateBranchProtectionData>> => {
    const mutationOptions: MutationOptions<SerenDbCreateBranchProtectionResponse, DefaultError, Options<SerenDbCreateBranchProtectionData>> = {
        mutationFn: async (fnOptions) => {
            const { data } = await serenDbCreateBranchProtection({
                ...options,
                ...fnOptions,
                throwOnError: true
            });
            return data;
        }
    };
    return mutationOptions;
};

export const serenDbListPublicationsQueryKey = (options: Options<SerenDbListPublicationsData>) => createQueryKey('serenDbListPublications', options);

/**
 * List publications for a branch.
 */
export const serenDbListPublicationsOptions = (options: Options<SerenDbListPublicationsData>) => queryOptions<SerenDbListPublicationsResponse, DefaultError, SerenDbListPublicationsResponse, ReturnType<typeof serenDbListPublicationsQueryKey>>({
    queryFn: async ({ queryKey, signal }) => {
        const { data } = await serenDbListPublications({
            ...options,
            ...queryKey[0],
            signal,
            throwOnError: true
        });
        return data;
    },
    queryKey: serenDbListPublicationsQueryKey(options)
});

/**
 * Create a publication for a branch.
 */
export const serenDbCreatePublicationMutation = (options?: Partial<Options<SerenDbCreatePublicationData>>): MutationOptions<SerenDbCreatePublicationResponse, DefaultError, Options<SerenDbCreatePublicationData>> => {
    const mutationOptions: MutationOptions<SerenDbCreatePublicationResponse, DefaultError, Options<SerenDbCreatePublicationData>> = {
        mutationFn: async (fnOptions) => {
            const { data } = await serenDbCreatePublication({
                ...options,
                ...fnOptions,
                throwOnError: true
            });
            return data;
        }
    };
    return mutationOptions;
};

/**
 * Delete a publication from a branch.
 */
export const serenDbDeletePublicationMutation = (options?: Partial<Options<SerenDbDeletePublicationData>>): MutationOptions<SerenDbDeletePublicationResponse, DefaultError, Options<SerenDbDeletePublicationData>> => {
    const mutationOptions: MutationOptions<SerenDbDeletePublicationResponse, DefaultError, Options<SerenDbDeletePublicationData>> = {
        mutationFn: async (fnOptions) => {
            const { data } = await serenDbDeletePublication({
                ...options,
                ...fnOptions,
                throwOnError: true
            });
            return data;
        }
    };
    return mutationOptions;
};

/**
 * Update a publication for a branch.
 */
export const serenDbUpdatePublicationMutation = (options?: Partial<Options<SerenDbUpdatePublicationData>>): MutationOptions<SerenDbUpdatePublicationResponse, DefaultError, Options<SerenDbUpdatePublicationData>> => {
    const mutationOptions: MutationOptions<SerenDbUpdatePublicationResponse, DefaultError, Options<SerenDbUpdatePublicationData>> = {
        mutationFn: async (fnOptions) => {
            const { data } = await serenDbUpdatePublication({
                ...options,
                ...fnOptions,
                throwOnError: true
            });
            return data;
        }
    };
    return mutationOptions;
};

export const serenDbListReplicationSlotsQueryKey = (options: Options<SerenDbListReplicationSlotsData>) => createQueryKey('serenDbListReplicationSlots', options);

/**
 * List replication slots for a branch.
 */
export const serenDbListReplicationSlotsOptions = (options: Options<SerenDbListReplicationSlotsData>) => queryOptions<SerenDbListReplicationSlotsResponse, DefaultError, SerenDbListReplicationSlotsResponse, ReturnType<typeof serenDbListReplicationSlotsQueryKey>>({
    queryFn: async ({ queryKey, signal }) => {
        const { data } = await serenDbListReplicationSlots({
            ...options,
            ...queryKey[0],
            signal,
            throwOnError: true
        });
        return data;
    },
    queryKey: serenDbListReplicationSlotsQueryKey(options)
});

/**
 * Create a replication slot for a branch.
 */
export const serenDbCreateReplicationSlotMutation = (options?: Partial<Options<SerenDbCreateReplicationSlotData>>): MutationOptions<SerenDbCreateReplicationSlotResponse, DefaultError, Options<SerenDbCreateReplicationSlotData>> => {
    const mutationOptions: MutationOptions<SerenDbCreateReplicationSlotResponse, DefaultError, Options<SerenDbCreateReplicationSlotData>> = {
        mutationFn: async (fnOptions) => {
            const { data } = await serenDbCreateReplicationSlot({
                ...options,
                ...fnOptions,
                throwOnError: true
            });
            return data;
        }
    };
    return mutationOptions;
};

/**
 * Delete a replication slot from a branch.
 */
export const serenDbDeleteReplicationSlotMutation = (options?: Partial<Options<SerenDbDeleteReplicationSlotData>>): MutationOptions<SerenDbDeleteReplicationSlotResponse, DefaultError, Options<SerenDbDeleteReplicationSlotData>> => {
    const mutationOptions: MutationOptions<SerenDbDeleteReplicationSlotResponse, DefaultError, Options<SerenDbDeleteReplicationSlotData>> = {
        mutationFn: async (fnOptions) => {
            const { data } = await serenDbDeleteReplicationSlot({
                ...options,
                ...fnOptions,
                throwOnError: true
            });
            return data;
        }
    };
    return mutationOptions;
};

/**
 * Reset a branch.
 */
export const serenDbResetBranchMutation = (options?: Partial<Options<SerenDbResetBranchData>>): MutationOptions<SerenDbResetBranchResponse, DefaultError, Options<SerenDbResetBranchData>> => {
    const mutationOptions: MutationOptions<SerenDbResetBranchResponse, DefaultError, Options<SerenDbResetBranchData>> = {
        mutationFn: async (fnOptions) => {
            const { data } = await serenDbResetBranch({
                ...options,
                ...fnOptions,
                throwOnError: true
            });
            return data;
        }
    };
    return mutationOptions;
};

/**
 * Restore a branch.
 */
export const serenDbRestoreBranchMutation = (options?: Partial<Options<SerenDbRestoreBranchData>>): MutationOptions<SerenDbRestoreBranchResponse, DefaultError, Options<SerenDbRestoreBranchData>> => {
    const mutationOptions: MutationOptions<SerenDbRestoreBranchResponse, DefaultError, Options<SerenDbRestoreBranchData>> = {
        mutationFn: async (fnOptions) => {
            const { data } = await serenDbRestoreBranch({
                ...options,
                ...fnOptions,
                throwOnError: true
            });
            return data;
        }
    };
    return mutationOptions;
};

export const serenDbListRolesQueryKey = (options: Options<SerenDbListRolesData>) => createQueryKey('serenDbListRoles', options);

/**
 * List all roles on a branch.
 */
export const serenDbListRolesOptions = (options: Options<SerenDbListRolesData>) => queryOptions<SerenDbListRolesResponse, DefaultError, SerenDbListRolesResponse, ReturnType<typeof serenDbListRolesQueryKey>>({
    queryFn: async ({ queryKey, signal }) => {
        const { data } = await serenDbListRoles({
            ...options,
            ...queryKey[0],
            signal,
            throwOnError: true
        });
        return data;
    },
    queryKey: serenDbListRolesQueryKey(options)
});

/**
 * Create a new role on a branch.
 */
export const serenDbCreateRoleMutation = (options?: Partial<Options<SerenDbCreateRoleData>>): MutationOptions<SerenDbCreateRoleResponse, DefaultError, Options<SerenDbCreateRoleData>> => {
    const mutationOptions: MutationOptions<SerenDbCreateRoleResponse, DefaultError, Options<SerenDbCreateRoleData>> = {
        mutationFn: async (fnOptions) => {
            const { data } = await serenDbCreateRole({
                ...options,
                ...fnOptions,
                throwOnError: true
            });
            return data;
        }
    };
    return mutationOptions;
};

/**
 * Delete a role from a branch.
 */
export const serenDbDeleteRoleMutation = (options?: Partial<Options<SerenDbDeleteRoleData>>): MutationOptions<SerenDbDeleteRoleResponse, DefaultError, Options<SerenDbDeleteRoleData>> => {
    const mutationOptions: MutationOptions<SerenDbDeleteRoleResponse, DefaultError, Options<SerenDbDeleteRoleData>> = {
        mutationFn: async (fnOptions) => {
            const { data } = await serenDbDeleteRole({
                ...options,
                ...fnOptions,
                throwOnError: true
            });
            return data;
        }
    };
    return mutationOptions;
};

/**
 * Reset a role's password.
 */
export const serenDbResetRolePasswordMutation = (options?: Partial<Options<SerenDbResetRolePasswordData>>): MutationOptions<SerenDbResetRolePasswordResponse, DefaultError, Options<SerenDbResetRolePasswordData>> => {
    const mutationOptions: MutationOptions<SerenDbResetRolePasswordResponse, DefaultError, Options<SerenDbResetRolePasswordData>> = {
        mutationFn: async (fnOptions) => {
            const { data } = await serenDbResetRolePassword({
                ...options,
                ...fnOptions,
                throwOnError: true
            });
            return data;
        }
    };
    return mutationOptions;
};

export const serenDbRevealRolePasswordQueryKey = (options: Options<SerenDbRevealRolePasswordData>) => createQueryKey('serenDbRevealRolePassword', options);

/**
 * Reveal a role password by role name.
 */
export const serenDbRevealRolePasswordOptions = (options: Options<SerenDbRevealRolePasswordData>) => queryOptions<SerenDbRevealRolePasswordResponse, DefaultError, SerenDbRevealRolePasswordResponse, ReturnType<typeof serenDbRevealRolePasswordQueryKey>>({
    queryFn: async ({ queryKey, signal }) => {
        const { data } = await serenDbRevealRolePassword({
            ...options,
            ...queryKey[0],
            signal,
            throwOnError: true
        });
        return data;
    },
    queryKey: serenDbRevealRolePasswordQueryKey(options)
});

/**
 * Set a branch as the default for its project.
 */
export const serenDbSetDefaultBranchMutation = (options?: Partial<Options<SerenDbSetDefaultBranchData>>): MutationOptions<SerenDbSetDefaultBranchResponse, DefaultError, Options<SerenDbSetDefaultBranchData>> => {
    const mutationOptions: MutationOptions<SerenDbSetDefaultBranchResponse, DefaultError, Options<SerenDbSetDefaultBranchData>> = {
        mutationFn: async (fnOptions) => {
            const { data } = await serenDbSetDefaultBranch({
                ...options,
                ...fnOptions,
                throwOnError: true
            });
            return data;
        }
    };
    return mutationOptions;
};

/**
 * Set a branch as default using set_as_default alias.
 */
export const serenDbSetDefaultBranchAliasMutation = (options?: Partial<Options<SerenDbSetDefaultBranchAliasData>>): MutationOptions<SerenDbSetDefaultBranchAliasResponse, DefaultError, Options<SerenDbSetDefaultBranchAliasData>> => {
    const mutationOptions: MutationOptions<SerenDbSetDefaultBranchAliasResponse, DefaultError, Options<SerenDbSetDefaultBranchAliasData>> = {
        mutationFn: async (fnOptions) => {
            const { data } = await serenDbSetDefaultBranchAlias({
                ...options,
                ...fnOptions,
                throwOnError: true
            });
            return data;
        }
    };
    return mutationOptions;
};

export const serenDbGetTimestampByLsnQueryKey = (options: Options<SerenDbGetTimestampByLsnData>) => createQueryKey('serenDbGetTimestampByLsn', options);

/**
 * Get timestamp by LSN for a branch.
 */
export const serenDbGetTimestampByLsnOptions = (options: Options<SerenDbGetTimestampByLsnData>) => queryOptions<SerenDbGetTimestampByLsnResponse, DefaultError, SerenDbGetTimestampByLsnResponse, ReturnType<typeof serenDbGetTimestampByLsnQueryKey>>({
    queryFn: async ({ queryKey, signal }) => {
        const { data } = await serenDbGetTimestampByLsn({
            ...options,
            ...queryKey[0],
            signal,
            throwOnError: true
        });
        return data;
    },
    queryKey: serenDbGetTimestampByLsnQueryKey(options)
});

export const serenDbConnectionUriQueryKey = (options: Options<SerenDbConnectionUriData>) => createQueryKey('serenDbConnectionUri', options);

/**
 * Get connection URI for a project.
 */
export const serenDbConnectionUriOptions = (options: Options<SerenDbConnectionUriData>) => queryOptions<SerenDbConnectionUriResponse, DefaultError, SerenDbConnectionUriResponse, ReturnType<typeof serenDbConnectionUriQueryKey>>({
    queryFn: async ({ queryKey, signal }) => {
        const { data } = await serenDbConnectionUri({
            ...options,
            ...queryKey[0],
            signal,
            throwOnError: true
        });
        return data;
    },
    queryKey: serenDbConnectionUriQueryKey(options)
});

export const serenDbGetProjectConsumptionQueryKey = (options: Options<SerenDbGetProjectConsumptionData>) => createQueryKey('serenDbGetProjectConsumption', options);

/**
 * Get consumption for a project.
 */
export const serenDbGetProjectConsumptionOptions = (options: Options<SerenDbGetProjectConsumptionData>) => queryOptions<SerenDbGetProjectConsumptionResponse, DefaultError, SerenDbGetProjectConsumptionResponse, ReturnType<typeof serenDbGetProjectConsumptionQueryKey>>({
    queryFn: async ({ queryKey, signal }) => {
        const { data } = await serenDbGetProjectConsumption({
            ...options,
            ...queryKey[0],
            signal,
            throwOnError: true
        });
        return data;
    },
    queryKey: serenDbGetProjectConsumptionQueryKey(options)
});

export const serenDbListProjectDatabasesQueryKey = (options: Options<SerenDbListProjectDatabasesData>) => createQueryKey('serenDbListProjectDatabases', options);

/**
 * List all databases for a project.
 */
export const serenDbListProjectDatabasesOptions = (options: Options<SerenDbListProjectDatabasesData>) => queryOptions<SerenDbListProjectDatabasesResponse, DefaultError, SerenDbListProjectDatabasesResponse, ReturnType<typeof serenDbListProjectDatabasesQueryKey>>({
    queryFn: async ({ queryKey, signal }) => {
        const { data } = await serenDbListProjectDatabases({
            ...options,
            ...queryKey[0],
            signal,
            throwOnError: true
        });
        return data;
    },
    queryKey: serenDbListProjectDatabasesQueryKey(options)
});

export const serenDbListProjectEndpointsQueryKey = (options: Options<SerenDbListProjectEndpointsData>) => createQueryKey('serenDbListProjectEndpoints', options);

/**
 * List all endpoints for a project.
 */
export const serenDbListProjectEndpointsOptions = (options: Options<SerenDbListProjectEndpointsData>) => queryOptions<SerenDbListProjectEndpointsResponse, DefaultError, SerenDbListProjectEndpointsResponse, ReturnType<typeof serenDbListProjectEndpointsQueryKey>>({
    queryFn: async ({ queryKey, signal }) => {
        const { data } = await serenDbListProjectEndpoints({
            ...options,
            ...queryKey[0],
            signal,
            throwOnError: true
        });
        return data;
    },
    queryKey: serenDbListProjectEndpointsQueryKey(options)
});

/**
 * Delete a project endpoint.
 */
export const serenDbDeleteProjectEndpointMutation = (options?: Partial<Options<SerenDbDeleteProjectEndpointData>>): MutationOptions<SerenDbDeleteProjectEndpointResponse, DefaultError, Options<SerenDbDeleteProjectEndpointData>> => {
    const mutationOptions: MutationOptions<SerenDbDeleteProjectEndpointResponse, DefaultError, Options<SerenDbDeleteProjectEndpointData>> = {
        mutationFn: async (fnOptions) => {
            const { data } = await serenDbDeleteProjectEndpoint({
                ...options,
                ...fnOptions,
                throwOnError: true
            });
            return data;
        }
    };
    return mutationOptions;
};

/**
 * Update a project endpoint.
 */
export const serenDbUpdateProjectEndpointMutation = (options?: Partial<Options<SerenDbUpdateProjectEndpointData>>): MutationOptions<SerenDbUpdateProjectEndpointResponse, DefaultError, Options<SerenDbUpdateProjectEndpointData>> => {
    const mutationOptions: MutationOptions<SerenDbUpdateProjectEndpointResponse, DefaultError, Options<SerenDbUpdateProjectEndpointData>> = {
        mutationFn: async (fnOptions) => {
            const { data } = await serenDbUpdateProjectEndpoint({
                ...options,
                ...fnOptions,
                throwOnError: true
            });
            return data;
        }
    };
    return mutationOptions;
};

/**
 * Restart an endpoint by project and endpoint ID.
 */
export const serenDbRestartEndpointMutation = (options?: Partial<Options<SerenDbRestartEndpointData>>): MutationOptions<SerenDbRestartEndpointResponse, DefaultError, Options<SerenDbRestartEndpointData>> => {
    const mutationOptions: MutationOptions<SerenDbRestartEndpointResponse, DefaultError, Options<SerenDbRestartEndpointData>> = {
        mutationFn: async (fnOptions) => {
            const { data } = await serenDbRestartEndpoint({
                ...options,
                ...fnOptions,
                throwOnError: true
            });
            return data;
        }
    };
    return mutationOptions;
};

/**
 * Start a project endpoint.
 */
export const serenDbStartProjectEndpointMutation = (options?: Partial<Options<SerenDbStartProjectEndpointData>>): MutationOptions<SerenDbStartProjectEndpointResponse, DefaultError, Options<SerenDbStartProjectEndpointData>> => {
    const mutationOptions: MutationOptions<SerenDbStartProjectEndpointResponse, DefaultError, Options<SerenDbStartProjectEndpointData>> = {
        mutationFn: async (fnOptions) => {
            const { data } = await serenDbStartProjectEndpoint({
                ...options,
                ...fnOptions,
                throwOnError: true
            });
            return data;
        }
    };
    return mutationOptions;
};

/**
 * Suspend a project endpoint.
 */
export const serenDbSuspendProjectEndpointMutation = (options?: Partial<Options<SerenDbSuspendProjectEndpointData>>): MutationOptions<SerenDbSuspendProjectEndpointResponse, DefaultError, Options<SerenDbSuspendProjectEndpointData>> => {
    const mutationOptions: MutationOptions<SerenDbSuspendProjectEndpointResponse, DefaultError, Options<SerenDbSuspendProjectEndpointData>> = {
        mutationFn: async (fnOptions) => {
            const { data } = await serenDbSuspendProjectEndpoint({
                ...options,
                ...fnOptions,
                throwOnError: true
            });
            return data;
        }
    };
    return mutationOptions;
};

export const serenDbListIpAllowListQueryKey = (options: Options<SerenDbListIpAllowListData>) => createQueryKey('serenDbListIpAllowList', options);

/**
 * List project IP allow list entries.
 */
export const serenDbListIpAllowListOptions = (options: Options<SerenDbListIpAllowListData>) => queryOptions<SerenDbListIpAllowListResponse, DefaultError, SerenDbListIpAllowListResponse, ReturnType<typeof serenDbListIpAllowListQueryKey>>({
    queryFn: async ({ queryKey, signal }) => {
        const { data } = await serenDbListIpAllowList({
            ...options,
            ...queryKey[0],
            signal,
            throwOnError: true
        });
        return data;
    },
    queryKey: serenDbListIpAllowListQueryKey(options)
});

/**
 * Add an IP allow list entry.
 */
export const serenDbAddIpAllowListMutation = (options?: Partial<Options<SerenDbAddIpAllowListData>>): MutationOptions<SerenDbAddIpAllowListResponse, DefaultError, Options<SerenDbAddIpAllowListData>> => {
    const mutationOptions: MutationOptions<SerenDbAddIpAllowListResponse, DefaultError, Options<SerenDbAddIpAllowListData>> = {
        mutationFn: async (fnOptions) => {
            const { data } = await serenDbAddIpAllowList({
                ...options,
                ...fnOptions,
                throwOnError: true
            });
            return data;
        }
    };
    return mutationOptions;
};

/**
 * Replace the project IP allow list.
 */
export const serenDbResetIpAllowListMutation = (options?: Partial<Options<SerenDbResetIpAllowListData>>): MutationOptions<SerenDbResetIpAllowListResponse, DefaultError, Options<SerenDbResetIpAllowListData>> => {
    const mutationOptions: MutationOptions<SerenDbResetIpAllowListResponse, DefaultError, Options<SerenDbResetIpAllowListData>> = {
        mutationFn: async (fnOptions) => {
            const { data } = await serenDbResetIpAllowList({
                ...options,
                ...fnOptions,
                throwOnError: true
            });
            return data;
        }
    };
    return mutationOptions;
};

/**
 * Remove an IP allow list entry.
 */
export const serenDbRemoveIpAllowListMutation = (options?: Partial<Options<SerenDbRemoveIpAllowListData>>): MutationOptions<SerenDbRemoveIpAllowListResponse, DefaultError, Options<SerenDbRemoveIpAllowListData>> => {
    const mutationOptions: MutationOptions<SerenDbRemoveIpAllowListResponse, DefaultError, Options<SerenDbRemoveIpAllowListData>> = {
        mutationFn: async (fnOptions) => {
            const { data } = await serenDbRemoveIpAllowList({
                ...options,
                ...fnOptions,
                throwOnError: true
            });
            return data;
        }
    };
    return mutationOptions;
};

export const serenDbListOperationsQueryKey = (options: Options<SerenDbListOperationsData>) => createQueryKey('serenDbListOperations', options);

/**
 * List operations for a project.
 */
export const serenDbListOperationsOptions = (options: Options<SerenDbListOperationsData>) => queryOptions<SerenDbListOperationsResponse, DefaultError, SerenDbListOperationsResponse, ReturnType<typeof serenDbListOperationsQueryKey>>({
    queryFn: async ({ queryKey, signal }) => {
        const { data } = await serenDbListOperations({
            ...options,
            ...queryKey[0],
            signal,
            throwOnError: true
        });
        return data;
    },
    queryKey: serenDbListOperationsQueryKey(options)
});

export const serenDbGetOperationQueryKey = (options: Options<SerenDbGetOperationData>) => createQueryKey('serenDbGetOperation', options);

/**
 * Get a specific operation for a project.
 */
export const serenDbGetOperationOptions = (options: Options<SerenDbGetOperationData>) => queryOptions<SerenDbGetOperationResponse, DefaultError, SerenDbGetOperationResponse, ReturnType<typeof serenDbGetOperationQueryKey>>({
    queryFn: async ({ queryKey, signal }) => {
        const { data } = await serenDbGetOperation({
            ...options,
            ...queryKey[0],
            signal,
            throwOnError: true
        });
        return data;
    },
    queryKey: serenDbGetOperationQueryKey(options)
});

export const serenDbGetReplicationSettingsQueryKey = (options: Options<SerenDbGetReplicationSettingsData>) => createQueryKey('serenDbGetReplicationSettings', options);

/**
 * Get logical replication settings for a project.
 */
export const serenDbGetReplicationSettingsOptions = (options: Options<SerenDbGetReplicationSettingsData>) => queryOptions<SerenDbGetReplicationSettingsResponse, DefaultError, SerenDbGetReplicationSettingsResponse, ReturnType<typeof serenDbGetReplicationSettingsQueryKey>>({
    queryFn: async ({ queryKey, signal }) => {
        const { data } = await serenDbGetReplicationSettings({
            ...options,
            ...queryKey[0],
            signal,
            throwOnError: true
        });
        return data;
    },
    queryKey: serenDbGetReplicationSettingsQueryKey(options)
});

/**
 * Update logical replication settings for a project.
 */
export const serenDbUpdateReplicationSettingsMutation = (options?: Partial<Options<SerenDbUpdateReplicationSettingsData>>): MutationOptions<SerenDbUpdateReplicationSettingsResponse, DefaultError, Options<SerenDbUpdateReplicationSettingsData>> => {
    const mutationOptions: MutationOptions<SerenDbUpdateReplicationSettingsResponse, DefaultError, Options<SerenDbUpdateReplicationSettingsData>> = {
        mutationFn: async (fnOptions) => {
            const { data } = await serenDbUpdateReplicationSettings({
                ...options,
                ...fnOptions,
                throwOnError: true
            });
            return data;
        }
    };
    return mutationOptions;
};

export const serenDbGetProjectSizeQueryKey = (options: Options<SerenDbGetProjectSizeData>) => createQueryKey('serenDbGetProjectSize', options);

/**
 * Get project size.
 */
export const serenDbGetProjectSizeOptions = (options: Options<SerenDbGetProjectSizeData>) => queryOptions<SerenDbGetProjectSizeResponse, DefaultError, SerenDbGetProjectSizeResponse, ReturnType<typeof serenDbGetProjectSizeQueryKey>>({
    queryFn: async ({ queryKey, signal }) => {
        const { data } = await serenDbGetProjectSize({
            ...options,
            ...queryKey[0],
            signal,
            throwOnError: true
        });
        return data;
    },
    queryKey: serenDbGetProjectSizeQueryKey(options)
});

export const serenDbListProjectVpcEndpointsQueryKey = (options: Options<SerenDbListProjectVpcEndpointsData>) => createQueryKey('serenDbListProjectVpcEndpoints', options);

/**
 * List project VPC endpoint assignments.
 */
export const serenDbListProjectVpcEndpointsOptions = (options: Options<SerenDbListProjectVpcEndpointsData>) => queryOptions<SerenDbListProjectVpcEndpointsResponse, DefaultError, SerenDbListProjectVpcEndpointsResponse, ReturnType<typeof serenDbListProjectVpcEndpointsQueryKey>>({
    queryFn: async ({ queryKey, signal }) => {
        const { data } = await serenDbListProjectVpcEndpoints({
            ...options,
            ...queryKey[0],
            signal,
            throwOnError: true
        });
        return data;
    },
    queryKey: serenDbListProjectVpcEndpointsQueryKey(options)
});

/**
 * Assign a VPC endpoint to a project.
 */
export const serenDbAssignProjectVpcEndpointMutation = (options?: Partial<Options<SerenDbAssignProjectVpcEndpointData>>): MutationOptions<SerenDbAssignProjectVpcEndpointResponse, DefaultError, Options<SerenDbAssignProjectVpcEndpointData>> => {
    const mutationOptions: MutationOptions<SerenDbAssignProjectVpcEndpointResponse, DefaultError, Options<SerenDbAssignProjectVpcEndpointData>> = {
        mutationFn: async (fnOptions) => {
            const { data } = await serenDbAssignProjectVpcEndpoint({
                ...options,
                ...fnOptions,
                throwOnError: true
            });
            return data;
        }
    };
    return mutationOptions;
};

/**
 * Remove a project VPC endpoint assignment.
 */
export const serenDbRemoveProjectVpcEndpointMutation = (options?: Partial<Options<SerenDbRemoveProjectVpcEndpointData>>): MutationOptions<SerenDbRemoveProjectVpcEndpointResponse, DefaultError, Options<SerenDbRemoveProjectVpcEndpointData>> => {
    const mutationOptions: MutationOptions<SerenDbRemoveProjectVpcEndpointResponse, DefaultError, Options<SerenDbRemoveProjectVpcEndpointData>> = {
        mutationFn: async (fnOptions) => {
            const { data } = await serenDbRemoveProjectVpcEndpoint({
                ...options,
                ...fnOptions,
                throwOnError: true
            });
            return data;
        }
    };
    return mutationOptions;
};

export const serenDbListProjectVpcEndpointsAliasQueryKey = (options: Options<SerenDbListProjectVpcEndpointsAliasData>) => createQueryKey('serenDbListProjectVpcEndpointsAlias', options);

/**
 * List project VPC endpoint assignments (underscore alias).
 */
export const serenDbListProjectVpcEndpointsAliasOptions = (options: Options<SerenDbListProjectVpcEndpointsAliasData>) => queryOptions<SerenDbListProjectVpcEndpointsAliasResponse, DefaultError, SerenDbListProjectVpcEndpointsAliasResponse, ReturnType<typeof serenDbListProjectVpcEndpointsAliasQueryKey>>({
    queryFn: async ({ queryKey, signal }) => {
        const { data } = await serenDbListProjectVpcEndpointsAlias({
            ...options,
            ...queryKey[0],
            signal,
            throwOnError: true
        });
        return data;
    },
    queryKey: serenDbListProjectVpcEndpointsAliasQueryKey(options)
});

/**
 * Remove a project VPC endpoint assignment by endpoint id (underscore alias).
 */
export const serenDbRemoveProjectVpcEndpointByVpcIdMutation = (options?: Partial<Options<SerenDbRemoveProjectVpcEndpointByVpcIdData>>): MutationOptions<SerenDbRemoveProjectVpcEndpointByVpcIdResponse, DefaultError, Options<SerenDbRemoveProjectVpcEndpointByVpcIdData>> => {
    const mutationOptions: MutationOptions<SerenDbRemoveProjectVpcEndpointByVpcIdResponse, DefaultError, Options<SerenDbRemoveProjectVpcEndpointByVpcIdData>> = {
        mutationFn: async (fnOptions) => {
            const { data } = await serenDbRemoveProjectVpcEndpointByVpcId({
                ...options,
                ...fnOptions,
                throwOnError: true
            });
            return data;
        }
    };
    return mutationOptions;
};

/**
 * Assign a VPC endpoint to a project by endpoint id (underscore alias).
 */
export const serenDbAssignProjectVpcEndpointByIdMutation = (options?: Partial<Options<SerenDbAssignProjectVpcEndpointByIdData>>): MutationOptions<SerenDbAssignProjectVpcEndpointByIdResponse, DefaultError, Options<SerenDbAssignProjectVpcEndpointByIdData>> => {
    const mutationOptions: MutationOptions<SerenDbAssignProjectVpcEndpointByIdResponse, DefaultError, Options<SerenDbAssignProjectVpcEndpointByIdData>> = {
        mutationFn: async (fnOptions) => {
            const { data } = await serenDbAssignProjectVpcEndpointById({
                ...options,
                ...fnOptions,
                throwOnError: true
            });
            return data;
        }
    };
    return mutationOptions;
};

/**
 * Execute a SQL query against a SerenDB database.
 */
export const serenDbQueryMutation = (options?: Partial<Options<SerenDbQueryData>>): MutationOptions<SerenDbQueryResponse, DefaultError, Options<SerenDbQueryData>> => {
    const mutationOptions: MutationOptions<SerenDbQueryResponse, DefaultError, Options<SerenDbQueryData>> = {
        mutationFn: async (fnOptions) => {
            const { data } = await serenDbQuery({
                ...options,
                ...fnOptions,
                throwOnError: true
            });
            return data;
        }
    };
    return mutationOptions;
};
