syntax = "proto3";

package yandex.cloud.mdb.greenplum.v1;

import "google/protobuf/timestamp.proto";
import "google/type/timeofday.proto";

import "yandex/cloud/validation.proto";

import "yandex/cloud/mdb/greenplum/v1/config.proto";
import "yandex/cloud/mdb/greenplum/v1/maintenance.proto";

option go_package = "github.com/yandex-cloud/go-genproto/yandex/cloud/mdb/greenplum/v1;greenplum";
option java_outer_classname = "GPC";
option java_package = "yandex.cloud.api.mdb.greenplum.v1";


// A Greenplum Cluster resource. For more information, see the
message Cluster {
  // Deployment environment.
  enum Environment {
    ENVIRONMENT_UNSPECIFIED = 0;

    // Stable environment with a conservative update policy:
    // only hotfixes are applied during regular maintenance.
    PRODUCTION = 1;

    // Environment with more aggressive update policy: new versions
    // are rolled out irrespective of backward compatibility.
    PRESTABLE = 2;
  }

  enum Health {

    // State of the cluster is unknown ([Host.health] for every host in the cluster is UNKNOWN).
    HEALTH_UNKNOWN = 0;

    // Cluster is alive and well ([Host.health] for every host in the cluster is ALIVE).
    ALIVE = 1;

    // Cluster is inoperable ([Host.health] for every host in the cluster is DEAD).
    DEAD = 2;

    // Cluster is working below capacity ([Host.health] for at least one host in the cluster is not ALIVE).
    DEGRADED = 3;
  }

  enum Status {

    // Cluster state is unknown.
    STATUS_UNKNOWN = 0;

    // Cluster is being created.
    CREATING = 1;

    // Cluster is running normally.
    RUNNING = 2;

    // Cluster encountered a problem and cannot operate.
    ERROR = 3;

    // Cluster is being updated.
    UPDATING = 4;

    // Cluster is stopping.
    STOPPING = 5;

    // Cluster stopped.
    STOPPED = 6;

    // Cluster is starting.
    STARTING = 7;
  }

  // ID of the Greenplum cluster.
  // This ID is assigned by MDB at creation time.
  string id = 1;

  // ID of the folder that the Greenplum cluster belongs to.
  string folder_id = 2;

  // Creation timestamp in [RFC3339](https://www.ietf.org/rfc/rfc3339.txt) text format.
  google.protobuf.Timestamp created_at = 3;

  // Name of the Greenplum cluster.
  // The name is unique within the folder. 1-63 characters long.
  string name = 4 [(required) = true, (length) = "<=63"];
  
  // Green plum cluster config
  GreenplumConfig config = 5;

  // Description of the Greenplum cluster. 0-256 characters long.
  string description = 6;

  // Custom labels for the Greenplum cluster as `key:value` pairs. Maximum 64 per resource.
  map<string, string> labels = 7;

  // Deployment environment of the Greenplum cluster.
  Environment environment = 8;

  // Description of monitoring systems relevant to the Greenplum cluster.
  repeated Monitoring monitoring = 9;

  // Configuration of the Greenplum master subcluster.
  MasterSubclusterConfig master_config = 10;

  // Configuration of the Greenplum segment subcluster.
  SegmentSubclusterConfig segment_config = 11;

  // Number of hosts of the master subcluster
  int64 master_host_count = 12;

  // Number of hosts of the segment subcluster
  int64 segment_host_count = 13;

  // Number of segments in the host
  int64 segment_in_host = 14;

  // ID of the network that the cluster belongs to.
  string network_id = 15;

  // Aggregated cluster health.
  Health health = 16;

  // Current state of the cluster.
  Status status = 17;

  // Window of maintenance operations.
  MaintenanceWindow maintenance_window = 18;

  // Maintenance operation planned at nearest maintenance_window.
  MaintenanceOperation planned_operation = 19;

  // User security groups
  repeated string security_group_ids = 20;

  // Owner user name
  string user_name = 21;

  // Deletion Protection inhibits deletion of the cluster
  bool deletion_protection = 22;
}

// Monitoring system metadata.
message Monitoring {
  // Name of the monitoring system.
  string name = 1;

  // Description of the monitoring system.
  string description = 2;

  // Link to the monitoring system charts for the Greenplum cluster.
  string link = 3;
}

message GreenplumConfig {
  // Version of the Greenplum server software.
  string version = 1;

  // Time to start the daily backup, in the UTC timezone.
  google.type.TimeOfDay backup_window_start = 2;

  // Access policy for external services.
  Access access = 3;

  // ID of the availability zone where the host resides.
  // To get a list of available zones, use the [yandex.cloud.compute.v1.ZoneService.List] request.
  string zone_id = 4 [(length) = "<=50"];

  // ID of the subnet that the host should belong to. This subnet should be a part
  // of the network that the cluster belongs to.
  // The ID of the network is set in the field [Cluster.network_id].
  string subnet_id = 5 [(length) = "<=50"];

  // Whether the host should get a public IP address on creation.
  //
  // After a host has been created, this setting cannot be changed. To remove an assigned public IP, or to assign
  // a public IP to a host without one, recreate the host with [assign_public_ip] set as needed.
  //
  // Possible values:
  // * false - don't assign a public IP to the master hosts.
  // * true - the master hosts should have a public IP address.
  bool assign_public_ip = 6;
}



message Access {
  // Allow to export data from the cluster to Yandex DataLens.
  bool data_lens = 1;

  // Allow SQL queries to the cluster databases from the Yandex.Cloud management console.
  bool web_sql = 2;
}
