syntax = "proto3";

package temporal.api.cloud.usage.v1;

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

import "google/protobuf/timestamp.proto";

message Summary {
    // Start of UTC day for now (inclusive)
    google.protobuf.Timestamp start_time = 1;
    // End of UTC day for now (exclusive)
    google.protobuf.Timestamp end_time = 2;
    // Records grouped by namespace
    repeated RecordGroup record_groups = 3;
    // True if data for given time window is not fully available yet (e.g. delays)
    // When true, records for the given time range could still be added/updated in the future (until false) 
    bool incomplete = 4;
}

message RecordGroup {
    // GroupBy keys and their values for this record group. Multiple fields are combined with logical AND.
    repeated GroupBy group_bys = 1;
    repeated Record records = 2;
}

message GroupBy {
    GroupByKey key = 1;
    string value = 2;
}

message Record {
    RecordType type = 1;
    RecordUnit unit = 2;
    double value = 3;
}

enum RecordType {
    RECORD_TYPE_UNSPECIFIED = 0;
    RECORD_TYPE_ACTIONS = 1;
    RECORD_TYPE_ACTIVE_STORAGE = 2;
    RECORD_TYPE_RETAINED_STORAGE = 3;
}

enum RecordUnit {
    RECORD_UNIT_UNSPECIFIED = 0;
    RECORD_UNIT_NUMBER = 1;
    RECORD_UNIT_BYTE_SECONDS = 2;
}

enum GroupByKey {
    GROUP_BY_KEY_UNSPECIFIED = 0;
    GROUP_BY_KEY_NAMESPACE = 1;
}