// M-Files Server gRPC API 26.11. Generated from the M-Files Server IDL; do not edit.
// Documentation: https://developer.m-files.com/APIs/gRPC-API/
syntax = "proto3";

package MFiles;

import "mfiles/api/annotations.proto";
import "mfiles/enums.proto";
import "mfiles/structs.proto";

option csharp_namespace = "MFiles.Grpc";
option go_package = "github.com/M-Files/mfiles-grpc-api/go/mfiles;mfiles";
option java_multiple_files = true;
option java_package = "com.mfiles.grpc";
option objc_class_prefix = "MF_";

// More methods for search indexers, continuing
// [IRPCIndexingDataSource](mfiles:MFiles.IRPCIndexingDataSource).
//
// **For M-Files components only.** M-Files' cloud search indexing services use these methods
// together with the combined enumerator of IRPCIndexingDataSource
// ([GetNextObjectsForIX](mfiles:MFiles.IRPCIndexingDataSource.GetNextObjectsForIX)). Applications
// should not call them; to search, use [IRPCSearch](mfiles:MFiles.IRPCSearch).
//
// - **Rights:** a vault session with the vault rights `see_all_objects` and `see_deleted_objects`; no
//   server role is needed. A normal user is denied. The data is returned
//   regardless of the caller's object permissions; the objects' own permissions are included for
//   the index.
// - **Tasks:** value list items for the index
//   ([GetValueListItemsForIX](mfiles:MFiles.IRPCIndexingDataSource2.GetValueListItemsForIX)), one
//   object by ID ([GetObjectForIXById](mfiles:MFiles.IRPCIndexingDataSource2.GetObjectForIXById)),
//   the extracted text of a file
//   ([GetTextContentForFileForIX](mfiles:MFiles.IRPCIndexingDataSource2.GetTextContentForFileForIX)),
//   the index configuration
//   ([GetIndexConfigurationsForIX](mfiles:MFiles.IRPCIndexingDataSource2.GetIndexConfigurationsForIX)),
//   and the current crawl position
//   ([GetCurrentTimestampForIX](mfiles:MFiles.IRPCIndexingDataSource2.GetCurrentTimestampForIX)).
// - Only for vaults that the server hosts itself; external (unmanaged) objects and files are not
//   supported and fail with "Not implemented." (0x80004001).
service IRPCIndexingDataSource2 {
	option (mfiles.api.service) = { book: "integration" level: LEVEL_SPECIALIZED title: "Indexing data source (version 2)" };

	// Gets the items of one value list for a search index: all items page by page, or the changes since
	// a known version.
	//
	// Unlike [GetValueListItemsWithPermissions](mfiles:MFiles.IRPCValueLists.GetValueListItemsWithPermissions),
	// it does not refresh items from an external database, does not replace "(current user)"
	// placeholders with the caller's identity, can return each item's permissions as stored, and pages
	// through long lists with `after_item_id`.
	//
	// **For M-Files components only.** M-Files' cloud search indexing services call it. Applications
	// should use [GetValueListItemsWithPermissions](mfiles:MFiles.IRPCValueLists.GetValueListItemsWithPermissions).
	// - Requires a vault session with the vault rights `see_all_objects` and `see_deleted_objects`.
	// - Read-only. With `results_limit` 0 the server applied a limit of 5000.
	// - Paging: pass `after_item_id` -1 on the first call, then the highest item ID of the previous
	//   page, until `has_more_results` is false.
	rpc GetValueListItemsForIX( GetValueListItemsForIXRequest ) returns ( GetValueListItemsForIXResponse ) {
		option idempotency_level = IDEMPOTENT;
		option (mfiles.api.method) = { session: SESSION_REQUIREMENT_SESSION internal: true };
	}

	// Gets the index data of one object by its ID: the same data that
	// [GetNextObjectsForIX](mfiles:MFiles.IRPCIndexingDataSource.GetNextObjectsForIX) returns for the
	// latest checked-in version and, if requested, the checked-out version.
	//
	// The checked-out version is returned whoever has checked it out, and the index metadata (relevance
	// score, last-modified time for indexing) is computed as in the enumerator.
	//
	// **For M-Files components only.** M-Files' cloud search indexing services call it to index an
	// object that a crawl has not delivered. Applications should not call it.
	// - Requires a vault session with the vault rights `see_all_objects` and `see_deleted_objects`.
	// - Read-only. An object that does not exist, is destroyed or has nothing to index fails with "Not
	//   found.". External (unmanaged) objects fail with "Not implemented.".
	// - Both response fields are unset only for an object that has never been checked in, read with
	//   `include_checked_out` false.
	rpc GetObjectForIXById( GetObjectForIXByIdRequest ) returns ( GetObjectForIXByIdResponse ) {
		option idempotency_level = IDEMPOTENT;
		option (mfiles.api.method) = { session: SESSION_REQUIREMENT_SESSION internal: true };
	}

	// Gets the text that the server extracts from a file version for indexing, in the response.
	//
	// The text is the same that the search index receives: it is produced with the vault's full-text
	// extraction settings even when viewer files are disabled for users, and it is cached on the server
	// for later use.
	//
	// **For M-Files components only.** M-Files' cloud search indexing services call it. Applications
	// should not call it.
	// - Requires a vault session with the vault rights `see_all_objects` and `see_deleted_objects`.
	// - May create and cache the text extract of the file on the server.
	// - A file with no extractable text returns an empty `text_content`. A file whose extraction failed
	//   returns `text_unavailable` true. External (unmanaged) files fail with "Not implemented.".
	rpc GetTextContentForFileForIX( GetTextContentForFileForIXRequest ) returns ( GetTextContentForFileForIXResponse ) {
		option idempotency_level = IDEMPOTENT;
		option (mfiles.api.method) = { session: SESSION_REQUIREMENT_SESSION internal: true };
	}

	// Gets the vault's search index configuration as JSON, without secrets, plus the vault settings
	// that an index built from it must agree on.
	//
	// The result contains only the indexes of the engines that the cloud search indexing services
	// serve (Smart Search and Aino Search), only an allowed set of their settings, and no setting that
	// the vault settings mark as a password.
	//
	// **For M-Files components only.** M-Files' cloud search indexing services call it. Applications
	// should not call it.
	// - Requires a vault session with the vault rights `see_all_objects` and `see_deleted_objects`.
	//   Read-only.
	rpc GetIndexConfigurationsForIX( GetIndexConfigurationsForIXRequest ) returns ( GetIndexConfigurationsForIXResponse ) {
		option idempotency_level = IDEMPOTENT;
		option (mfiles.api.method) = { session: SESSION_REQUIREMENT_SESSION internal: true };
	}

	// Gets the vault's current crawl position for the combined enumerator: a crawl that starts there
	// sees every change committed after the call and none committed before it.
	//
	// **For M-Files components only.** M-Files' cloud search indexing services call it to start a crawl
	// from "now" instead of from the beginning of the vault's history. Applications should not call
	// it.
	// - Requires a vault session with the vault rights `see_all_objects` and `see_deleted_objects`; a
	//   normal user is denied. Read-only.
	// - Not available on all servers: it fails with "Not implemented." where the server does not offer
	//   it. An older server answers with gRPC status `UNIMPLEMENTED`.
	rpc GetCurrentTimestampForIX( GetCurrentTimestampForIXRequest ) returns ( GetCurrentTimestampForIXResponse ) {
		option idempotency_level = IDEMPOTENT;
		option (mfiles.api.method) = { session: SESSION_REQUIREMENT_SESSION internal: true };
	}
}

