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

import { type Client, type Options as Options2, type TDataShape, urlSearchParamsBodySerializer } from './client';
import { client } from './client.gen';
import type { AdminActivateUserData, AdminActivateUserErrors, AdminActivateUserResponses, AdminAddOrganizationMemberData, AdminAddOrganizationMemberErrors, AdminAddOrganizationMemberResponses, AdminBulkUserActionData, AdminBulkUserActionErrors, AdminBulkUserActionResponses, AdminCreateOrganizationData, AdminCreateOrganizationErrors, AdminCreateOrganizationResponses, AdminCreateUserData, AdminCreateUserErrors, AdminCreateUserResponses, AdminDeactivateUserData, AdminDeactivateUserErrors, AdminDeactivateUserResponses, AdminDeleteOrganizationData, AdminDeleteOrganizationErrors, AdminDeleteOrganizationResponses, AdminDeleteUserData, AdminDeleteUserErrors, AdminDeleteUserResponses, AdminGetOrganizationData, AdminGetOrganizationErrors, AdminGetOrganizationResponses, AdminGetStatsData, AdminGetStatsResponses, AdminGetUserData, AdminGetUserErrors, AdminGetUserResponses, AdminListOrganizationMembersData, AdminListOrganizationMembersErrors, AdminListOrganizationMembersResponses, AdminListOrganizationsData, AdminListOrganizationsErrors, AdminListOrganizationsResponses, AdminListSessionsData, AdminListSessionsErrors, AdminListSessionsResponses, AdminListUsersData, AdminListUsersErrors, AdminListUsersResponses, AdminRemoveOrganizationMemberData, AdminRemoveOrganizationMemberErrors, AdminRemoveOrganizationMemberResponses, AdminUpdateOrganizationData, AdminUpdateOrganizationErrors, AdminUpdateOrganizationResponses, AdminUpdateUserData, AdminUpdateUserErrors, AdminUpdateUserResponses, ChangeCurrentUserPasswordData, ChangeCurrentUserPasswordErrors, ChangeCurrentUserPasswordResponses, CleanupExpiredSessionsData, CleanupExpiredSessionsResponses, ConfirmPasswordResetData, ConfirmPasswordResetErrors, ConfirmPasswordResetResponses, DeleteOauthClientData, DeleteOauthClientErrors, DeleteOauthClientResponses, DeleteUserData, DeleteUserErrors, DeleteUserResponses, GetCurrentUserProfileData, GetCurrentUserProfileResponses, GetMyOrganizationsData, GetMyOrganizationsErrors, GetMyOrganizationsResponses, GetOauthAuthorizationUrlData, GetOauthAuthorizationUrlErrors, GetOauthAuthorizationUrlResponses, GetOauthServerMetadataData, GetOauthServerMetadataResponses, GetOrganizationData, GetOrganizationErrors, GetOrganizationMembersData, GetOrganizationMembersErrors, GetOrganizationMembersResponses, GetOrganizationResponses, GetUserByIdData, GetUserByIdErrors, GetUserByIdResponses, HandleOauthCallbackData, HandleOauthCallbackErrors, HandleOauthCallbackResponses, HealthCheckData, HealthCheckResponses, ListMyOauthConsentsData, ListMyOauthConsentsResponses, ListMySessionsData, ListMySessionsResponses, ListOauthAccountsData, ListOauthAccountsResponses, ListOauthClientsData, ListOauthClientsResponses, ListOauthProvidersData, ListOauthProvidersResponses, ListUsersData, ListUsersErrors, ListUsersResponses, LoginData, LoginErrors, LoginOauthData, LoginOauthErrors, LoginOauthResponses, LoginResponses, LogoutAllData, LogoutAllResponses, LogoutData, LogoutErrors, LogoutResponses, OauthProviderAuthorizeData, OauthProviderAuthorizeErrors, OauthProviderAuthorizeResponses, OauthProviderConsentData, OauthProviderConsentErrors, OauthProviderConsentResponses, OauthProviderIntrospectData, OauthProviderIntrospectErrors, OauthProviderIntrospectResponses, OauthProviderRevokeData, OauthProviderRevokeErrors, OauthProviderRevokeResponses, OauthProviderTokenData, OauthProviderTokenErrors, OauthProviderTokenResponses, RefreshTokenData, RefreshTokenErrors, RefreshTokenResponses, RegisterData, RegisterErrors, RegisterOauthClientData, RegisterOauthClientErrors, RegisterOauthClientResponses, RegisterResponses, RequestPasswordResetData, RequestPasswordResetErrors, RequestPasswordResetResponses, RevokeMyOauthConsentData, RevokeMyOauthConsentErrors, RevokeMyOauthConsentResponses, RevokeSessionData, RevokeSessionErrors, RevokeSessionResponses, RootGetData, RootGetResponses, SendTestEventData, SendTestEventErrors, SendTestEventResponses, StartOauthLinkData, StartOauthLinkErrors, StartOauthLinkResponses, StreamProjectEventsData, StreamProjectEventsErrors, StreamProjectEventsResponses, UnlinkOauthAccountData, UnlinkOauthAccountErrors, UnlinkOauthAccountResponses, UpdateCurrentUserData, UpdateCurrentUserErrors, UpdateCurrentUserResponses, UpdateOrganizationData, UpdateOrganizationErrors, UpdateOrganizationResponses, UpdateUserData, UpdateUserErrors, UpdateUserResponses } 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>;
};

/**
 * Root
 */
