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

import type { Options as ClientOptions, TDataShape, Client } from "./client";
import type {
	RegisterData,
	RegisterResponses,
	RegisterErrors,
	LoginData,
	LoginResponses,
	LoginErrors,
	LogoutData,
	LogoutResponses,
	GetMeData,
	GetMeResponses,
	GetMeErrors,
	GetStatusData,
	GetStatusResponses,
	ListVolumesData,
	ListVolumesResponses,
	CreateVolumeData,
	CreateVolumeResponses,
	TestConnectionData,
	TestConnectionResponses,
	DeleteVolumeData,
	DeleteVolumeResponses,
	GetVolumeData,
	GetVolumeResponses,
	GetVolumeErrors,
	UpdateVolumeData,
	UpdateVolumeResponses,
	UpdateVolumeErrors,
	GetContainersUsingVolumeData,
	GetContainersUsingVolumeResponses,
	GetContainersUsingVolumeErrors,
	MountVolumeData,
	MountVolumeResponses,
	MountVolumeErrors,
	UnmountVolumeData,
	UnmountVolumeResponses,
	UnmountVolumeErrors,
	HealthCheckVolumeData,
	HealthCheckVolumeResponses,
	HealthCheckVolumeErrors,
} from "./types.gen";
import { client as _heyApiClient } from "./client.gen";

export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean> = ClientOptions<
	TData,
	ThrowOnError
> & {
	/**
	 * You can provide a client instance returned by `createClient()` instead of
	 * individual options. This might be also useful if you want to implement a
	 * custom client.
	 */
	client?: Client;
	/**
	 * You can pass arbitrary values through the `meta` object. This can be
	 * used to access values that aren't defined as part of the SDK function.
	 */
	meta?: Record<string, unknown>;
};

/**
 * Register a new user
 */
export const register = <ThrowOnError extends boolean = false>(options?: Options<RegisterData, ThrowOnError>) => {
	return (options?.client ?? _heyApiClient).post<RegisterResponses, RegisterErrors, ThrowOnError>({
		url: "/api/v1/auth/register",
		...options,
		headers: {
			"Content-Type": "application/json",
			...options?.headers,
		},
	});
};

/**
 * Login with username and password
 */
export const login = <ThrowOnError extends boolean = false>(options?: Options<LoginData, ThrowOnError>) => {
	return (options?.client ?? _heyApiClient).post<LoginResponses, LoginErrors, ThrowOnError>({
		url: "/api/v1/auth/login",
		...options,
		headers: {
			"Content-Type": "application/json",
			...options?.headers,
		},
	});
};

/**
 * Logout current user
 */
export const logout = <ThrowOnError extends boolean = false>(options?: Options<LogoutData, ThrowOnError>) => {
	return (options?.client ?? _heyApiClient).post<LogoutResponses, unknown, ThrowOnError>({
		url: "/api/v1/auth/logout",
		...options,
	});
};

/**
 * Get current authenticated user
 */
export const getMe = <ThrowOnError extends boolean = false>(options?: Options<GetMeData, ThrowOnError>) => {
	return (options?.client ?? _heyApiClient).get<GetMeResponses, GetMeErrors, ThrowOnError>({
		url: "/api/v1/auth/me",
		...options,
	});
};

/**
 * Get authentication system status
 */
export const getStatus = <ThrowOnError extends boolean = false>(options?: Options<GetStatusData, ThrowOnError>) => {
	return (options?.client ?? _heyApiClient).get<GetStatusResponses, unknown, ThrowOnError>({
		url: "/api/v1/auth/status",
		...options,
	});
};

/**
 * List all volumes
 */
export const listVolumes = <ThrowOnError extends boolean = false>(options?: Options<ListVolumesData, ThrowOnError>) => {
	return (options?.client ?? _heyApiClient).get<ListVolumesResponses, unknown, ThrowOnError>({
		url: "/api/v1/volumes",
		...options,
	});
};

/**
 * Create a new volume
 */
export const createVolume = <ThrowOnError extends boolean = false>(
	options?: Options<CreateVolumeData, ThrowOnError>,
) => {
	return (options?.client ?? _heyApiClient).post<CreateVolumeResponses, unknown, ThrowOnError>({
		url: "/api/v1/volumes",
		...options,
		headers: {
			"Content-Type": "application/json",
			...options?.headers,
		},
	});
};

/**
 * Test connection to backend
 */
export const testConnection = <ThrowOnError extends boolean = false>(
	options?: Options<TestConnectionData, ThrowOnError>,
) => {
	return (options?.client ?? _heyApiClient).post<TestConnectionResponses, unknown, ThrowOnError>({
		url: "/api/v1/volumes/test-connection",
		...options,
		headers: {
			"Content-Type": "application/json",
			...options?.headers,
		},
	});
};

/**
 * Delete a volume
 */
export const deleteVolume = <ThrowOnError extends boolean = false>(
	options: Options<DeleteVolumeData, ThrowOnError>,
) => {
	return (options.client ?? _heyApiClient).delete<DeleteVolumeResponses, unknown, ThrowOnError>({
		url: "/api/v1/volumes/{name}",
		...options,
	});
};

/**
 * Get a volume by name
 */
export const getVolume = <ThrowOnError extends boolean = false>(options: Options<GetVolumeData, ThrowOnError>) => {
	return (options.client ?? _heyApiClient).get<GetVolumeResponses, GetVolumeErrors, ThrowOnError>({
		url: "/api/v1/volumes/{name}",
		...options,
	});
};

/**
 * Update a volume's configuration
 */
export const updateVolume = <ThrowOnError extends boolean = false>(
	options: Options<UpdateVolumeData, ThrowOnError>,
) => {
	return (options.client ?? _heyApiClient).put<UpdateVolumeResponses, UpdateVolumeErrors, ThrowOnError>({
		url: "/api/v1/volumes/{name}",
		...options,
		headers: {
			"Content-Type": "application/json",
			...options.headers,
		},
	});
};

/**
 * Get containers using a volume by name
 */
export const getContainersUsingVolume = <ThrowOnError extends boolean = false>(
	options: Options<GetContainersUsingVolumeData, ThrowOnError>,
) => {
	return (options.client ?? _heyApiClient).get<
		GetContainersUsingVolumeResponses,
		GetContainersUsingVolumeErrors,
		ThrowOnError
	>({
		url: "/api/v1/volumes/{name}/containers",
		...options,
	});
};

/**
 * Mount a volume
 */
export const mountVolume = <ThrowOnError extends boolean = false>(options: Options<MountVolumeData, ThrowOnError>) => {
	return (options.client ?? _heyApiClient).post<MountVolumeResponses, MountVolumeErrors, ThrowOnError>({
		url: "/api/v1/volumes/{name}/mount",
		...options,
	});
};

/**
 * Unmount a volume
 */
export const unmountVolume = <ThrowOnError extends boolean = false>(
	options: Options<UnmountVolumeData, ThrowOnError>,
) => {
	return (options.client ?? _heyApiClient).post<UnmountVolumeResponses, UnmountVolumeErrors, ThrowOnError>({
		url: "/api/v1/volumes/{name}/unmount",
		...options,
	});
};

/**
 * Perform a health check on a volume
 */
export const healthCheckVolume = <ThrowOnError extends boolean = false>(
	options: Options<HealthCheckVolumeData, ThrowOnError>,
) => {
	return (options.client ?? _heyApiClient).post<HealthCheckVolumeResponses, HealthCheckVolumeErrors, ThrowOnError>({
		url: "/api/v1/volumes/{name}/health-check",
		...options,
	});
};