// The request of GetValueListItemsForIX.
message GetValueListItemsForIXRequest {

	// The ID of the value list to fetch.
	int32 value_list = 1;

	// The version of the list that the caller has. 0 returns the full list (first page).
	int64 known_version = 2;

	// True if the caller can process a delta response.
	bool allow_delta = 3;

	// True to return `item_acls` and `item_acls_for_indexing`.
	bool include_permissions = 4;

	// True to include deleted items, so that the index can mark them deleted.
	bool include_deleted_items = 5;

	// Paging cursor of the full list: -1 on the first call, then the highest item ID of the previous page.
	int32 after_item_id = 6;

	// The maximum number of items. 0 means the server default.
	uint32 results_limit = 7;
}

// The response of GetValueListItemsForIX.
message GetValueListItemsForIXResponse {

	// The current version of the list. If it equals `known_version`, no items are returned.
	int64 current_version = 1;

	// True if the response is a delta. False if it is a full-list page (or the unchanged-since-caller no-op case).
	bool is_delta = 2;

	// True if more items follow; call again with `after_item_id`.
	bool has_more_results = 3;

	// The actual results limit the server applied.
	uint32 results_limit = 4;

	// Removed item IDs (delta mode only). Empty otherwise.
	repeated int32 removed_items = 5;

	// The changed items (delta) or one page of the full list. Deleted items have the deleted flag set.
	repeated ValueListItem items = 6;

	// The permissions of each item as stored, in the order of `items`. Empty if `include_permissions` was false.
	repeated AccessControlList item_acls = 7;

	// The read permissions of each item, resolved for the index, in the order of `items`. Empty if `include_permissions` was false or the server does not supply them.
	repeated SimpleACL item_acls_for_indexing = 8;
}

