syntax = "proto3";

package temporal.api.cloud.operation.v1;

option go_package = "go.temporal.io/api/cloud/operation/v1;operation";
option java_package = "io.temporal.api.cloud.operation.v1";
option java_multiple_files = true;
option java_outer_classname = "MessageProto";
option ruby_package = "Temporalio::Api::Cloud::Operation::V1";
option csharp_namespace = "Temporalio.Api.Cloud.Operation.V1";

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

message AsyncOperation {
    // The operation id.
    string id = 1;
    // The current state of this operation.
    // Possible values are: pending, in_progress, failed, cancelled, fulfilled.
    // Deprecated: Not supported after v0.3.0 api version. Use state instead.
    // temporal:versioning:max_version=v0.3.0
    string state_deprecated = 2 [deprecated = true];
    // The current state of this operation.
    // temporal:versioning:min_version=v0.3.0
    // temporal:enums:replaces=state_deprecated
    State state = 9;
    // The recommended duration to check back for an update in the operation's state.
    google.protobuf.Duration check_duration = 3;
    // The type of operation being performed.
    string operation_type = 4;
    // The input to the operation being performed.
    //
    // (-- api-linter: core::0146::any=disabled --)
    google.protobuf.Any operation_input = 5;
    // If the operation failed, the reason for the failure.
    string failure_reason = 6;
    // The date and time when the operation initiated.
    google.protobuf.Timestamp started_time = 7;
    // The date and time when the operation completed.
    google.protobuf.Timestamp finished_time = 8;

    enum State {
        STATE_UNSPECIFIED = 0;
        STATE_PENDING = 1;     // The operation is pending.
        STATE_IN_PROGRESS = 2; // The operation is in progress.
        STATE_FAILED = 3;      // The operation failed, check failure_reason for more details.
        STATE_CANCELLED = 4;   // The operation was cancelled.
        STATE_FULFILLED = 5;   // The operation was fulfilled.
        STATE_REJECTED = 6;    // The operation was rejected.
    }
}