export const rootGet = <ThrowOnError extends boolean = false>(options?: Options<RootGetData, ThrowOnError>) => {
    return (options?.client ?? client).get<RootGetResponses, unknown, ThrowOnError>({
        responseType: 'text',
        url: '/',
        ...options
    });
};

/**
 * Health Check
 *
 * Check the health status of the API and its dependencies
 */
export const healthCheck = <ThrowOnError extends boolean = false>(options?: Options<HealthCheckData, ThrowOnError>) => {
    return (options?.client ?? client).get<HealthCheckResponses, unknown, ThrowOnError>({
        responseType: 'json',
        url: '/health',
        ...options
    });
};

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

/**
 * Login
 *
 * Login with username and password.
 *
 * Creates a new session for this device.
 *
 * Returns:
 * Access and refresh tokens.
 */
export const login = <ThrowOnError extends boolean = false>(options: Options<LoginData, ThrowOnError>) => {
    return (options.client ?? client).post<LoginResponses, LoginErrors, ThrowOnError>({
        responseType: 'json',
        url: '/api/v1/auth/login',
        ...options,
        headers: {
            'Content-Type': 'application/json',
            ...options.headers
        }
    });
};

/**
 * Login Oauth
 *
 * OAuth2-compatible login endpoint, used by the OpenAPI UI.
 *
 * Creates a new session for this device.
 *
 * Returns:
 * Access and refresh tokens.
 */
export const loginOauth = <ThrowOnError extends boolean = false>(options: Options<LoginOauthData, ThrowOnError>) => {
    return (options.client ?? client).post<LoginOauthResponses, LoginOauthErrors, ThrowOnError>({
        ...urlSearchParamsBodySerializer,
        responseType: 'json',
        url: '/api/v1/auth/login/oauth',
        ...options,
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded',
            ...options.headers
        }
    });
};

/**
 * Refresh Token
 *
 * Refresh access token using a refresh token.
 *
 * Validates that the session is still active before issuing new tokens.
 *
 * Returns:
 * New access and refresh tokens.
 */
export const refreshToken = <ThrowOnError extends boolean = false>(options: Options<RefreshTokenData, ThrowOnError>) => {
    return (options.client ?? client).post<RefreshTokenResponses, RefreshTokenErrors, ThrowOnError>({
        responseType: 'json',
        url: '/api/v1/auth/refresh',
        ...options,
        headers: {
            'Content-Type': 'application/json',
            ...options.headers
        }
    });
};

/**
 * Request Password Reset
 *
 * Request a password reset link.
 *
 * An email will be sent with a reset link if the email exists.
 * Always returns success to prevent email enumeration.
 *
 * **Rate Limit**: 3 requests/minute
 */
export const requestPasswordReset = <ThrowOnError extends boolean = false>(options: Options<RequestPasswordResetData, ThrowOnError>) => {
    return (options.client ?? client).post<RequestPasswordResetResponses, RequestPasswordResetErrors, ThrowOnError>({
        responseType: 'json',
        url: '/api/v1/auth/password-reset/request',
        ...options,
        headers: {
            'Content-Type': 'application/json',
            ...options.headers
        }
    });
};

/**
 * Confirm Password Reset
 *
 * Reset password using a token from email.
 *
 * **Rate Limit**: 5 requests/minute
 */
export const confirmPasswordReset = <ThrowOnError extends boolean = false>(options: Options<ConfirmPasswordResetData, ThrowOnError>) => {
    return (options.client ?? client).post<ConfirmPasswordResetResponses, ConfirmPasswordResetErrors, ThrowOnError>({
        responseType: 'json',
        url: '/api/v1/auth/password-reset/confirm',
        ...options,
        headers: {
            'Content-Type': 'application/json',
            ...options.headers
        }
    });
};

/**
 * Logout from Current Device
 *
 * Logout from the current device only.
 *
 * Other devices will remain logged in.
 *
 * Requires the refresh token to identify which session to terminate.
 *
 * **Rate Limit**: 10 requests/minute
 */
export const logout = <ThrowOnError extends boolean = false>(options: Options<LogoutData, ThrowOnError>) => {
    return (options.client ?? client).post<LogoutResponses, LogoutErrors, ThrowOnError>({
        responseType: 'json',
        security: [
            {
                scheme: 'bearer',
                type: 'http'
            }
        ],
        url: '/api/v1/auth/logout',
        ...options,
        headers: {
            'Content-Type': 'application/json',
            ...options.headers
        }
    });
};

/**
 * Logout from All Devices
 *
 * Logout from ALL devices.
 *
 * This will terminate all active sessions for the current user.
 * You will need to log in again on all devices.
 *
 * **Rate Limit**: 5 requests/minute
 */
export const logoutAll = <ThrowOnError extends boolean = false>(options?: Options<LogoutAllData, ThrowOnError>) => {
    return (options?.client ?? client).post<LogoutAllResponses, unknown, ThrowOnError>({
        responseType: 'json',
        security: [
            {
                scheme: 'bearer',
                type: 'http'
            }
        ],
        url: '/api/v1/auth/logout-all',
        ...options
    });
};

/**
 * List OAuth Providers
 *
 * Get list of enabled OAuth providers for the login/register UI.
 *
 * Returns:
 * List of enabled providers with display info.
 */
export const listOauthProviders = <ThrowOnError extends boolean = false>(options?: Options<ListOauthProvidersData, ThrowOnError>) => {
    return (options?.client ?? client).get<ListOauthProvidersResponses, unknown, ThrowOnError>({
        responseType: 'json',
        url: '/api/v1/oauth/providers',
        ...options
    });
};

