// 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_";

// Workspace tabs: the views of related objects shown for an object of a given type.
//
// Supports workspaces: the tabs that a client shows for an object of a given object type, each tab
// being a view of related objects (for example the projects and contacts of a customer). Used by
// M-Files clients that show workspaces; applications rarely call it.
//
// How the parts fit together:
//
// - A workspace tab is a view that lists objects of a target object type related to the object of
//   the source object type. The server keeps, per source and target object type pair, one hidden
//   filter-only view under which the tab views live.
// - [CreateTemporaryWorkspaceView](mfiles:MFiles.IRPCWorkspace.CreateTemporaryWorkspaceView)
//   returns ready-made definitions of a new tab view and of its reverse-direction view. Save the
//   one you want with [AddNewView](mfiles:MFiles.IRPCViews.AddNewView).
// - [GetWorkspaceSettings](mfiles:MFiles.IRPCWorkspace.GetWorkspaceSettings) and
//   [SetWorkspaceSettings](mfiles:MFiles.IRPCWorkspace.SetWorkspaceSettings) read and store the
//   order of the tabs, per user and as a default for all users.
//
// All three methods fail with "Not implemented." on servers where workspaces are not enabled.
service IRPCWorkspace {
	option (mfiles.api.service) = { book: "vault" level: LEVEL_STANDARD title: "Workspaces" };

	// Builds the definitions of a new workspace tab view and its reverse view for a pair of object
	// types, without saving the views.
	//
	// - Requires a vault session. No special vault rights are needed.
	// - Both IDs must be real object types; a value list fails with "The parameter is incorrect.".
	// - The returned views are not saved and have no name. They are located under the pair's
	//   filter-only view and give read access to all users. Set the name and any other fields, then
	//   save a view with [AddNewView](mfiles:MFiles.IRPCViews.AddNewView).
	// - Side effect: the first call for a pair of object types creates and saves the pair's hidden
	//   filter-only view, which later calls reuse.
	rpc CreateTemporaryWorkspaceView( CreateTemporaryWorkspaceViewRequest ) returns ( CreateTemporaryWorkspaceViewResponse ) {
		option (mfiles.api.method) = { session: SESSION_REQUIREMENT_SESSION_OR_ASSERTION returns_metadata_structure_version: true };
	}

	// Gets the tab order of the workspace of an object type: the caller's effective order, or the
	// default for all users.
	//
	// - Requires a vault session. No special vault rights are needed.
	// - `WORKSPACE_SETTINGS_SCOPE_EFFECTIVE` (default) returns the caller's own order, or the default
	//   order when the caller has none. `WORKSPACE_SETTINGS_SCOPE_DEFAULTS` returns the default order,
	//   limited to common views.
	// - The stored order is reconciled with the tab views that exist and that the caller can see:
	//   views that no longer exist are dropped and new views are appended. When nothing is stored,
	//   `view_ids` lists all visible tab views.
	// - An object type without workspace views, or an unknown ID, returns empty `view_ids`.
	rpc GetWorkspaceSettings( GetWorkspaceSettingsRequest ) returns ( GetWorkspaceSettingsResponse ) {
		option (mfiles.api.method) = { session: SESSION_REQUIREMENT_SESSION_OR_ASSERTION returns_metadata_structure_version: true };
	}

	// Stores the tab order of the workspace of an object type for the caller or as the default for
	// all users, or resets the caller's order.
	//
	// - Requires a vault session. The actions `WORKSPACE_SETTINGS_ACTION_SET_AS_DEFAULT_TO_ALL_USERS`
	//   and `WORKSPACE_SETTINGS_ACTION_SET_AS_DEFAULT_TO_ALL_USERS_OVERRIDE` also need the vault right
	//   `manage_common_views`.
	// - `workspace_settings.view_ids` must not be empty except with
	//   `WORKSPACE_SETTINGS_ACTION_RESET_TO_DEFAULT`, and every ID must be a tab view of this
	//   workspace; otherwise the call fails with "The parameter is incorrect.". A default order may
	//   contain only common views.
	// - `WORKSPACE_SETTINGS_ACTION_RESET_TO_DEFAULT` deletes the caller's own order.
	//   `WORKSPACE_SETTINGS_ACTION_SET_AS_DEFAULT_TO_ALL_USERS_OVERRIDE` stores the default and deletes
	//   every user's own order for this object type.
	rpc SetWorkspaceSettings( SetWorkspaceSettingsRequest ) returns ( SetWorkspaceSettingsResponse ) {
		option (mfiles.api.method) = { session: SESSION_REQUIREMENT_SESSION_OR_ASSERTION returns_metadata_structure_version: true };
	}
}

// The request of CreateTemporaryWorkspaceView.
message CreateTemporaryWorkspaceViewRequest {

	// The object type of the object whose workspace shows the tab.
	int32 source_object_type_id = 1;

	// The object type of the related objects that the tab lists.
	int32 target_object_type_id = 2;
}

// The response of CreateTemporaryWorkspaceView.
message CreateTemporaryWorkspaceViewResponse {

	// The tab view, not yet saved.
	View view = 1;

	// The view in the reverse direction, not yet saved.
	View reverse = 2;
}

// The request of GetWorkspaceSettings.
message GetWorkspaceSettingsRequest {

	// The source object type of the workspace.
	int32 object_type_id = 1;

	// Which order to return. Leave unset (`WORKSPACE_SETTINGS_SCOPE_EFFECTIVE`) for the caller's own effective order.
	WorkspaceSettingsScope scope = 2;
}

// The response of GetWorkspaceSettings.
message GetWorkspaceSettingsResponse {

	// The tab view IDs in display order.
	WorkspaceSettings workspace_settings = 1;
}

// The request of SetWorkspaceSettings.
message SetWorkspaceSettingsRequest {

	// The source object type of the workspace.
	int32 object_type_id = 1;

	// What to do. Leave unset (`WORKSPACE_SETTINGS_ACTION_APPLY_PERSONAL_SETTINGS`) to store the caller's own order.
	WorkspaceSettingsAction workspace_settings_action = 2;

	// The tab view IDs in display order. Ignored when resetting.
	WorkspaceSettings workspace_settings = 3;
}

// The response of SetWorkspaceSettings.
message SetWorkspaceSettingsResponse {
}
