syntax = "proto3";

package temporal.api.update.v1;

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

import "temporal/api/common/v1/message.proto";
import "temporal/api/enums/v1/update.proto";
import "temporal/api/failure/v1/message.proto";

// Specifies client's intent to wait for Update results.
message WaitPolicy {
    // Indicates the Update lifecycle stage that the Update must reach before
    // API call is returned.
    // NOTE: This field works together with API call timeout which is limited by
    // server timeout (maximum wait time). If server timeout is expired before
    // user specified timeout, API call returns even if specified stage is not reached.
    temporal.api.enums.v1.UpdateWorkflowExecutionLifecycleStage lifecycle_stage = 1;
}

// The data needed by a client to refer to a previously invoked Workflow Update.
message UpdateRef {
    temporal.api.common.v1.WorkflowExecution workflow_execution = 1;
    string update_id = 2;
}

// The outcome of a Workflow Update: success or failure.
message Outcome {
    oneof value {
        temporal.api.common.v1.Payloads success = 1;
        temporal.api.failure.v1.Failure failure = 2;
    }
}

// Metadata about a Workflow Update.
message Meta {
    // An ID with workflow-scoped uniqueness for this Update.
    string update_id = 1;

    // A string identifying the agent that requested this Update.
    string identity = 2;
}

message Input {
    // Headers that are passed with the Update from the requesting entity.
    // These can include things like auth or tracing tokens.
    temporal.api.common.v1.Header header = 1;

    // The name of the Update handler to invoke on the target Workflow.
    string name = 2;

    // The arguments to pass to the named Update handler.
    temporal.api.common.v1.Payloads args = 3;
}

// The client request that triggers a Workflow Update.
message Request {
    Meta meta = 1;
    Input input = 2;
}

// An Update protocol message indicating that a Workflow Update has been rejected.
message Rejection {
    string rejected_request_message_id = 1;
    int64 rejected_request_sequencing_event_id = 2;
    Request rejected_request = 3;
    temporal.api.failure.v1.Failure failure = 4;
}

// An Update protocol message indicating that a Workflow Update has
// been accepted (i.e. passed the worker-side validation phase).
message Acceptance {
    string accepted_request_message_id = 1;
    int64 accepted_request_sequencing_event_id = 2;
    Request accepted_request = 3;
}

// An Update protocol message indicating that a Workflow Update has
// completed with the contained outcome.
message Response {
    Meta meta = 1;
    Outcome outcome = 2;
}