/**
 * Get OAuth Authorization URL
 *
 * Get the authorization URL to redirect the user to the OAuth provider.
 *
 * The frontend should redirect the user to the returned URL.
 * After authentication, the provider will redirect back to the callback URL.
 *
 * **Rate Limit**: 10 requests/minute
 */
export const getOauthAuthorizationUrl = <ThrowOnError extends boolean = false>(options: Options<GetOauthAuthorizationUrlData, ThrowOnError>) => {
    return (options.client ?? client).get<GetOauthAuthorizationUrlResponses, GetOauthAuthorizationUrlErrors, ThrowOnError>({
        responseType: 'json',
        url: '/api/v1/oauth/authorize/{provider}',
        ...options
    });
};

/**
 * OAuth Callback
 *
 * Handle OAuth callback from provider.
 *
 * The frontend should call this endpoint with the code and state
 * parameters received from the OAuth provider redirect.
 *
 * Returns:
 * JWT tokens for the authenticated user.
 *
 * **Rate Limit**: 10 requests/minute
 */
export const handleOauthCallback = <ThrowOnError extends boolean = false>(options: Options<HandleOauthCallbackData, ThrowOnError>) => {
    return (options.client ?? client).post<HandleOauthCallbackResponses, HandleOauthCallbackErrors, ThrowOnError>({
        responseType: 'json',
        url: '/api/v1/oauth/callback/{provider}',
        ...options,
        headers: {
            'Content-Type': 'application/json',
            ...options.headers
        }
    });
};

/**
 * List Linked OAuth Accounts
 *
 * Get list of OAuth accounts linked to the current user.
 *
 * Requires authentication.
 */
export const listOauthAccounts = <ThrowOnError extends boolean = false>(options?: Options<ListOauthAccountsData, ThrowOnError>) => {
    return (options?.client ?? client).get<ListOauthAccountsResponses, unknown, ThrowOnError>({
        responseType: 'json',
        security: [
            {
                scheme: 'bearer',
                type: 'http'
            }
        ],
        url: '/api/v1/oauth/accounts',
        ...options
    });
};

/**
 * Unlink OAuth Account
 *
 * Unlink an OAuth provider from the current user.
 *
 * The user must have either a password set or another OAuth provider
 * linked to ensure they can still log in.
 *
 * **Rate Limit**: 5 requests/minute
 */
export const unlinkOauthAccount = <ThrowOnError extends boolean = false>(options: Options<UnlinkOauthAccountData, ThrowOnError>) => {
    return (options.client ?? client).delete<UnlinkOauthAccountResponses, UnlinkOauthAccountErrors, ThrowOnError>({
        responseType: 'json',
        security: [
            {
                scheme: 'bearer',
                type: 'http'
            }
        ],
        url: '/api/v1/oauth/accounts/{provider}',
        ...options
    });
};

/**
 * Start Account Linking
 *
 * Start the OAuth flow to link a new provider to the current user.
 *
 * This is a convenience endpoint that redirects to /authorize/{provider}
 * with the current user context.
 *
 * **Rate Limit**: 10 requests/minute
 */
export const startOauthLink = <ThrowOnError extends boolean = false>(options: Options<StartOauthLinkData, ThrowOnError>) => {
    return (options.client ?? client).post<StartOauthLinkResponses, StartOauthLinkErrors, ThrowOnError>({
        responseType: 'json',
        security: [
            {
                scheme: 'bearer',
                type: 'http'
            }
        ],
        url: '/api/v1/oauth/link/{provider}',
        ...options
    });
};

/**
 * Authorization Endpoint
 *
 * OAuth 2.0 Authorization Endpoint.
 *
 * Initiates the authorization code flow:
 * 1. Validates client and parameters
 * 2. Checks if user is authenticated (redirects to login if not)
 * 3. Checks existing consent
 * 4. Redirects to consent page if needed
 * 5. Issues authorization code and redirects back to client
 *
 * Required parameters:
 * - response_type: Must be "code"
 * - client_id: Registered client ID
 * - redirect_uri: Must match registered URI
 *
 * Recommended parameters:
 * - state: CSRF protection
 * - code_challenge + code_challenge_method: PKCE (required for public clients)
 * - scope: Requested permissions
 */
export const oauthProviderAuthorize = <ThrowOnError extends boolean = false>(options: Options<OauthProviderAuthorizeData, ThrowOnError>) => {
    return (options.client ?? client).get<OauthProviderAuthorizeResponses, OauthProviderAuthorizeErrors, ThrowOnError>({
        responseType: 'json',
        url: '/api/v1/oauth/provider/authorize',
        ...options
    });
};

/**
 * Submit Authorization Consent
 *
 * Submit user consent for OAuth authorization.
 *
 * Called by the consent page after user approves or denies.
 */
export const oauthProviderConsent = <ThrowOnError extends boolean = false>(options: Options<OauthProviderConsentData, ThrowOnError>) => {
    return (options.client ?? client).post<OauthProviderConsentResponses, OauthProviderConsentErrors, ThrowOnError>({
        ...urlSearchParamsBodySerializer,
        responseType: 'json',
        security: [
            {
                scheme: 'bearer',
                type: 'http'
            }
        ],
        url: '/api/v1/oauth/provider/authorize/consent',
        ...options,
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded',
            ...options.headers
        }
    });
};

/**
 * Token Endpoint
 *
 * OAuth 2.0 Token Endpoint.
 *
 * Supports:
 * - authorization_code: Exchange code for tokens
 * - refresh_token: Refresh access token
 *
 * Client authentication:
 * - Confidential clients: client_secret (Basic auth or POST body)
 * - Public clients: No secret, but PKCE code_verifier required
 */