// The request of GetObjectForIXById.
message GetObjectForIXByIdRequest {

	// The object, by its internal ID.
	ObjID obj_id = 1;

	// True to also return the checked-out version when the object is checked out.
	bool include_checked_out = 2;
}

// The response of GetObjectForIXById: the index data of the latest checked-in version, of the
// checked-out version, or of both. An object that does not exist fails the call with "Not found."
// instead.
message GetObjectForIXByIdResponse {

	// The index data of the latest checked-in version. Unset if the object has no checked-in version.
	ObjectDataForIX latest_checked_in = 1;

	// The index data of the checked-out version. Unset unless `include_checked_out` is true and the object is checked out.
	ObjectDataForIX checked_out = 2;
}

// The request of GetTextContentForFileForIX.
message GetTextContentForFileForIXRequest {

	// The object and file version.
	ObjFileVer obj_file_ver = 1;

	// `FILE_FORMAT_PLAIN_TEXT` or `FILE_FORMAT_MARKDOWN`; unset (`FILE_FORMAT_NATIVE`) means plain text. A Markdown request falls back to plain text when the server cannot produce Markdown.
	FileFormat file_format = 2;
}

// The response of GetTextContentForFileForIX: the extracted text in the response body and the
// format actually produced.
message GetTextContentForFileForIXResponse {

	// The extracted text (UTF-8). Empty when the file has no extractable text.
	string text_content = 1;

	// The format actually produced.
	FileFormat file_format = 2;

	// True when no text could be produced for a non-empty file; `text_content` is then empty and says nothing about the file.
	bool text_unavailable = 3;
}

// The request of GetIndexConfigurationsForIX.
message GetIndexConfigurationsForIXRequest {
}

// The response of GetIndexConfigurationsForIX: the vault's search index configuration without
// secrets, plus the vault settings that an index built from it must agree on.
message GetIndexConfigurationsForIXResponse {

	// A JSON object with `Indices` (the stored index settings) and the added members `FacetSources` (the vault's facet definitions), `SearchLanguages` (the full-text search languages as ISO codes, primary first) and `VaultTimeZone` (the vault's time zone, in the fields of the Windows time zone information structure). Members that are empty or cannot be resolved are left out. Example: `{"Indices":[],"SearchLanguages":["en"],"VaultTimeZone":{"bias":-120,...}}`.
	string index_configurations_json = 1;
}

// The request of GetCurrentTimestampForIX.
message GetCurrentTimestampForIXRequest {
}

// Response for GetCurrentTimestampForIX. Carries the vault's current indexing head: the position from
// which a ForIX crawl sees no change committed before the call and every change committed after it.
message GetCurrentTimestampForIXResponse {

	// The position as an integer timestamp, for starting a crawl with [GetNextObjectsForIX](mfiles:MFiles.IRPCIndexingDataSource.GetNextObjectsForIX) and [HasMoreObjectsForIX](mfiles:MFiles.IRPCIndexingDataSource.HasMoreObjectsForIX). Each value is capped so that it never passes a change that is still being committed.
	LogicalTimestamp current_version_for_ix = 1;

	// The current Change Tracking version, read before the position, in the form that [GetSmallestTimestampForMetadataIX](mfiles:MFiles.IRPCIndexingDataSource.GetSmallestTimestampForMetadataIX) reports it; 1 when the vault does not use Change Tracking.
	LogicalTimestamp current_change_tracking_version = 2;
}
