syntax = "proto3";

package yandex.cloud.mdb.kafka.v1;

import "google/protobuf/wrappers.proto";
import "yandex/cloud/validation.proto";

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


// A Kafka user.
// For more information, see the [Operations -> Accounts](/docs/managed-kafka/operations/cluster-accounts) section of the documentation.
message User {
  // Name of the Kafka user.
  string name = 1;

  // ID of the Apache Kafka® cluster the user belongs to.
  //
  // To get the Apache Kafka® cluster ID, make a [ClusterService.List] request.
  string cluster_id = 2;

  // Set of permissions granted to this user.
  repeated Permission permissions = 3;
}

message UserSpec {
  // Name of the Kafka user.
  string name = 1 [(required) = true, (length) = "1-63", (pattern) = "[a-zA-Z0-9_]*"];

  // Password of the Kafka user.
  string password = 2 [(required) = true, (length) = "8-128"];

  // Set of permissions granted to the user.
  repeated Permission permissions = 3;
}

message Permission {
  enum AccessRole {
    ACCESS_ROLE_UNSPECIFIED = 0;

    // producer role for the user.
    ACCESS_ROLE_PRODUCER = 1;

    // consumer role for the user.
    ACCESS_ROLE_CONSUMER = 2;

    // admin role for the user.
    ACCESS_ROLE_ADMIN = 3;
  }

  // Name or prefix-pattern with wildcard for the topic that the permission grants access to.
  //
  // To get the topic name, make a [TopicService.List] request.
  string topic_name = 1;

  // Access role type to grant to the user.
  AccessRole role = 2;
}