export const oauthProviderToken = <ThrowOnError extends boolean = false>(options: Options<OauthProviderTokenData, ThrowOnError>) => {
    return (options.client ?? client).post<OauthProviderTokenResponses, OauthProviderTokenErrors, ThrowOnError>({
        ...urlSearchParamsBodySerializer,
        responseType: 'json',
        url: '/api/v1/oauth/provider/token',
        ...options,
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded',
            ...options.headers
        }
    });
};

/**
 * Token Revocation Endpoint
 *
 * OAuth 2.0 Token Revocation Endpoint (RFC 7009).
 *
 * Revokes an access token or refresh token.
 * Always returns 200 OK (even if token is invalid) per spec.
 */
export const oauthProviderRevoke = <ThrowOnError extends boolean = false>(options: Options<OauthProviderRevokeData, ThrowOnError>) => {
    return (options.client ?? client).post<OauthProviderRevokeResponses, OauthProviderRevokeErrors, ThrowOnError>({
        ...urlSearchParamsBodySerializer,
        responseType: 'json',
        url: '/api/v1/oauth/provider/revoke',
        ...options,
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded',
            ...options.headers
        }
    });
};

/**
 * Token Introspection Endpoint
 *
 * OAuth 2.0 Token Introspection Endpoint (RFC 7662).
 *
 * Allows resource servers to query the authorization server
 * to determine the active state and metadata of a token.
 */
export const oauthProviderIntrospect = <ThrowOnError extends boolean = false>(options: Options<OauthProviderIntrospectData, ThrowOnError>) => {
    return (options.client ?? client).post<OauthProviderIntrospectResponses, OauthProviderIntrospectErrors, ThrowOnError>({
        ...urlSearchParamsBodySerializer,
        responseType: 'json',
        url: '/api/v1/oauth/provider/introspect',
        ...options,
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded',
            ...options.headers
        }
    });
};

/**
 * List OAuth Clients
 *
 * List all registered OAuth clients (admin only).
 */
export const listOauthClients = <ThrowOnError extends boolean = false>(options?: Options<ListOauthClientsData, ThrowOnError>) => {
    return (options?.client ?? client).get<ListOauthClientsResponses, unknown, ThrowOnError>({
        responseType: 'json',
        security: [
            {
                scheme: 'bearer',
                type: 'http'
            }
        ],
        url: '/api/v1/oauth/provider/clients',
        ...options
    });
};

/**
 * Register OAuth Client
 *
 * Register a new OAuth client (admin only).
 *
 * Creates an MCP client that can authenticate against this API.
 * Returns client_id and client_secret (for confidential clients).
 *
 * **Important:** Store the client_secret securely - it won't be shown again!
 */
export const registerOauthClient = <ThrowOnError extends boolean = false>(options: Options<RegisterOauthClientData, ThrowOnError>) => {
    return (options.client ?? client).post<RegisterOauthClientResponses, RegisterOauthClientErrors, ThrowOnError>({
        ...urlSearchParamsBodySerializer,
        responseType: 'json',
        security: [
            {
                scheme: 'bearer',
                type: 'http'
            }
        ],
        url: '/api/v1/oauth/provider/clients',
        ...options,
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded',
            ...options.headers
        }
    });
};

/**
 * Delete OAuth Client
 *
 * Delete an OAuth client (admin only). Revokes all tokens.
 */
export const deleteOauthClient = <ThrowOnError extends boolean = false>(options: Options<DeleteOauthClientData, ThrowOnError>) => {
    return (options.client ?? client).delete<DeleteOauthClientResponses, DeleteOauthClientErrors, ThrowOnError>({
        security: [
            {
                scheme: 'bearer',
                type: 'http'
            }
        ],
        url: '/api/v1/oauth/provider/clients/{client_id}',
        ...options
    });
};

/**
 * List My Consents
 *
 * List OAuth applications the current user has authorized.
 */
export const listMyOauthConsents = <ThrowOnError extends boolean = false>(options?: Options<ListMyOauthConsentsData, ThrowOnError>) => {
    return (options?.client ?? client).get<ListMyOauthConsentsResponses, unknown, ThrowOnError>({
        responseType: 'json',
        security: [
            {
                scheme: 'bearer',
                type: 'http'
            }
        ],
        url: '/api/v1/oauth/provider/consents',
        ...options
    });
};

/**
 * Revoke My Consent
 *
 * Revoke authorization for an OAuth application. Also revokes all tokens.
 */
export const revokeMyOauthConsent = <ThrowOnError extends boolean = false>(options: Options<RevokeMyOauthConsentData, ThrowOnError>) => {
    return (options.client ?? client).delete<RevokeMyOauthConsentResponses, RevokeMyOauthConsentErrors, ThrowOnError>({
        security: [
            {
                scheme: 'bearer',
                type: 'http'
            }
        ],
        url: '/api/v1/oauth/provider/consents/{client_id}',
        ...options
    });
};

/**
 * List Users
 *
 * List all users with pagination, filtering, and sorting (admin only).
 *
 * **Authentication**: Required (Bearer token)
 * **Authorization**: Superuser only
 *
 * **Filtering**: is_active, is_superuser
 * **Sorting**: Any user field (email, first_name, last_name, created_at, etc.)
 *
 * **Rate Limit**: 60 requests/minute
 */
export const listUsers = <ThrowOnError extends boolean = false>(options?: Options<ListUsersData, ThrowOnError>) => {
    return (options?.client ?? client).get<ListUsersResponses, ListUsersErrors, ThrowOnError>({
        responseType: 'json',
        security: [
            {
                scheme: 'bearer',
                type: 'http'
            }
        ],
        url: '/api/v1/users',
        ...options
    });
};

