syntax = "proto3";

package temporal.api.namespace.v1;

option go_package = "go.temporal.io/api/namespace/v1;namespace";
option java_package = "io.temporal.api.namespace.v1";
option java_multiple_files = true;
option java_outer_classname = "MessageProto";
option ruby_package = "Temporalio::Api::Namespace::V1";
option csharp_namespace = "Temporalio.Api.Namespace.V1";

import "google/protobuf/duration.proto";
import "google/protobuf/timestamp.proto";

import "temporal/api/enums/v1/namespace.proto";


message NamespaceInfo {
    string name = 1;
    temporal.api.enums.v1.NamespaceState state = 2;
    string description = 3;
    string owner_email = 4;
    // A key-value map for any customized purpose.
    map<string, string> data = 5;
    string id = 6;
    // All capabilities the namespace supports.
    Capabilities capabilities = 7;

    // Namespace capability details. Should contain what features are enabled in a namespace.
    message Capabilities {
        // True if the namespace supports eager workflow start.
        bool eager_workflow_start = 1;
        // True if the namespace supports sync update
        bool sync_update = 2;
        // True if the namespace supports async update
        bool async_update = 3;
        // True if the namespace supports worker heartbeats
        bool worker_heartbeats = 4;
        // True if the namespace supports reported problems search attribute
        bool reported_problems_search_attribute = 5;
        // True if the namespace supports pausing workflows
        bool workflow_pause = 6;
        // True if the namespace supports standalone activities
        bool standalone_activities = 7;
        // True if the namespace supports server-side completion of outstanding worker polls on shutdown.
        // When enabled, the server will complete polls for workers that send WorkerInstanceKey in their
        // poll requests and call ShutdownWorker with the same WorkerInstanceKey. The poll will return
        // an empty response. When this flag is true, workers should allow polls to return gracefully
        // rather than terminating any open polls on shutdown.
        bool worker_poll_complete_on_shutdown = 8;
        // True if the namespace supports poller autoscaling
        bool poller_autoscaling = 9;
    }

    // Namespace configured limits
    Limits limits = 8;
    message Limits {
        // Maximum size in bytes for payload fields in workflow history events
        // (e.g., workflow/activity inputs and results, failure details, signal payloads).
        // When exceeded, the server will reject the operation with an error.
        int64 blob_size_limit_error = 1;
        // Maximum total memo size in bytes per workflow execution.
        int64 memo_size_limit_error = 2;
    }

    // Whether scheduled workflows are supported on this namespace. This is only needed
    // temporarily while the feature is experimental, so we can give it a high tag.
    bool supports_schedules = 100;
}

message NamespaceConfig {
    google.protobuf.Duration workflow_execution_retention_ttl = 1;
    BadBinaries bad_binaries = 2;
    // If unspecified (ARCHIVAL_STATE_UNSPECIFIED) then default server configuration is used.
    temporal.api.enums.v1.ArchivalState history_archival_state = 3;
    string history_archival_uri = 4;
    // If unspecified (ARCHIVAL_STATE_UNSPECIFIED) then default server configuration is used.
    temporal.api.enums.v1.ArchivalState visibility_archival_state = 5;
    string visibility_archival_uri = 6;
    // Map from field name to alias.
    map<string, string> custom_search_attribute_aliases = 7;
}

message BadBinaries {
    map<string, BadBinaryInfo> binaries = 1;
}

message BadBinaryInfo {
    string reason = 1;
    string operator = 2;
    google.protobuf.Timestamp create_time = 3;
}

message UpdateNamespaceInfo {
    string description = 1;
    string owner_email = 2;
    // A key-value map for any customized purpose.
    // If data already exists on the namespace,
    // this will merge with the existing key values.
    map<string, string> data = 3;
    // New namespace state, server will reject if transition is not allowed.
    // Allowed transitions are:
    //  Registered -> [ Deleted | Deprecated | Handover ]
    //  Handover -> [ Registered ]
    // Default is NAMESPACE_STATE_UNSPECIFIED which is do not change state.
    temporal.api.enums.v1.NamespaceState state = 4;
}

message NamespaceFilter {
    // By default namespaces in NAMESPACE_STATE_DELETED state are not included.
    // Setting include_deleted to true will include deleted namespaces.
    // Note: Namespace is in NAMESPACE_STATE_DELETED state when it was deleted from the system but associated data is not deleted yet.
    bool include_deleted = 1;
}
