syntax = "proto3";

package temporal.api.cloud.account.v1;

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

import "temporal/api/cloud/resource/v1/message.proto";
import "temporal/api/cloud/sink/v1/message.proto";
import "google/protobuf/timestamp.proto";

message MetricsSpec {
    // The ca cert(s) in PEM format that clients connecting to the metrics endpoint can use for authentication.
    // This must only be one value, but the CA can have a chain.
    bytes accepted_client_ca = 2;
}

message AccountSpec {
    // The metrics specification for this account.
    // If not specified, metrics will not be enabled.
    MetricsSpec metrics = 1;
}

message Metrics {
    // The prometheus metrics endpoint uri.
    // This is only populated when the metrics is enabled in the metrics specification.
    string uri = 1;
}

message Account {
    // The id of the account.
    string id = 1;
    // The account specification.
    AccountSpec spec = 2;
    // The current version of the account specification.
    // The next update operation will have to include this version.
    string resource_version = 3;
    // The current state of the account.
    temporal.api.cloud.resource.v1.ResourceState state = 4;
    // The id of the async operation that is updating the account, if any.
    string async_operation_id = 5;
    // Information related to metrics.
    Metrics metrics = 6;
}

// AuditLogSinkSpec is only used by Audit Log
message AuditLogSinkSpec {
  // Name of the sink e.g. "audit_log_01"
  string name = 1;

  oneof sink_type {
    // The KinesisSpec when destination_type is Kinesis
    api.cloud.sink.v1.KinesisSpec kinesis_sink = 2;

    // The PubSubSpec when destination_type is PubSub
    api.cloud.sink.v1.PubSubSpec pub_sub_sink = 3;
  }

  // Enabled indicates whether the sink is enabled or not.
  bool enabled = 4;
}

// AuditLogSink is only used by Audit Log
message AuditLogSink {
    // Name of the sink e.g. "audit_log_01"
    string name = 1;

    // The version of the audit log sink resource.
    string resource_version = 2;

    // The current state of the audit log sink.
    temporal.api.cloud.resource.v1.ResourceState state = 3;

    // The specification details of the audit log sink.
    AuditLogSinkSpec spec = 4;

    // The health status of the audit log sink.
    Health health = 5;

    // An error message describing any issues with the audit log sink, if applicable.
    string error_message = 6;

    // The last succeeded timestamp for the internal workflow responsible for adding data to the sink.
    google.protobuf.Timestamp last_succeeded_time = 7;

    // The health status of the audit log sink.
    enum Health {
        HEALTH_UNSPECIFIED = 0;
        // The audit log sink is healthy and functioning correctly.
        HEALTH_OK = 1;
        // The audit log sink has an internal error.
        HEALTH_ERROR_INTERNAL = 2;
        // The audit log sink has a configuration error.
        HEALTH_ERROR_USER_CONFIGURATION = 3;
    }
}