/**
 * Get Current User
 *
 * Get the current authenticated user's profile.
 *
 * **Authentication**: Required (Bearer token)
 *
 * **Rate Limit**: 60 requests/minute
 */
export const getCurrentUserProfile = <ThrowOnError extends boolean = false>(options?: Options<GetCurrentUserProfileData, ThrowOnError>) => {
    return (options?.client ?? client).get<GetCurrentUserProfileResponses, unknown, ThrowOnError>({
        responseType: 'json',
        security: [
            {
                scheme: 'bearer',
                type: 'http'
            }
        ],
        url: '/api/v1/users/me',
        ...options
    });
};

/**
 * Update Current User
 *
 * Update the current authenticated user's profile.
 *
 * Users can update their own profile information (except is_superuser).
 *
 * **Authentication**: Required (Bearer token)
 *
 * **Rate Limit**: 30 requests/minute
 */
export const updateCurrentUser = <ThrowOnError extends boolean = false>(options: Options<UpdateCurrentUserData, ThrowOnError>) => {
    return (options.client ?? client).patch<UpdateCurrentUserResponses, UpdateCurrentUserErrors, ThrowOnError>({
        responseType: 'json',
        security: [
            {
                scheme: 'bearer',
                type: 'http'
            }
        ],
        url: '/api/v1/users/me',
        ...options,
        headers: {
            'Content-Type': 'application/json',
            ...options.headers
        }
    });
};

/**
 * Delete User
 *
 * Delete a specific user by their ID.
 *
 * **Authentication**: Required (Bearer token)
 * **Authorization**: Superuser only
 *
 * **Rate Limit**: 10 requests/minute
 *
 * **Note**: This performs a hard delete. Consider implementing soft deletes for production.
 */
export const deleteUser = <ThrowOnError extends boolean = false>(options: Options<DeleteUserData, ThrowOnError>) => {
    return (options.client ?? client).delete<DeleteUserResponses, DeleteUserErrors, ThrowOnError>({
        responseType: 'json',
        security: [
            {
                scheme: 'bearer',
                type: 'http'
            }
        ],
        url: '/api/v1/users/{user_id}',
        ...options
    });
};

/**
 * Get User by ID
 *
 * Get a specific user by their ID.
 *
 * **Authentication**: Required (Bearer token)
 * **Authorization**:
 * - Regular users: Can only access their own profile
 * - Superusers: Can access any profile
 *
 * **Rate Limit**: 60 requests/minute
 */
export const getUserById = <ThrowOnError extends boolean = false>(options: Options<GetUserByIdData, ThrowOnError>) => {
    return (options.client ?? client).get<GetUserByIdResponses, GetUserByIdErrors, ThrowOnError>({
        responseType: 'json',
        security: [
            {
                scheme: 'bearer',
                type: 'http'
            }
        ],
        url: '/api/v1/users/{user_id}',
        ...options
    });
};

/**
 * Update User
 *
 * Update a specific user by their ID.
 *
 * **Authentication**: Required (Bearer token)
 * **Authorization**:
 * - Regular users: Can only update their own profile (except is_superuser)
 * - Superusers: Can update any profile
 *
 * **Rate Limit**: 30 requests/minute
 */
export const updateUser = <ThrowOnError extends boolean = false>(options: Options<UpdateUserData, ThrowOnError>) => {
    return (options.client ?? client).patch<UpdateUserResponses, UpdateUserErrors, ThrowOnError>({
        responseType: 'json',
        security: [
            {
                scheme: 'bearer',
                type: 'http'
            }
        ],
        url: '/api/v1/users/{user_id}',
        ...options,
        headers: {
            'Content-Type': 'application/json',
            ...options.headers
        }
    });
};

/**
 * Change Current User Password
 *
 * Change the current authenticated user's password.
 *
 * Requires the current password for verification.
 *
 * **Authentication**: Required (Bearer token)
 *
 * **Rate Limit**: 5 requests/minute
 */
export const changeCurrentUserPassword = <ThrowOnError extends boolean = false>(options: Options<ChangeCurrentUserPasswordData, ThrowOnError>) => {
    return (options.client ?? client).patch<ChangeCurrentUserPasswordResponses, ChangeCurrentUserPasswordErrors, ThrowOnError>({
        responseType: 'json',
        security: [
            {
                scheme: 'bearer',
                type: 'http'
            }
        ],
        url: '/api/v1/users/me/password',
        ...options,
        headers: {
            'Content-Type': 'application/json',
            ...options.headers
        }
    });
};

/**
 * List My Active Sessions
 *
 * Get a list of all active sessions for the current user.
 *
 * This shows where you're currently logged in.
 *
 * **Rate Limit**: 30 requests/minute
 */
export const listMySessions = <ThrowOnError extends boolean = false>(options?: Options<ListMySessionsData, ThrowOnError>) => {
    return (options?.client ?? client).get<ListMySessionsResponses, unknown, ThrowOnError>({
        responseType: 'json',
        security: [
            {
                scheme: 'bearer',
                type: 'http'
            }
        ],
        url: '/api/v1/sessions/me',
        ...options
    });
};

/**
 * Revoke Specific Session
 *
 * Revoke a specific session by ID.
 *
 * This logs you out from that particular device.
 * You can only revoke your own sessions.
 *
 * **Rate Limit**: 10 requests/minute
 */
