/**
 * Generated by orval v8.3.0 🍺
 * Do not edit manually.
 * Mission Control API
 * OpenAPI spec version: 0.1.0
 */
import { useMutation, useQuery } from "@tanstack/react-query";
import type {
  DataTag,
  DefinedInitialDataOptions,
  DefinedUseQueryResult,
  MutationFunction,
  QueryClient,
  QueryFunction,
  QueryKey,
  UndefinedInitialDataOptions,
  UseMutationOptions,
  UseMutationResult,
  UseQueryOptions,
  UseQueryResult,
} from "@tanstack/react-query";

import type {
  CronStatusResponse,
  GatewayAgentImportPreviewResponse,
  GatewayAgentImportRequest,
  GatewayAgentImportResponse,
  GatewayCommandsResponse,
  GatewayCreate,
  GatewayRead,
  GatewaySessionHistoryResponse,
  GatewaySessionMessageRequest,
  GatewaySessionResponse,
  GatewaySessionsResponse,
  GatewayTemplatesSyncResult,
  GatewayUpdate,
  GatewaysStatusApiV1GatewaysStatusGetParams,
  GatewaysStatusResponse,
  GetGatewayConfigApiV1GatewaysGatewayIdConfigGet200,
  GetGatewayLogsApiV1GatewaysGatewayIdLogsGet200,
  GetGatewayLogsApiV1GatewaysGatewayIdLogsGetParams,
  GetGatewayRuntimeActivityApiV1GatewaysGatewayIdRuntimeActivityGet200,
  GetGatewaySessionApiV1GatewaysSessionsSessionIdGetParams,
  GetSessionHistoryApiV1GatewaysSessionsSessionIdHistoryGetParams,
  HTTPValidationError,
  LimitOffsetPageTypeVarCustomizedGatewayRead,
  ListGatewaySessionsApiV1GatewaysSessionsGetParams,
  ListGatewaysApiV1GatewaysGetParams,
  OkResponse,
  PatchGatewayConfigApiV1GatewaysGatewayIdConfigPatch200,
  PatchGatewayConfigApiV1GatewaysGatewayIdConfigPatchBody,
  ProviderUsageResponse,
  RuntimeUsageResponse,
  SendGatewaySessionMessageApiV1GatewaysSessionsSessionIdMessagePostParams,
  SyncGatewayTemplatesApiV1GatewaysGatewayIdTemplatesSyncPostParams,
  SystemHealthResponse,
} from ".././model";

import { customFetch } from "../../mutator";

type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1];

/**
 * Return gateway connectivity and session status.
 * @summary Gateways Status
 */
export type gatewaysStatusApiV1GatewaysStatusGetResponse200 = {
  data: GatewaysStatusResponse;
  status: 200;
};

export type gatewaysStatusApiV1GatewaysStatusGetResponse422 = {
  data: HTTPValidationError;
  status: 422;
};

export type gatewaysStatusApiV1GatewaysStatusGetResponseSuccess =
  gatewaysStatusApiV1GatewaysStatusGetResponse200 & {
    headers: Headers;
  };
export type gatewaysStatusApiV1GatewaysStatusGetResponseError =
  gatewaysStatusApiV1GatewaysStatusGetResponse422 & {
    headers: Headers;
  };

export type gatewaysStatusApiV1GatewaysStatusGetResponse =
  | gatewaysStatusApiV1GatewaysStatusGetResponseSuccess
  | gatewaysStatusApiV1GatewaysStatusGetResponseError;

export const getGatewaysStatusApiV1GatewaysStatusGetUrl = (
  params?: GatewaysStatusApiV1GatewaysStatusGetParams,
) => {
  const normalizedParams = new URLSearchParams();

  Object.entries(params || {}).forEach(([key, value]) => {
    if (value !== undefined) {
      normalizedParams.append(key, value === null ? "null" : value.toString());
    }
  });

  const stringifiedParams = normalizedParams.toString();

  return stringifiedParams.length > 0
    ? `/api/v1/gateways/status?${stringifiedParams}`
    : `/api/v1/gateways/status`;
};

export const gatewaysStatusApiV1GatewaysStatusGet = async (
  params?: GatewaysStatusApiV1GatewaysStatusGetParams,
  options?: RequestInit,
): Promise<gatewaysStatusApiV1GatewaysStatusGetResponse> => {
  return customFetch<gatewaysStatusApiV1GatewaysStatusGetResponse>(
    getGatewaysStatusApiV1GatewaysStatusGetUrl(params),
    {
      ...options,
      method: "GET",
    },
  );
};

export const getGatewaysStatusApiV1GatewaysStatusGetQueryKey = (
  params?: GatewaysStatusApiV1GatewaysStatusGetParams,
) => {
  return [`/api/v1/gateways/status`, ...(params ? [params] : [])] as const;
};

export const getGatewaysStatusApiV1GatewaysStatusGetQueryOptions = <
  TData = Awaited<ReturnType<typeof gatewaysStatusApiV1GatewaysStatusGet>>,
  TError = HTTPValidationError,
>(
  params?: GatewaysStatusApiV1GatewaysStatusGetParams,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof gatewaysStatusApiV1GatewaysStatusGet>>,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof customFetch>;
  },
) => {
  const { query: queryOptions, request: requestOptions } = options ?? {};

  const queryKey =
    queryOptions?.queryKey ??
    getGatewaysStatusApiV1GatewaysStatusGetQueryKey(params);

  const queryFn: QueryFunction<
    Awaited<ReturnType<typeof gatewaysStatusApiV1GatewaysStatusGet>>
  > = ({ signal }) =>
    gatewaysStatusApiV1GatewaysStatusGet(params, { signal, ...requestOptions });

  return { queryKey, queryFn, ...queryOptions } as UseQueryOptions<
    Awaited<ReturnType<typeof gatewaysStatusApiV1GatewaysStatusGet>>,
    TError,
    TData
  > & { queryKey: DataTag<QueryKey, TData, TError> };
};

export type GatewaysStatusApiV1GatewaysStatusGetQueryResult = NonNullable<
  Awaited<ReturnType<typeof gatewaysStatusApiV1GatewaysStatusGet>>
>;
export type GatewaysStatusApiV1GatewaysStatusGetQueryError =
  HTTPValidationError;

export function useGatewaysStatusApiV1GatewaysStatusGet<
  TData = Awaited<ReturnType<typeof gatewaysStatusApiV1GatewaysStatusGet>>,
  TError = HTTPValidationError,
