syntax = "proto3";

package temporal.api.operatorservice.v1;

option go_package = "go.temporal.io/api/operatorservice/v1;operatorservice";
option java_package = "io.temporal.api.operatorservice.v1";
option java_multiple_files = true;
option java_outer_classname = "RequestResponseProto";
option ruby_package = "Temporalio::Api::OperatorService::V1";
option csharp_namespace = "Temporalio.Api.OperatorService.V1";

import "temporal/api/enums/v1/common.proto";
import "temporal/api/nexus/v1/message.proto";
import "google/protobuf/duration.proto";

// (-- Search Attribute --)

message AddSearchAttributesRequest {
    // Mapping between search attribute name and its IndexedValueType.
    map<string, temporal.api.enums.v1.IndexedValueType> search_attributes = 1;
    string namespace = 2;
}

message AddSearchAttributesResponse {
}

message RemoveSearchAttributesRequest {
    // Search attribute names to delete.
    repeated string search_attributes = 1;
    string namespace = 2;
}

message RemoveSearchAttributesResponse {
}

message ListSearchAttributesRequest {
    string namespace = 1;
}

message ListSearchAttributesResponse {
    // Mapping between custom (user-registered) search attribute name to its IndexedValueType.
    map<string, temporal.api.enums.v1.IndexedValueType> custom_attributes = 1;
    // Mapping between system (predefined) search attribute name to its IndexedValueType.
    map<string, temporal.api.enums.v1.IndexedValueType> system_attributes = 2;
    // Mapping from the attribute name to the visibility storage native type.
    map<string, string> storage_schema = 3;
}

message DeleteNamespaceRequest {
    // Only one of namespace or namespace_id must be specified to identify namespace.
    string namespace = 1;
    string namespace_id = 2;
    // If provided, the deletion of namespace info will be delayed for the given duration (0 means no delay).
    // If not provided, the default delay configured in the cluster will be used.
    google.protobuf.Duration namespace_delete_delay = 3;
}

message DeleteNamespaceResponse {
    // Temporary namespace name that is used during reclaim resources step.
    string deleted_namespace = 1;
}

message AddOrUpdateRemoteClusterRequest {
    // Frontend Address is a cross cluster accessible address for gRPC traffic. This field is required.
    string frontend_address = 1;
    // Flag to enable / disable the cross cluster connection.
    bool enable_remote_cluster_connection = 2;
    // Frontend HTTP Address is a cross cluster accessible address for HTTP traffic. This field is optional. If not provided
    //  on update, the existing HTTP address will be removed.
    string frontend_http_address = 3;
    // Controls whether replication streams are active.
    bool enable_replication = 4;
}

message AddOrUpdateRemoteClusterResponse {
}

message RemoveRemoteClusterRequest {
    // Remote cluster name to be removed.
    string cluster_name = 1;
}

message RemoveRemoteClusterResponse {
}

message ListClustersRequest {
    int32 page_size = 1;
    bytes next_page_token = 2;
}

message ListClustersResponse {
    // List of all cluster information
    repeated ClusterMetadata clusters = 1;
    bytes next_page_token = 4;
}

message ClusterMetadata {
    // Name of the cluster name.
    string cluster_name = 1;
    // Id of the cluster.
    string cluster_id = 2;
    // gRPC address.
    string address = 3;
    // HTTP address, if one exists.
    string http_address = 7;
    // A unique failover version across all connected clusters.
    int64 initial_failover_version = 4;
    // History service shard number.
    int32 history_shard_count = 5;
    // A flag to indicate if a connection is active.
    bool is_connection_enabled = 6;
    // A flag to indicate if replication is enabled.
    bool is_replication_enabled = 8;
}

message GetNexusEndpointRequest {
    // Server-generated unique endpoint ID.
    string id = 1;
}

message GetNexusEndpointResponse {
    temporal.api.nexus.v1.Endpoint endpoint = 1;
}

message CreateNexusEndpointRequest {
    // Endpoint definition to create.
    temporal.api.nexus.v1.EndpointSpec spec = 1;
}

message CreateNexusEndpointResponse {
    // Data post acceptance. Can be used to issue additional updates to this record.
    temporal.api.nexus.v1.Endpoint endpoint = 1;
}

message UpdateNexusEndpointRequest {
    // Server-generated unique endpoint ID.
    string id = 1;
    // Data version for this endpoint. Must match current version.
    int64 version = 2;

    temporal.api.nexus.v1.EndpointSpec spec = 3;
}

message UpdateNexusEndpointResponse {
    // Data post acceptance. Can be used to issue additional updates to this record.
    temporal.api.nexus.v1.Endpoint endpoint = 1;
}

message DeleteNexusEndpointRequest {
    // Server-generated unique endpoint ID.
    string id = 1;
    // Data version for this endpoint. Must match current version.
    int64 version = 2;
}

message DeleteNexusEndpointResponse {
}

message ListNexusEndpointsRequest {
    int32 page_size = 1;
    // To get the next page, pass in `ListNexusEndpointsResponse.next_page_token` from the previous page's
    // response, the token will be empty if there's no other page.
    // Note: the last page may be empty if the total number of endpoints registered is a multiple of the page size.
    bytes next_page_token = 2;
    // Name of the incoming endpoint to filter on - optional. Specifying this will result in zero or one results.
    // (-- api-linter: core::203::field-behavior-required=disabled
    //     aip.dev/not-precedent: Not following linter rules. --)
    string name = 3;
}

message ListNexusEndpointsResponse {
    // Token for getting the next page.
    bytes next_page_token = 1;
    repeated temporal.api.nexus.v1.Endpoint endpoints = 2;
}