export const revokeSession = <ThrowOnError extends boolean = false>(options: Options<RevokeSessionData, ThrowOnError>) => {
    return (options.client ?? client).delete<RevokeSessionResponses, RevokeSessionErrors, ThrowOnError>({
        responseType: 'json',
        security: [
            {
                scheme: 'bearer',
                type: 'http'
            }
        ],
        url: '/api/v1/sessions/{session_id}',
        ...options
    });
};

/**
 * Cleanup Expired Sessions
 *
 * Remove expired sessions for the current user.
 *
 * This is a cleanup operation to remove old session records.
 *
 * **Rate Limit**: 5 requests/minute
 */
export const cleanupExpiredSessions = <ThrowOnError extends boolean = false>(options?: Options<CleanupExpiredSessionsData, ThrowOnError>) => {
    return (options?.client ?? client).delete<CleanupExpiredSessionsResponses, unknown, ThrowOnError>({
        responseType: 'json',
        security: [
            {
                scheme: 'bearer',
                type: 'http'
            }
        ],
        url: '/api/v1/sessions/me/expired',
        ...options
    });
};

/**
 * Admin: Get Dashboard Stats
 *
 * Get aggregated statistics for the admin dashboard (admin only)
 */
export const adminGetStats = <ThrowOnError extends boolean = false>(options?: Options<AdminGetStatsData, ThrowOnError>) => {
    return (options?.client ?? client).get<AdminGetStatsResponses, unknown, ThrowOnError>({
        responseType: 'json',
        security: [
            {
                scheme: 'bearer',
                type: 'http'
            }
        ],
        url: '/api/v1/admin/stats',
        ...options
    });
};

/**
 * Admin: List All Users
 *
 * Get paginated list of all users with filtering and search (admin only)
 */
export const adminListUsers = <ThrowOnError extends boolean = false>(options?: Options<AdminListUsersData, ThrowOnError>) => {
    return (options?.client ?? client).get<AdminListUsersResponses, AdminListUsersErrors, ThrowOnError>({
        responseType: 'json',
        security: [
            {
                scheme: 'bearer',
                type: 'http'
            }
        ],
        url: '/api/v1/admin/users',
        ...options
    });
};

/**
 * Admin: Create User
 *
 * Create a new user (admin only)
 */
export const adminCreateUser = <ThrowOnError extends boolean = false>(options: Options<AdminCreateUserData, ThrowOnError>) => {
    return (options.client ?? client).post<AdminCreateUserResponses, AdminCreateUserErrors, ThrowOnError>({
        responseType: 'json',
        security: [
            {
                scheme: 'bearer',
                type: 'http'
            }
        ],
        url: '/api/v1/admin/users',
        ...options,
        headers: {
            'Content-Type': 'application/json',
            ...options.headers
        }
    });
};

/**
 * Admin: Delete User
 *
 * Soft delete a user (admin only)
 */
export const adminDeleteUser = <ThrowOnError extends boolean = false>(options: Options<AdminDeleteUserData, ThrowOnError>) => {
    return (options.client ?? client).delete<AdminDeleteUserResponses, AdminDeleteUserErrors, ThrowOnError>({
        responseType: 'json',
        security: [
            {
                scheme: 'bearer',
                type: 'http'
            }
        ],
        url: '/api/v1/admin/users/{user_id}',
        ...options
    });
};

/**
 * Admin: Get User Details
 *
 * Get detailed user information (admin only)
 */
export const adminGetUser = <ThrowOnError extends boolean = false>(options: Options<AdminGetUserData, ThrowOnError>) => {
    return (options.client ?? client).get<AdminGetUserResponses, AdminGetUserErrors, ThrowOnError>({
        responseType: 'json',
        security: [
            {
                scheme: 'bearer',
                type: 'http'
            }
        ],
        url: '/api/v1/admin/users/{user_id}',
        ...options
    });
};

/**
 * Admin: Update User
 *
 * Update user information (admin only)
 */
export const adminUpdateUser = <ThrowOnError extends boolean = false>(options: Options<AdminUpdateUserData, ThrowOnError>) => {
    return (options.client ?? client).put<AdminUpdateUserResponses, AdminUpdateUserErrors, ThrowOnError>({
        responseType: 'json',
        security: [
            {
                scheme: 'bearer',
                type: 'http'
            }
        ],
        url: '/api/v1/admin/users/{user_id}',
        ...options,
        headers: {
            'Content-Type': 'application/json',
            ...options.headers
        }
    });
};

/**
 * Admin: Activate User
 *
 * Activate a user account (admin only)
 */
export const adminActivateUser = <ThrowOnError extends boolean = false>(options: Options<AdminActivateUserData, ThrowOnError>) => {
    return (options.client ?? client).post<AdminActivateUserResponses, AdminActivateUserErrors, ThrowOnError>({
        responseType: 'json',
        security: [
            {
                scheme: 'bearer',
                type: 'http'
            }
        ],
        url: '/api/v1/admin/users/{user_id}/activate',
        ...options
    });
};

/**
 * Admin: Deactivate User
 *
 * Deactivate a user account (admin only)
 */
export const adminDeactivateUser = <ThrowOnError extends boolean = false>(options: Options<AdminDeactivateUserData, ThrowOnError>) => {
    return (options.client ?? client).post<AdminDeactivateUserResponses, AdminDeactivateUserErrors, ThrowOnError>({
        responseType: 'json',
        security: [
            {
                scheme: 'bearer',
                type: 'http'
            }
        ],
        url: '/api/v1/admin/users/{user_id}/deactivate',
        ...options
    });
};

/**
 * Admin: Bulk User Action
 *
 * Perform bulk actions on multiple users (admin only)
 */