>(
  params: undefined | GatewaysStatusApiV1GatewaysStatusGetParams,
  options: {
    query: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof gatewaysStatusApiV1GatewaysStatusGet>>,
        TError,
        TData
      >
    > &
      Pick<
        DefinedInitialDataOptions<
          Awaited<ReturnType<typeof gatewaysStatusApiV1GatewaysStatusGet>>,
          TError,
          Awaited<ReturnType<typeof gatewaysStatusApiV1GatewaysStatusGet>>
        >,
        "initialData"
      >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): DefinedUseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useGatewaysStatusApiV1GatewaysStatusGet<
  TData = Awaited<ReturnType<typeof gatewaysStatusApiV1GatewaysStatusGet>>,
  TError = HTTPValidationError,
>(
  params?: GatewaysStatusApiV1GatewaysStatusGetParams,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof gatewaysStatusApiV1GatewaysStatusGet>>,
        TError,
        TData
      >
    > &
      Pick<
        UndefinedInitialDataOptions<
          Awaited<ReturnType<typeof gatewaysStatusApiV1GatewaysStatusGet>>,
          TError,
          Awaited<ReturnType<typeof gatewaysStatusApiV1GatewaysStatusGet>>
        >,
        "initialData"
      >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useGatewaysStatusApiV1GatewaysStatusGet<
  TData = Awaited<ReturnType<typeof gatewaysStatusApiV1GatewaysStatusGet>>,
  TError = HTTPValidationError,
>(
  params?: GatewaysStatusApiV1GatewaysStatusGetParams,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof gatewaysStatusApiV1GatewaysStatusGet>>,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
/**
 * @summary Gateways Status
 */

export function useGatewaysStatusApiV1GatewaysStatusGet<
  TData = Awaited<ReturnType<typeof gatewaysStatusApiV1GatewaysStatusGet>>,
  TError = HTTPValidationError,
>(
  params?: GatewaysStatusApiV1GatewaysStatusGetParams,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof gatewaysStatusApiV1GatewaysStatusGet>>,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
} {
  const queryOptions = getGatewaysStatusApiV1GatewaysStatusGetQueryOptions(
    params,
    options,
  );

  const query = useQuery(queryOptions, queryClient) as UseQueryResult<
    TData,
    TError
  > & { queryKey: DataTag<QueryKey, TData, TError> };

  return { ...query, queryKey: queryOptions.queryKey };
}

/**
 * List sessions for a gateway associated with a board.
 * @summary List Gateway Sessions
 */
export type listGatewaySessionsApiV1GatewaysSessionsGetResponse200 = {
  data: GatewaySessionsResponse;
  status: 200;
};

export type listGatewaySessionsApiV1GatewaysSessionsGetResponse422 = {
  data: HTTPValidationError;
  status: 422;
};

export type listGatewaySessionsApiV1GatewaysSessionsGetResponseSuccess =
  listGatewaySessionsApiV1GatewaysSessionsGetResponse200 & {
    headers: Headers;
  };
export type listGatewaySessionsApiV1GatewaysSessionsGetResponseError =
  listGatewaySessionsApiV1GatewaysSessionsGetResponse422 & {
    headers: Headers;
  };

export type listGatewaySessionsApiV1GatewaysSessionsGetResponse =
  | listGatewaySessionsApiV1GatewaysSessionsGetResponseSuccess
  | listGatewaySessionsApiV1GatewaysSessionsGetResponseError;

export const getListGatewaySessionsApiV1GatewaysSessionsGetUrl = (
  params?: ListGatewaySessionsApiV1GatewaysSessionsGetParams,
) => {
  const normalizedParams = new URLSearchParams();

  Object.entries(params || {}).forEach(([key, value]) => {
    if (value !== undefined) {
      normalizedParams.append(key, value === null ? "null" : value.toString());
    }
  });

  const stringifiedParams = normalizedParams.toString();

  return stringifiedParams.length > 0
    ? `/api/v1/gateways/sessions?${stringifiedParams}`
    : `/api/v1/gateways/sessions`;
};

export const listGatewaySessionsApiV1GatewaysSessionsGet = async (
  params?: ListGatewaySessionsApiV1GatewaysSessionsGetParams,
  options?: RequestInit,
): Promise<listGatewaySessionsApiV1GatewaysSessionsGetResponse> => {
  return customFetch<listGatewaySessionsApiV1GatewaysSessionsGetResponse>(
    getListGatewaySessionsApiV1GatewaysSessionsGetUrl(params),
    {
      ...options,
      method: "GET",
    },
  );
};

export const getListGatewaySessionsApiV1GatewaysSessionsGetQueryKey = (
  params?: ListGatewaySessionsApiV1GatewaysSessionsGetParams,
) => {
  return [`/api/v1/gateways/sessions`, ...(params ? [params] : [])] as const;
};

export const getListGatewaySessionsApiV1GatewaysSessionsGetQueryOptions = <
  TData = Awaited<
    ReturnType<typeof listGatewaySessionsApiV1GatewaysSessionsGet>
  >,
  TError = HTTPValidationError,
>(
  params?: ListGatewaySessionsApiV1GatewaysSessionsGetParams,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof listGatewaySessionsApiV1GatewaysSessionsGet>>,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof customFetch>;
  },
) => {
  const { query: queryOptions, request: requestOptions } = options ?? {};

  const queryKey =
    queryOptions?.queryKey ??
    getListGatewaySessionsApiV1GatewaysSessionsGetQueryKey(params);

  const queryFn: QueryFunction<
    Awaited<ReturnType<typeof listGatewaySessionsApiV1GatewaysSessionsGet>>
  > = ({ signal }) =>
    listGatewaySessionsApiV1GatewaysSessionsGet(params, {
      signal,
      ...requestOptions,
    });

  return { queryKey, queryFn, ...queryOptions } as UseQueryOptions<
    Awaited<ReturnType<typeof listGatewaySessionsApiV1GatewaysSessionsGet>>,
    TError,
    TData
  > & { queryKey: DataTag<QueryKey, TData, TError> };
};

export type ListGatewaySessionsApiV1GatewaysSessionsGetQueryResult =
  NonNullable<
    Awaited<ReturnType<typeof listGatewaySessionsApiV1GatewaysSessionsGet>>
  >;
export type ListGatewaySessionsApiV1GatewaysSessionsGetQueryError =
  HTTPValidationError;

export function useListGatewaySessionsApiV1GatewaysSessionsGet<
  TData = Awaited<
    ReturnType<typeof listGatewaySessionsApiV1GatewaysSessionsGet>
  >,
  TError = HTTPValidationError,
>(
  params: undefined | ListGatewaySessionsApiV1GatewaysSessionsGetParams,
  options: {
    query: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof listGatewaySessionsApiV1GatewaysSessionsGet>>,
        TError,
        TData
      >
    > &
      Pick<
        DefinedInitialDataOptions<
          Awaited<
            ReturnType<typeof listGatewaySessionsApiV1GatewaysSessionsGet>
          >,
          TError,
          Awaited<
            ReturnType<typeof listGatewaySessionsApiV1GatewaysSessionsGet>
          >
        >,
        "initialData"
      >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): DefinedUseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useListGatewaySessionsApiV1GatewaysSessionsGet<
  TData = Awaited<
    ReturnType<typeof listGatewaySessionsApiV1GatewaysSessionsGet>
  >,
  TError = HTTPValidationError,
>(
  params?: ListGatewaySessionsApiV1GatewaysSessionsGetParams,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof listGatewaySessionsApiV1GatewaysSessionsGet>>,
        TError,
        TData
      >
    > &
      Pick<
        UndefinedInitialDataOptions<
          Awaited<
            ReturnType<typeof listGatewaySessionsApiV1GatewaysSessionsGet>
          >,
          TError,
          Awaited<
            ReturnType<typeof listGatewaySessionsApiV1GatewaysSessionsGet>
          >
        >,
        "initialData"
      >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useListGatewaySessionsApiV1GatewaysSessionsGet<
  TData = Awaited<
    ReturnType<typeof listGatewaySessionsApiV1GatewaysSessionsGet>
  >,
  TError = HTTPValidationError,
>(
  params?: ListGatewaySessionsApiV1GatewaysSessionsGetParams,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof listGatewaySessionsApiV1GatewaysSessionsGet>>,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
/**
 * @summary List Gateway Sessions
 */

export function useListGatewaySessionsApiV1GatewaysSessionsGet<
  TData = Awaited<
    ReturnType<typeof listGatewaySessionsApiV1GatewaysSessionsGet>
  >,
  TError = HTTPValidationError,
>(
  params?: ListGatewaySessionsApiV1GatewaysSessionsGetParams,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof listGatewaySessionsApiV1GatewaysSessionsGet>>,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
} {
  const queryOptions =
    getListGatewaySessionsApiV1GatewaysSessionsGetQueryOptions(params, options);

  const query = useQuery(queryOptions, queryClient) as UseQueryResult<
    TData,
    TError
  > & { queryKey: DataTag<QueryKey, TData, TError> };

  return { ...query, queryKey: queryOptions.queryKey };
}

/**
 * Get a specific gateway session by key.
 * @summary Get Gateway Session
 */
export type getGatewaySessionApiV1GatewaysSessionsSessionIdGetResponse200 = {
  data: GatewaySessionResponse;
  status: 200;
};

export type getGatewaySessionApiV1GatewaysSessionsSessionIdGetResponse422 = {
  data: HTTPValidationError;
  status: 422;
};

export type getGatewaySessionApiV1GatewaysSessionsSessionIdGetResponseSuccess =
  getGatewaySessionApiV1GatewaysSessionsSessionIdGetResponse200 & {
    headers: Headers;
  };
export type getGatewaySessionApiV1GatewaysSessionsSessionIdGetResponseError =
  getGatewaySessionApiV1GatewaysSessionsSessionIdGetResponse422 & {
    headers: Headers;
  };

export type getGatewaySessionApiV1GatewaysSessionsSessionIdGetResponse =
  | getGatewaySessionApiV1GatewaysSessionsSessionIdGetResponseSuccess
  | getGatewaySessionApiV1GatewaysSessionsSessionIdGetResponseError;

export const getGetGatewaySessionApiV1GatewaysSessionsSessionIdGetUrl = (
  sessionId: string,
  params?: GetGatewaySessionApiV1GatewaysSessionsSessionIdGetParams,
) => {
  const normalizedParams = new URLSearchParams();

  Object.entries(params || {}).forEach(([key, value]) => {
    if (value !== undefined) {
      normalizedParams.append(key, value === null ? "null" : value.toString());
    }
  });

  const stringifiedParams = normalizedParams.toString();

  return stringifiedParams.length > 0
    ? `/api/v1/gateways/sessions/${sessionId}?${stringifiedParams}`
    : `/api/v1/gateways/sessions/${sessionId}`;
};

export const getGatewaySessionApiV1GatewaysSessionsSessionIdGet = async (
  sessionId: string,
  params?: GetGatewaySessionApiV1GatewaysSessionsSessionIdGetParams,
  options?: RequestInit,
): Promise<getGatewaySessionApiV1GatewaysSessionsSessionIdGetResponse> => {
  return customFetch<getGatewaySessionApiV1GatewaysSessionsSessionIdGetResponse>(
    getGetGatewaySessionApiV1GatewaysSessionsSessionIdGetUrl(sessionId, params),
    {
      ...options,
      method: "GET",
    },
  );
};

export const getGetGatewaySessionApiV1GatewaysSessionsSessionIdGetQueryKey = (
  sessionId: string,
  params?: GetGatewaySessionApiV1GatewaysSessionsSessionIdGetParams,
) => {
  return [
    `/api/v1/gateways/sessions/${sessionId}`,
    ...(params ? [params] : []),
  ] as const;
};

export const getGetGatewaySessionApiV1GatewaysSessionsSessionIdGetQueryOptions =
  <
    TData = Awaited<
      ReturnType<typeof getGatewaySessionApiV1GatewaysSessionsSessionIdGet>
    >,
    TError = HTTPValidationError,
  >(
    sessionId: string,
    params?: GetGatewaySessionApiV1GatewaysSessionsSessionIdGetParams,
    options?: {
      query?: Partial<
        UseQueryOptions<
          Awaited<
            ReturnType<
              typeof getGatewaySessionApiV1GatewaysSessionsSessionIdGet
            >
          >,
          TError,
          TData
        >
      >;
      request?: SecondParameter<typeof customFetch>;
    },
  ) => {
    const { query: queryOptions, request: requestOptions } = options ?? {};

    const queryKey =
      queryOptions?.queryKey ??
      getGetGatewaySessionApiV1GatewaysSessionsSessionIdGetQueryKey(
        sessionId,
        params,
      );

    const queryFn: QueryFunction<
      Awaited<
        ReturnType<typeof getGatewaySessionApiV1GatewaysSessionsSessionIdGet>
      >
    > = ({ signal }) =>
      getGatewaySessionApiV1GatewaysSessionsSessionIdGet(sessionId, params, {
        signal,
        ...requestOptions,
      });

    return {
      queryKey,
      queryFn,
      enabled: !!sessionId,
      ...queryOptions,
    } as UseQueryOptions<
      Awaited<
        ReturnType<typeof getGatewaySessionApiV1GatewaysSessionsSessionIdGet>
      >,
      TError,
      TData
    > & { queryKey: DataTag<QueryKey, TData, TError> };
  };

export type GetGatewaySessionApiV1GatewaysSessionsSessionIdGetQueryResult =
  NonNullable<
    Awaited<
      ReturnType<typeof getGatewaySessionApiV1GatewaysSessionsSessionIdGet>
    >
  >;
export type GetGatewaySessionApiV1GatewaysSessionsSessionIdGetQueryError =
  HTTPValidationError;

export function useGetGatewaySessionApiV1GatewaysSessionsSessionIdGet<
  TData = Awaited<
    ReturnType<typeof getGatewaySessionApiV1GatewaysSessionsSessionIdGet>
  >,
  TError = HTTPValidationError,
>(
  sessionId: string,
  params: undefined | GetGatewaySessionApiV1GatewaysSessionsSessionIdGetParams,
  options: {
    query: Partial<
      UseQueryOptions<
        Awaited<
          ReturnType<typeof getGatewaySessionApiV1GatewaysSessionsSessionIdGet>
        >,
        TError,
        TData
      >
    > &
      Pick<
        DefinedInitialDataOptions<
          Awaited<
            ReturnType<
              typeof getGatewaySessionApiV1GatewaysSessionsSessionIdGet
            >
          >,
          TError,
          Awaited<
            ReturnType<
              typeof getGatewaySessionApiV1GatewaysSessionsSessionIdGet
            >
          >
        >,
        "initialData"
      >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): DefinedUseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useGetGatewaySessionApiV1GatewaysSessionsSessionIdGet<
  TData = Awaited<
    ReturnType<typeof getGatewaySessionApiV1GatewaysSessionsSessionIdGet>
  >,
  TError = HTTPValidationError,
>(
  sessionId: string,
  params?: GetGatewaySessionApiV1GatewaysSessionsSessionIdGetParams,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<
          ReturnType<typeof getGatewaySessionApiV1GatewaysSessionsSessionIdGet>
        >,
        TError,
        TData
      >
    > &
      Pick<
        UndefinedInitialDataOptions<
          Awaited<
            ReturnType<
              typeof getGatewaySessionApiV1GatewaysSessionsSessionIdGet
            >
          >,
          TError,
          Awaited<
            ReturnType<
              typeof getGatewaySessionApiV1GatewaysSessionsSessionIdGet
            >
          >
        >,
        "initialData"
      >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useGetGatewaySessionApiV1GatewaysSessionsSessionIdGet<
  TData = Awaited<
    ReturnType<typeof getGatewaySessionApiV1GatewaysSessionsSessionIdGet>
  >,
  TError = HTTPValidationError,
>(
  sessionId: string,
  params?: GetGatewaySessionApiV1GatewaysSessionsSessionIdGetParams,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<
          ReturnType<typeof getGatewaySessionApiV1GatewaysSessionsSessionIdGet>
        >,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
/**
 * @summary Get Gateway Session
 */

export function useGetGatewaySessionApiV1GatewaysSessionsSessionIdGet<
  TData = Awaited<
    ReturnType<typeof getGatewaySessionApiV1GatewaysSessionsSessionIdGet>
  >,
  TError = HTTPValidationError,
>(
  sessionId: string,
  params?: GetGatewaySessionApiV1GatewaysSessionsSessionIdGetParams,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<
          ReturnType<typeof getGatewaySessionApiV1GatewaysSessionsSessionIdGet>
        >,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
} {
  const queryOptions =
    getGetGatewaySessionApiV1GatewaysSessionsSessionIdGetQueryOptions(
      sessionId,
      params,
      options,
    );

  const query = useQuery(queryOptions, queryClient) as UseQueryResult<
    TData,
    TError
  > & { queryKey: DataTag<QueryKey, TData, TError> };

  return { ...query, queryKey: queryOptions.queryKey };
}

/**
 * Fetch chat history for a gateway session.
 * @summary Get Session History
 */
export type getSessionHistoryApiV1GatewaysSessionsSessionIdHistoryGetResponse200 =
  {
    data: GatewaySessionHistoryResponse;
    status: 200;
  };

export type getSessionHistoryApiV1GatewaysSessionsSessionIdHistoryGetResponse422 =
  {
    data: HTTPValidationError;
    status: 422;
  };

export type getSessionHistoryApiV1GatewaysSessionsSessionIdHistoryGetResponseSuccess =
  getSessionHistoryApiV1GatewaysSessionsSessionIdHistoryGetResponse200 & {
    headers: Headers;
  };
export type getSessionHistoryApiV1GatewaysSessionsSessionIdHistoryGetResponseError =
  getSessionHistoryApiV1GatewaysSessionsSessionIdHistoryGetResponse422 & {
    headers: Headers;
  };

export type getSessionHistoryApiV1GatewaysSessionsSessionIdHistoryGetResponse =
  | getSessionHistoryApiV1GatewaysSessionsSessionIdHistoryGetResponseSuccess
  | getSessionHistoryApiV1GatewaysSessionsSessionIdHistoryGetResponseError;

export const getGetSessionHistoryApiV1GatewaysSessionsSessionIdHistoryGetUrl = (
  sessionId: string,
  params?: GetSessionHistoryApiV1GatewaysSessionsSessionIdHistoryGetParams,
) => {
  const normalizedParams = new URLSearchParams();

  Object.entries(params || {}).forEach(([key, value]) => {
    if (value !== undefined) {
      normalizedParams.append(key, value === null ? "null" : value.toString());
    }
  });

  const stringifiedParams = normalizedParams.toString();

  return stringifiedParams.length > 0
    ? `/api/v1/gateways/sessions/${sessionId}/history?${stringifiedParams}`
    : `/api/v1/gateways/sessions/${sessionId}/history`;
};

export const getSessionHistoryApiV1GatewaysSessionsSessionIdHistoryGet = async (
  sessionId: string,
  params?: GetSessionHistoryApiV1GatewaysSessionsSessionIdHistoryGetParams,
  options?: RequestInit,
): Promise<getSessionHistoryApiV1GatewaysSessionsSessionIdHistoryGetResponse> => {
  return customFetch<getSessionHistoryApiV1GatewaysSessionsSessionIdHistoryGetResponse>(
    getGetSessionHistoryApiV1GatewaysSessionsSessionIdHistoryGetUrl(
      sessionId,
      params,
    ),
    {
      ...options,
      method: "GET",
    },
  );
};

export const getGetSessionHistoryApiV1GatewaysSessionsSessionIdHistoryGetQueryKey =
  (
    sessionId: string,
    params?: GetSessionHistoryApiV1GatewaysSessionsSessionIdHistoryGetParams,
  ) => {
    return [
      `/api/v1/gateways/sessions/${sessionId}/history`,
      ...(params ? [params] : []),
    ] as const;
  };

export const getGetSessionHistoryApiV1GatewaysSessionsSessionIdHistoryGetQueryOptions =
  <
    TData = Awaited<
      ReturnType<
        typeof getSessionHistoryApiV1GatewaysSessionsSessionIdHistoryGet
      >
    >,
    TError = HTTPValidationError,
  >(
    sessionId: string,
    params?: GetSessionHistoryApiV1GatewaysSessionsSessionIdHistoryGetParams,
    options?: {
      query?: Partial<
        UseQueryOptions<
          Awaited<
            ReturnType<
              typeof getSessionHistoryApiV1GatewaysSessionsSessionIdHistoryGet
            >
          >,
          TError,
          TData
        >
      >;
      request?: SecondParameter<typeof customFetch>;
    },
  ) => {
    const { query: queryOptions, request: requestOptions } = options ?? {};

    const queryKey =
      queryOptions?.queryKey ??
      getGetSessionHistoryApiV1GatewaysSessionsSessionIdHistoryGetQueryKey(
        sessionId,
        params,
      );

    const queryFn: QueryFunction<
      Awaited<
        ReturnType<
          typeof getSessionHistoryApiV1GatewaysSessionsSessionIdHistoryGet
        >
      >
    > = ({ signal }) =>
      getSessionHistoryApiV1GatewaysSessionsSessionIdHistoryGet(
        sessionId,
        params,
        { signal, ...requestOptions },
      );

    return {
      queryKey,
      queryFn,
      enabled: !!sessionId,
      ...queryOptions,
    } as UseQueryOptions<
      Awaited<
        ReturnType<
          typeof getSessionHistoryApiV1GatewaysSessionsSessionIdHistoryGet
        >
      >,
      TError,
      TData
    > & { queryKey: DataTag<QueryKey, TData, TError> };
  };

export type GetSessionHistoryApiV1GatewaysSessionsSessionIdHistoryGetQueryResult =
  NonNullable<
    Awaited<
      ReturnType<
        typeof getSessionHistoryApiV1GatewaysSessionsSessionIdHistoryGet
      >
    >
  >;
export type GetSessionHistoryApiV1GatewaysSessionsSessionIdHistoryGetQueryError =
  HTTPValidationError;

export function useGetSessionHistoryApiV1GatewaysSessionsSessionIdHistoryGet<
  TData = Awaited<
    ReturnType<typeof getSessionHistoryApiV1GatewaysSessionsSessionIdHistoryGet>
  >,
  TError = HTTPValidationError,
>(
  sessionId: string,
  params:
    | undefined
    | GetSessionHistoryApiV1GatewaysSessionsSessionIdHistoryGetParams,
  options: {
    query: Partial<
      UseQueryOptions<
        Awaited<
          ReturnType<
            typeof getSessionHistoryApiV1GatewaysSessionsSessionIdHistoryGet
          >
        >,
        TError,
        TData
      >
    > &
      Pick<
        DefinedInitialDataOptions<
          Awaited<
            ReturnType<
              typeof getSessionHistoryApiV1GatewaysSessionsSessionIdHistoryGet
            >
          >,
          TError,
          Awaited<
            ReturnType<
              typeof getSessionHistoryApiV1GatewaysSessionsSessionIdHistoryGet
            >
          >
        >,
        "initialData"
      >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): DefinedUseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useGetSessionHistoryApiV1GatewaysSessionsSessionIdHistoryGet<
  TData = Awaited<
    ReturnType<typeof getSessionHistoryApiV1GatewaysSessionsSessionIdHistoryGet>
  >,
  TError = HTTPValidationError,
>(
  sessionId: string,
  params?: GetSessionHistoryApiV1GatewaysSessionsSessionIdHistoryGetParams,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<
          ReturnType<
            typeof getSessionHistoryApiV1GatewaysSessionsSessionIdHistoryGet
          >
        >,
        TError,
        TData
      >
    > &
      Pick<
        UndefinedInitialDataOptions<
          Awaited<
            ReturnType<
              typeof getSessionHistoryApiV1GatewaysSessionsSessionIdHistoryGet
            >
          >,
          TError,
          Awaited<
            ReturnType<
              typeof getSessionHistoryApiV1GatewaysSessionsSessionIdHistoryGet
            >
          >
        >,
        "initialData"
      >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useGetSessionHistoryApiV1GatewaysSessionsSessionIdHistoryGet<
  TData = Awaited<
    ReturnType<typeof getSessionHistoryApiV1GatewaysSessionsSessionIdHistoryGet>
  >,
  TError = HTTPValidationError,
>(
  sessionId: string,
  params?: GetSessionHistoryApiV1GatewaysSessionsSessionIdHistoryGetParams,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<
          ReturnType<
            typeof getSessionHistoryApiV1GatewaysSessionsSessionIdHistoryGet
          >
        >,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
/**
 * @summary Get Session History
 */

export function useGetSessionHistoryApiV1GatewaysSessionsSessionIdHistoryGet<
  TData = Awaited<
    ReturnType<typeof getSessionHistoryApiV1GatewaysSessionsSessionIdHistoryGet>
  >,
  TError = HTTPValidationError,
>(
  sessionId: string,
  params?: GetSessionHistoryApiV1GatewaysSessionsSessionIdHistoryGetParams,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<
          ReturnType<
            typeof getSessionHistoryApiV1GatewaysSessionsSessionIdHistoryGet
          >
        >,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
} {
  const queryOptions =
    getGetSessionHistoryApiV1GatewaysSessionsSessionIdHistoryGetQueryOptions(
      sessionId,
      params,
      options,
    );

  const query = useQuery(queryOptions, queryClient) as UseQueryResult<
    TData,
    TError
  > & { queryKey: DataTag<QueryKey, TData, TError> };

  return { ...query, queryKey: queryOptions.queryKey };
}

/**
 * Send a message into a specific gateway session.
 * @summary Send Gateway Session Message
 */
export type sendGatewaySessionMessageApiV1GatewaysSessionsSessionIdMessagePostResponse200 =
  {
    data: OkResponse;
    status: 200;
  };

export type sendGatewaySessionMessageApiV1GatewaysSessionsSessionIdMessagePostResponse422 =
  {
    data: HTTPValidationError;
    status: 422;
  };

export type sendGatewaySessionMessageApiV1GatewaysSessionsSessionIdMessagePostResponseSuccess =
  sendGatewaySessionMessageApiV1GatewaysSessionsSessionIdMessagePostResponse200 & {
    headers: Headers;
  };
export type sendGatewaySessionMessageApiV1GatewaysSessionsSessionIdMessagePostResponseError =
  sendGatewaySessionMessageApiV1GatewaysSessionsSessionIdMessagePostResponse422 & {
    headers: Headers;
  };

export type sendGatewaySessionMessageApiV1GatewaysSessionsSessionIdMessagePostResponse =

    | sendGatewaySessionMessageApiV1GatewaysSessionsSessionIdMessagePostResponseSuccess
    | sendGatewaySessionMessageApiV1GatewaysSessionsSessionIdMessagePostResponseError;

export const getSendGatewaySessionMessageApiV1GatewaysSessionsSessionIdMessagePostUrl =
  (
    sessionId: string,
    params?: SendGatewaySessionMessageApiV1GatewaysSessionsSessionIdMessagePostParams,
  ) => {
    const normalizedParams = new URLSearchParams();

    Object.entries(params || {}).forEach(([key, value]) => {
      if (value !== undefined) {
        normalizedParams.append(
          key,
          value === null ? "null" : value.toString(),
        );
      }
    });

    const stringifiedParams = normalizedParams.toString();

    return stringifiedParams.length > 0
      ? `/api/v1/gateways/sessions/${sessionId}/message?${stringifiedParams}`
      : `/api/v1/gateways/sessions/${sessionId}/message`;
  };

export const sendGatewaySessionMessageApiV1GatewaysSessionsSessionIdMessagePost =
  async (
    sessionId: string,
    gatewaySessionMessageRequest: GatewaySessionMessageRequest,
    params?: SendGatewaySessionMessageApiV1GatewaysSessionsSessionIdMessagePostParams,
    options?: RequestInit,
  ): Promise<sendGatewaySessionMessageApiV1GatewaysSessionsSessionIdMessagePostResponse> => {
    return customFetch<sendGatewaySessionMessageApiV1GatewaysSessionsSessionIdMessagePostResponse>(
      getSendGatewaySessionMessageApiV1GatewaysSessionsSessionIdMessagePostUrl(
        sessionId,
        params,
      ),
      {
        ...options,
        method: "POST",
        headers: { "Content-Type": "application/json", ...options?.headers },
        body: JSON.stringify(gatewaySessionMessageRequest),
      },
    );
  };

export const getSendGatewaySessionMessageApiV1GatewaysSessionsSessionIdMessagePostMutationOptions =
  <TError = HTTPValidationError, TContext = unknown>(options?: {
    mutation?: UseMutationOptions<
      Awaited<
        ReturnType<
          typeof sendGatewaySessionMessageApiV1GatewaysSessionsSessionIdMessagePost
        >
      >,
      TError,
      {
        sessionId: string;
        data: GatewaySessionMessageRequest;
        params?: SendGatewaySessionMessageApiV1GatewaysSessionsSessionIdMessagePostParams;
      },
      TContext
    >;
    request?: SecondParameter<typeof customFetch>;
  }): UseMutationOptions<
    Awaited<
      ReturnType<
        typeof sendGatewaySessionMessageApiV1GatewaysSessionsSessionIdMessagePost
      >
    >,
    TError,
    {
      sessionId: string;
      data: GatewaySessionMessageRequest;
      params?: SendGatewaySessionMessageApiV1GatewaysSessionsSessionIdMessagePostParams;
    },
    TContext
  > => {
    const mutationKey = [
      "sendGatewaySessionMessageApiV1GatewaysSessionsSessionIdMessagePost",
    ];
    const { mutation: mutationOptions, request: requestOptions } = options
      ? options.mutation &&
        "mutationKey" in options.mutation &&
        options.mutation.mutationKey
        ? options
        : { ...options, mutation: { ...options.mutation, mutationKey } }
      : { mutation: { mutationKey }, request: undefined };

    const mutationFn: MutationFunction<
      Awaited<
        ReturnType<
          typeof sendGatewaySessionMessageApiV1GatewaysSessionsSessionIdMessagePost
        >
      >,
      {
        sessionId: string;
        data: GatewaySessionMessageRequest;
        params?: SendGatewaySessionMessageApiV1GatewaysSessionsSessionIdMessagePostParams;
      }
    > = (props) => {
      const { sessionId, data, params } = props ?? {};

      return sendGatewaySessionMessageApiV1GatewaysSessionsSessionIdMessagePost(
        sessionId,
        data,
        params,
        requestOptions,
      );
    };

    return { mutationFn, ...mutationOptions };
  };

export type SendGatewaySessionMessageApiV1GatewaysSessionsSessionIdMessagePostMutationResult =
  NonNullable<
    Awaited<
      ReturnType<
        typeof sendGatewaySessionMessageApiV1GatewaysSessionsSessionIdMessagePost
      >
    >
  >;
export type SendGatewaySessionMessageApiV1GatewaysSessionsSessionIdMessagePostMutationBody =
  GatewaySessionMessageRequest;
export type SendGatewaySessionMessageApiV1GatewaysSessionsSessionIdMessagePostMutationError =
  HTTPValidationError;

/**
 * @summary Send Gateway Session Message
 */
export const useSendGatewaySessionMessageApiV1GatewaysSessionsSessionIdMessagePost =
  <TError = HTTPValidationError, TContext = unknown>(
    options?: {
      mutation?: UseMutationOptions<
        Awaited<
          ReturnType<
            typeof sendGatewaySessionMessageApiV1GatewaysSessionsSessionIdMessagePost
          >
        >,
        TError,
        {
          sessionId: string;
          data: GatewaySessionMessageRequest;
          params?: SendGatewaySessionMessageApiV1GatewaysSessionsSessionIdMessagePostParams;
        },
        TContext
      >;
      request?: SecondParameter<typeof customFetch>;
    },
    queryClient?: QueryClient,
  ): UseMutationResult<
    Awaited<
      ReturnType<
        typeof sendGatewaySessionMessageApiV1GatewaysSessionsSessionIdMessagePost
      >
    >,
    TError,
    {
      sessionId: string;
      data: GatewaySessionMessageRequest;
      params?: SendGatewaySessionMessageApiV1GatewaysSessionsSessionIdMessagePostParams;
    },
    TContext
  > => {
    return useMutation(
      getSendGatewaySessionMessageApiV1GatewaysSessionsSessionIdMessagePostMutationOptions(
        options,
      ),
      queryClient,
    );
  };
/**
 * Return supported gateway protocol methods and events.
 * @summary Gateway Commands
 */
export type gatewayCommandsApiV1GatewaysCommandsGetResponse200 = {
  data: GatewayCommandsResponse;
  status: 200;
};

export type gatewayCommandsApiV1GatewaysCommandsGetResponseSuccess =
  gatewayCommandsApiV1GatewaysCommandsGetResponse200 & {
    headers: Headers;
  };
export type gatewayCommandsApiV1GatewaysCommandsGetResponse =
  gatewayCommandsApiV1GatewaysCommandsGetResponseSuccess;

export const getGatewayCommandsApiV1GatewaysCommandsGetUrl = () => {
  return `/api/v1/gateways/commands`;
};

export const gatewayCommandsApiV1GatewaysCommandsGet = async (
  options?: RequestInit,
): Promise<gatewayCommandsApiV1GatewaysCommandsGetResponse> => {
  return customFetch<gatewayCommandsApiV1GatewaysCommandsGetResponse>(
    getGatewayCommandsApiV1GatewaysCommandsGetUrl(),
    {
      ...options,
      method: "GET",
    },
  );
};

export const getGatewayCommandsApiV1GatewaysCommandsGetQueryKey = () => {
  return [`/api/v1/gateways/commands`] as const;
};

export const getGatewayCommandsApiV1GatewaysCommandsGetQueryOptions = <
  TData = Awaited<ReturnType<typeof gatewayCommandsApiV1GatewaysCommandsGet>>,
  TError = unknown,
>(options?: {
  query?: Partial<
    UseQueryOptions<
      Awaited<ReturnType<typeof gatewayCommandsApiV1GatewaysCommandsGet>>,
      TError,
      TData
    >
  >;
  request?: SecondParameter<typeof customFetch>;
}) => {
  const { query: queryOptions, request: requestOptions } = options ?? {};

  const queryKey =
    queryOptions?.queryKey ??
    getGatewayCommandsApiV1GatewaysCommandsGetQueryKey();

  const queryFn: QueryFunction<
    Awaited<ReturnType<typeof gatewayCommandsApiV1GatewaysCommandsGet>>
  > = ({ signal }) =>
    gatewayCommandsApiV1GatewaysCommandsGet({ signal, ...requestOptions });

  return { queryKey, queryFn, ...queryOptions } as UseQueryOptions<
    Awaited<ReturnType<typeof gatewayCommandsApiV1GatewaysCommandsGet>>,
    TError,
    TData
  > & { queryKey: DataTag<QueryKey, TData, TError> };
};

export type GatewayCommandsApiV1GatewaysCommandsGetQueryResult = NonNullable<
  Awaited<ReturnType<typeof gatewayCommandsApiV1GatewaysCommandsGet>>
>;
export type GatewayCommandsApiV1GatewaysCommandsGetQueryError = unknown;

export function useGatewayCommandsApiV1GatewaysCommandsGet<
  TData = Awaited<ReturnType<typeof gatewayCommandsApiV1GatewaysCommandsGet>>,
  TError = unknown,
>(
  options: {
    query: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof gatewayCommandsApiV1GatewaysCommandsGet>>,
        TError,
        TData
      >
    > &
      Pick<
        DefinedInitialDataOptions<
          Awaited<ReturnType<typeof gatewayCommandsApiV1GatewaysCommandsGet>>,
          TError,
          Awaited<ReturnType<typeof gatewayCommandsApiV1GatewaysCommandsGet>>
        >,
        "initialData"
      >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): DefinedUseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useGatewayCommandsApiV1GatewaysCommandsGet<
  TData = Awaited<ReturnType<typeof gatewayCommandsApiV1GatewaysCommandsGet>>,
  TError = unknown,
>(
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof gatewayCommandsApiV1GatewaysCommandsGet>>,
        TError,
        TData
      >
    > &
      Pick<
        UndefinedInitialDataOptions<
          Awaited<ReturnType<typeof gatewayCommandsApiV1GatewaysCommandsGet>>,
          TError,
          Awaited<ReturnType<typeof gatewayCommandsApiV1GatewaysCommandsGet>>
        >,
        "initialData"
      >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useGatewayCommandsApiV1GatewaysCommandsGet<
  TData = Awaited<ReturnType<typeof gatewayCommandsApiV1GatewaysCommandsGet>>,
  TError = unknown,
>(
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof gatewayCommandsApiV1GatewaysCommandsGet>>,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
/**
 * @summary Gateway Commands
 */

export function useGatewayCommandsApiV1GatewaysCommandsGet<
  TData = Awaited<ReturnType<typeof gatewayCommandsApiV1GatewaysCommandsGet>>,
  TError = unknown,
>(
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof gatewayCommandsApiV1GatewaysCommandsGet>>,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
} {
  const queryOptions =
    getGatewayCommandsApiV1GatewaysCommandsGetQueryOptions(options);

  const query = useQuery(queryOptions, queryClient) as UseQueryResult<
    TData,
    TError
  > & { queryKey: DataTag<QueryKey, TData, TError> };

  return { ...query, queryKey: queryOptions.queryKey };
}

/**
 * List gateways for the caller's organization.
 * @summary List Gateways
 */
export type listGatewaysApiV1GatewaysGetResponse200 = {
  data: LimitOffsetPageTypeVarCustomizedGatewayRead;
  status: 200;
};

export type listGatewaysApiV1GatewaysGetResponse422 = {
  data: HTTPValidationError;
  status: 422;
};

export type listGatewaysApiV1GatewaysGetResponseSuccess =
  listGatewaysApiV1GatewaysGetResponse200 & {
    headers: Headers;
  };
export type listGatewaysApiV1GatewaysGetResponseError =
  listGatewaysApiV1GatewaysGetResponse422 & {
    headers: Headers;
  };

export type listGatewaysApiV1GatewaysGetResponse =
  | listGatewaysApiV1GatewaysGetResponseSuccess
  | listGatewaysApiV1GatewaysGetResponseError;

export const getListGatewaysApiV1GatewaysGetUrl = (
  params?: ListGatewaysApiV1GatewaysGetParams,
) => {
  const normalizedParams = new URLSearchParams();

  Object.entries(params || {}).forEach(([key, value]) => {
    if (value !== undefined) {
      normalizedParams.append(key, value === null ? "null" : value.toString());
    }
  });

  const stringifiedParams = normalizedParams.toString();

  return stringifiedParams.length > 0
    ? `/api/v1/gateways?${stringifiedParams}`
    : `/api/v1/gateways`;
};

export const listGatewaysApiV1GatewaysGet = async (
  params?: ListGatewaysApiV1GatewaysGetParams,
  options?: RequestInit,
): Promise<listGatewaysApiV1GatewaysGetResponse> => {
  return customFetch<listGatewaysApiV1GatewaysGetResponse>(
    getListGatewaysApiV1GatewaysGetUrl(params),
    {
      ...options,
      method: "GET",
    },
  );
};

export const getListGatewaysApiV1GatewaysGetQueryKey = (
  params?: ListGatewaysApiV1GatewaysGetParams,
) => {
  return [`/api/v1/gateways`, ...(params ? [params] : [])] as const;
};

export const getListGatewaysApiV1GatewaysGetQueryOptions = <
  TData = Awaited<ReturnType<typeof listGatewaysApiV1GatewaysGet>>,
  TError = HTTPValidationError,
>(
  params?: ListGatewaysApiV1GatewaysGetParams,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof listGatewaysApiV1GatewaysGet>>,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof customFetch>;
  },
) => {
  const { query: queryOptions, request: requestOptions } = options ?? {};

  const queryKey =
    queryOptions?.queryKey ?? getListGatewaysApiV1GatewaysGetQueryKey(params);

  const queryFn: QueryFunction<
    Awaited<ReturnType<typeof listGatewaysApiV1GatewaysGet>>
  > = ({ signal }) =>
    listGatewaysApiV1GatewaysGet(params, { signal, ...requestOptions });

  return { queryKey, queryFn, ...queryOptions } as UseQueryOptions<
    Awaited<ReturnType<typeof listGatewaysApiV1GatewaysGet>>,
    TError,
    TData
  > & { queryKey: DataTag<QueryKey, TData, TError> };
};

export type ListGatewaysApiV1GatewaysGetQueryResult = NonNullable<
  Awaited<ReturnType<typeof listGatewaysApiV1GatewaysGet>>
>;
export type ListGatewaysApiV1GatewaysGetQueryError = HTTPValidationError;

export function useListGatewaysApiV1GatewaysGet<
  TData = Awaited<ReturnType<typeof listGatewaysApiV1GatewaysGet>>,
  TError = HTTPValidationError,
>(
  params: undefined | ListGatewaysApiV1GatewaysGetParams,
  options: {
    query: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof listGatewaysApiV1GatewaysGet>>,
        TError,
        TData
      >
    > &
      Pick<
        DefinedInitialDataOptions<
          Awaited<ReturnType<typeof listGatewaysApiV1GatewaysGet>>,
          TError,
          Awaited<ReturnType<typeof listGatewaysApiV1GatewaysGet>>
        >,
        "initialData"
      >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): DefinedUseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useListGatewaysApiV1GatewaysGet<
  TData = Awaited<ReturnType<typeof listGatewaysApiV1GatewaysGet>>,
  TError = HTTPValidationError,
>(
  params?: ListGatewaysApiV1GatewaysGetParams,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof listGatewaysApiV1GatewaysGet>>,
        TError,
        TData
      >
    > &
      Pick<
        UndefinedInitialDataOptions<
          Awaited<ReturnType<typeof listGatewaysApiV1GatewaysGet>>,
          TError,
          Awaited<ReturnType<typeof listGatewaysApiV1GatewaysGet>>
        >,
        "initialData"
      >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useListGatewaysApiV1GatewaysGet<
  TData = Awaited<ReturnType<typeof listGatewaysApiV1GatewaysGet>>,
  TError = HTTPValidationError,
>(
  params?: ListGatewaysApiV1GatewaysGetParams,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof listGatewaysApiV1GatewaysGet>>,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
/**
 * @summary List Gateways
 */

export function useListGatewaysApiV1GatewaysGet<
  TData = Awaited<ReturnType<typeof listGatewaysApiV1GatewaysGet>>,
  TError = HTTPValidationError,
>(
  params?: ListGatewaysApiV1GatewaysGetParams,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof listGatewaysApiV1GatewaysGet>>,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
} {
  const queryOptions = getListGatewaysApiV1GatewaysGetQueryOptions(
    params,
    options,
  );

  const query = useQuery(queryOptions, queryClient) as UseQueryResult<
    TData,
    TError
  > & { queryKey: DataTag<QueryKey, TData, TError> };

  return { ...query, queryKey: queryOptions.queryKey };
}

/**
 * Create a gateway and provision or refresh its main agent.
 * @summary Create Gateway
 */
export type createGatewayApiV1GatewaysPostResponse200 = {
  data: GatewayRead;
  status: 200;
};

export type createGatewayApiV1GatewaysPostResponse422 = {
  data: HTTPValidationError;
  status: 422;
};

export type createGatewayApiV1GatewaysPostResponseSuccess =
  createGatewayApiV1GatewaysPostResponse200 & {
    headers: Headers;
  };
export type createGatewayApiV1GatewaysPostResponseError =
  createGatewayApiV1GatewaysPostResponse422 & {
    headers: Headers;
  };

export type createGatewayApiV1GatewaysPostResponse =
  | createGatewayApiV1GatewaysPostResponseSuccess
  | createGatewayApiV1GatewaysPostResponseError;

export const getCreateGatewayApiV1GatewaysPostUrl = () => {
  return `/api/v1/gateways`;
};

export const createGatewayApiV1GatewaysPost = async (
  gatewayCreate: GatewayCreate,
  options?: RequestInit,
): Promise<createGatewayApiV1GatewaysPostResponse> => {
  return customFetch<createGatewayApiV1GatewaysPostResponse>(
    getCreateGatewayApiV1GatewaysPostUrl(),
    {
      ...options,
      method: "POST",
      headers: { "Content-Type": "application/json", ...options?.headers },
      body: JSON.stringify(gatewayCreate),
    },
  );
};

export const getCreateGatewayApiV1GatewaysPostMutationOptions = <
  TError = HTTPValidationError,
  TContext = unknown,
>(options?: {
  mutation?: UseMutationOptions<
    Awaited<ReturnType<typeof createGatewayApiV1GatewaysPost>>,
    TError,
    { data: GatewayCreate },
    TContext
  >;
  request?: SecondParameter<typeof customFetch>;
}): UseMutationOptions<
  Awaited<ReturnType<typeof createGatewayApiV1GatewaysPost>>,
  TError,
  { data: GatewayCreate },
  TContext
> => {
  const mutationKey = ["createGatewayApiV1GatewaysPost"];
  const { mutation: mutationOptions, request: requestOptions } = options
    ? options.mutation &&
      "mutationKey" in options.mutation &&
      options.mutation.mutationKey
      ? options
      : { ...options, mutation: { ...options.mutation, mutationKey } }
    : { mutation: { mutationKey }, request: undefined };

  const mutationFn: MutationFunction<
    Awaited<ReturnType<typeof createGatewayApiV1GatewaysPost>>,
    { data: GatewayCreate }
  > = (props) => {
    const { data } = props ?? {};

    return createGatewayApiV1GatewaysPost(data, requestOptions);
  };

  return { mutationFn, ...mutationOptions };
};

export type CreateGatewayApiV1GatewaysPostMutationResult = NonNullable<
  Awaited<ReturnType<typeof createGatewayApiV1GatewaysPost>>
>;
export type CreateGatewayApiV1GatewaysPostMutationBody = GatewayCreate;
export type CreateGatewayApiV1GatewaysPostMutationError = HTTPValidationError;

/**
 * @summary Create Gateway
 */
export const useCreateGatewayApiV1GatewaysPost = <
  TError = HTTPValidationError,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof createGatewayApiV1GatewaysPost>>,
      TError,
      { data: GatewayCreate },
      TContext
    >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof createGatewayApiV1GatewaysPost>>,
  TError,
  { data: GatewayCreate },
  TContext
> => {
  return useMutation(
    getCreateGatewayApiV1GatewaysPostMutationOptions(options),
    queryClient,
  );
};
/**
 * Return one gateway by id for the caller's organization.
 * @summary Get Gateway
 */
export type getGatewayApiV1GatewaysGatewayIdGetResponse200 = {
  data: GatewayRead;
  status: 200;
};

export type getGatewayApiV1GatewaysGatewayIdGetResponse422 = {
  data: HTTPValidationError;
  status: 422;
};

export type getGatewayApiV1GatewaysGatewayIdGetResponseSuccess =
  getGatewayApiV1GatewaysGatewayIdGetResponse200 & {
    headers: Headers;
  };
export type getGatewayApiV1GatewaysGatewayIdGetResponseError =
  getGatewayApiV1GatewaysGatewayIdGetResponse422 & {
    headers: Headers;
  };

export type getGatewayApiV1GatewaysGatewayIdGetResponse =
  | getGatewayApiV1GatewaysGatewayIdGetResponseSuccess
  | getGatewayApiV1GatewaysGatewayIdGetResponseError;

export const getGetGatewayApiV1GatewaysGatewayIdGetUrl = (
  gatewayId: string,
) => {
  return `/api/v1/gateways/${gatewayId}`;
};

export const getGatewayApiV1GatewaysGatewayIdGet = async (
  gatewayId: string,
  options?: RequestInit,
): Promise<getGatewayApiV1GatewaysGatewayIdGetResponse> => {
  return customFetch<getGatewayApiV1GatewaysGatewayIdGetResponse>(
    getGetGatewayApiV1GatewaysGatewayIdGetUrl(gatewayId),
    {
      ...options,
      method: "GET",
    },
  );
};

export const getGetGatewayApiV1GatewaysGatewayIdGetQueryKey = (
  gatewayId: string,
) => {
  return [`/api/v1/gateways/${gatewayId}`] as const;
};

export const getGetGatewayApiV1GatewaysGatewayIdGetQueryOptions = <
  TData = Awaited<ReturnType<typeof getGatewayApiV1GatewaysGatewayIdGet>>,
  TError = HTTPValidationError,
>(
  gatewayId: string,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof getGatewayApiV1GatewaysGatewayIdGet>>,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof customFetch>;
  },
) => {
  const { query: queryOptions, request: requestOptions } = options ?? {};

  const queryKey =
    queryOptions?.queryKey ??
    getGetGatewayApiV1GatewaysGatewayIdGetQueryKey(gatewayId);

  const queryFn: QueryFunction<
    Awaited<ReturnType<typeof getGatewayApiV1GatewaysGatewayIdGet>>
  > = ({ signal }) =>
    getGatewayApiV1GatewaysGatewayIdGet(gatewayId, {
      signal,
      ...requestOptions,
    });

  return {
    queryKey,
    queryFn,
    enabled: !!gatewayId,
    ...queryOptions,
  } as UseQueryOptions<
    Awaited<ReturnType<typeof getGatewayApiV1GatewaysGatewayIdGet>>,
    TError,
    TData
  > & { queryKey: DataTag<QueryKey, TData, TError> };
};

export type GetGatewayApiV1GatewaysGatewayIdGetQueryResult = NonNullable<
  Awaited<ReturnType<typeof getGatewayApiV1GatewaysGatewayIdGet>>
>;
export type GetGatewayApiV1GatewaysGatewayIdGetQueryError = HTTPValidationError;

export function useGetGatewayApiV1GatewaysGatewayIdGet<
  TData = Awaited<ReturnType<typeof getGatewayApiV1GatewaysGatewayIdGet>>,
  TError = HTTPValidationError,
>(
  gatewayId: string,
  options: {
    query: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof getGatewayApiV1GatewaysGatewayIdGet>>,
        TError,
        TData
      >
    > &
      Pick<
        DefinedInitialDataOptions<
          Awaited<ReturnType<typeof getGatewayApiV1GatewaysGatewayIdGet>>,
          TError,
          Awaited<ReturnType<typeof getGatewayApiV1GatewaysGatewayIdGet>>
        >,
        "initialData"
      >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): DefinedUseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useGetGatewayApiV1GatewaysGatewayIdGet<
  TData = Awaited<ReturnType<typeof getGatewayApiV1GatewaysGatewayIdGet>>,
  TError = HTTPValidationError,
>(
  gatewayId: string,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof getGatewayApiV1GatewaysGatewayIdGet>>,
        TError,
        TData
      >
    > &
      Pick<
        UndefinedInitialDataOptions<
          Awaited<ReturnType<typeof getGatewayApiV1GatewaysGatewayIdGet>>,
          TError,
          Awaited<ReturnType<typeof getGatewayApiV1GatewaysGatewayIdGet>>
        >,
        "initialData"
      >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useGetGatewayApiV1GatewaysGatewayIdGet<
  TData = Awaited<ReturnType<typeof getGatewayApiV1GatewaysGatewayIdGet>>,
  TError = HTTPValidationError,
>(
  gatewayId: string,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof getGatewayApiV1GatewaysGatewayIdGet>>,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
/**
 * @summary Get Gateway
 */

export function useGetGatewayApiV1GatewaysGatewayIdGet<
  TData = Awaited<ReturnType<typeof getGatewayApiV1GatewaysGatewayIdGet>>,
  TError = HTTPValidationError,
>(
  gatewayId: string,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof getGatewayApiV1GatewaysGatewayIdGet>>,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
} {
  const queryOptions = getGetGatewayApiV1GatewaysGatewayIdGetQueryOptions(
    gatewayId,
    options,
  );

  const query = useQuery(queryOptions, queryClient) as UseQueryResult<
    TData,
    TError
  > & { queryKey: DataTag<QueryKey, TData, TError> };

  return { ...query, queryKey: queryOptions.queryKey };
}

/**
 * Patch a gateway and refresh the main-agent provisioning state.
 * @summary Update Gateway
 */
export type updateGatewayApiV1GatewaysGatewayIdPatchResponse200 = {
  data: GatewayRead;
  status: 200;
};

export type updateGatewayApiV1GatewaysGatewayIdPatchResponse422 = {
  data: HTTPValidationError;
  status: 422;
};

export type updateGatewayApiV1GatewaysGatewayIdPatchResponseSuccess =
  updateGatewayApiV1GatewaysGatewayIdPatchResponse200 & {
    headers: Headers;
  };
export type updateGatewayApiV1GatewaysGatewayIdPatchResponseError =
  updateGatewayApiV1GatewaysGatewayIdPatchResponse422 & {
    headers: Headers;
  };

export type updateGatewayApiV1GatewaysGatewayIdPatchResponse =
  | updateGatewayApiV1GatewaysGatewayIdPatchResponseSuccess
  | updateGatewayApiV1GatewaysGatewayIdPatchResponseError;

export const getUpdateGatewayApiV1GatewaysGatewayIdPatchUrl = (
  gatewayId: string,
) => {
  return `/api/v1/gateways/${gatewayId}`;
};

export const updateGatewayApiV1GatewaysGatewayIdPatch = async (
  gatewayId: string,
  gatewayUpdate: GatewayUpdate,
  options?: RequestInit,
): Promise<updateGatewayApiV1GatewaysGatewayIdPatchResponse> => {
  return customFetch<updateGatewayApiV1GatewaysGatewayIdPatchResponse>(
    getUpdateGatewayApiV1GatewaysGatewayIdPatchUrl(gatewayId),
    {
      ...options,
      method: "PATCH",
      headers: { "Content-Type": "application/json", ...options?.headers },
      body: JSON.stringify(gatewayUpdate),
    },
  );
};

export const getUpdateGatewayApiV1GatewaysGatewayIdPatchMutationOptions = <
  TError = HTTPValidationError,
  TContext = unknown,
>(options?: {
  mutation?: UseMutationOptions<
    Awaited<ReturnType<typeof updateGatewayApiV1GatewaysGatewayIdPatch>>,
    TError,
    { gatewayId: string; data: GatewayUpdate },
    TContext
  >;
  request?: SecondParameter<typeof customFetch>;
}): UseMutationOptions<
  Awaited<ReturnType<typeof updateGatewayApiV1GatewaysGatewayIdPatch>>,
  TError,
  { gatewayId: string; data: GatewayUpdate },
  TContext
> => {
  const mutationKey = ["updateGatewayApiV1GatewaysGatewayIdPatch"];
  const { mutation: mutationOptions, request: requestOptions } = options
    ? options.mutation &&
      "mutationKey" in options.mutation &&
      options.mutation.mutationKey
      ? options
      : { ...options, mutation: { ...options.mutation, mutationKey } }
    : { mutation: { mutationKey }, request: undefined };

  const mutationFn: MutationFunction<
    Awaited<ReturnType<typeof updateGatewayApiV1GatewaysGatewayIdPatch>>,
    { gatewayId: string; data: GatewayUpdate }
  > = (props) => {
    const { gatewayId, data } = props ?? {};

    return updateGatewayApiV1GatewaysGatewayIdPatch(
      gatewayId,
      data,
      requestOptions,
    );
  };

  return { mutationFn, ...mutationOptions };
};

export type UpdateGatewayApiV1GatewaysGatewayIdPatchMutationResult =
  NonNullable<
    Awaited<ReturnType<typeof updateGatewayApiV1GatewaysGatewayIdPatch>>
  >;
export type UpdateGatewayApiV1GatewaysGatewayIdPatchMutationBody =
  GatewayUpdate;
export type UpdateGatewayApiV1GatewaysGatewayIdPatchMutationError =
  HTTPValidationError;

/**
 * @summary Update Gateway
 */
export const useUpdateGatewayApiV1GatewaysGatewayIdPatch = <
  TError = HTTPValidationError,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof updateGatewayApiV1GatewaysGatewayIdPatch>>,
      TError,
      { gatewayId: string; data: GatewayUpdate },
      TContext
    >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof updateGatewayApiV1GatewaysGatewayIdPatch>>,
  TError,
  { gatewayId: string; data: GatewayUpdate },
  TContext
> => {
  return useMutation(
    getUpdateGatewayApiV1GatewaysGatewayIdPatchMutationOptions(options),
    queryClient,
  );
};
/**
 * Delete a gateway in the caller's organization.
 * @summary Delete Gateway
 */
export type deleteGatewayApiV1GatewaysGatewayIdDeleteResponse200 = {
  data: OkResponse;
  status: 200;
};

export type deleteGatewayApiV1GatewaysGatewayIdDeleteResponse422 = {
  data: HTTPValidationError;
  status: 422;
};

export type deleteGatewayApiV1GatewaysGatewayIdDeleteResponseSuccess =
  deleteGatewayApiV1GatewaysGatewayIdDeleteResponse200 & {
    headers: Headers;
  };
export type deleteGatewayApiV1GatewaysGatewayIdDeleteResponseError =
  deleteGatewayApiV1GatewaysGatewayIdDeleteResponse422 & {
    headers: Headers;
  };

export type deleteGatewayApiV1GatewaysGatewayIdDeleteResponse =
  | deleteGatewayApiV1GatewaysGatewayIdDeleteResponseSuccess
  | deleteGatewayApiV1GatewaysGatewayIdDeleteResponseError;

export const getDeleteGatewayApiV1GatewaysGatewayIdDeleteUrl = (
  gatewayId: string,
) => {
  return `/api/v1/gateways/${gatewayId}`;
};

export const deleteGatewayApiV1GatewaysGatewayIdDelete = async (
  gatewayId: string,
  options?: RequestInit,
): Promise<deleteGatewayApiV1GatewaysGatewayIdDeleteResponse> => {
  return customFetch<deleteGatewayApiV1GatewaysGatewayIdDeleteResponse>(
    getDeleteGatewayApiV1GatewaysGatewayIdDeleteUrl(gatewayId),
    {
      ...options,
      method: "DELETE",
    },
  );
};

export const getDeleteGatewayApiV1GatewaysGatewayIdDeleteMutationOptions = <
  TError = HTTPValidationError,
  TContext = unknown,
>(options?: {
  mutation?: UseMutationOptions<
    Awaited<ReturnType<typeof deleteGatewayApiV1GatewaysGatewayIdDelete>>,
    TError,
    { gatewayId: string },
    TContext
  >;
  request?: SecondParameter<typeof customFetch>;
}): UseMutationOptions<
  Awaited<ReturnType<typeof deleteGatewayApiV1GatewaysGatewayIdDelete>>,
  TError,
  { gatewayId: string },
  TContext
> => {
  const mutationKey = ["deleteGatewayApiV1GatewaysGatewayIdDelete"];
  const { mutation: mutationOptions, request: requestOptions } = options
    ? options.mutation &&
      "mutationKey" in options.mutation &&
      options.mutation.mutationKey
      ? options
      : { ...options, mutation: { ...options.mutation, mutationKey } }
    : { mutation: { mutationKey }, request: undefined };

  const mutationFn: MutationFunction<
    Awaited<ReturnType<typeof deleteGatewayApiV1GatewaysGatewayIdDelete>>,
    { gatewayId: string }
  > = (props) => {
    const { gatewayId } = props ?? {};

    return deleteGatewayApiV1GatewaysGatewayIdDelete(gatewayId, requestOptions);
  };

  return { mutationFn, ...mutationOptions };
};

export type DeleteGatewayApiV1GatewaysGatewayIdDeleteMutationResult =
  NonNullable<
    Awaited<ReturnType<typeof deleteGatewayApiV1GatewaysGatewayIdDelete>>
  >;

export type DeleteGatewayApiV1GatewaysGatewayIdDeleteMutationError =
  HTTPValidationError;

/**
 * @summary Delete Gateway
 */
export const useDeleteGatewayApiV1GatewaysGatewayIdDelete = <
  TError = HTTPValidationError,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof deleteGatewayApiV1GatewaysGatewayIdDelete>>,
      TError,
      { gatewayId: string },
      TContext
    >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof deleteGatewayApiV1GatewaysGatewayIdDelete>>,
  TError,
  { gatewayId: string },
  TContext
> => {
  return useMutation(
    getDeleteGatewayApiV1GatewaysGatewayIdDeleteMutationOptions(options),
    queryClient,
  );
};
/**
 * Sync templates for a gateway and optionally rotate runtime settings.
 * @summary Sync Gateway Templates
 */
export type syncGatewayTemplatesApiV1GatewaysGatewayIdTemplatesSyncPostResponse200 =
  {
    data: GatewayTemplatesSyncResult;
    status: 200;
  };

export type syncGatewayTemplatesApiV1GatewaysGatewayIdTemplatesSyncPostResponse422 =
  {
    data: HTTPValidationError;
    status: 422;
  };

export type syncGatewayTemplatesApiV1GatewaysGatewayIdTemplatesSyncPostResponseSuccess =
  syncGatewayTemplatesApiV1GatewaysGatewayIdTemplatesSyncPostResponse200 & {
    headers: Headers;
  };
export type syncGatewayTemplatesApiV1GatewaysGatewayIdTemplatesSyncPostResponseError =
  syncGatewayTemplatesApiV1GatewaysGatewayIdTemplatesSyncPostResponse422 & {
    headers: Headers;
  };

export type syncGatewayTemplatesApiV1GatewaysGatewayIdTemplatesSyncPostResponse =

    | syncGatewayTemplatesApiV1GatewaysGatewayIdTemplatesSyncPostResponseSuccess
    | syncGatewayTemplatesApiV1GatewaysGatewayIdTemplatesSyncPostResponseError;

export const getSyncGatewayTemplatesApiV1GatewaysGatewayIdTemplatesSyncPostUrl =
  (
    gatewayId: string,
    params?: SyncGatewayTemplatesApiV1GatewaysGatewayIdTemplatesSyncPostParams,
  ) => {
    const normalizedParams = new URLSearchParams();

    Object.entries(params || {}).forEach(([key, value]) => {
      if (value !== undefined) {
        normalizedParams.append(
          key,
          value === null ? "null" : value.toString(),
        );
      }
    });

    const stringifiedParams = normalizedParams.toString();

    return stringifiedParams.length > 0
      ? `/api/v1/gateways/${gatewayId}/templates/sync?${stringifiedParams}`
      : `/api/v1/gateways/${gatewayId}/templates/sync`;
  };

export const syncGatewayTemplatesApiV1GatewaysGatewayIdTemplatesSyncPost =
  async (
    gatewayId: string,
    params?: SyncGatewayTemplatesApiV1GatewaysGatewayIdTemplatesSyncPostParams,
    options?: RequestInit,
  ): Promise<syncGatewayTemplatesApiV1GatewaysGatewayIdTemplatesSyncPostResponse> => {
    return customFetch<syncGatewayTemplatesApiV1GatewaysGatewayIdTemplatesSyncPostResponse>(
      getSyncGatewayTemplatesApiV1GatewaysGatewayIdTemplatesSyncPostUrl(
        gatewayId,
        params,
      ),
      {
        ...options,
        method: "POST",
      },
    );
  };

export const getSyncGatewayTemplatesApiV1GatewaysGatewayIdTemplatesSyncPostMutationOptions =
  <TError = HTTPValidationError, TContext = unknown>(options?: {
    mutation?: UseMutationOptions<
      Awaited<
        ReturnType<
          typeof syncGatewayTemplatesApiV1GatewaysGatewayIdTemplatesSyncPost
        >
      >,
      TError,
      {
        gatewayId: string;
        params?: SyncGatewayTemplatesApiV1GatewaysGatewayIdTemplatesSyncPostParams;
      },
      TContext
    >;
    request?: SecondParameter<typeof customFetch>;
  }): UseMutationOptions<
    Awaited<
      ReturnType<
        typeof syncGatewayTemplatesApiV1GatewaysGatewayIdTemplatesSyncPost
      >
    >,
    TError,
    {
      gatewayId: string;
      params?: SyncGatewayTemplatesApiV1GatewaysGatewayIdTemplatesSyncPostParams;
    },
    TContext
  > => {
    const mutationKey = [
      "syncGatewayTemplatesApiV1GatewaysGatewayIdTemplatesSyncPost",
    ];
    const { mutation: mutationOptions, request: requestOptions } = options
      ? options.mutation &&
        "mutationKey" in options.mutation &&
        options.mutation.mutationKey
        ? options
        : { ...options, mutation: { ...options.mutation, mutationKey } }
      : { mutation: { mutationKey }, request: undefined };

    const mutationFn: MutationFunction<
      Awaited<
        ReturnType<
          typeof syncGatewayTemplatesApiV1GatewaysGatewayIdTemplatesSyncPost
        >
      >,
      {
        gatewayId: string;
        params?: SyncGatewayTemplatesApiV1GatewaysGatewayIdTemplatesSyncPostParams;
      }
    > = (props) => {
      const { gatewayId, params } = props ?? {};

      return syncGatewayTemplatesApiV1GatewaysGatewayIdTemplatesSyncPost(
        gatewayId,
        params,
        requestOptions,
      );
    };

    return { mutationFn, ...mutationOptions };
  };

export type SyncGatewayTemplatesApiV1GatewaysGatewayIdTemplatesSyncPostMutationResult =
  NonNullable<
    Awaited<
      ReturnType<
        typeof syncGatewayTemplatesApiV1GatewaysGatewayIdTemplatesSyncPost
      >
    >
  >;

export type SyncGatewayTemplatesApiV1GatewaysGatewayIdTemplatesSyncPostMutationError =
  HTTPValidationError;

/**
 * @summary Sync Gateway Templates
 */
export const useSyncGatewayTemplatesApiV1GatewaysGatewayIdTemplatesSyncPost = <
  TError = HTTPValidationError,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<
        ReturnType<
          typeof syncGatewayTemplatesApiV1GatewaysGatewayIdTemplatesSyncPost
        >
      >,
      TError,
      {
        gatewayId: string;
        params?: SyncGatewayTemplatesApiV1GatewaysGatewayIdTemplatesSyncPostParams;
      },
      TContext
    >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<
    ReturnType<
      typeof syncGatewayTemplatesApiV1GatewaysGatewayIdTemplatesSyncPost
    >
  >,
  TError,
  {
    gatewayId: string;
    params?: SyncGatewayTemplatesApiV1GatewaysGatewayIdTemplatesSyncPostParams;
  },
  TContext
> => {
  return useMutation(
    getSyncGatewayTemplatesApiV1GatewaysGatewayIdTemplatesSyncPostMutationOptions(
      options,
    ),
    queryClient,
  );
};
/**
 * Preview existing gateway runtime agents that can be imported.
 * @summary Preview Import Gateway Agents
 */
export type previewImportGatewayAgentsApiV1GatewaysGatewayIdAgentsImportPreviewGetResponse200 =
  {
    data: GatewayAgentImportPreviewResponse;
    status: 200;
  };

export type previewImportGatewayAgentsApiV1GatewaysGatewayIdAgentsImportPreviewGetResponse422 =
  {
    data: HTTPValidationError;
    status: 422;
  };

export type previewImportGatewayAgentsApiV1GatewaysGatewayIdAgentsImportPreviewGetResponseSuccess =
  previewImportGatewayAgentsApiV1GatewaysGatewayIdAgentsImportPreviewGetResponse200 & {
    headers: Headers;
  };
export type previewImportGatewayAgentsApiV1GatewaysGatewayIdAgentsImportPreviewGetResponseError =
  previewImportGatewayAgentsApiV1GatewaysGatewayIdAgentsImportPreviewGetResponse422 & {
    headers: Headers;
  };

export type previewImportGatewayAgentsApiV1GatewaysGatewayIdAgentsImportPreviewGetResponse =

    | previewImportGatewayAgentsApiV1GatewaysGatewayIdAgentsImportPreviewGetResponseSuccess
    | previewImportGatewayAgentsApiV1GatewaysGatewayIdAgentsImportPreviewGetResponseError;

export const getPreviewImportGatewayAgentsApiV1GatewaysGatewayIdAgentsImportPreviewGetUrl =
  (gatewayId: string) => {
    return `/api/v1/gateways/${gatewayId}/agents/import-preview`;
  };

export const previewImportGatewayAgentsApiV1GatewaysGatewayIdAgentsImportPreviewGet =
  async (
    gatewayId: string,
    options?: RequestInit,
  ): Promise<previewImportGatewayAgentsApiV1GatewaysGatewayIdAgentsImportPreviewGetResponse> => {
    return customFetch<previewImportGatewayAgentsApiV1GatewaysGatewayIdAgentsImportPreviewGetResponse>(
      getPreviewImportGatewayAgentsApiV1GatewaysGatewayIdAgentsImportPreviewGetUrl(
        gatewayId,
      ),
      {
        ...options,
        method: "GET",
      },
    );
  };

export const getPreviewImportGatewayAgentsApiV1GatewaysGatewayIdAgentsImportPreviewGetQueryKey =
  (gatewayId: string) => {
    return [`/api/v1/gateways/${gatewayId}/agents/import-preview`] as const;
  };

export const getPreviewImportGatewayAgentsApiV1GatewaysGatewayIdAgentsImportPreviewGetQueryOptions =
  <
    TData = Awaited<
      ReturnType<
        typeof previewImportGatewayAgentsApiV1GatewaysGatewayIdAgentsImportPreviewGet
      >
    >,
    TError = HTTPValidationError,
  >(
    gatewayId: string,
    options?: {
      query?: Partial<
        UseQueryOptions<
          Awaited<
            ReturnType<
              typeof previewImportGatewayAgentsApiV1GatewaysGatewayIdAgentsImportPreviewGet
            >
          >,
          TError,
          TData
        >
      >;
      request?: SecondParameter<typeof customFetch>;
    },
  ) => {
    const { query: queryOptions, request: requestOptions } = options ?? {};

    const queryKey =
      queryOptions?.queryKey ??
      getPreviewImportGatewayAgentsApiV1GatewaysGatewayIdAgentsImportPreviewGetQueryKey(
        gatewayId,
      );

    const queryFn: QueryFunction<
      Awaited<
        ReturnType<
          typeof previewImportGatewayAgentsApiV1GatewaysGatewayIdAgentsImportPreviewGet
        >
      >
    > = ({ signal }) =>
      previewImportGatewayAgentsApiV1GatewaysGatewayIdAgentsImportPreviewGet(
        gatewayId,
        { signal, ...requestOptions },
      );

    return {
      queryKey,
      queryFn,
      enabled: !!gatewayId,
      ...queryOptions,
    } as UseQueryOptions<
      Awaited<
        ReturnType<
          typeof previewImportGatewayAgentsApiV1GatewaysGatewayIdAgentsImportPreviewGet
        >
      >,
      TError,
      TData
    > & { queryKey: DataTag<QueryKey, TData, TError> };
  };

export type PreviewImportGatewayAgentsApiV1GatewaysGatewayIdAgentsImportPreviewGetQueryResult =
  NonNullable<
    Awaited<
      ReturnType<
        typeof previewImportGatewayAgentsApiV1GatewaysGatewayIdAgentsImportPreviewGet
      >
    >
  >;
export type PreviewImportGatewayAgentsApiV1GatewaysGatewayIdAgentsImportPreviewGetQueryError =
  HTTPValidationError;

export function usePreviewImportGatewayAgentsApiV1GatewaysGatewayIdAgentsImportPreviewGet<
  TData = Awaited<
    ReturnType<
      typeof previewImportGatewayAgentsApiV1GatewaysGatewayIdAgentsImportPreviewGet
    >
  >,
  TError = HTTPValidationError,
>(
  gatewayId: string,
  options: {
    query: Partial<
      UseQueryOptions<
        Awaited<
          ReturnType<
            typeof previewImportGatewayAgentsApiV1GatewaysGatewayIdAgentsImportPreviewGet
          >
        >,
        TError,
        TData
      >
    > &
      Pick<
        DefinedInitialDataOptions<
          Awaited<
            ReturnType<
              typeof previewImportGatewayAgentsApiV1GatewaysGatewayIdAgentsImportPreviewGet
            >
          >,
          TError,
          Awaited<
            ReturnType<
              typeof previewImportGatewayAgentsApiV1GatewaysGatewayIdAgentsImportPreviewGet
            >
          >
        >,
        "initialData"
      >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): DefinedUseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function usePreviewImportGatewayAgentsApiV1GatewaysGatewayIdAgentsImportPreviewGet<
  TData = Awaited<
    ReturnType<
      typeof previewImportGatewayAgentsApiV1GatewaysGatewayIdAgentsImportPreviewGet
    >
  >,
  TError = HTTPValidationError,
>(
  gatewayId: string,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<
          ReturnType<
            typeof previewImportGatewayAgentsApiV1GatewaysGatewayIdAgentsImportPreviewGet
          >
        >,
        TError,
        TData
      >
    > &
      Pick<
        UndefinedInitialDataOptions<
          Awaited<
            ReturnType<
              typeof previewImportGatewayAgentsApiV1GatewaysGatewayIdAgentsImportPreviewGet
            >
          >,
          TError,
          Awaited<
            ReturnType<
              typeof previewImportGatewayAgentsApiV1GatewaysGatewayIdAgentsImportPreviewGet
            >
          >
        >,
        "initialData"
      >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function usePreviewImportGatewayAgentsApiV1GatewaysGatewayIdAgentsImportPreviewGet<
  TData = Awaited<
    ReturnType<
      typeof previewImportGatewayAgentsApiV1GatewaysGatewayIdAgentsImportPreviewGet
    >
  >,
  TError = HTTPValidationError,
>(
  gatewayId: string,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<
          ReturnType<
            typeof previewImportGatewayAgentsApiV1GatewaysGatewayIdAgentsImportPreviewGet
          >
        >,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
/**
 * @summary Preview Import Gateway Agents
 */

export function usePreviewImportGatewayAgentsApiV1GatewaysGatewayIdAgentsImportPreviewGet<
  TData = Awaited<
    ReturnType<
      typeof previewImportGatewayAgentsApiV1GatewaysGatewayIdAgentsImportPreviewGet
    >
  >,
  TError = HTTPValidationError,
>(
  gatewayId: string,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<
          ReturnType<
            typeof previewImportGatewayAgentsApiV1GatewaysGatewayIdAgentsImportPreviewGet
          >
        >,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
} {
  const queryOptions =
    getPreviewImportGatewayAgentsApiV1GatewaysGatewayIdAgentsImportPreviewGetQueryOptions(
      gatewayId,
      options,
    );

  const query = useQuery(queryOptions, queryClient) as UseQueryResult<
    TData,
    TError
  > & { queryKey: DataTag<QueryKey, TData, TError> };

  return { ...query, queryKey: queryOptions.queryKey };
}

/**
 * Import selected existing gateway runtime agents into Pipeline.
 * @summary Import Gateway Agents
 */
export type importGatewayAgentsApiV1GatewaysGatewayIdAgentsImportPostResponse200 =
  {
    data: GatewayAgentImportResponse;
    status: 200;
  };

export type importGatewayAgentsApiV1GatewaysGatewayIdAgentsImportPostResponse422 =
  {
    data: HTTPValidationError;
    status: 422;
  };

export type importGatewayAgentsApiV1GatewaysGatewayIdAgentsImportPostResponseSuccess =
  importGatewayAgentsApiV1GatewaysGatewayIdAgentsImportPostResponse200 & {
    headers: Headers;
  };
export type importGatewayAgentsApiV1GatewaysGatewayIdAgentsImportPostResponseError =
  importGatewayAgentsApiV1GatewaysGatewayIdAgentsImportPostResponse422 & {
    headers: Headers;
  };

export type importGatewayAgentsApiV1GatewaysGatewayIdAgentsImportPostResponse =
  | importGatewayAgentsApiV1GatewaysGatewayIdAgentsImportPostResponseSuccess
  | importGatewayAgentsApiV1GatewaysGatewayIdAgentsImportPostResponseError;

export const getImportGatewayAgentsApiV1GatewaysGatewayIdAgentsImportPostUrl = (
  gatewayId: string,
) => {
  return `/api/v1/gateways/${gatewayId}/agents/import`;
};

export const importGatewayAgentsApiV1GatewaysGatewayIdAgentsImportPost = async (
  gatewayId: string,
  gatewayAgentImportRequest: GatewayAgentImportRequest,
  options?: RequestInit,
): Promise<importGatewayAgentsApiV1GatewaysGatewayIdAgentsImportPostResponse> => {
  return customFetch<importGatewayAgentsApiV1GatewaysGatewayIdAgentsImportPostResponse>(
    getImportGatewayAgentsApiV1GatewaysGatewayIdAgentsImportPostUrl(gatewayId),
    {
      ...options,
      method: "POST",
      headers: { "Content-Type": "application/json", ...options?.headers },
      body: JSON.stringify(gatewayAgentImportRequest),
    },
  );
};

export const getImportGatewayAgentsApiV1GatewaysGatewayIdAgentsImportPostMutationOptions =
  <TError = HTTPValidationError, TContext = unknown>(options?: {
    mutation?: UseMutationOptions<
      Awaited<
        ReturnType<
          typeof importGatewayAgentsApiV1GatewaysGatewayIdAgentsImportPost
        >
      >,
      TError,
      { gatewayId: string; data: GatewayAgentImportRequest },
      TContext
    >;
    request?: SecondParameter<typeof customFetch>;
  }): UseMutationOptions<
    Awaited<
      ReturnType<
        typeof importGatewayAgentsApiV1GatewaysGatewayIdAgentsImportPost
      >
    >,
    TError,
    { gatewayId: string; data: GatewayAgentImportRequest },
    TContext
  > => {
    const mutationKey = [
      "importGatewayAgentsApiV1GatewaysGatewayIdAgentsImportPost",
    ];
    const { mutation: mutationOptions, request: requestOptions } = options
      ? options.mutation &&
        "mutationKey" in options.mutation &&
        options.mutation.mutationKey
        ? options
        : { ...options, mutation: { ...options.mutation, mutationKey } }
      : { mutation: { mutationKey }, request: undefined };

    const mutationFn: MutationFunction<
      Awaited<
        ReturnType<
          typeof importGatewayAgentsApiV1GatewaysGatewayIdAgentsImportPost
        >
      >,
      { gatewayId: string; data: GatewayAgentImportRequest }
    > = (props) => {
      const { gatewayId, data } = props ?? {};

      return importGatewayAgentsApiV1GatewaysGatewayIdAgentsImportPost(
        gatewayId,
        data,
        requestOptions,
      );
    };

    return { mutationFn, ...mutationOptions };
  };

export type ImportGatewayAgentsApiV1GatewaysGatewayIdAgentsImportPostMutationResult =
  NonNullable<
    Awaited<
      ReturnType<
        typeof importGatewayAgentsApiV1GatewaysGatewayIdAgentsImportPost
      >
    >
  >;
export type ImportGatewayAgentsApiV1GatewaysGatewayIdAgentsImportPostMutationBody =
  GatewayAgentImportRequest;
export type ImportGatewayAgentsApiV1GatewaysGatewayIdAgentsImportPostMutationError =
  HTTPValidationError;

/**
 * @summary Import Gateway Agents
 */
export const useImportGatewayAgentsApiV1GatewaysGatewayIdAgentsImportPost = <
  TError = HTTPValidationError,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<
        ReturnType<
          typeof importGatewayAgentsApiV1GatewaysGatewayIdAgentsImportPost
        >
      >,
      TError,
      { gatewayId: string; data: GatewayAgentImportRequest },
      TContext
    >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<
    ReturnType<typeof importGatewayAgentsApiV1GatewaysGatewayIdAgentsImportPost>
  >,
  TError,
  { gatewayId: string; data: GatewayAgentImportRequest },
  TContext
> => {
  return useMutation(
    getImportGatewayAgentsApiV1GatewaysGatewayIdAgentsImportPostMutationOptions(
      options,
    ),
    queryClient,
  );
};
/**
 * Return model usage, token counts, estimated spend, burn rate, and time-remaining predictions for the specified gateway.  Visible to all organisation members.
 * @summary Gateway runtime usage
 */
export type getGatewayRuntimeUsageApiV1GatewaysGatewayIdRuntimeUsageGetResponse200 =
  {
    data: RuntimeUsageResponse;
    status: 200;
  };

export type getGatewayRuntimeUsageApiV1GatewaysGatewayIdRuntimeUsageGetResponse422 =
  {
    data: HTTPValidationError;
    status: 422;
  };

export type getGatewayRuntimeUsageApiV1GatewaysGatewayIdRuntimeUsageGetResponseSuccess =
  getGatewayRuntimeUsageApiV1GatewaysGatewayIdRuntimeUsageGetResponse200 & {
    headers: Headers;
  };
export type getGatewayRuntimeUsageApiV1GatewaysGatewayIdRuntimeUsageGetResponseError =
  getGatewayRuntimeUsageApiV1GatewaysGatewayIdRuntimeUsageGetResponse422 & {
    headers: Headers;
  };

export type getGatewayRuntimeUsageApiV1GatewaysGatewayIdRuntimeUsageGetResponse =

    | getGatewayRuntimeUsageApiV1GatewaysGatewayIdRuntimeUsageGetResponseSuccess
    | getGatewayRuntimeUsageApiV1GatewaysGatewayIdRuntimeUsageGetResponseError;

export const getGetGatewayRuntimeUsageApiV1GatewaysGatewayIdRuntimeUsageGetUrl =
  (gatewayId: string) => {
    return `/api/v1/gateways/${gatewayId}/runtime-usage`;
  };

export const getGatewayRuntimeUsageApiV1GatewaysGatewayIdRuntimeUsageGet =
  async (
    gatewayId: string,
    options?: RequestInit,
  ): Promise<getGatewayRuntimeUsageApiV1GatewaysGatewayIdRuntimeUsageGetResponse> => {
    return customFetch<getGatewayRuntimeUsageApiV1GatewaysGatewayIdRuntimeUsageGetResponse>(
      getGetGatewayRuntimeUsageApiV1GatewaysGatewayIdRuntimeUsageGetUrl(
        gatewayId,
      ),
      {
        ...options,
        method: "GET",
      },
    );
  };

export const getGetGatewayRuntimeUsageApiV1GatewaysGatewayIdRuntimeUsageGetQueryKey =
  (gatewayId: string) => {
    return [`/api/v1/gateways/${gatewayId}/runtime-usage`] as const;
  };

export const getGetGatewayRuntimeUsageApiV1GatewaysGatewayIdRuntimeUsageGetQueryOptions =
  <
    TData = Awaited<
      ReturnType<
        typeof getGatewayRuntimeUsageApiV1GatewaysGatewayIdRuntimeUsageGet
      >
    >,
    TError = HTTPValidationError,
  >(
    gatewayId: string,
    options?: {
      query?: Partial<
        UseQueryOptions<
          Awaited<
            ReturnType<
              typeof getGatewayRuntimeUsageApiV1GatewaysGatewayIdRuntimeUsageGet
            >
          >,
          TError,
          TData
        >
      >;
      request?: SecondParameter<typeof customFetch>;
    },
  ) => {
    const { query: queryOptions, request: requestOptions } = options ?? {};

    const queryKey =
      queryOptions?.queryKey ??
      getGetGatewayRuntimeUsageApiV1GatewaysGatewayIdRuntimeUsageGetQueryKey(
        gatewayId,
      );

    const queryFn: QueryFunction<
      Awaited<
        ReturnType<
          typeof getGatewayRuntimeUsageApiV1GatewaysGatewayIdRuntimeUsageGet
        >
      >
    > = ({ signal }) =>
      getGatewayRuntimeUsageApiV1GatewaysGatewayIdRuntimeUsageGet(gatewayId, {
        signal,
        ...requestOptions,
      });

    return {
      queryKey,
      queryFn,
      enabled: !!gatewayId,
      ...queryOptions,
    } as UseQueryOptions<
      Awaited<
        ReturnType<
          typeof getGatewayRuntimeUsageApiV1GatewaysGatewayIdRuntimeUsageGet
        >
      >,
      TError,
      TData
    > & { queryKey: DataTag<QueryKey, TData, TError> };
  };

export type GetGatewayRuntimeUsageApiV1GatewaysGatewayIdRuntimeUsageGetQueryResult =
  NonNullable<
    Awaited<
      ReturnType<
        typeof getGatewayRuntimeUsageApiV1GatewaysGatewayIdRuntimeUsageGet
      >
    >
  >;
export type GetGatewayRuntimeUsageApiV1GatewaysGatewayIdRuntimeUsageGetQueryError =
  HTTPValidationError;

export function useGetGatewayRuntimeUsageApiV1GatewaysGatewayIdRuntimeUsageGet<
  TData = Awaited<
    ReturnType<
      typeof getGatewayRuntimeUsageApiV1GatewaysGatewayIdRuntimeUsageGet
    >
  >,
  TError = HTTPValidationError,
>(
  gatewayId: string,
  options: {
    query: Partial<
      UseQueryOptions<
        Awaited<
          ReturnType<
            typeof getGatewayRuntimeUsageApiV1GatewaysGatewayIdRuntimeUsageGet
          >
        >,
        TError,
        TData
      >
    > &
      Pick<
        DefinedInitialDataOptions<
          Awaited<
            ReturnType<
              typeof getGatewayRuntimeUsageApiV1GatewaysGatewayIdRuntimeUsageGet
            >
          >,
          TError,
          Awaited<
            ReturnType<
              typeof getGatewayRuntimeUsageApiV1GatewaysGatewayIdRuntimeUsageGet
            >
          >
        >,
        "initialData"
      >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): DefinedUseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useGetGatewayRuntimeUsageApiV1GatewaysGatewayIdRuntimeUsageGet<
  TData = Awaited<
    ReturnType<
      typeof getGatewayRuntimeUsageApiV1GatewaysGatewayIdRuntimeUsageGet
    >
  >,
  TError = HTTPValidationError,
>(
  gatewayId: string,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<
          ReturnType<
            typeof getGatewayRuntimeUsageApiV1GatewaysGatewayIdRuntimeUsageGet
          >
        >,
        TError,
        TData
      >
    > &
      Pick<
        UndefinedInitialDataOptions<
          Awaited<
            ReturnType<
              typeof getGatewayRuntimeUsageApiV1GatewaysGatewayIdRuntimeUsageGet
            >
          >,
          TError,
          Awaited<
            ReturnType<
              typeof getGatewayRuntimeUsageApiV1GatewaysGatewayIdRuntimeUsageGet
            >
          >
        >,
        "initialData"
      >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useGetGatewayRuntimeUsageApiV1GatewaysGatewayIdRuntimeUsageGet<
  TData = Awaited<
    ReturnType<
      typeof getGatewayRuntimeUsageApiV1GatewaysGatewayIdRuntimeUsageGet
    >
  >,
  TError = HTTPValidationError,
>(
  gatewayId: string,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<
          ReturnType<
            typeof getGatewayRuntimeUsageApiV1GatewaysGatewayIdRuntimeUsageGet
          >
        >,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
/**
 * @summary Gateway runtime usage
 */

export function useGetGatewayRuntimeUsageApiV1GatewaysGatewayIdRuntimeUsageGet<
  TData = Awaited<
    ReturnType<
      typeof getGatewayRuntimeUsageApiV1GatewaysGatewayIdRuntimeUsageGet
    >
  >,
  TError = HTTPValidationError,
>(
  gatewayId: string,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<
          ReturnType<
            typeof getGatewayRuntimeUsageApiV1GatewaysGatewayIdRuntimeUsageGet
          >
        >,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
} {
  const queryOptions =
    getGetGatewayRuntimeUsageApiV1GatewaysGatewayIdRuntimeUsageGetQueryOptions(
      gatewayId,
      options,
    );

  const query = useQuery(queryOptions, queryClient) as UseQueryResult<
    TData,
    TError
  > & { queryKey: DataTag<QueryKey, TData, TError> };

  return { ...query, queryKey: queryOptions.queryKey };
}

/**
 * Return provider-native subscription usage data scraped from the CLI (e.g. ``claude /usage``).  Returns an empty results list when USAGE_SCRAPER_ENABLED=false (the default).  Enable with USAGE_SCRAPER_ENABLED=true and ensure the required prerequisites (tmux, claude binary) are accessible from the backend process.
 * @summary Gateway provider-native usage (opt-in scraper)
 */
export type getGatewayProviderUsageApiV1GatewaysGatewayIdProviderUsageGetResponse200 =
  {
    data: ProviderUsageResponse;
    status: 200;
  };

export type getGatewayProviderUsageApiV1GatewaysGatewayIdProviderUsageGetResponse422 =
  {
    data: HTTPValidationError;
    status: 422;
  };

export type getGatewayProviderUsageApiV1GatewaysGatewayIdProviderUsageGetResponseSuccess =
  getGatewayProviderUsageApiV1GatewaysGatewayIdProviderUsageGetResponse200 & {
    headers: Headers;
  };
export type getGatewayProviderUsageApiV1GatewaysGatewayIdProviderUsageGetResponseError =
  getGatewayProviderUsageApiV1GatewaysGatewayIdProviderUsageGetResponse422 & {
    headers: Headers;
  };

export type getGatewayProviderUsageApiV1GatewaysGatewayIdProviderUsageGetResponse =

    | getGatewayProviderUsageApiV1GatewaysGatewayIdProviderUsageGetResponseSuccess
    | getGatewayProviderUsageApiV1GatewaysGatewayIdProviderUsageGetResponseError;

export const getGetGatewayProviderUsageApiV1GatewaysGatewayIdProviderUsageGetUrl =
  (gatewayId: string) => {
    return `/api/v1/gateways/${gatewayId}/provider-usage`;
  };

export const getGatewayProviderUsageApiV1GatewaysGatewayIdProviderUsageGet =
  async (
    gatewayId: string,
    options?: RequestInit,
  ): Promise<getGatewayProviderUsageApiV1GatewaysGatewayIdProviderUsageGetResponse> => {
    return customFetch<getGatewayProviderUsageApiV1GatewaysGatewayIdProviderUsageGetResponse>(
      getGetGatewayProviderUsageApiV1GatewaysGatewayIdProviderUsageGetUrl(
        gatewayId,
      ),
      {
        ...options,
        method: "GET",
      },
    );
  };

export const getGetGatewayProviderUsageApiV1GatewaysGatewayIdProviderUsageGetQueryKey =
  (gatewayId: string) => {
    return [`/api/v1/gateways/${gatewayId}/provider-usage`] as const;
  };

export const getGetGatewayProviderUsageApiV1GatewaysGatewayIdProviderUsageGetQueryOptions =
  <
    TData = Awaited<
      ReturnType<
        typeof getGatewayProviderUsageApiV1GatewaysGatewayIdProviderUsageGet
      >
    >,
    TError = HTTPValidationError,
  >(
    gatewayId: string,
    options?: {
      query?: Partial<
        UseQueryOptions<
          Awaited<
            ReturnType<
              typeof getGatewayProviderUsageApiV1GatewaysGatewayIdProviderUsageGet
            >
          >,
          TError,
          TData
        >
      >;
      request?: SecondParameter<typeof customFetch>;
    },
  ) => {
    const { query: queryOptions, request: requestOptions } = options ?? {};

    const queryKey =
      queryOptions?.queryKey ??
      getGetGatewayProviderUsageApiV1GatewaysGatewayIdProviderUsageGetQueryKey(
        gatewayId,
      );

    const queryFn: QueryFunction<
      Awaited<
        ReturnType<
          typeof getGatewayProviderUsageApiV1GatewaysGatewayIdProviderUsageGet
        >
      >
    > = ({ signal }) =>
      getGatewayProviderUsageApiV1GatewaysGatewayIdProviderUsageGet(gatewayId, {
        signal,
        ...requestOptions,
      });

    return {
      queryKey,
      queryFn,
      enabled: !!gatewayId,
      ...queryOptions,
    } as UseQueryOptions<
      Awaited<
        ReturnType<
          typeof getGatewayProviderUsageApiV1GatewaysGatewayIdProviderUsageGet
        >
      >,
      TError,
      TData
    > & { queryKey: DataTag<QueryKey, TData, TError> };
  };

export type GetGatewayProviderUsageApiV1GatewaysGatewayIdProviderUsageGetQueryResult =
  NonNullable<
    Awaited<
      ReturnType<
        typeof getGatewayProviderUsageApiV1GatewaysGatewayIdProviderUsageGet
      >
    >
  >;
export type GetGatewayProviderUsageApiV1GatewaysGatewayIdProviderUsageGetQueryError =
  HTTPValidationError;

export function useGetGatewayProviderUsageApiV1GatewaysGatewayIdProviderUsageGet<
  TData = Awaited<
    ReturnType<
      typeof getGatewayProviderUsageApiV1GatewaysGatewayIdProviderUsageGet
    >
  >,
  TError = HTTPValidationError,
>(
  gatewayId: string,
  options: {
    query: Partial<
      UseQueryOptions<
        Awaited<
          ReturnType<
            typeof getGatewayProviderUsageApiV1GatewaysGatewayIdProviderUsageGet
          >
        >,
        TError,
        TData
      >
    > &
      Pick<
        DefinedInitialDataOptions<
          Awaited<
            ReturnType<
              typeof getGatewayProviderUsageApiV1GatewaysGatewayIdProviderUsageGet
            >
          >,
          TError,
          Awaited<
            ReturnType<
              typeof getGatewayProviderUsageApiV1GatewaysGatewayIdProviderUsageGet
            >
          >
        >,
        "initialData"
      >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): DefinedUseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useGetGatewayProviderUsageApiV1GatewaysGatewayIdProviderUsageGet<
  TData = Awaited<
    ReturnType<
      typeof getGatewayProviderUsageApiV1GatewaysGatewayIdProviderUsageGet
    >
  >,
  TError = HTTPValidationError,
>(
  gatewayId: string,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<
          ReturnType<
            typeof getGatewayProviderUsageApiV1GatewaysGatewayIdProviderUsageGet
          >
        >,
        TError,
        TData
      >
    > &
      Pick<
        UndefinedInitialDataOptions<
          Awaited<
            ReturnType<
              typeof getGatewayProviderUsageApiV1GatewaysGatewayIdProviderUsageGet
            >
          >,
          TError,
          Awaited<
            ReturnType<
              typeof getGatewayProviderUsageApiV1GatewaysGatewayIdProviderUsageGet
            >
          >
        >,
        "initialData"
      >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useGetGatewayProviderUsageApiV1GatewaysGatewayIdProviderUsageGet<
  TData = Awaited<
    ReturnType<
      typeof getGatewayProviderUsageApiV1GatewaysGatewayIdProviderUsageGet
    >
  >,
  TError = HTTPValidationError,
>(
  gatewayId: string,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<
          ReturnType<
            typeof getGatewayProviderUsageApiV1GatewaysGatewayIdProviderUsageGet
          >
        >,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
/**
 * @summary Gateway provider-native usage (opt-in scraper)
 */

export function useGetGatewayProviderUsageApiV1GatewaysGatewayIdProviderUsageGet<
  TData = Awaited<
    ReturnType<
      typeof getGatewayProviderUsageApiV1GatewaysGatewayIdProviderUsageGet
    >
  >,
  TError = HTTPValidationError,
>(
  gatewayId: string,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<
          ReturnType<
            typeof getGatewayProviderUsageApiV1GatewaysGatewayIdProviderUsageGet
          >
        >,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
} {
  const queryOptions =
    getGetGatewayProviderUsageApiV1GatewaysGatewayIdProviderUsageGetQueryOptions(
      gatewayId,
      options,
    );

  const query = useQuery(queryOptions, queryClient) as UseQueryResult<
    TData,
    TError
  > & { queryKey: DataTag<QueryKey, TData, TError> };

  return { ...query, queryKey: queryOptions.queryKey };
}

/**
 * Return the list of cron jobs configured on the gateway with their last-run status.
 * @summary Gateway cron job status
 */
export type getGatewayCronApiV1GatewaysGatewayIdCronGetResponse200 = {
  data: CronStatusResponse;
  status: 200;
};

export type getGatewayCronApiV1GatewaysGatewayIdCronGetResponse422 = {
  data: HTTPValidationError;
  status: 422;
};

export type getGatewayCronApiV1GatewaysGatewayIdCronGetResponseSuccess =
  getGatewayCronApiV1GatewaysGatewayIdCronGetResponse200 & {
    headers: Headers;
  };
export type getGatewayCronApiV1GatewaysGatewayIdCronGetResponseError =
  getGatewayCronApiV1GatewaysGatewayIdCronGetResponse422 & {
    headers: Headers;
  };

export type getGatewayCronApiV1GatewaysGatewayIdCronGetResponse =
  | getGatewayCronApiV1GatewaysGatewayIdCronGetResponseSuccess
  | getGatewayCronApiV1GatewaysGatewayIdCronGetResponseError;

export const getGetGatewayCronApiV1GatewaysGatewayIdCronGetUrl = (
  gatewayId: string,
) => {
  return `/api/v1/gateways/${gatewayId}/cron`;
};

export const getGatewayCronApiV1GatewaysGatewayIdCronGet = async (
  gatewayId: string,
  options?: RequestInit,
): Promise<getGatewayCronApiV1GatewaysGatewayIdCronGetResponse> => {
  return customFetch<getGatewayCronApiV1GatewaysGatewayIdCronGetResponse>(
    getGetGatewayCronApiV1GatewaysGatewayIdCronGetUrl(gatewayId),
    {
      ...options,
      method: "GET",
    },
  );
};

export const getGetGatewayCronApiV1GatewaysGatewayIdCronGetQueryKey = (
  gatewayId: string,
) => {
  return [`/api/v1/gateways/${gatewayId}/cron`] as const;
};

export const getGetGatewayCronApiV1GatewaysGatewayIdCronGetQueryOptions = <
  TData = Awaited<
    ReturnType<typeof getGatewayCronApiV1GatewaysGatewayIdCronGet>
  >,
  TError = HTTPValidationError,
>(
  gatewayId: string,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof getGatewayCronApiV1GatewaysGatewayIdCronGet>>,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof customFetch>;
  },
) => {
  const { query: queryOptions, request: requestOptions } = options ?? {};

  const queryKey =
    queryOptions?.queryKey ??
    getGetGatewayCronApiV1GatewaysGatewayIdCronGetQueryKey(gatewayId);

  const queryFn: QueryFunction<
    Awaited<ReturnType<typeof getGatewayCronApiV1GatewaysGatewayIdCronGet>>
  > = ({ signal }) =>
    getGatewayCronApiV1GatewaysGatewayIdCronGet(gatewayId, {
      signal,
      ...requestOptions,
    });

  return {
    queryKey,
    queryFn,
    enabled: !!gatewayId,
    ...queryOptions,
  } as UseQueryOptions<
    Awaited<ReturnType<typeof getGatewayCronApiV1GatewaysGatewayIdCronGet>>,
    TError,
    TData
  > & { queryKey: DataTag<QueryKey, TData, TError> };
};

export type GetGatewayCronApiV1GatewaysGatewayIdCronGetQueryResult =
  NonNullable<
    Awaited<ReturnType<typeof getGatewayCronApiV1GatewaysGatewayIdCronGet>>
  >;
export type GetGatewayCronApiV1GatewaysGatewayIdCronGetQueryError =
  HTTPValidationError;

export function useGetGatewayCronApiV1GatewaysGatewayIdCronGet<
  TData = Awaited<
    ReturnType<typeof getGatewayCronApiV1GatewaysGatewayIdCronGet>
  >,
  TError = HTTPValidationError,
>(
  gatewayId: string,
  options: {
    query: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof getGatewayCronApiV1GatewaysGatewayIdCronGet>>,
        TError,
        TData
      >
    > &
      Pick<
        DefinedInitialDataOptions<
          Awaited<
            ReturnType<typeof getGatewayCronApiV1GatewaysGatewayIdCronGet>
          >,
          TError,
          Awaited<
            ReturnType<typeof getGatewayCronApiV1GatewaysGatewayIdCronGet>
          >
        >,
        "initialData"
      >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): DefinedUseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useGetGatewayCronApiV1GatewaysGatewayIdCronGet<
  TData = Awaited<
    ReturnType<typeof getGatewayCronApiV1GatewaysGatewayIdCronGet>
  >,
  TError = HTTPValidationError,
>(
  gatewayId: string,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof getGatewayCronApiV1GatewaysGatewayIdCronGet>>,
        TError,
        TData
      >
    > &
      Pick<
        UndefinedInitialDataOptions<
          Awaited<
            ReturnType<typeof getGatewayCronApiV1GatewaysGatewayIdCronGet>
          >,
          TError,
          Awaited<
            ReturnType<typeof getGatewayCronApiV1GatewaysGatewayIdCronGet>
          >
        >,
        "initialData"
      >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useGetGatewayCronApiV1GatewaysGatewayIdCronGet<
  TData = Awaited<
    ReturnType<typeof getGatewayCronApiV1GatewaysGatewayIdCronGet>
  >,
  TError = HTTPValidationError,
>(
  gatewayId: string,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof getGatewayCronApiV1GatewaysGatewayIdCronGet>>,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
/**
 * @summary Gateway cron job status
 */

export function useGetGatewayCronApiV1GatewaysGatewayIdCronGet<
  TData = Awaited<
    ReturnType<typeof getGatewayCronApiV1GatewaysGatewayIdCronGet>
  >,
  TError = HTTPValidationError,
>(
  gatewayId: string,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof getGatewayCronApiV1GatewaysGatewayIdCronGet>>,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
} {
  const queryOptions =
    getGetGatewayCronApiV1GatewaysGatewayIdCronGetQueryOptions(
      gatewayId,
      options,
    );

  const query = useQuery(queryOptions, queryClient) as UseQueryResult<
    TData,
    TError
  > & { queryKey: DataTag<QueryKey, TData, TError> };

  return { ...query, queryKey: queryOptions.queryKey };
}

/**
 * Return current CPU, RAM, disk, and uptime stats plus a 24-hour history.
 * @summary Gateway system health
 */
export type getGatewayHealthApiV1GatewaysGatewayIdHealthGetResponse200 = {
  data: SystemHealthResponse;
  status: 200;
};

export type getGatewayHealthApiV1GatewaysGatewayIdHealthGetResponse422 = {
  data: HTTPValidationError;
  status: 422;
};

export type getGatewayHealthApiV1GatewaysGatewayIdHealthGetResponseSuccess =
  getGatewayHealthApiV1GatewaysGatewayIdHealthGetResponse200 & {
    headers: Headers;
  };
export type getGatewayHealthApiV1GatewaysGatewayIdHealthGetResponseError =
  getGatewayHealthApiV1GatewaysGatewayIdHealthGetResponse422 & {
    headers: Headers;
  };

export type getGatewayHealthApiV1GatewaysGatewayIdHealthGetResponse =
  | getGatewayHealthApiV1GatewaysGatewayIdHealthGetResponseSuccess
  | getGatewayHealthApiV1GatewaysGatewayIdHealthGetResponseError;

export const getGetGatewayHealthApiV1GatewaysGatewayIdHealthGetUrl = (
  gatewayId: string,
) => {
  return `/api/v1/gateways/${gatewayId}/health`;
};

export const getGatewayHealthApiV1GatewaysGatewayIdHealthGet = async (
  gatewayId: string,
  options?: RequestInit,
): Promise<getGatewayHealthApiV1GatewaysGatewayIdHealthGetResponse> => {
  return customFetch<getGatewayHealthApiV1GatewaysGatewayIdHealthGetResponse>(
    getGetGatewayHealthApiV1GatewaysGatewayIdHealthGetUrl(gatewayId),
    {
      ...options,
      method: "GET",
    },
  );
};

export const getGetGatewayHealthApiV1GatewaysGatewayIdHealthGetQueryKey = (
  gatewayId: string,
) => {
  return [`/api/v1/gateways/${gatewayId}/health`] as const;
};

export const getGetGatewayHealthApiV1GatewaysGatewayIdHealthGetQueryOptions = <
  TData = Awaited<
    ReturnType<typeof getGatewayHealthApiV1GatewaysGatewayIdHealthGet>
  >,
  TError = HTTPValidationError,
>(
  gatewayId: string,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<
          ReturnType<typeof getGatewayHealthApiV1GatewaysGatewayIdHealthGet>
        >,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof customFetch>;
  },
) => {
  const { query: queryOptions, request: requestOptions } = options ?? {};

  const queryKey =
    queryOptions?.queryKey ??
    getGetGatewayHealthApiV1GatewaysGatewayIdHealthGetQueryKey(gatewayId);

  const queryFn: QueryFunction<
    Awaited<ReturnType<typeof getGatewayHealthApiV1GatewaysGatewayIdHealthGet>>
  > = ({ signal }) =>
    getGatewayHealthApiV1GatewaysGatewayIdHealthGet(gatewayId, {
      signal,
      ...requestOptions,
    });

  return {
    queryKey,
    queryFn,
    enabled: !!gatewayId,
    ...queryOptions,
  } as UseQueryOptions<
    Awaited<ReturnType<typeof getGatewayHealthApiV1GatewaysGatewayIdHealthGet>>,
    TError,
    TData
  > & { queryKey: DataTag<QueryKey, TData, TError> };
};

export type GetGatewayHealthApiV1GatewaysGatewayIdHealthGetQueryResult =
  NonNullable<
    Awaited<ReturnType<typeof getGatewayHealthApiV1GatewaysGatewayIdHealthGet>>
  >;
export type GetGatewayHealthApiV1GatewaysGatewayIdHealthGetQueryError =
  HTTPValidationError;

export function useGetGatewayHealthApiV1GatewaysGatewayIdHealthGet<
  TData = Awaited<
    ReturnType<typeof getGatewayHealthApiV1GatewaysGatewayIdHealthGet>
  >,
  TError = HTTPValidationError,
>(
  gatewayId: string,
  options: {
    query: Partial<
      UseQueryOptions<
        Awaited<
          ReturnType<typeof getGatewayHealthApiV1GatewaysGatewayIdHealthGet>
        >,
        TError,
        TData
      >
    > &
      Pick<
        DefinedInitialDataOptions<
          Awaited<
            ReturnType<typeof getGatewayHealthApiV1GatewaysGatewayIdHealthGet>
          >,
          TError,
          Awaited<
            ReturnType<typeof getGatewayHealthApiV1GatewaysGatewayIdHealthGet>
          >
        >,
        "initialData"
      >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): DefinedUseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useGetGatewayHealthApiV1GatewaysGatewayIdHealthGet<
  TData = Awaited<
    ReturnType<typeof getGatewayHealthApiV1GatewaysGatewayIdHealthGet>
  >,
  TError = HTTPValidationError,
>(
  gatewayId: string,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<
          ReturnType<typeof getGatewayHealthApiV1GatewaysGatewayIdHealthGet>
        >,
        TError,
        TData
      >
    > &
      Pick<
        UndefinedInitialDataOptions<
          Awaited<
            ReturnType<typeof getGatewayHealthApiV1GatewaysGatewayIdHealthGet>
          >,
          TError,
          Awaited<
            ReturnType<typeof getGatewayHealthApiV1GatewaysGatewayIdHealthGet>
          >
        >,
        "initialData"
      >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useGetGatewayHealthApiV1GatewaysGatewayIdHealthGet<
  TData = Awaited<
    ReturnType<typeof getGatewayHealthApiV1GatewaysGatewayIdHealthGet>
  >,
  TError = HTTPValidationError,
>(
  gatewayId: string,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<
          ReturnType<typeof getGatewayHealthApiV1GatewaysGatewayIdHealthGet>
        >,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
/**
 * @summary Gateway system health
 */

export function useGetGatewayHealthApiV1GatewaysGatewayIdHealthGet<
  TData = Awaited<
    ReturnType<typeof getGatewayHealthApiV1GatewaysGatewayIdHealthGet>
  >,
  TError = HTTPValidationError,
>(
  gatewayId: string,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<
          ReturnType<typeof getGatewayHealthApiV1GatewaysGatewayIdHealthGet>
        >,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
} {
  const queryOptions =
    getGetGatewayHealthApiV1GatewaysGatewayIdHealthGetQueryOptions(
      gatewayId,
      options,
    );

  const query = useQuery(queryOptions, queryClient) as UseQueryResult<
    TData,
    TError
  > & { queryKey: DataTag<QueryKey, TData, TError> };

  return { ...query, queryKey: queryOptions.queryKey };
}

/**
 * Return the most recent log lines from the gateway process. Admin-only.
 * @summary Tail gateway logs (admin)
 */
export type getGatewayLogsApiV1GatewaysGatewayIdLogsGetResponse200 = {
  data: GetGatewayLogsApiV1GatewaysGatewayIdLogsGet200;
  status: 200;
};

export type getGatewayLogsApiV1GatewaysGatewayIdLogsGetResponse422 = {
  data: HTTPValidationError;
  status: 422;
};

export type getGatewayLogsApiV1GatewaysGatewayIdLogsGetResponseSuccess =
  getGatewayLogsApiV1GatewaysGatewayIdLogsGetResponse200 & {
    headers: Headers;
  };
export type getGatewayLogsApiV1GatewaysGatewayIdLogsGetResponseError =
  getGatewayLogsApiV1GatewaysGatewayIdLogsGetResponse422 & {
    headers: Headers;
  };

export type getGatewayLogsApiV1GatewaysGatewayIdLogsGetResponse =
  | getGatewayLogsApiV1GatewaysGatewayIdLogsGetResponseSuccess
  | getGatewayLogsApiV1GatewaysGatewayIdLogsGetResponseError;

export const getGetGatewayLogsApiV1GatewaysGatewayIdLogsGetUrl = (
  gatewayId: string,
  params?: GetGatewayLogsApiV1GatewaysGatewayIdLogsGetParams,
) => {
  const normalizedParams = new URLSearchParams();

  Object.entries(params || {}).forEach(([key, value]) => {
    if (value !== undefined) {
      normalizedParams.append(key, value === null ? "null" : value.toString());
    }
  });

  const stringifiedParams = normalizedParams.toString();

  return stringifiedParams.length > 0
    ? `/api/v1/gateways/${gatewayId}/logs?${stringifiedParams}`
    : `/api/v1/gateways/${gatewayId}/logs`;
};

export const getGatewayLogsApiV1GatewaysGatewayIdLogsGet = async (
  gatewayId: string,
  params?: GetGatewayLogsApiV1GatewaysGatewayIdLogsGetParams,
  options?: RequestInit,
): Promise<getGatewayLogsApiV1GatewaysGatewayIdLogsGetResponse> => {
  return customFetch<getGatewayLogsApiV1GatewaysGatewayIdLogsGetResponse>(
    getGetGatewayLogsApiV1GatewaysGatewayIdLogsGetUrl(gatewayId, params),
    {
      ...options,
      method: "GET",
    },
  );
};

export const getGetGatewayLogsApiV1GatewaysGatewayIdLogsGetQueryKey = (
  gatewayId: string,
  params?: GetGatewayLogsApiV1GatewaysGatewayIdLogsGetParams,
) => {
  return [
    `/api/v1/gateways/${gatewayId}/logs`,
    ...(params ? [params] : []),
  ] as const;
};

export const getGetGatewayLogsApiV1GatewaysGatewayIdLogsGetQueryOptions = <
  TData = Awaited<
    ReturnType<typeof getGatewayLogsApiV1GatewaysGatewayIdLogsGet>
  >,
  TError = HTTPValidationError,
>(
  gatewayId: string,
  params?: GetGatewayLogsApiV1GatewaysGatewayIdLogsGetParams,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof getGatewayLogsApiV1GatewaysGatewayIdLogsGet>>,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof customFetch>;
  },
) => {
  const { query: queryOptions, request: requestOptions } = options ?? {};

  const queryKey =
    queryOptions?.queryKey ??
    getGetGatewayLogsApiV1GatewaysGatewayIdLogsGetQueryKey(gatewayId, params);

  const queryFn: QueryFunction<
    Awaited<ReturnType<typeof getGatewayLogsApiV1GatewaysGatewayIdLogsGet>>
  > = ({ signal }) =>
    getGatewayLogsApiV1GatewaysGatewayIdLogsGet(gatewayId, params, {
      signal,
      ...requestOptions,
    });

  return {
    queryKey,
    queryFn,
    enabled: !!gatewayId,
    ...queryOptions,
  } as UseQueryOptions<
    Awaited<ReturnType<typeof getGatewayLogsApiV1GatewaysGatewayIdLogsGet>>,
    TError,
    TData
  > & { queryKey: DataTag<QueryKey, TData, TError> };
};

export type GetGatewayLogsApiV1GatewaysGatewayIdLogsGetQueryResult =
  NonNullable<
    Awaited<ReturnType<typeof getGatewayLogsApiV1GatewaysGatewayIdLogsGet>>
  >;
export type GetGatewayLogsApiV1GatewaysGatewayIdLogsGetQueryError =
  HTTPValidationError;

export function useGetGatewayLogsApiV1GatewaysGatewayIdLogsGet<
  TData = Awaited<
    ReturnType<typeof getGatewayLogsApiV1GatewaysGatewayIdLogsGet>
  >,
  TError = HTTPValidationError,
>(
  gatewayId: string,
  params: undefined | GetGatewayLogsApiV1GatewaysGatewayIdLogsGetParams,
  options: {
    query: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof getGatewayLogsApiV1GatewaysGatewayIdLogsGet>>,
        TError,
        TData
      >
    > &
      Pick<
        DefinedInitialDataOptions<
          Awaited<
            ReturnType<typeof getGatewayLogsApiV1GatewaysGatewayIdLogsGet>
          >,
          TError,
          Awaited<
            ReturnType<typeof getGatewayLogsApiV1GatewaysGatewayIdLogsGet>
          >
        >,
        "initialData"
      >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): DefinedUseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useGetGatewayLogsApiV1GatewaysGatewayIdLogsGet<
  TData = Awaited<
    ReturnType<typeof getGatewayLogsApiV1GatewaysGatewayIdLogsGet>
  >,
  TError = HTTPValidationError,
>(
  gatewayId: string,
  params?: GetGatewayLogsApiV1GatewaysGatewayIdLogsGetParams,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof getGatewayLogsApiV1GatewaysGatewayIdLogsGet>>,
        TError,
        TData
      >
    > &
      Pick<
        UndefinedInitialDataOptions<
          Awaited<
            ReturnType<typeof getGatewayLogsApiV1GatewaysGatewayIdLogsGet>
          >,
          TError,
          Awaited<
            ReturnType<typeof getGatewayLogsApiV1GatewaysGatewayIdLogsGet>
          >
        >,
        "initialData"
      >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useGetGatewayLogsApiV1GatewaysGatewayIdLogsGet<
  TData = Awaited<
    ReturnType<typeof getGatewayLogsApiV1GatewaysGatewayIdLogsGet>
  >,
  TError = HTTPValidationError,
>(
  gatewayId: string,
  params?: GetGatewayLogsApiV1GatewaysGatewayIdLogsGetParams,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof getGatewayLogsApiV1GatewaysGatewayIdLogsGet>>,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
/**
 * @summary Tail gateway logs (admin)
 */

export function useGetGatewayLogsApiV1GatewaysGatewayIdLogsGet<
  TData = Awaited<
    ReturnType<typeof getGatewayLogsApiV1GatewaysGatewayIdLogsGet>
  >,
  TError = HTTPValidationError,
>(
  gatewayId: string,
  params?: GetGatewayLogsApiV1GatewaysGatewayIdLogsGetParams,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof getGatewayLogsApiV1GatewaysGatewayIdLogsGet>>,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
} {
  const queryOptions =
    getGetGatewayLogsApiV1GatewaysGatewayIdLogsGetQueryOptions(
      gatewayId,
      params,
      options,
    );

  const query = useQuery(queryOptions, queryClient) as UseQueryResult<
    TData,
    TError
  > & { queryKey: DataTag<QueryKey, TData, TError> };

  return { ...query, queryKey: queryOptions.queryKey };
}

/**
 * Return the current gateway configuration with secrets masked. Admin-only.
 * @summary Read gateway config (admin)
 */
export type getGatewayConfigApiV1GatewaysGatewayIdConfigGetResponse200 = {
  data: GetGatewayConfigApiV1GatewaysGatewayIdConfigGet200;
  status: 200;
};

export type getGatewayConfigApiV1GatewaysGatewayIdConfigGetResponse422 = {
  data: HTTPValidationError;
  status: 422;
};

export type getGatewayConfigApiV1GatewaysGatewayIdConfigGetResponseSuccess =
  getGatewayConfigApiV1GatewaysGatewayIdConfigGetResponse200 & {
    headers: Headers;
  };
export type getGatewayConfigApiV1GatewaysGatewayIdConfigGetResponseError =
  getGatewayConfigApiV1GatewaysGatewayIdConfigGetResponse422 & {
    headers: Headers;
  };

export type getGatewayConfigApiV1GatewaysGatewayIdConfigGetResponse =
  | getGatewayConfigApiV1GatewaysGatewayIdConfigGetResponseSuccess
  | getGatewayConfigApiV1GatewaysGatewayIdConfigGetResponseError;

export const getGetGatewayConfigApiV1GatewaysGatewayIdConfigGetUrl = (
  gatewayId: string,
) => {
  return `/api/v1/gateways/${gatewayId}/config`;
};

export const getGatewayConfigApiV1GatewaysGatewayIdConfigGet = async (
  gatewayId: string,
  options?: RequestInit,
): Promise<getGatewayConfigApiV1GatewaysGatewayIdConfigGetResponse> => {
  return customFetch<getGatewayConfigApiV1GatewaysGatewayIdConfigGetResponse>(
    getGetGatewayConfigApiV1GatewaysGatewayIdConfigGetUrl(gatewayId),
    {
      ...options,
      method: "GET",
    },
  );
};

export const getGetGatewayConfigApiV1GatewaysGatewayIdConfigGetQueryKey = (
  gatewayId: string,
) => {
  return [`/api/v1/gateways/${gatewayId}/config`] as const;
};

export const getGetGatewayConfigApiV1GatewaysGatewayIdConfigGetQueryOptions = <
  TData = Awaited<
    ReturnType<typeof getGatewayConfigApiV1GatewaysGatewayIdConfigGet>
  >,
  TError = HTTPValidationError,
>(
  gatewayId: string,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<
          ReturnType<typeof getGatewayConfigApiV1GatewaysGatewayIdConfigGet>
        >,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof customFetch>;
  },
) => {
  const { query: queryOptions, request: requestOptions } = options ?? {};

  const queryKey =
    queryOptions?.queryKey ??
    getGetGatewayConfigApiV1GatewaysGatewayIdConfigGetQueryKey(gatewayId);

  const queryFn: QueryFunction<
    Awaited<ReturnType<typeof getGatewayConfigApiV1GatewaysGatewayIdConfigGet>>
  > = ({ signal }) =>
    getGatewayConfigApiV1GatewaysGatewayIdConfigGet(gatewayId, {
      signal,
      ...requestOptions,
    });

  return {
    queryKey,
    queryFn,
    enabled: !!gatewayId,
    ...queryOptions,
  } as UseQueryOptions<
    Awaited<ReturnType<typeof getGatewayConfigApiV1GatewaysGatewayIdConfigGet>>,
    TError,
    TData
  > & { queryKey: DataTag<QueryKey, TData, TError> };
};

export type GetGatewayConfigApiV1GatewaysGatewayIdConfigGetQueryResult =
  NonNullable<
    Awaited<ReturnType<typeof getGatewayConfigApiV1GatewaysGatewayIdConfigGet>>
  >;
export type GetGatewayConfigApiV1GatewaysGatewayIdConfigGetQueryError =
  HTTPValidationError;

export function useGetGatewayConfigApiV1GatewaysGatewayIdConfigGet<
  TData = Awaited<
    ReturnType<typeof getGatewayConfigApiV1GatewaysGatewayIdConfigGet>
  >,
  TError = HTTPValidationError,
>(
  gatewayId: string,
  options: {
    query: Partial<
      UseQueryOptions<
        Awaited<
          ReturnType<typeof getGatewayConfigApiV1GatewaysGatewayIdConfigGet>
        >,
        TError,
        TData
      >
    > &
      Pick<
        DefinedInitialDataOptions<
          Awaited<
            ReturnType<typeof getGatewayConfigApiV1GatewaysGatewayIdConfigGet>
          >,
          TError,
          Awaited<
            ReturnType<typeof getGatewayConfigApiV1GatewaysGatewayIdConfigGet>
          >
        >,
        "initialData"
      >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): DefinedUseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useGetGatewayConfigApiV1GatewaysGatewayIdConfigGet<
  TData = Awaited<
    ReturnType<typeof getGatewayConfigApiV1GatewaysGatewayIdConfigGet>
  >,
  TError = HTTPValidationError,
>(
  gatewayId: string,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<
          ReturnType<typeof getGatewayConfigApiV1GatewaysGatewayIdConfigGet>
        >,
        TError,
        TData
      >
    > &
      Pick<
        UndefinedInitialDataOptions<
          Awaited<
            ReturnType<typeof getGatewayConfigApiV1GatewaysGatewayIdConfigGet>
          >,
          TError,
          Awaited<
            ReturnType<typeof getGatewayConfigApiV1GatewaysGatewayIdConfigGet>
          >
        >,
        "initialData"
      >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useGetGatewayConfigApiV1GatewaysGatewayIdConfigGet<
  TData = Awaited<
    ReturnType<typeof getGatewayConfigApiV1GatewaysGatewayIdConfigGet>
  >,
  TError = HTTPValidationError,
>(
  gatewayId: string,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<
          ReturnType<typeof getGatewayConfigApiV1GatewaysGatewayIdConfigGet>
        >,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
/**
 * @summary Read gateway config (admin)
 */

export function useGetGatewayConfigApiV1GatewaysGatewayIdConfigGet<
  TData = Awaited<
    ReturnType<typeof getGatewayConfigApiV1GatewaysGatewayIdConfigGet>
  >,
  TError = HTTPValidationError,
>(
  gatewayId: string,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<
          ReturnType<typeof getGatewayConfigApiV1GatewaysGatewayIdConfigGet>
        >,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
} {
  const queryOptions =
    getGetGatewayConfigApiV1GatewaysGatewayIdConfigGetQueryOptions(
      gatewayId,
      options,
    );

  const query = useQuery(queryOptions, queryClient) as UseQueryResult<
    TData,
    TError
  > & { queryKey: DataTag<QueryKey, TData, TError> };

  return { ...query, queryKey: queryOptions.queryKey };
}

/**
 * Apply partial config updates to the gateway using config.patch + config.apply. Secrets must be submitted in full — not masked values. Each call is audit-logged. Admin-only.
 * @summary Update gateway config (admin)
 */
export type patchGatewayConfigApiV1GatewaysGatewayIdConfigPatchResponse200 = {
  data: PatchGatewayConfigApiV1GatewaysGatewayIdConfigPatch200;
  status: 200;
};

export type patchGatewayConfigApiV1GatewaysGatewayIdConfigPatchResponse422 = {
  data: HTTPValidationError;
  status: 422;
};

export type patchGatewayConfigApiV1GatewaysGatewayIdConfigPatchResponseSuccess =
  patchGatewayConfigApiV1GatewaysGatewayIdConfigPatchResponse200 & {
    headers: Headers;
  };
export type patchGatewayConfigApiV1GatewaysGatewayIdConfigPatchResponseError =
  patchGatewayConfigApiV1GatewaysGatewayIdConfigPatchResponse422 & {
    headers: Headers;
  };

export type patchGatewayConfigApiV1GatewaysGatewayIdConfigPatchResponse =
  | patchGatewayConfigApiV1GatewaysGatewayIdConfigPatchResponseSuccess
  | patchGatewayConfigApiV1GatewaysGatewayIdConfigPatchResponseError;

export const getPatchGatewayConfigApiV1GatewaysGatewayIdConfigPatchUrl = (
  gatewayId: string,
) => {
  return `/api/v1/gateways/${gatewayId}/config`;
};

export const patchGatewayConfigApiV1GatewaysGatewayIdConfigPatch = async (
  gatewayId: string,
  patchGatewayConfigApiV1GatewaysGatewayIdConfigPatchBody: PatchGatewayConfigApiV1GatewaysGatewayIdConfigPatchBody,
  options?: RequestInit,
): Promise<patchGatewayConfigApiV1GatewaysGatewayIdConfigPatchResponse> => {
  return customFetch<patchGatewayConfigApiV1GatewaysGatewayIdConfigPatchResponse>(
    getPatchGatewayConfigApiV1GatewaysGatewayIdConfigPatchUrl(gatewayId),
    {
      ...options,
      method: "PATCH",
      headers: { "Content-Type": "application/json", ...options?.headers },
      body: JSON.stringify(
        patchGatewayConfigApiV1GatewaysGatewayIdConfigPatchBody,
      ),
    },
  );
};

export const getPatchGatewayConfigApiV1GatewaysGatewayIdConfigPatchMutationOptions =
  <TError = HTTPValidationError, TContext = unknown>(options?: {
    mutation?: UseMutationOptions<
      Awaited<
        ReturnType<typeof patchGatewayConfigApiV1GatewaysGatewayIdConfigPatch>
      >,
      TError,
      {
        gatewayId: string;
        data: PatchGatewayConfigApiV1GatewaysGatewayIdConfigPatchBody;
      },
      TContext
    >;
    request?: SecondParameter<typeof customFetch>;
  }): UseMutationOptions<
    Awaited<
      ReturnType<typeof patchGatewayConfigApiV1GatewaysGatewayIdConfigPatch>
    >,
    TError,
    {
      gatewayId: string;
      data: PatchGatewayConfigApiV1GatewaysGatewayIdConfigPatchBody;
    },
    TContext
  > => {
    const mutationKey = ["patchGatewayConfigApiV1GatewaysGatewayIdConfigPatch"];
    const { mutation: mutationOptions, request: requestOptions } = options
      ? options.mutation &&
        "mutationKey" in options.mutation &&
        options.mutation.mutationKey
        ? options
        : { ...options, mutation: { ...options.mutation, mutationKey } }
      : { mutation: { mutationKey }, request: undefined };

    const mutationFn: MutationFunction<
      Awaited<
        ReturnType<typeof patchGatewayConfigApiV1GatewaysGatewayIdConfigPatch>
      >,
      {
        gatewayId: string;
        data: PatchGatewayConfigApiV1GatewaysGatewayIdConfigPatchBody;
      }
    > = (props) => {
      const { gatewayId, data } = props ?? {};

      return patchGatewayConfigApiV1GatewaysGatewayIdConfigPatch(
        gatewayId,
        data,
        requestOptions,
      );
    };

    return { mutationFn, ...mutationOptions };
  };

export type PatchGatewayConfigApiV1GatewaysGatewayIdConfigPatchMutationResult =
  NonNullable<
    Awaited<
      ReturnType<typeof patchGatewayConfigApiV1GatewaysGatewayIdConfigPatch>
    >
  >;
export type PatchGatewayConfigApiV1GatewaysGatewayIdConfigPatchMutationBody =
  PatchGatewayConfigApiV1GatewaysGatewayIdConfigPatchBody;
export type PatchGatewayConfigApiV1GatewaysGatewayIdConfigPatchMutationError =
  HTTPValidationError;

/**
 * @summary Update gateway config (admin)
 */
export const usePatchGatewayConfigApiV1GatewaysGatewayIdConfigPatch = <
  TError = HTTPValidationError,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<
        ReturnType<typeof patchGatewayConfigApiV1GatewaysGatewayIdConfigPatch>
      >,
      TError,
      {
        gatewayId: string;
        data: PatchGatewayConfigApiV1GatewaysGatewayIdConfigPatchBody;
      },
      TContext
    >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<
    ReturnType<typeof patchGatewayConfigApiV1GatewaysGatewayIdConfigPatch>
  >,
  TError,
  {
    gatewayId: string;
    data: PatchGatewayConfigApiV1GatewaysGatewayIdConfigPatchBody;
  },
  TContext
> => {
  return useMutation(
    getPatchGatewayConfigApiV1GatewaysGatewayIdConfigPatchMutationOptions(
      options,
    ),
    queryClient,
  );
};
/**
 * Return the most recent messages from all active sessions on the gateway, normalised and redacted.  Use the streaming endpoint for a live feed.
 * @summary Recent gateway runtime messages (REST snapshot)
 */
export type getGatewayRuntimeActivityApiV1GatewaysGatewayIdRuntimeActivityGetResponse200 =
  {
    data: GetGatewayRuntimeActivityApiV1GatewaysGatewayIdRuntimeActivityGet200;
    status: 200;
  };

export type getGatewayRuntimeActivityApiV1GatewaysGatewayIdRuntimeActivityGetResponse422 =
  {
    data: HTTPValidationError;
    status: 422;
  };

export type getGatewayRuntimeActivityApiV1GatewaysGatewayIdRuntimeActivityGetResponseSuccess =
  getGatewayRuntimeActivityApiV1GatewaysGatewayIdRuntimeActivityGetResponse200 & {
    headers: Headers;
  };
export type getGatewayRuntimeActivityApiV1GatewaysGatewayIdRuntimeActivityGetResponseError =
  getGatewayRuntimeActivityApiV1GatewaysGatewayIdRuntimeActivityGetResponse422 & {
    headers: Headers;
  };

export type getGatewayRuntimeActivityApiV1GatewaysGatewayIdRuntimeActivityGetResponse =

    | getGatewayRuntimeActivityApiV1GatewaysGatewayIdRuntimeActivityGetResponseSuccess
    | getGatewayRuntimeActivityApiV1GatewaysGatewayIdRuntimeActivityGetResponseError;

export const getGetGatewayRuntimeActivityApiV1GatewaysGatewayIdRuntimeActivityGetUrl =
  (gatewayId: string) => {
    return `/api/v1/gateways/${gatewayId}/runtime-activity`;
  };

export const getGatewayRuntimeActivityApiV1GatewaysGatewayIdRuntimeActivityGet =
  async (
    gatewayId: string,
    options?: RequestInit,
  ): Promise<getGatewayRuntimeActivityApiV1GatewaysGatewayIdRuntimeActivityGetResponse> => {
    return customFetch<getGatewayRuntimeActivityApiV1GatewaysGatewayIdRuntimeActivityGetResponse>(
      getGetGatewayRuntimeActivityApiV1GatewaysGatewayIdRuntimeActivityGetUrl(
        gatewayId,
      ),
      {
        ...options,
        method: "GET",
      },
    );
  };

export const getGetGatewayRuntimeActivityApiV1GatewaysGatewayIdRuntimeActivityGetQueryKey =
  (gatewayId: string) => {
    return [`/api/v1/gateways/${gatewayId}/runtime-activity`] as const;
  };

export const getGetGatewayRuntimeActivityApiV1GatewaysGatewayIdRuntimeActivityGetQueryOptions =
  <
    TData = Awaited<
      ReturnType<
        typeof getGatewayRuntimeActivityApiV1GatewaysGatewayIdRuntimeActivityGet
      >
    >,
    TError = HTTPValidationError,
  >(
    gatewayId: string,
    options?: {
      query?: Partial<
        UseQueryOptions<
          Awaited<
            ReturnType<
              typeof getGatewayRuntimeActivityApiV1GatewaysGatewayIdRuntimeActivityGet
            >
          >,
          TError,
          TData
        >
      >;
      request?: SecondParameter<typeof customFetch>;
    },
  ) => {
    const { query: queryOptions, request: requestOptions } = options ?? {};

    const queryKey =
      queryOptions?.queryKey ??
      getGetGatewayRuntimeActivityApiV1GatewaysGatewayIdRuntimeActivityGetQueryKey(
        gatewayId,
      );

    const queryFn: QueryFunction<
      Awaited<
        ReturnType<
          typeof getGatewayRuntimeActivityApiV1GatewaysGatewayIdRuntimeActivityGet
        >
      >
    > = ({ signal }) =>
      getGatewayRuntimeActivityApiV1GatewaysGatewayIdRuntimeActivityGet(
        gatewayId,
        { signal, ...requestOptions },
      );

    return {
      queryKey,
      queryFn,
      enabled: !!gatewayId,
      ...queryOptions,
    } as UseQueryOptions<
      Awaited<
        ReturnType<
          typeof getGatewayRuntimeActivityApiV1GatewaysGatewayIdRuntimeActivityGet
        >
      >,
      TError,
      TData
    > & { queryKey: DataTag<QueryKey, TData, TError> };
  };

export type GetGatewayRuntimeActivityApiV1GatewaysGatewayIdRuntimeActivityGetQueryResult =
  NonNullable<
    Awaited<
      ReturnType<
        typeof getGatewayRuntimeActivityApiV1GatewaysGatewayIdRuntimeActivityGet
      >
    >
  >;
export type GetGatewayRuntimeActivityApiV1GatewaysGatewayIdRuntimeActivityGetQueryError =
  HTTPValidationError;

export function useGetGatewayRuntimeActivityApiV1GatewaysGatewayIdRuntimeActivityGet<
  TData = Awaited<
    ReturnType<
      typeof getGatewayRuntimeActivityApiV1GatewaysGatewayIdRuntimeActivityGet
    >
  >,
  TError = HTTPValidationError,
>(
  gatewayId: string,
  options: {
    query: Partial<
      UseQueryOptions<
        Awaited<
          ReturnType<
            typeof getGatewayRuntimeActivityApiV1GatewaysGatewayIdRuntimeActivityGet
          >
        >,
        TError,
        TData
      >
    > &
      Pick<
        DefinedInitialDataOptions<
          Awaited<
            ReturnType<
              typeof getGatewayRuntimeActivityApiV1GatewaysGatewayIdRuntimeActivityGet
            >
          >,
          TError,
          Awaited<
            ReturnType<
              typeof getGatewayRuntimeActivityApiV1GatewaysGatewayIdRuntimeActivityGet
            >
          >
        >,
        "initialData"
      >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): DefinedUseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useGetGatewayRuntimeActivityApiV1GatewaysGatewayIdRuntimeActivityGet<
  TData = Awaited<
    ReturnType<
      typeof getGatewayRuntimeActivityApiV1GatewaysGatewayIdRuntimeActivityGet
    >
  >,
  TError = HTTPValidationError,
>(
  gatewayId: string,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<
          ReturnType<
            typeof getGatewayRuntimeActivityApiV1GatewaysGatewayIdRuntimeActivityGet
          >
        >,
        TError,
        TData
      >
    > &
      Pick<
        UndefinedInitialDataOptions<
          Awaited<
            ReturnType<
              typeof getGatewayRuntimeActivityApiV1GatewaysGatewayIdRuntimeActivityGet
            >
          >,
          TError,
          Awaited<
            ReturnType<
              typeof getGatewayRuntimeActivityApiV1GatewaysGatewayIdRuntimeActivityGet
            >
          >
        >,
        "initialData"
      >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useGetGatewayRuntimeActivityApiV1GatewaysGatewayIdRuntimeActivityGet<
  TData = Awaited<
    ReturnType<
      typeof getGatewayRuntimeActivityApiV1GatewaysGatewayIdRuntimeActivityGet
    >
  >,
  TError = HTTPValidationError,
>(
  gatewayId: string,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<
          ReturnType<
            typeof getGatewayRuntimeActivityApiV1GatewaysGatewayIdRuntimeActivityGet
          >
        >,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
/**
 * @summary Recent gateway runtime messages (REST snapshot)
 */

export function useGetGatewayRuntimeActivityApiV1GatewaysGatewayIdRuntimeActivityGet<
  TData = Awaited<
    ReturnType<
      typeof getGatewayRuntimeActivityApiV1GatewaysGatewayIdRuntimeActivityGet
    >
  >,
  TError = HTTPValidationError,
>(
  gatewayId: string,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<
          ReturnType<
            typeof getGatewayRuntimeActivityApiV1GatewaysGatewayIdRuntimeActivityGet
          >
        >,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
} {
  const queryOptions =
    getGetGatewayRuntimeActivityApiV1GatewaysGatewayIdRuntimeActivityGetQueryOptions(
      gatewayId,
      options,
    );

  const query = useQuery(queryOptions, queryClient) as UseQueryResult<
    TData,
    TError
  > & { queryKey: DataTag<QueryKey, TData, TError> };

  return { ...query, queryKey: queryOptions.queryKey };
}

/**
 * Stream normalised gateway session messages as server-sent events. Each event is of type ``runtime_message``.  The stream polls the gateway every few seconds and emits only new messages.
 * @summary Live gateway runtime activity (SSE)
 */
export type streamGatewayRuntimeActivityApiV1GatewaysGatewayIdRuntimeActivityStreamGetResponse200 =
  {
    data: unknown;
    status: 200;
  };

export type streamGatewayRuntimeActivityApiV1GatewaysGatewayIdRuntimeActivityStreamGetResponse422 =
  {
    data: HTTPValidationError;
    status: 422;
  };

export type streamGatewayRuntimeActivityApiV1GatewaysGatewayIdRuntimeActivityStreamGetResponseSuccess =
  streamGatewayRuntimeActivityApiV1GatewaysGatewayIdRuntimeActivityStreamGetResponse200 & {
    headers: Headers;
  };
export type streamGatewayRuntimeActivityApiV1GatewaysGatewayIdRuntimeActivityStreamGetResponseError =
  streamGatewayRuntimeActivityApiV1GatewaysGatewayIdRuntimeActivityStreamGetResponse422 & {
    headers: Headers;
  };

export type streamGatewayRuntimeActivityApiV1GatewaysGatewayIdRuntimeActivityStreamGetResponse =

    | streamGatewayRuntimeActivityApiV1GatewaysGatewayIdRuntimeActivityStreamGetResponseSuccess
    | streamGatewayRuntimeActivityApiV1GatewaysGatewayIdRuntimeActivityStreamGetResponseError;

export const getStreamGatewayRuntimeActivityApiV1GatewaysGatewayIdRuntimeActivityStreamGetUrl =
  (gatewayId: string) => {
    return `/api/v1/gateways/${gatewayId}/runtime-activity/stream`;
  };

export const streamGatewayRuntimeActivityApiV1GatewaysGatewayIdRuntimeActivityStreamGet =
  async (
    gatewayId: string,
    options?: RequestInit,
  ): Promise<streamGatewayRuntimeActivityApiV1GatewaysGatewayIdRuntimeActivityStreamGetResponse> => {
    return customFetch<streamGatewayRuntimeActivityApiV1GatewaysGatewayIdRuntimeActivityStreamGetResponse>(
      getStreamGatewayRuntimeActivityApiV1GatewaysGatewayIdRuntimeActivityStreamGetUrl(
        gatewayId,
      ),
      {
        ...options,
        method: "GET",
      },
    );
  };

export const getStreamGatewayRuntimeActivityApiV1GatewaysGatewayIdRuntimeActivityStreamGetQueryKey =
  (gatewayId: string) => {
    return [`/api/v1/gateways/${gatewayId}/runtime-activity/stream`] as const;
  };

export const getStreamGatewayRuntimeActivityApiV1GatewaysGatewayIdRuntimeActivityStreamGetQueryOptions =
  <
    TData = Awaited<
      ReturnType<
        typeof streamGatewayRuntimeActivityApiV1GatewaysGatewayIdRuntimeActivityStreamGet
      >
    >,
    TError = HTTPValidationError,
  >(
    gatewayId: string,
    options?: {
      query?: Partial<
        UseQueryOptions<
          Awaited<
            ReturnType<
              typeof streamGatewayRuntimeActivityApiV1GatewaysGatewayIdRuntimeActivityStreamGet
            >
          >,
          TError,
          TData
        >
      >;
      request?: SecondParameter<typeof customFetch>;
    },
  ) => {
    const { query: queryOptions, request: requestOptions } = options ?? {};

    const queryKey =
      queryOptions?.queryKey ??
      getStreamGatewayRuntimeActivityApiV1GatewaysGatewayIdRuntimeActivityStreamGetQueryKey(
        gatewayId,
      );

    const queryFn: QueryFunction<
      Awaited<
        ReturnType<
          typeof streamGatewayRuntimeActivityApiV1GatewaysGatewayIdRuntimeActivityStreamGet
        >
      >
    > = ({ signal }) =>
      streamGatewayRuntimeActivityApiV1GatewaysGatewayIdRuntimeActivityStreamGet(
        gatewayId,
        { signal, ...requestOptions },
      );

    return {
      queryKey,
      queryFn,
      enabled: !!gatewayId,
      ...queryOptions,
    } as UseQueryOptions<
      Awaited<
        ReturnType<
          typeof streamGatewayRuntimeActivityApiV1GatewaysGatewayIdRuntimeActivityStreamGet
        >
      >,
      TError,
      TData
    > & { queryKey: DataTag<QueryKey, TData, TError> };
  };

export type StreamGatewayRuntimeActivityApiV1GatewaysGatewayIdRuntimeActivityStreamGetQueryResult =
  NonNullable<
    Awaited<
      ReturnType<
        typeof streamGatewayRuntimeActivityApiV1GatewaysGatewayIdRuntimeActivityStreamGet
      >
    >
  >;
export type StreamGatewayRuntimeActivityApiV1GatewaysGatewayIdRuntimeActivityStreamGetQueryError =
  HTTPValidationError;

export function useStreamGatewayRuntimeActivityApiV1GatewaysGatewayIdRuntimeActivityStreamGet<
  TData = Awaited<
    ReturnType<
      typeof streamGatewayRuntimeActivityApiV1GatewaysGatewayIdRuntimeActivityStreamGet
    >
  >,
  TError = HTTPValidationError,
>(
  gatewayId: string,
  options: {
    query: Partial<
      UseQueryOptions<
        Awaited<
          ReturnType<
            typeof streamGatewayRuntimeActivityApiV1GatewaysGatewayIdRuntimeActivityStreamGet
          >
        >,
        TError,
        TData
      >
    > &
      Pick<
        DefinedInitialDataOptions<
          Awaited<
            ReturnType<
              typeof streamGatewayRuntimeActivityApiV1GatewaysGatewayIdRuntimeActivityStreamGet
            >
          >,
          TError,
          Awaited<
            ReturnType<
              typeof streamGatewayRuntimeActivityApiV1GatewaysGatewayIdRuntimeActivityStreamGet
            >
          >
        >,
        "initialData"
      >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): DefinedUseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useStreamGatewayRuntimeActivityApiV1GatewaysGatewayIdRuntimeActivityStreamGet<
  TData = Awaited<
    ReturnType<
      typeof streamGatewayRuntimeActivityApiV1GatewaysGatewayIdRuntimeActivityStreamGet
    >
  >,
  TError = HTTPValidationError,
>(
  gatewayId: string,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<
          ReturnType<
            typeof streamGatewayRuntimeActivityApiV1GatewaysGatewayIdRuntimeActivityStreamGet
          >
        >,
        TError,
        TData
      >
    > &
      Pick<
        UndefinedInitialDataOptions<
          Awaited<
            ReturnType<
              typeof streamGatewayRuntimeActivityApiV1GatewaysGatewayIdRuntimeActivityStreamGet
            >
          >,
          TError,
          Awaited<
            ReturnType<
              typeof streamGatewayRuntimeActivityApiV1GatewaysGatewayIdRuntimeActivityStreamGet
            >
          >
        >,
        "initialData"
      >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useStreamGatewayRuntimeActivityApiV1GatewaysGatewayIdRuntimeActivityStreamGet<
  TData = Awaited<
    ReturnType<
      typeof streamGatewayRuntimeActivityApiV1GatewaysGatewayIdRuntimeActivityStreamGet
    >
  >,
  TError = HTTPValidationError,
>(
  gatewayId: string,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<
          ReturnType<
            typeof streamGatewayRuntimeActivityApiV1GatewaysGatewayIdRuntimeActivityStreamGet
          >
        >,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
/**
 * @summary Live gateway runtime activity (SSE)
 */

export function useStreamGatewayRuntimeActivityApiV1GatewaysGatewayIdRuntimeActivityStreamGet<
  TData = Awaited<
    ReturnType<
      typeof streamGatewayRuntimeActivityApiV1GatewaysGatewayIdRuntimeActivityStreamGet
    >
  >,
  TError = HTTPValidationError,
>(
  gatewayId: string,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<
          ReturnType<
            typeof streamGatewayRuntimeActivityApiV1GatewaysGatewayIdRuntimeActivityStreamGet
          >
        >,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
} {
  const queryOptions =
    getStreamGatewayRuntimeActivityApiV1GatewaysGatewayIdRuntimeActivityStreamGetQueryOptions(
      gatewayId,
      options,
    );

  const query = useQuery(queryOptions, queryClient) as UseQueryResult<
    TData,
    TError
  > & { queryKey: DataTag<QueryKey, TData, TError> };

  return { ...query, queryKey: queryOptions.queryKey };
}
