/**
 * 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 {
  ForgejoRepositoryCreate,
  ForgejoRepositoryRead,
  ForgejoRepositoryUpdate,
  ForgejoRepositoryValidationResponse,
  HTTPValidationError,
  OkResponse,
  SyncRepositoryIssuesApiV1ForgejoRepositoriesRepositoryIdSyncPost200,
} from ".././model";

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

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

/**
 * List Forgejo repositories for the caller's organization.
 * @summary List Repositories
 */
export type listRepositoriesApiV1ForgejoRepositoriesGetResponse200 = {
  data: ForgejoRepositoryRead[];
  status: 200;
};

export type listRepositoriesApiV1ForgejoRepositoriesGetResponseSuccess =
  listRepositoriesApiV1ForgejoRepositoriesGetResponse200 & {
    headers: Headers;
  };
export type listRepositoriesApiV1ForgejoRepositoriesGetResponse =
  listRepositoriesApiV1ForgejoRepositoriesGetResponseSuccess;

export const getListRepositoriesApiV1ForgejoRepositoriesGetUrl = () => {
  return `/api/v1/forgejo/repositories`;
};

export const listRepositoriesApiV1ForgejoRepositoriesGet = async (
  options?: RequestInit,
): Promise<listRepositoriesApiV1ForgejoRepositoriesGetResponse> => {
  return customFetch<listRepositoriesApiV1ForgejoRepositoriesGetResponse>(
    getListRepositoriesApiV1ForgejoRepositoriesGetUrl(),
    {
      ...options,
      method: "GET",
    },
  );
};

export const getListRepositoriesApiV1ForgejoRepositoriesGetQueryKey = () => {
  return [`/api/v1/forgejo/repositories`] as const;
};

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

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

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

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

export type ListRepositoriesApiV1ForgejoRepositoriesGetQueryResult =
  NonNullable<
    Awaited<ReturnType<typeof listRepositoriesApiV1ForgejoRepositoriesGet>>
  >;
export type ListRepositoriesApiV1ForgejoRepositoriesGetQueryError = unknown;

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

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

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

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

/**
 * Create a Forgejo repository tracked for the caller's organization.
 * @summary Create Repository
 */
export type createRepositoryApiV1ForgejoRepositoriesPostResponse200 = {
  data: ForgejoRepositoryRead;
  status: 200;
};

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

export type createRepositoryApiV1ForgejoRepositoriesPostResponseSuccess =
  createRepositoryApiV1ForgejoRepositoriesPostResponse200 & {
    headers: Headers;
  };
export type createRepositoryApiV1ForgejoRepositoriesPostResponseError =
  createRepositoryApiV1ForgejoRepositoriesPostResponse422 & {
    headers: Headers;
  };

export type createRepositoryApiV1ForgejoRepositoriesPostResponse =
  | createRepositoryApiV1ForgejoRepositoriesPostResponseSuccess
  | createRepositoryApiV1ForgejoRepositoriesPostResponseError;

export const getCreateRepositoryApiV1ForgejoRepositoriesPostUrl = () => {
  return `/api/v1/forgejo/repositories`;
};

export const createRepositoryApiV1ForgejoRepositoriesPost = async (
  forgejoRepositoryCreate: ForgejoRepositoryCreate,
  options?: RequestInit,
): Promise<createRepositoryApiV1ForgejoRepositoriesPostResponse> => {
  return customFetch<createRepositoryApiV1ForgejoRepositoriesPostResponse>(
    getCreateRepositoryApiV1ForgejoRepositoriesPostUrl(),
    {
      ...options,
      method: "POST",
      headers: { "Content-Type": "application/json", ...options?.headers },
      body: JSON.stringify(forgejoRepositoryCreate),
    },
  );
};

export const getCreateRepositoryApiV1ForgejoRepositoriesPostMutationOptions = <
  TError = HTTPValidationError,
  TContext = unknown,
