/* generated using openapi-typescript-codegen -- do not edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
import type { ApiResponse_String } from '../models/ApiResponse_String';
import type { ApiResponse_Vec_WikiPage } from '../models/ApiResponse_Vec_WikiPage';
import type { ApiResponse_Vec_WikiPageRevision } from '../models/ApiResponse_Vec_WikiPageRevision';
import type { ApiResponse_WikiCompareResult } from '../models/ApiResponse_WikiCompareResult';
import type { ApiResponse_WikiPage } from '../models/ApiResponse_WikiPage';
import type { ApiResponse_WikiPageRevision } from '../models/ApiResponse_WikiPageRevision';
import type { CreateWikiPageParams } from '../models/CreateWikiPageParams';
import type { UpdateWikiPageParams } from '../models/UpdateWikiPageParams';
import type { CancelablePromise } from '../core/CancelablePromise';
import { OpenAPI } from '../core/OpenAPI';
import { request as __request } from '../core/request';
export class WikiService {
	/**
	 * List wiki pages in a repository
	 * Returns a paginated list of all wiki pages in the repository.
	 * Supports searching by title or content.
	 * Requires read access to the repository.
	 * @returns ApiResponse_Vec_WikiPage Wiki pages listed successfully.
	 * @throws ApiError
	 */
	public static wikiListPages({
		workspaceName,
		repoName,
		search,
		limit,
		offset,
	}: {
		/**
		 * Workspace name (unique identifier)
		 */
		workspaceName: string,
		/**
		 * Repository name (unique within the workspace)
		 */
		repoName: string,
		/**
		 * Search query to filter pages by title or content
		 */
		search?: string | null,
		/**
		 * Maximum number of pages to return (default: 50, max: 100)
		 */
		limit?: number | null,
		/**
		 * Number of pages to skip for pagination (default: 0)
		 */
		offset?: number | null,
	}): CancelablePromise<ApiResponse_Vec_WikiPage> {
		return __request(OpenAPI, {
			method: 'GET',
			url: '/api/v1/workspaces/{workspace_name}/repos/{repo_name}/wiki',
			path: {
				'workspace_name': workspaceName,
				'repo_name': repoName,
			},
			query: {
				'search': search,
				'limit': limit,
				'offset': offset,
			},
			errors: {
				401: `Authentication required or session expired`,
				403: `Insufficient permissions to access this repository`,
				404: `Repository or workspace not found`,
				500: `Internal server error`,
			},
		});
	}
	/**
	 * Create a wiki page
	 * Creates a new wiki page in the repository.
	 * Requires at least Member role in the repository.
	 *
	 * The title is automatically converted to a URL-friendly slug.
	 * An initial revision is created with the page.
	 *
	 * Returns the created wiki page with full metadata.
	 * @returns ApiResponse_WikiPage Wiki page created successfully.
	 * @throws ApiError
	 */
	public static wikiCreatePage({
		workspaceName,
		repoName,
		requestBody,
	}: {
		/**
		 * Workspace name (unique identifier)
		 */
		workspaceName: string,
		/**
		 * Repository name (unique within the workspace)
		 */
		repoName: string,
		/**
		 * Wiki page creation parameters
		 */
		requestBody: CreateWikiPageParams,
	}): CancelablePromise<ApiResponse_WikiPage> {
		return __request(OpenAPI, {
			method: 'POST',
			url: '/api/v1/workspaces/{workspace_name}/repos/{repo_name}/wiki',
			path: {
				'workspace_name': workspaceName,
				'repo_name': repoName,
			},
			body: requestBody,
			mediaType: 'application/json',
			errors: {
				400: `Invalid parameters: empty title or content`,
				401: `Authentication required or session expired`,
				403: `Insufficient permissions (requires Member role or higher)`,
				404: `Repository or workspace not found`,
				500: `Internal server error`,
			},
		});
	}
	/**
	 * Get a wiki page
	 * Retrieves a single wiki page by its slug.
	 * Requires read access to the repository.
	 * @returns ApiResponse_WikiPage Wiki page retrieved successfully.
	 * @throws ApiError
	 */
	public static wikiGetPage({
		workspaceName,
		repoName,
		slug,
	}: {
		/**
		 * Workspace name (unique identifier)
		 */
		workspaceName: string,
		/**
		 * Repository name (unique within the workspace)
		 */
		repoName: string,
		/**
		 * Wiki page slug (URL-friendly identifier)
		 */
		slug: string,
	}): CancelablePromise<ApiResponse_WikiPage> {
		return __request(OpenAPI, {
			method: 'GET',
			url: '/api/v1/workspaces/{workspace_name}/repos/{repo_name}/wiki/{slug}',
			path: {
				'workspace_name': workspaceName,
				'repo_name': repoName,
				'slug': slug,
			},
			errors: {
				401: `Authentication required or session expired`,
				403: `Insufficient permissions to access this repository`,
				404: `Wiki page, repository, or workspace not found`,
				500: `Internal server error`,
			},
		});
	}
	/**
	 * Update a wiki page
	 * Updates an existing wiki page's title, content, or both.
	 * Requires at least Member role in the repository.
	 *
	 * A new revision is automatically created with the changes.
	 * Optionally include a commit message to describe the changes.
	 *
	 * All fields are optional; only provided fields are updated.
	 * Returns the updated wiki page.
	 * @returns ApiResponse_WikiPage Wiki page updated successfully.
	 * @throws ApiError
	 */
	public static wikiUpdatePage({
		workspaceName,
		repoName,
		slug,
		requestBody,
	}: {
		/**
		 * Workspace name (unique identifier)
		 */
		workspaceName: string,
		/**
		 * Repository name (unique within the workspace)
		 */
		repoName: string,
		/**
		 * Wiki page slug (URL-friendly identifier)
		 */
		slug: string,
		/**
		 * Wiki page update parameters (all fields optional)
		 */
		requestBody: UpdateWikiPageParams,
	}): CancelablePromise<ApiResponse_WikiPage> {
		return __request(OpenAPI, {
			method: 'PUT',
			url: '/api/v1/workspaces/{workspace_name}/repos/{repo_name}/wiki/{slug}',
			path: {
				'workspace_name': workspaceName,
				'repo_name': repoName,
				'slug': slug,
			},
			body: requestBody,
			mediaType: 'application/json',
			errors: {
				400: `Invalid parameters`,
				401: `Authentication required or session expired`,
				403: `Insufficient permissions (requires Member role or higher)`,
				404: `Wiki page, repository, or workspace not found`,
				500: `Internal server error`,
			},
		});
	}
	/**
	 * Delete a wiki page
	 * Soft-deletes a wiki page. The page is marked as deleted but remains in the database.
	 * Requires Admin role in the repository.
	 *
	 * The page and its revision history are preserved but no longer accessible via the API.
	 * Returns success message on completion.
	 * @returns ApiResponse_String Wiki page deleted successfully.
	 * @throws ApiError
	 */
	public static wikiDeletePage({
		workspaceName,
		repoName,
		slug,
	}: {
		/**
		 * Workspace name (unique identifier)
		 */
		workspaceName: string,
		/**
		 * Repository name (unique within the workspace)
		 */
		repoName: string,
		/**
		 * Wiki page slug (URL-friendly identifier)
		 */
		slug: string,
	}): CancelablePromise<ApiResponse_String> {
		return __request(OpenAPI, {
			method: 'DELETE',
			url: '/api/v1/workspaces/{workspace_name}/repos/{repo_name}/wiki/{slug}',
			path: {
				'workspace_name': workspaceName,
				'repo_name': repoName,
				'slug': slug,
			},
			errors: {
				401: `Authentication required or session expired`,
				403: `Insufficient permissions (requires Admin role)`,
				404: `Wiki page, repository, or workspace not found`,
				500: `Internal server error`,
			},
		});
	}
	/**
	 * Compare two wiki page revisions
	 * Compares two versions of a wiki page and returns both revisions.
	 * Requires read access to the repository.
	 *
	 * Returns the old and new revisions for client-side diff computation.
	 * The client can compute the diff between the two content snapshots.
	 * @returns ApiResponse_WikiCompareResult Revisions compared successfully. Returns old and new revision objects.
	 * @throws ApiError
	 */
	public static wikiCompareRevisions({
		workspaceName,
		repoName,
		slug,
		oldVersion,
		newVersion,
	}: {
		/**
		 * Workspace name (unique identifier)
		 */
		workspaceName: string,
		/**
		 * Repository name (unique within the workspace)
		 */
		repoName: string,
		/**
		 * Wiki page slug (URL-friendly identifier)
		 */
		slug: string,
		/**
		 * Older version number to compare from
		 */
		oldVersion: number,
		/**
		 * Newer version number to compare to
		 */
		newVersion: number,
	}): CancelablePromise<ApiResponse_WikiCompareResult> {
		return __request(OpenAPI, {
			method: 'GET',
			url: '/api/v1/workspaces/{workspace_name}/repos/{repo_name}/wiki/{slug}/compare',
			path: {
				'workspace_name': workspaceName,
				'repo_name': repoName,
				'slug': slug,
			},
			query: {
				'old_version': oldVersion,
				'new_version': newVersion,
			},
			errors: {
				400: `Invalid version numbers`,
				401: `Authentication required or session expired`,
				403: `Insufficient permissions to access this repository`,
				404: `Wiki page, revisions, repository, or workspace not found`,
				500: `Internal server error`,
			},
		});
	}
	/**
	 * Revert a wiki page to a historical version
	 * Reverts the wiki page to a specified historical version.
	 * Requires at least Member role in the repository.
	 *
	 * This creates a new revision with the content from the target version.
	 * The current content is not lost; it remains in the revision history.
	 *
	 * Returns the updated wiki page with the reverted content.
	 * @returns ApiResponse_WikiPage Wiki page reverted successfully.
	 * @throws ApiError
	 */
	public static wikiRevertPage({
		workspaceName,
		repoName,
		slug,
		version,
		commitMessage,
	}: {
		/**
		 * Workspace name (unique identifier)
		 */
		workspaceName: string,
		/**
		 * Repository name (unique within the workspace)
		 */
		repoName: string,
		/**
		 * Wiki page slug (URL-friendly identifier)
		 */
		slug: string,
		/**
		 * Target version number to revert to
		 */
		version: number,
		/**
		 * Optional commit message describing the revert
		 */
		commitMessage?: string | null,
	}): CancelablePromise<ApiResponse_WikiPage> {
		return __request(OpenAPI, {
			method: 'POST',
			url: '/api/v1/workspaces/{workspace_name}/repos/{repo_name}/wiki/{slug}/revert',
			path: {
				'workspace_name': workspaceName,
				'repo_name': repoName,
				'slug': slug,
			},
			query: {
				'version': version,
				'commit_message': commitMessage,
			},
			errors: {
				400: `Invalid version number`,
				401: `Authentication required or session expired`,
				403: `Insufficient permissions (requires Member role or higher)`,
				404: `Wiki page, revision, repository, or workspace not found`,
				500: `Internal server error`,
			},
		});
	}
	/**
	 * List wiki page revisions
	 * Returns a paginated list of all revisions for a wiki page, sorted by version (newest first).
	 * Requires read access to the repository.
	 *
	 * Each revision includes the full content snapshot at that version,
	 * the editor who made the change, and an optional commit message.
	 * @returns ApiResponse_Vec_WikiPageRevision Revisions listed successfully.
	 * @throws ApiError
	 */
	public static wikiListRevisions({
		workspaceName,
		repoName,
		slug,
		limit,
		offset,
	}: {
		/**
		 * Workspace name (unique identifier)
		 */
		workspaceName: string,
		/**
		 * Repository name (unique within the workspace)
		 */
		repoName: string,
		/**
		 * Wiki page slug (URL-friendly identifier)
		 */
		slug: string,
		/**
		 * Maximum number of revisions to return (default: 50, max: 100)
		 */
		limit?: number | null,
		/**
		 * Number of revisions to skip for pagination (default: 0)
		 */
		offset?: number | null,
	}): CancelablePromise<ApiResponse_Vec_WikiPageRevision> {
		return __request(OpenAPI, {
			method: 'GET',
			url: '/api/v1/workspaces/{workspace_name}/repos/{repo_name}/wiki/{slug}/revisions',
			path: {
				'workspace_name': workspaceName,
				'repo_name': repoName,
				'slug': slug,
			},
			query: {
				'limit': limit,
				'offset': offset,
			},
			errors: {
				401: `Authentication required or session expired`,
				403: `Insufficient permissions to access this repository`,
				404: `Wiki page, repository, or workspace not found`,
				500: `Internal server error`,
			},
		});
	}
	/**
	 * Get a specific wiki page revision
	 * Retrieves a specific revision of a wiki page by version number.
	 * Requires read access to the repository.
	 *
	 * Returns the full revision with content snapshot, editor, and commit message.
	 * @returns ApiResponse_WikiPageRevision Revision retrieved successfully.
	 * @throws ApiError
	 */
	public static wikiGetRevision({
		workspaceName,
		repoName,
		slug,
		version,
	}: {
		/**
		 * Workspace name (unique identifier)
		 */
		workspaceName: string,
		/**
		 * Repository name (unique within the workspace)
		 */
		repoName: string,
		/**
		 * Wiki page slug (URL-friendly identifier)
		 */
		slug: string,
		/**
		 * Revision version number
		 */
		version: number,
	}): CancelablePromise<ApiResponse_WikiPageRevision> {
		return __request(OpenAPI, {
			method: 'GET',
			url: '/api/v1/workspaces/{workspace_name}/repos/{repo_name}/wiki/{slug}/revisions/{version}',
			path: {
				'workspace_name': workspaceName,
				'repo_name': repoName,
				'slug': slug,
				'version': version,
			},
			errors: {
				401: `Authentication required or session expired`,
				403: `Insufficient permissions to access this repository`,
				404: `Wiki page, revision, repository, or workspace not found`,
				500: `Internal server error`,
			},
		});
	}
}
