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

import type { Client, Options as Options2, TDataShape } from './client';
import { client } from './client.gen';
import type { CreateTokenAllAdminsData, CreateTokenAllAdminsErrors, CreateTokenAllAdminsResponses, CreateTokenCliData, CreateTokenCliErrors, CreateTokenCliResponses, CreateTokenData, CreateTokenErrors, CreateTokenResponses, LoginAllAdminsData, LoginAllAdminsErrors } from './types.gen';

export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean> = Options2<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>;
};

/**
 * Create Token All Admins
 *
 * Create a token with no credentials only if ``simple_auth_manager_all_admins`` is True.
 */
export const createTokenAllAdmins = <ThrowOnError extends boolean = false>(options?: Options<CreateTokenAllAdminsData, ThrowOnError>) => (options?.client ?? client).get<CreateTokenAllAdminsResponses, CreateTokenAllAdminsErrors, ThrowOnError>({
    responseType: 'json',
    url: '/auth/token',
    ...options
});

/**
 * Create Token
 *
 * Authenticate the user.
 */
export const createToken = <ThrowOnError extends boolean = false>(options: Options<CreateTokenData, ThrowOnError>) => (options.client ?? client).post<CreateTokenResponses, CreateTokenErrors, ThrowOnError>({
    responseType: 'json',
    url: '/auth/token',
    ...options,
    headers: {
        'Content-Type': 'application/json',
        ...options.headers
    }
});

/**
 * Login All Admins
 *
 * Login the user with no credentials.
 */
export const loginAllAdmins = <ThrowOnError extends boolean = false>(options?: Options<LoginAllAdminsData, ThrowOnError>) => (options?.client ?? client).get<unknown, LoginAllAdminsErrors, ThrowOnError>({ url: '/auth/token/login', ...options });

/**
 * Create Token Cli
 *
 * Authenticate the user for the CLI.
 */
export const createTokenCli = <ThrowOnError extends boolean = false>(options: Options<CreateTokenCliData, ThrowOnError>) => (options.client ?? client).post<CreateTokenCliResponses, CreateTokenCliErrors, ThrowOnError>({
    responseType: 'json',
    url: '/auth/token/cli',
    ...options,
    headers: {
        'Content-Type': 'application/json',
        ...options.headers
    }
});