export const adminBulkUserAction = <ThrowOnError extends boolean = false>(options: Options<AdminBulkUserActionData, ThrowOnError>) => {
    return (options.client ?? client).post<AdminBulkUserActionResponses, AdminBulkUserActionErrors, ThrowOnError>({
        responseType: 'json',
        security: [
            {
                scheme: 'bearer',
                type: 'http'
            }
        ],
        url: '/api/v1/admin/users/bulk-action',
        ...options,
        headers: {
            'Content-Type': 'application/json',
            ...options.headers
        }
    });
};

/**
 * Admin: List Organizations
 *
 * Get paginated list of all organizations (admin only)
 */
export const adminListOrganizations = <ThrowOnError extends boolean = false>(options?: Options<AdminListOrganizationsData, ThrowOnError>) => {
    return (options?.client ?? client).get<AdminListOrganizationsResponses, AdminListOrganizationsErrors, ThrowOnError>({
        responseType: 'json',
        security: [
            {
                scheme: 'bearer',
                type: 'http'
            }
        ],
        url: '/api/v1/admin/organizations',
        ...options
    });
};

/**
 * Admin: Create Organization
 *
 * Create a new organization (admin only)
 */
export const adminCreateOrganization = <ThrowOnError extends boolean = false>(options: Options<AdminCreateOrganizationData, ThrowOnError>) => {
    return (options.client ?? client).post<AdminCreateOrganizationResponses, AdminCreateOrganizationErrors, ThrowOnError>({
        responseType: 'json',
        security: [
            {
                scheme: 'bearer',
                type: 'http'
            }
        ],
        url: '/api/v1/admin/organizations',
        ...options,
        headers: {
            'Content-Type': 'application/json',
            ...options.headers
        }
    });
};

/**
 * Admin: Delete Organization
 *
 * Delete an organization (admin only)
 */
export const adminDeleteOrganization = <ThrowOnError extends boolean = false>(options: Options<AdminDeleteOrganizationData, ThrowOnError>) => {
    return (options.client ?? client).delete<AdminDeleteOrganizationResponses, AdminDeleteOrganizationErrors, ThrowOnError>({
        responseType: 'json',
        security: [
            {
                scheme: 'bearer',
                type: 'http'
            }
        ],
        url: '/api/v1/admin/organizations/{org_id}',
        ...options
    });
};

/**
 * Admin: Get Organization Details
 *
 * Get detailed organization information (admin only)
 */
export const adminGetOrganization = <ThrowOnError extends boolean = false>(options: Options<AdminGetOrganizationData, ThrowOnError>) => {
    return (options.client ?? client).get<AdminGetOrganizationResponses, AdminGetOrganizationErrors, ThrowOnError>({
        responseType: 'json',
        security: [
            {
                scheme: 'bearer',
                type: 'http'
            }
        ],
        url: '/api/v1/admin/organizations/{org_id}',
        ...options
    });
};

/**
 * Admin: Update Organization
 *
 * Update organization information (admin only)
 */
export const adminUpdateOrganization = <ThrowOnError extends boolean = false>(options: Options<AdminUpdateOrganizationData, ThrowOnError>) => {
    return (options.client ?? client).put<AdminUpdateOrganizationResponses, AdminUpdateOrganizationErrors, ThrowOnError>({
        responseType: 'json',
        security: [
            {
                scheme: 'bearer',
                type: 'http'
            }
        ],
        url: '/api/v1/admin/organizations/{org_id}',
        ...options,
        headers: {
            'Content-Type': 'application/json',
            ...options.headers
        }
    });
};

/**
 * Admin: List Organization Members
 *
 * Get all members of an organization (admin only)
 */
export const adminListOrganizationMembers = <ThrowOnError extends boolean = false>(options: Options<AdminListOrganizationMembersData, ThrowOnError>) => {
    return (options.client ?? client).get<AdminListOrganizationMembersResponses, AdminListOrganizationMembersErrors, ThrowOnError>({
        responseType: 'json',
        security: [
            {
                scheme: 'bearer',
                type: 'http'
            }
        ],
        url: '/api/v1/admin/organizations/{org_id}/members',
        ...options
    });
};

/**
 * Admin: Add Member to Organization
 *
 * Add a user to an organization (admin only)
 */
export const adminAddOrganizationMember = <ThrowOnError extends boolean = false>(options: Options<AdminAddOrganizationMemberData, ThrowOnError>) => {
    return (options.client ?? client).post<AdminAddOrganizationMemberResponses, AdminAddOrganizationMemberErrors, ThrowOnError>({
        responseType: 'json',
        security: [
            {
                scheme: 'bearer',
                type: 'http'
            }
        ],
        url: '/api/v1/admin/organizations/{org_id}/members',
        ...options,
        headers: {
            'Content-Type': 'application/json',
            ...options.headers
        }
    });
};

/**
 * Admin: Remove Member from Organization
 *
 * Remove a user from an organization (admin only)
 */
export const adminRemoveOrganizationMember = <ThrowOnError extends boolean = false>(options: Options<AdminRemoveOrganizationMemberData, ThrowOnError>) => {
    return (options.client ?? client).delete<AdminRemoveOrganizationMemberResponses, AdminRemoveOrganizationMemberErrors, ThrowOnError>({
        responseType: 'json',
        security: [
            {
                scheme: 'bearer',
                type: 'http'
            }
        ],
        url: '/api/v1/admin/organizations/{org_id}/members/{user_id}',
        ...options
    });
};

/**
 * Admin: List All Sessions
 *
 * List all sessions across all users (admin only).
 *
 * Returns paginated list of sessions with user information.
 * Useful for admin dashboard statistics and session monitoring.
 */