>(options?: {
  mutation?: UseMutationOptions<
    Awaited<ReturnType<typeof createRepositoryApiV1ForgejoRepositoriesPost>>,
    TError,
    { data: ForgejoRepositoryCreate },
    TContext
  >;
  request?: SecondParameter<typeof customFetch>;
}): UseMutationOptions<
  Awaited<ReturnType<typeof createRepositoryApiV1ForgejoRepositoriesPost>>,
  TError,
  { data: ForgejoRepositoryCreate },
  TContext
> => {
  const mutationKey = ["createRepositoryApiV1ForgejoRepositoriesPost"];
  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 createRepositoryApiV1ForgejoRepositoriesPost>>,
    { data: ForgejoRepositoryCreate }
  > = (props) => {
    const { data } = props ?? {};

    return createRepositoryApiV1ForgejoRepositoriesPost(data, requestOptions);
  };

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

export type CreateRepositoryApiV1ForgejoRepositoriesPostMutationResult =
  NonNullable<
    Awaited<ReturnType<typeof createRepositoryApiV1ForgejoRepositoriesPost>>
  >;
export type CreateRepositoryApiV1ForgejoRepositoriesPostMutationBody =
  ForgejoRepositoryCreate;
export type CreateRepositoryApiV1ForgejoRepositoriesPostMutationError =
  HTTPValidationError;

/**
 * @summary Create Repository
 */
export const useCreateRepositoryApiV1ForgejoRepositoriesPost = <
  TError = HTTPValidationError,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof createRepositoryApiV1ForgejoRepositoriesPost>>,
      TError,
      { data: ForgejoRepositoryCreate },
      TContext
    >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof createRepositoryApiV1ForgejoRepositoriesPost>>,
  TError,
  { data: ForgejoRepositoryCreate },
  TContext
> => {
  return useMutation(
    getCreateRepositoryApiV1ForgejoRepositoriesPostMutationOptions(options),
    queryClient,
  );
};
/**
 * Return one Forgejo repository by id for the caller's organization.
 * @summary Get Repository
 */
export type getRepositoryApiV1ForgejoRepositoriesRepositoryIdGetResponse200 = {
  data: ForgejoRepositoryRead;
  status: 200;
};

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

export type getRepositoryApiV1ForgejoRepositoriesRepositoryIdGetResponseSuccess =
  getRepositoryApiV1ForgejoRepositoriesRepositoryIdGetResponse200 & {
    headers: Headers;
  };
export type getRepositoryApiV1ForgejoRepositoriesRepositoryIdGetResponseError =
  getRepositoryApiV1ForgejoRepositoriesRepositoryIdGetResponse422 & {
    headers: Headers;
  };

export type getRepositoryApiV1ForgejoRepositoriesRepositoryIdGetResponse =
  | getRepositoryApiV1ForgejoRepositoriesRepositoryIdGetResponseSuccess
  | getRepositoryApiV1ForgejoRepositoriesRepositoryIdGetResponseError;

export const getGetRepositoryApiV1ForgejoRepositoriesRepositoryIdGetUrl = (
  repositoryId: string,
) => {
  return `/api/v1/forgejo/repositories/${repositoryId}`;
};

export const getRepositoryApiV1ForgejoRepositoriesRepositoryIdGet = async (
  repositoryId: string,
  options?: RequestInit,
): Promise<getRepositoryApiV1ForgejoRepositoriesRepositoryIdGetResponse> => {
  return customFetch<getRepositoryApiV1ForgejoRepositoriesRepositoryIdGetResponse>(
    getGetRepositoryApiV1ForgejoRepositoriesRepositoryIdGetUrl(repositoryId),
    {
      ...options,
      method: "GET",
    },
  );
};

export const getGetRepositoryApiV1ForgejoRepositoriesRepositoryIdGetQueryKey = (
  repositoryId: string,
) => {
  return [`/api/v1/forgejo/repositories/${repositoryId}`] as const;
};

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

    const queryKey =
      queryOptions?.queryKey ??
      getGetRepositoryApiV1ForgejoRepositoriesRepositoryIdGetQueryKey(
        repositoryId,
      );

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

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

export type GetRepositoryApiV1ForgejoRepositoriesRepositoryIdGetQueryResult =
  NonNullable<
    Awaited<
      ReturnType<typeof getRepositoryApiV1ForgejoRepositoriesRepositoryIdGet>
    >
  >;
export type GetRepositoryApiV1ForgejoRepositoriesRepositoryIdGetQueryError =
  HTTPValidationError;

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

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

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

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

/**
 * Patch a Forgejo repository for the caller's organization.
 * @summary Update Repository
 */
export type updateRepositoryApiV1ForgejoRepositoriesRepositoryIdPatchResponse200 =
  {
    data: ForgejoRepositoryRead;
    status: 200;
  };

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

export type updateRepositoryApiV1ForgejoRepositoriesRepositoryIdPatchResponseSuccess =
  updateRepositoryApiV1ForgejoRepositoriesRepositoryIdPatchResponse200 & {
    headers: Headers;
  };
export type updateRepositoryApiV1ForgejoRepositoriesRepositoryIdPatchResponseError =
  updateRepositoryApiV1ForgejoRepositoriesRepositoryIdPatchResponse422 & {
    headers: Headers;
  };

export type updateRepositoryApiV1ForgejoRepositoriesRepositoryIdPatchResponse =
  | updateRepositoryApiV1ForgejoRepositoriesRepositoryIdPatchResponseSuccess
  | updateRepositoryApiV1ForgejoRepositoriesRepositoryIdPatchResponseError;

export const getUpdateRepositoryApiV1ForgejoRepositoriesRepositoryIdPatchUrl = (
  repositoryId: string,
) => {
  return `/api/v1/forgejo/repositories/${repositoryId}`;
};

export const updateRepositoryApiV1ForgejoRepositoriesRepositoryIdPatch = async (
  repositoryId: string,
  forgejoRepositoryUpdate: ForgejoRepositoryUpdate,
  options?: RequestInit,
): Promise<updateRepositoryApiV1ForgejoRepositoriesRepositoryIdPatchResponse> => {
  return customFetch<updateRepositoryApiV1ForgejoRepositoriesRepositoryIdPatchResponse>(
    getUpdateRepositoryApiV1ForgejoRepositoriesRepositoryIdPatchUrl(
      repositoryId,
    ),
    {
      ...options,
      method: "PATCH",
      headers: { "Content-Type": "application/json", ...options?.headers },
      body: JSON.stringify(forgejoRepositoryUpdate),
    },
  );
};

export const getUpdateRepositoryApiV1ForgejoRepositoriesRepositoryIdPatchMutationOptions =
  <TError = HTTPValidationError, TContext = unknown>(options?: {
    mutation?: UseMutationOptions<
      Awaited<
        ReturnType<
          typeof updateRepositoryApiV1ForgejoRepositoriesRepositoryIdPatch
        >
      >,
      TError,
      { repositoryId: string; data: ForgejoRepositoryUpdate },
      TContext
    >;
    request?: SecondParameter<typeof customFetch>;
  }): UseMutationOptions<
    Awaited<
      ReturnType<
        typeof updateRepositoryApiV1ForgejoRepositoriesRepositoryIdPatch
      >
    >,
    TError,
    { repositoryId: string; data: ForgejoRepositoryUpdate },
    TContext
  > => {
    const mutationKey = [
      "updateRepositoryApiV1ForgejoRepositoriesRepositoryIdPatch",
    ];
    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 updateRepositoryApiV1ForgejoRepositoriesRepositoryIdPatch
        >
      >,
      { repositoryId: string; data: ForgejoRepositoryUpdate }
    > = (props) => {
      const { repositoryId, data } = props ?? {};

      return updateRepositoryApiV1ForgejoRepositoriesRepositoryIdPatch(
        repositoryId,
        data,
        requestOptions,
      );
    };

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

export type UpdateRepositoryApiV1ForgejoRepositoriesRepositoryIdPatchMutationResult =
  NonNullable<
    Awaited<
      ReturnType<
        typeof updateRepositoryApiV1ForgejoRepositoriesRepositoryIdPatch
      >
    >
  >;
export type UpdateRepositoryApiV1ForgejoRepositoriesRepositoryIdPatchMutationBody =
  ForgejoRepositoryUpdate;
export type UpdateRepositoryApiV1ForgejoRepositoriesRepositoryIdPatchMutationError =
  HTTPValidationError;

/**
 * @summary Update Repository
 */
export const useUpdateRepositoryApiV1ForgejoRepositoriesRepositoryIdPatch = <
  TError = HTTPValidationError,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<
        ReturnType<
          typeof updateRepositoryApiV1ForgejoRepositoriesRepositoryIdPatch
        >
      >,
      TError,
      { repositoryId: string; data: ForgejoRepositoryUpdate },
      TContext
    >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<
    ReturnType<typeof updateRepositoryApiV1ForgejoRepositoriesRepositoryIdPatch>
  >,
  TError,
  { repositoryId: string; data: ForgejoRepositoryUpdate },
  TContext
> => {
  return useMutation(
    getUpdateRepositoryApiV1ForgejoRepositoriesRepositoryIdPatchMutationOptions(
      options,
    ),
    queryClient,
  );
};
/**
 * Delete a Forgejo repository for the caller's organization.
 * @summary Delete Repository
 */
export type deleteRepositoryApiV1ForgejoRepositoriesRepositoryIdDeleteResponse200 =
  {
    data: OkResponse;
    status: 200;
  };

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

export type deleteRepositoryApiV1ForgejoRepositoriesRepositoryIdDeleteResponseSuccess =
  deleteRepositoryApiV1ForgejoRepositoriesRepositoryIdDeleteResponse200 & {
    headers: Headers;
  };
export type deleteRepositoryApiV1ForgejoRepositoriesRepositoryIdDeleteResponseError =
  deleteRepositoryApiV1ForgejoRepositoriesRepositoryIdDeleteResponse422 & {
    headers: Headers;
  };

export type deleteRepositoryApiV1ForgejoRepositoriesRepositoryIdDeleteResponse =
  | deleteRepositoryApiV1ForgejoRepositoriesRepositoryIdDeleteResponseSuccess
  | deleteRepositoryApiV1ForgejoRepositoriesRepositoryIdDeleteResponseError;

export const getDeleteRepositoryApiV1ForgejoRepositoriesRepositoryIdDeleteUrl =
  (repositoryId: string) => {
    return `/api/v1/forgejo/repositories/${repositoryId}`;
  };

export const deleteRepositoryApiV1ForgejoRepositoriesRepositoryIdDelete =
  async (
    repositoryId: string,
    options?: RequestInit,
  ): Promise<deleteRepositoryApiV1ForgejoRepositoriesRepositoryIdDeleteResponse> => {
    return customFetch<deleteRepositoryApiV1ForgejoRepositoriesRepositoryIdDeleteResponse>(
      getDeleteRepositoryApiV1ForgejoRepositoriesRepositoryIdDeleteUrl(
        repositoryId,
      ),
      {
        ...options,
        method: "DELETE",
      },
    );
  };

export const getDeleteRepositoryApiV1ForgejoRepositoriesRepositoryIdDeleteMutationOptions =
  <TError = HTTPValidationError, TContext = unknown>(options?: {
    mutation?: UseMutationOptions<
      Awaited<
        ReturnType<
          typeof deleteRepositoryApiV1ForgejoRepositoriesRepositoryIdDelete
        >
      >,
      TError,
      { repositoryId: string },
      TContext
    >;
    request?: SecondParameter<typeof customFetch>;
  }): UseMutationOptions<
    Awaited<
      ReturnType<
        typeof deleteRepositoryApiV1ForgejoRepositoriesRepositoryIdDelete
      >
    >,
    TError,
    { repositoryId: string },
    TContext
  > => {
    const mutationKey = [
      "deleteRepositoryApiV1ForgejoRepositoriesRepositoryIdDelete",
    ];
    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 deleteRepositoryApiV1ForgejoRepositoriesRepositoryIdDelete
        >
      >,
      { repositoryId: string }
    > = (props) => {
      const { repositoryId } = props ?? {};

      return deleteRepositoryApiV1ForgejoRepositoriesRepositoryIdDelete(
        repositoryId,
        requestOptions,
      );
    };

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

export type DeleteRepositoryApiV1ForgejoRepositoriesRepositoryIdDeleteMutationResult =
  NonNullable<
    Awaited<
      ReturnType<
        typeof deleteRepositoryApiV1ForgejoRepositoriesRepositoryIdDelete
      >
    >
  >;

export type DeleteRepositoryApiV1ForgejoRepositoriesRepositoryIdDeleteMutationError =
  HTTPValidationError;

/**
 * @summary Delete Repository
 */
export const useDeleteRepositoryApiV1ForgejoRepositoriesRepositoryIdDelete = <
  TError = HTTPValidationError,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<
        ReturnType<
          typeof deleteRepositoryApiV1ForgejoRepositoriesRepositoryIdDelete
        >
      >,
      TError,
      { repositoryId: string },
      TContext
    >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<
    ReturnType<
      typeof deleteRepositoryApiV1ForgejoRepositoriesRepositoryIdDelete
    >
  >,
  TError,
  { repositoryId: string },
  TContext
> => {
  return useMutation(
    getDeleteRepositoryApiV1ForgejoRepositoriesRepositoryIdDeleteMutationOptions(
      options,
    ),
    queryClient,
  );
};
/**
 * Test if a Forgejo repository exists and can be accessed with the connection token.
 * @summary Validate Forgejo Repository
 */
export type validateRepositoryApiV1ForgejoRepositoriesRepositoryIdValidatePostResponse200 =
  {
    data: ForgejoRepositoryValidationResponse;
    status: 200;
  };

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

export type validateRepositoryApiV1ForgejoRepositoriesRepositoryIdValidatePostResponseSuccess =
  validateRepositoryApiV1ForgejoRepositoriesRepositoryIdValidatePostResponse200 & {
    headers: Headers;
  };
export type validateRepositoryApiV1ForgejoRepositoriesRepositoryIdValidatePostResponseError =
  validateRepositoryApiV1ForgejoRepositoriesRepositoryIdValidatePostResponse422 & {
    headers: Headers;
  };

export type validateRepositoryApiV1ForgejoRepositoriesRepositoryIdValidatePostResponse =

    | validateRepositoryApiV1ForgejoRepositoriesRepositoryIdValidatePostResponseSuccess
    | validateRepositoryApiV1ForgejoRepositoriesRepositoryIdValidatePostResponseError;

export const getValidateRepositoryApiV1ForgejoRepositoriesRepositoryIdValidatePostUrl =
  (repositoryId: string) => {
    return `/api/v1/forgejo/repositories/${repositoryId}/validate`;
  };

export const validateRepositoryApiV1ForgejoRepositoriesRepositoryIdValidatePost =
  async (
    repositoryId: string,
    options?: RequestInit,
  ): Promise<validateRepositoryApiV1ForgejoRepositoriesRepositoryIdValidatePostResponse> => {
    return customFetch<validateRepositoryApiV1ForgejoRepositoriesRepositoryIdValidatePostResponse>(
      getValidateRepositoryApiV1ForgejoRepositoriesRepositoryIdValidatePostUrl(
        repositoryId,
      ),
      {
        ...options,
        method: "POST",
      },
    );
  };

export const getValidateRepositoryApiV1ForgejoRepositoriesRepositoryIdValidatePostMutationOptions =
  <TError = HTTPValidationError, TContext = unknown>(options?: {
    mutation?: UseMutationOptions<
      Awaited<
        ReturnType<
          typeof validateRepositoryApiV1ForgejoRepositoriesRepositoryIdValidatePost
        >
      >,
      TError,
      { repositoryId: string },
      TContext
    >;
    request?: SecondParameter<typeof customFetch>;
  }): UseMutationOptions<
    Awaited<
      ReturnType<
        typeof validateRepositoryApiV1ForgejoRepositoriesRepositoryIdValidatePost
      >
    >,
    TError,
    { repositoryId: string },
    TContext
  > => {
    const mutationKey = [
      "validateRepositoryApiV1ForgejoRepositoriesRepositoryIdValidatePost",
    ];
    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 validateRepositoryApiV1ForgejoRepositoriesRepositoryIdValidatePost
        >
      >,
      { repositoryId: string }
    > = (props) => {
      const { repositoryId } = props ?? {};

      return validateRepositoryApiV1ForgejoRepositoriesRepositoryIdValidatePost(
        repositoryId,
        requestOptions,
      );
    };

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

export type ValidateRepositoryApiV1ForgejoRepositoriesRepositoryIdValidatePostMutationResult =
  NonNullable<
    Awaited<
      ReturnType<
        typeof validateRepositoryApiV1ForgejoRepositoriesRepositoryIdValidatePost
      >
    >
  >;

export type ValidateRepositoryApiV1ForgejoRepositoriesRepositoryIdValidatePostMutationError =
  HTTPValidationError;

/**
 * @summary Validate Forgejo Repository
 */
export const useValidateRepositoryApiV1ForgejoRepositoriesRepositoryIdValidatePost =
  <TError = HTTPValidationError, TContext = unknown>(
    options?: {
      mutation?: UseMutationOptions<
        Awaited<
          ReturnType<
            typeof validateRepositoryApiV1ForgejoRepositoriesRepositoryIdValidatePost
          >
        >,
        TError,
        { repositoryId: string },
        TContext
      >;
      request?: SecondParameter<typeof customFetch>;
    },
    queryClient?: QueryClient,
  ): UseMutationResult<
    Awaited<
      ReturnType<
        typeof validateRepositoryApiV1ForgejoRepositoriesRepositoryIdValidatePost
      >
    >,
    TError,
    { repositoryId: string },
    TContext
  > => {
    return useMutation(
      getValidateRepositoryApiV1ForgejoRepositoriesRepositoryIdValidatePostMutationOptions(
        options,
      ),
      queryClient,
    );
  };
/**
 * Sync issues from a Forgejo repository.
 * @summary Sync Issues from Repository
 */
export type syncRepositoryIssuesApiV1ForgejoRepositoriesRepositoryIdSyncPostResponse200 =
  {
    data: SyncRepositoryIssuesApiV1ForgejoRepositoriesRepositoryIdSyncPost200;
    status: 200;
  };

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

export type syncRepositoryIssuesApiV1ForgejoRepositoriesRepositoryIdSyncPostResponseSuccess =
  syncRepositoryIssuesApiV1ForgejoRepositoriesRepositoryIdSyncPostResponse200 & {
    headers: Headers;
  };
export type syncRepositoryIssuesApiV1ForgejoRepositoriesRepositoryIdSyncPostResponseError =
  syncRepositoryIssuesApiV1ForgejoRepositoriesRepositoryIdSyncPostResponse422 & {
    headers: Headers;
  };

export type syncRepositoryIssuesApiV1ForgejoRepositoriesRepositoryIdSyncPostResponse =

    | syncRepositoryIssuesApiV1ForgejoRepositoriesRepositoryIdSyncPostResponseSuccess
    | syncRepositoryIssuesApiV1ForgejoRepositoriesRepositoryIdSyncPostResponseError;

export const getSyncRepositoryIssuesApiV1ForgejoRepositoriesRepositoryIdSyncPostUrl =
  (repositoryId: string) => {
    return `/api/v1/forgejo/repositories/${repositoryId}/sync`;
  };

export const syncRepositoryIssuesApiV1ForgejoRepositoriesRepositoryIdSyncPost =
  async (
    repositoryId: string,
    options?: RequestInit,
  ): Promise<syncRepositoryIssuesApiV1ForgejoRepositoriesRepositoryIdSyncPostResponse> => {
    return customFetch<syncRepositoryIssuesApiV1ForgejoRepositoriesRepositoryIdSyncPostResponse>(
      getSyncRepositoryIssuesApiV1ForgejoRepositoriesRepositoryIdSyncPostUrl(
        repositoryId,
      ),
      {
        ...options,
        method: "POST",
      },
    );
  };

export const getSyncRepositoryIssuesApiV1ForgejoRepositoriesRepositoryIdSyncPostMutationOptions =
  <TError = HTTPValidationError, TContext = unknown>(options?: {
    mutation?: UseMutationOptions<
      Awaited<
        ReturnType<
          typeof syncRepositoryIssuesApiV1ForgejoRepositoriesRepositoryIdSyncPost
        >
      >,
      TError,
      { repositoryId: string },
      TContext
    >;
    request?: SecondParameter<typeof customFetch>;
  }): UseMutationOptions<
    Awaited<
      ReturnType<
        typeof syncRepositoryIssuesApiV1ForgejoRepositoriesRepositoryIdSyncPost
      >
    >,
    TError,
    { repositoryId: string },
    TContext
  > => {
    const mutationKey = [
      "syncRepositoryIssuesApiV1ForgejoRepositoriesRepositoryIdSyncPost",
    ];
    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 syncRepositoryIssuesApiV1ForgejoRepositoriesRepositoryIdSyncPost
        >
      >,
      { repositoryId: string }
    > = (props) => {
      const { repositoryId } = props ?? {};

      return syncRepositoryIssuesApiV1ForgejoRepositoriesRepositoryIdSyncPost(
        repositoryId,
        requestOptions,
      );
    };

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

export type SyncRepositoryIssuesApiV1ForgejoRepositoriesRepositoryIdSyncPostMutationResult =
  NonNullable<
    Awaited<
      ReturnType<
        typeof syncRepositoryIssuesApiV1ForgejoRepositoriesRepositoryIdSyncPost
      >
    >
  >;

export type SyncRepositoryIssuesApiV1ForgejoRepositoriesRepositoryIdSyncPostMutationError =
  HTTPValidationError;

/**
 * @summary Sync Issues from Repository
 */
export const useSyncRepositoryIssuesApiV1ForgejoRepositoriesRepositoryIdSyncPost =
  <TError = HTTPValidationError, TContext = unknown>(
    options?: {
      mutation?: UseMutationOptions<
        Awaited<
          ReturnType<
            typeof syncRepositoryIssuesApiV1ForgejoRepositoriesRepositoryIdSyncPost
          >
        >,
        TError,
        { repositoryId: string },
        TContext
      >;
      request?: SecondParameter<typeof customFetch>;
    },
    queryClient?: QueryClient,
  ): UseMutationResult<
    Awaited<
      ReturnType<
        typeof syncRepositoryIssuesApiV1ForgejoRepositoriesRepositoryIdSyncPost
      >
    >,
    TError,
    { repositoryId: string },
    TContext
  > => {
    return useMutation(
      getSyncRepositoryIssuesApiV1ForgejoRepositoriesRepositoryIdSyncPostMutationOptions(
        options,
      ),
      queryClient,
    );
  };
