// Copyright (c) 2020 Temporal Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

syntax = "proto3";

package temporal.server.api.archiver.v1;

option go_package = "go.temporal.io/server/api/archiver/v1;archiver";

import "google/protobuf/timestamp.proto";

import "dependencies/gogoproto/gogo.proto";

import "temporal/api/common/v1/message.proto";
import "temporal/api/history/v1/message.proto";
import "temporal/api/enums/v1/workflow.proto";

message HistoryBlobHeader {
    string namespace = 1;
    string namespace_id = 2;
    string workflow_id = 3;
    string run_id = 4;
    bool is_last = 5;
    int64 first_failover_version = 6;
    int64 last_failover_version = 7;
    int64 first_event_id = 8;
    int64 last_event_id = 9;
    int64 event_count = 10;
}

message HistoryBlob  {
    HistoryBlobHeader header = 1;
    repeated temporal.api.history.v1.History body = 2;
}

// VisibilityRecord is a single workflow visibility record in archive.
message VisibilityRecord {
    string namespace_id = 1;
    string namespace = 2;
    string workflow_id = 3;
    string run_id = 4;
    string workflow_type_name = 5;
    google.protobuf.Timestamp start_time = 6 [(gogoproto.stdtime) = true];
    google.protobuf.Timestamp execution_time = 7 [(gogoproto.stdtime) = true];
    google.protobuf.Timestamp close_time = 8 [(gogoproto.stdtime) = true];
    temporal.api.enums.v1.WorkflowExecutionStatus status = 9;
    int64 history_length = 10;
    temporal.api.common.v1.Memo memo = 11;
    map<string, string> search_attributes = 12;
    string history_archival_uri = 13;
}