export const adminListSessions = <ThrowOnError extends boolean = false>(options?: Options<AdminListSessionsData, ThrowOnError>) => {
    return (options?.client ?? client).get<AdminListSessionsResponses, AdminListSessionsErrors, ThrowOnError>({
        responseType: 'json',
        security: [
            {
                scheme: 'bearer',
                type: 'http'
            }
        ],
        url: '/api/v1/admin/sessions',
        ...options
    });
};

/**
 * Get My Organizations
 *
 * Get all organizations the current user belongs to
 */
export const getMyOrganizations = <ThrowOnError extends boolean = false>(options?: Options<GetMyOrganizationsData, ThrowOnError>) => {
    return (options?.client ?? client).get<GetMyOrganizationsResponses, GetMyOrganizationsErrors, ThrowOnError>({
        responseType: 'json',
        security: [
            {
                scheme: 'bearer',
                type: 'http'
            }
        ],
        url: '/api/v1/organizations/me',
        ...options
    });
};

/**
 * Get Organization Details
 *
 * Get details of an organization the user belongs to
 */
export const getOrganization = <ThrowOnError extends boolean = false>(options: Options<GetOrganizationData, ThrowOnError>) => {
    return (options.client ?? client).get<GetOrganizationResponses, GetOrganizationErrors, ThrowOnError>({
        responseType: 'json',
        security: [
            {
                scheme: 'bearer',
                type: 'http'
            }
        ],
        url: '/api/v1/organizations/{organization_id}',
        ...options
    });
};

/**
 * Update Organization
 *
 * Update organization details (admin/owner only)
 */
export const updateOrganization = <ThrowOnError extends boolean = false>(options: Options<UpdateOrganizationData, ThrowOnError>) => {
    return (options.client ?? client).put<UpdateOrganizationResponses, UpdateOrganizationErrors, ThrowOnError>({
        responseType: 'json',
        security: [
            {
                scheme: 'bearer',
                type: 'http'
            }
        ],
        url: '/api/v1/organizations/{organization_id}',
        ...options,
        headers: {
            'Content-Type': 'application/json',
            ...options.headers
        }
    });
};

/**
 * Get Organization Members
 *
 * Get all members of an organization (members can view)
 */
export const getOrganizationMembers = <ThrowOnError extends boolean = false>(options: Options<GetOrganizationMembersData, ThrowOnError>) => {
    return (options.client ?? client).get<GetOrganizationMembersResponses, GetOrganizationMembersErrors, ThrowOnError>({
        responseType: 'json',
        security: [
            {
                scheme: 'bearer',
                type: 'http'
            }
        ],
        url: '/api/v1/organizations/{organization_id}/members',
        ...options
    });
};

/**
 * Stream Project Events
 *
 * Stream real-time events for a project via Server-Sent Events (SSE).
 *
 * **Authentication**: Required (Bearer token)
 * **Authorization**: Must have access to the project
 *
 * **SSE Event Format**:
 * ```
 * event: agent.status_changed
 * id: 550e8400-e29b-41d4-a716-446655440000
 * data: {"id": "...", "type": "agent.status_changed", "project_id": "...", ...}
 *
 * : keepalive
 *
 * event: issue.created
 * id: 550e8400-e29b-41d4-a716-446655440001
 * data: {...}
 * ```
 *
 * **Reconnection**: Include the `Last-Event-ID` header with the last received
 * event ID to resume from where you left off.
 *
 * **Keepalive**: The server sends a comment (`: keepalive`) every 30 seconds
 * to keep the connection alive.
 *
 * **Rate Limit**: 10 connections/minute per IP
 */
export const streamProjectEvents = <ThrowOnError extends boolean = false>(options: Options<StreamProjectEventsData, ThrowOnError>) => {
    return (options.client ?? client).sse.get<StreamProjectEventsResponses, StreamProjectEventsErrors, ThrowOnError>({
        responseType: 'text',
        security: [
            {
                scheme: 'bearer',
                type: 'http'
            }
        ],
        url: '/api/v1/projects/{project_id}/events/stream',
        ...options
    });
};

/**
 * Send Test Event (Development Only)
 *
 * Send a test event to a project's event stream. This endpoint is
 * intended for development and testing purposes.
 *
 * **Authentication**: Required (Bearer token)
 * **Authorization**: Must have access to the project
 *
 * **Note**: This endpoint should be disabled or restricted in production.
 */
export const sendTestEvent = <ThrowOnError extends boolean = false>(options: Options<SendTestEventData, ThrowOnError>) => {
    return (options.client ?? client).post<SendTestEventResponses, SendTestEventErrors, ThrowOnError>({
        responseType: 'json',
        security: [
            {
                scheme: 'bearer',
                type: 'http'
            }
        ],
        url: '/api/v1/projects/{project_id}/events/test',
        ...options
    });
};

/**
 * OAuth Server Metadata
 *
 * OAuth 2.0 Authorization Server Metadata (RFC 8414).
 *
 * Returns server metadata including supported endpoints, scopes,
 * and capabilities. MCP clients use this to discover the server.
 *
 * Note: This endpoint is at the root level per RFC 8414.
 */
export const getOauthServerMetadata = <ThrowOnError extends boolean = false>(options?: Options<GetOauthServerMetadataData, ThrowOnError>) => {
    return (options?.client ?? client).get<GetOauthServerMetadataResponses, unknown, ThrowOnError>({
        responseType: 'json',
        url: '/.well-known/oauth-authorization-server',
        ...options
    });
};
