package NYql;
option java_package = "ru.yandex.yql.proto";

import "yql/essentials/protos/clickhouse.proto";


/////////////////////////////// common ///////////////////////////////

message TActivationByHour {
    required uint32 Hour = 1;
    required uint32 Percentage = 2;
}

message TActivationPercentage {
    optional uint32 Percentage = 1 [default = 0];
    repeated TActivationByHour ByHour = 2;
    repeated string IncludeUsers = 3;
    repeated string ExcludeUsers = 4;
    optional bool ExcludeRobots = 5 [default = true];
    repeated string Tags = 6;
    repeated string IncludeGroups = 7;
    repeated string ExcludeGroups = 8;
    repeated string IncludeRevisions = 9;
    repeated string ExcludeRevisions = 10;
}

message TAttr {
    required string Name = 1;
    required string Value = 2;
    optional TActivationPercentage Activation = 3;
}

message TRemoteFilePattern {
    required string Pattern = 1; // regexp to match
    required string Cluster = 2;  // replacement string for YT server
    required string Path = 3;    // replacement string for remote file path
}

enum EYtLogLevel {
    YL_NONE        = -1;
    YL_FATAL       = 0;
    YL_ERROR       = 1;
    YL_INFO        = 2;
    YL_DEBUG       = 3;
};

enum EHostScheme {
    HS_HTTP        = 0;
    HS_HTTPS       = 1;
};

enum ETokenType {
    IAM = 0;
    OAUTH = 1;
    BLACKBOX = 2;
    CREDENTIALS = 3;
};

/////////////////////////////// HTTP GATEWAY //////////////////////

message TExplicitDNSRecord {
  enum ProtocolVersion {
    ANY = 0;
    IPV4 = 1;
    IPV6 = 2;
  };

  optional string Address = 1 [default = ""];
  optional uint32 Port = 2 [default = 443];
  optional string ExpectedIP = 3 [default = ""];
  optional ProtocolVersion Protocol = 4 [default = ANY];
}

message TDnsResolverConfig {
  optional uint32 RefreshMs = 1 [default = 60000];
  repeated TExplicitDNSRecord ExplicitDNSRecord = 100;
}

message THttpGatewayConfig {
    optional uint32 MaxInFlightCount = 1;
    optional uint64 MaxSimulatenousDownloadsSize = 2;
    optional uint32 BuffersSizePerStream = 3;
    optional uint64 ConnectionTimeoutSeconds = 4;
    optional uint64 BytesPerSecondLimit = 5;
    optional uint64 DownloadBufferBytesLimit = 6;
    optional uint64 RequestTimeoutSeconds = 7;
    optional uint64 LowSpeedTimeSeconds = 8;
    optional uint64 LowSpeedBytesLimit = 9;
    optional TDnsResolverConfig DnsResolverConfig = 10;
    optional uint64 MaxRetries = 11;
}

/////////////////////////////// YT ///////////////////////////////

message TYtClusterConfig {
    optional string Name = 1; // Short cluster name
    optional string Cluster = 2; // Real cluster server name with port
    optional bool Default = 3 [default = false]; // Default cluster
    optional string YTToken = 4; // token to use at YT servers
    optional string YTName = 5; // YT cluster name
    optional bool EnabledYtQlQueries = 6 [default = true]; // Allow to handle YtQl queries

    repeated TAttr Settings = 100;
}

message TFileWithMd5 {
    optional string File = 1;
    optional string Md5 = 2;
}

message TYtGatewayConfig {
    optional uint32 GatewayThreads = 1 [default = 0]; // Number of gateway MtpQueue threads. The adaptive MtpQueue will be used for 0 value
    optional EYtLogLevel YtLogLevel = 2 [default = YL_ERROR]; // The verbosity level of YT log
    optional string PerfToolsPath = 4; // Path to perftools libraries
    optional bool PerfToolsFromPackage = 5; // Use perftools from package
    optional string MrJobBin = 6; // Path to mrjob executable. If not set then main executable will be used
    optional string MrJobBinMd5 = 13; // MD5 checksum of mrjob executable. Should not be specified directly
    optional string MrJobUdfsDir = 7; // Path to linux udfs. If not set then loaded into main executable will be used
    optional bool ExecuteUdfLocallyIfPossible = 8; // Turns on local execution mode for calc job with UDF.
    optional bool LocalChainTest = 9 [default = false]; // Chain local execution jobs for test purpose.
    optional string YtDebugLogFile = 10; // File for full YT debug log
    optional uint64 YtDebugLogSize = 11 [default = 0]; // Max YT debug log size
    optional bool YtDebugLogAlwaysWrite = 12 [default = false]; // Write YT debug log always or on error only
    optional string LocalChainFile = 14; // File to dump table contet in test mode
    repeated TFileWithMd5 MrJobSystemLibsWithMd5 = 15; // Paths to linux dynamic libraries required for running mrjob.

    repeated TRemoteFilePattern RemoteFilePatterns = 100;
    repeated TYtClusterConfig ClusterMapping = 101; // Accepted cluster shortcuts. All names not from this list will be rejected
    repeated TAttr DefaultSettings = 102;
}

/////////////////////////////// Grut ///////////////////////////////

message TYtOrmClusterConfig {
    optional string Name = 1; // Examples: grut_testing, grut_stable, grut_dev
    optional string Cluster = 2; // Examples: sas, vla, etc
    optional bool Enabled = 3 [default = true]; // Allow to handle YTORM queries
    optional string EndpointSetId = 4; // Examples: grut-stable.object_api, grut-testing.object_api, etc
}

message TYtOrmGatewayConfig {
    repeated TYtOrmClusterConfig ClusterMapping = 1;
}

/////////////////////////////// Kikimr ///////////////////////////////

message THostPort {
    required string Host = 1;
    required uint32 Port = 2;
    optional uint64 TotalTimeoutMs = 3;
}

message TKikimrGrpcData {
    repeated string Locators = 1;
    optional uint64 TimeoutMs = 2;
    optional uint64 MaxMessageSizeBytes = 3;
    optional uint32 MaxInFlight = 4;
    optional bool EnableEndpointDiscovery = 5;
    optional bool UseLegacyApi = 6;
}

message TKikimrClusterConfig {
    optional string Name = 1;
    optional bool Default = 2 [default = false];
    repeated THostPort MessageBus = 3;
    optional TKikimrGrpcData Grpc = 4;
    optional string Database = 5;
    optional uint32 TvmId = 6 [default = 0];
    optional string Token = 7;
    optional string ProxyUrl = 8;
    optional string Location = 9;
    optional bool IsFromMvp = 10;
    optional ETokenType TokenType = 11;
    repeated TAttr Settings = 101;
}

message TKikimrGatewayConfig {
    repeated TKikimrClusterConfig ClusterMapping = 1;
    repeated TAttr DefaultSettings = 2;
}

/////////////////////////////// Kikimr MVP ///////////////////////////////

message TKikimrMvpProxyConfig {
    optional string Host = 1;
    optional uint32 Port = 2;
    optional string BasePath = 3;
    optional uint32 TvmId = 4 [default = 0];
}

message TKikimrMvpGatewayConfig {
    repeated TKikimrMvpProxyConfig ProxyMapping = 1;
}

///////////////////////////// Ydb /////////////////////////////

message TYdbClusterConfig {
    optional string Name = 1;
    optional string Endpoint = 2;
    optional string Token = 3;
    optional TKikimrGrpcData Grpc = 4;
    optional uint32 TvmId = 5 [default = 0];
    optional string Database = 6;
    optional string Id = 7;
    optional bool Secure = 8;
    optional string ServiceAccountId = 9;
    optional string ServiceAccountIdSignature = 10;
    optional bool AddBearerToToken = 11; // whether to use prefix "Bearer " in token
    repeated TAttr Settings = 100;
}

message TYdbGatewayConfig {
    repeated TYdbClusterConfig ClusterMapping = 1;
    optional string DefaultEndpoint = 2;
    optional string DefaultToken = 3;
    repeated TAttr DefaultSettings = 4;
}

///////////////////////////// ClickHouse /////////////////////////////

message TClickHouseClusterConfig {
    optional string Name = 1;
    optional bool Default = 2 [default = false];
    optional string Cluster = 3;
    optional string CHToken = 4;
    repeated TAttr Settings = 101;
    optional EHostScheme HostScheme = 5;
    optional uint32 HostPort = 6;
    optional string CHTokenYavSecretId = 7;
    optional string CHTokenYavVersionId = 8;
    optional string CHTokenYavKey = 9;
    optional NYql.NProto.TClickHouseRunnerConfig Runner = 10;
    optional uint32 NativeHostPort = 11 [default = 9000];
    optional bool NativeSecure = 12 [default = false];
    optional string Id = 13;
    repeated string GroupAllowed = 14;
}

message TClickHouseGatewayConfig {
    repeated TClickHouseClusterConfig ClusterMapping = 1;
    repeated TAttr DefaultSettings = 2;
}

///////////////////////////// RTMR /////////////////////////////
enum EYfArtifactType {
    AT_NONE  = 0;
    AT_FILE  = 1;
    AT_LAYER = 2;
};

enum ERtmrOperationType {
    OT_NONE        = 0;
    OT_LF_PARSE    = 1;
    OT_YDB_OUT     = 2;
    OT_SOLOMON_OUT = 3;
    OT_PQ_OUT      = 4;
};

message TYfArtifactLink {
    optional EYfArtifactType Type = 1;
    optional string Url = 2; // in any format suitable for file storage
    optional string TargetFilePath = 3; // ignored for Type=AT_LAYER
};

message TRtmrOperationArtifactsInfo {
    optional ERtmrOperationType Type = 1;
    repeated TYfArtifactLink Links = 2;
};

message TRtmrPqConsumerInfo {
    optional string Cluster = 1;
    optional string Consumer = 2;
}

message TRtmrClusterConfig {
    optional string Name = 1;
    optional bool Default = 2 [default = false];
    optional string Cluster = 3;
    optional string RemoteName = 4;
    optional string YfCluster = 5;
    optional string S3TokenPath = 6;
    optional string S3FileCachePath = 7;
    optional uint32 TvmId = 8 [default = 0];
    optional string TvmSecretPath = 9;
    repeated string Users = 10;
    optional bool UploadViaYfClient = 11 [default = false];
    optional string MdsTorrentUrl = 12;
    repeated TRtmrOperationArtifactsInfo ArtifactOverrides = 13; // override CommonArtifacts by ERtmrOperationType
    optional string PqConsumer = 14;
    repeated TRtmrPqConsumerInfo PqConsumerMapping = 15;
    optional uint32 MaxPqPartitions = 16;
    optional uint32 PreviewCollectTimeoutMs = 17;
    optional string SbdTvmSecretFile = 18;
    optional uint64 SbdTvmClientId = 19;
    optional uint64 SbdTvmServerId = 20 [default = 2021848];
    repeated TAttr Settings = 101;
}

message TRtmrGatewayConfig {
    repeated TRtmrClusterConfig ClusterMapping = 1;
    repeated TAttr DefaultSettings = 2;
    optional string YqlRtmrDynLib = 3; // path to libyql-dynlib.so
    optional bool UseFakeYfUpload = 4 [default = false]; // use in tests only to speedup upload
    repeated string Artifacts = 5;  /// default artifacts to put into every function
    repeated TRtmrOperationArtifactsInfo CommonArtifacts = 6; // common artifacts for all clusters
    optional uint32 MaxPqPartitions = 7 [default = 10];
    optional uint32 PreviewCollectTimeoutMs = 8 [default = 2000];
    optional bool KeepActiveProcess = 9 [default = false];
}

///////////////////////////// Pq //////////////////////////////

message TPqClusterConfig {
    enum EClusterType {
        CT_UNSPECIFIED = 0;
        CT_PERS_QUEUE = 1;
        CT_DATA_STREAMS = 2;
    }

    optional string Name = 1;
    optional EClusterType ClusterType = 2 [default = CT_PERS_QUEUE];
    optional string Endpoint = 3;
    optional string ConfigManagerEndpoint = 4;
    optional string Token = 5;
    optional string Database = 6 [default = "/Root"];
    optional uint32 TvmId = 7 [default = 0];
    optional bool UseSsl = 8; // grpcs
    optional string ServiceAccountId = 9;
    optional string ServiceAccountIdSignature = 10;
    optional bool AddBearerToToken = 11; // whether to use prefix "Bearer " in token
    optional string DatabaseId = 12;
    repeated TAttr Settings = 100;
    optional bool SharedReading = 101;
    optional string ReconnectPeriod = 102; // disabled by default, example of a parameter: 5m
    optional string ReadGroup = 103;
}

message TPqGatewayConfig {
    repeated TPqClusterConfig ClusterMapping = 1;
    optional string DefaultToken = 2;
    repeated TAttr DefaultSettings = 100;
}

///////////////////////////// Stat /////////////////////////////

message TStatClusterConfig {
    optional string Name = 1; // Short cluster name
    optional string Cluster = 2; // Real cluster server name with port
    optional bool Default = 3 [default = false]; // Default cluster
    optional string StatToken = 4; // token to use in communication with Statface
    optional string StatName = 5; // Stat cluster name

    repeated TAttr Settings = 100;
}

message TStatGatewayConfig {
    optional uint32 GatewayThreads = 1 [default = 0]; // Number of gateway MtpQueue threads. The adaptive MtpQueue will be used for 0 value

    repeated TStatClusterConfig ClusterMapping = 101; // Accepted cluster shortcuts. All names not from this list will be rejected
    repeated TAttr DefaultSettings = 102;
}

///////////////////////////// CHYT /////////////////////////////

message TChytClusterConfig {
    optional string Name = 1; // Short cluster name
    optional string YtCluster = 2; // Name of the corresponding YT cluster.
}

message TChytGatewayConfig {
    repeated TChytClusterConfig ClusterMapping = 1;
}

///////////////////////////// S3 /////////////////////////////

message TS3ClusterConfig {
    optional string Name = 1; // Short cluster name
    optional string Url = 2;
    optional string Token = 3;
    optional string ServiceAccountId = 4;
    optional string ServiceAccountIdSignature = 5;
    repeated TAttr Settings = 100;
}

message TS3FormatSizeLimit {
    optional string Name = 1;          // Format name i.e. csv_with_names
    optional uint64 FileSizeLimit = 2; // Max allowed size for this format
}

message TS3GatewayConfig {
    repeated TS3ClusterConfig ClusterMapping = 1;

    optional uint64 FileSizeLimit = 2;               // Global limit
    repeated TS3FormatSizeLimit FormatSizeLimit = 6; // Format limits (override FileSizeLimit)
    optional uint64 BlockFileSizeLimit = 10;         // Global limit for block readers (overrides FormatSizeLimit)
    optional uint64 MaxFilesPerQuery = 3;
    optional uint64 MaxReadSizePerQuery = 4;
    optional uint64 MaxDiscoveryFilesPerQuery = 5;
    optional uint64 MaxInflightListsPerQuery = 7;
    optional uint64 MaxDirectoriesAndFilesPerQuery = 8;
    optional uint64 MinDesiredDirectoriesOfFilesPerQuery = 9;
    optional bool AllowConcurrentListings = 11 [default = false];
    optional uint64 ListingCallbackThreadCount = 12;
    optional uint64 ListingCallbackPerThreadQueueSize = 13;
    optional uint64 RegexpCacheSize = 14;
    optional uint64 GeneratorPathsLimit = 15;
    optional uint64 MaxListingResultSizePerPartition = 16;
    optional uint64 RowsInBatch = 17; // Default = 1000
    optional uint64 MaxInflight = 18; // Default = 20
    optional uint64 DataInflight = 19; // Default = 200 MB
    optional bool AllowLocalFiles = 20;

    repeated TAttr DefaultSettings = 100;
}

///////////////////////////// Solomon /////////////////////////////

message TSolomonClusterConfig {
    enum ESolomonClusterType {
        SCT_UNSPECIFIED = 0;
        SCT_SOLOMON = 1;
        SCT_MONITORING = 2;
    }

    message TShardPath {
        required string Project = 1; // CloudId for YC
        required string Cluster = 2; // FolderId for YC
    }

    optional string Name = 1;
    optional string Cluster = 2;
    optional bool UseSsl = 3;
    optional ESolomonClusterType ClusterType = 4 [default = SCT_SOLOMON];
    optional string Token = 5;
    optional string ServiceAccountId = 6;
    optional string ServiceAccountIdSignature = 7;
    optional TShardPath Path = 8;

    repeated TAttr Settings = 100;
}

message TSolomonGatewayConfig {
    repeated TSolomonClusterConfig ClusterMapping = 1;
    repeated TAttr DefaultSettings = 2;
}

message TFileStorageAdditionalConfig {
    message TUrlPattern {
        required string Pattern = 1;
        optional string Alias = 2;
    }

    message TSchemeTranslate {
        required string Pattern = 1; // regexp to match
        required string TargetUrl = 2; // replacement string for target URL
    }

    repeated TUrlPattern AllowedUrls = 2; // Whitelist of url regexps; disabled if empty
    repeated TUrlPattern ExternalAllowedUrls = 3; // Whitelist of url regexps for external users; disabled if empty
    repeated TSchemeTranslate CustomSchemes = 4;
}

/////////////////////////////// Postgresql /////////////////////////////

message TPostgresqlClusterConfig {
    optional string Name = 1;
    optional string Cluster = 2;
    optional string PGtoken = 3;
    optional string TargetServerType = 4;
    optional uint64 MaxResultBufferSize = 5 [default = 1000000]; // Zero value disables adaptiveFetch
}

message TPostgresqlGatewayConfig {
    repeated TPostgresqlClusterConfig ClusterMapping = 1;
    optional uint64 MaxResultBufferSize = 2 [default = 1000000]; // Zero value disables adaptiveFetch by default
}

/////////////////////////////// Mysql /////////////////////////////

message TMysqlClusterConfig {
    optional string Name = 1;
    optional string Cluster = 2;
    optional string MysqlToken = 3;
}

message TMysqlGatewayConfig {
    repeated TMysqlClusterConfig ClusterMapping = 1;
}


/////////////////////////////// Dq /////////////////////////////////////
message TDqGatewayConfig {
    message TDefaultAutoByHourPercentage {
        required uint32 Hour = 1;
        required uint32 Percentage = 2;
    }

    optional uint32 DefaultAutoPercentage = 1 [default = 0]; // Probability of 'DqEngine="auto"'
    repeated TDefaultAutoByHourPercentage DefaultAutoByHour = 2;
    repeated string NoDefaultAutoForUsers = 3;

    repeated string DefaultAnalyzeQueryForUsers = 4;

    repeated TAttr DefaultSettings = 102;

    optional uint32 WithHiddenPercentage = 5 [default = 0];     // Depricated. TODO: remove
    repeated TDefaultAutoByHourPercentage WithHiddenByHour = 6; // Depricated. TODO: remove
    repeated string NoWithHiddenForUsers = 7;                   // Depricated. TODO: remove
    repeated string WithHiddenForUsers = 8;                     // Depricated. TODO: remove

    optional TActivationPercentage HiddenActivation = 9;
}

/////////////////////////////// Yql Core ///////////////////////////////

message TCoreAttr {
    required string Name = 1;
    repeated string Args = 2;
    optional TActivationPercentage Activation = 3;
}

message TYqlCoreConfig {
    repeated TCoreAttr Flags = 1;
    optional TActivationPercentage QPlayerActivation = 2;
}

/////////////////////////////// Sql Core ///////////////////////////////
message TWarnAsErrorByHourPercentage {
    required uint32 Hour = 1;
    required uint32 Percentage = 2;
}

message TSqlCoreConfig {
    optional uint32 V0SyntaxWarnAsErrorPercentage = 1 [default = 0]; // Probability of 'deprecated syntax'
                                                                     // warning to become an error
    repeated TWarnAsErrorByHourPercentage V0SyntaxWarnAsErrorByHour = 2;
    repeated string NoV0SyntaxErrorForUsers = 3;

    repeated string TranslationFlags = 4;
}

/////////////////////////////// Db Tool ///////////////////////////////

message TUserException {
    required string Login = 1;
    optional uint32 ExpireDays = 2 [default = 0]; // 0 - don't delete history at all
}

message TDbToolConfig {
    optional uint32 DefaultExpireDays = 1;
    optional string RobotPattern = 2;
    repeated string DeleteQueryRunner = 3;
    repeated TUserException UserException = 4;
}


/////////// Generic gateway for the external data sources ////////////

// TGenericEndpoint represents the network address of a generic data source instance
message TGenericEndpoint {
    optional string host = 1;
    optional uint32 port = 2;
}


// TGenericCredentials represents various ways of user authentication in the data source instance
message TGenericCredentials {
    message TBasic {
        optional string username = 1;
        optional string password = 2;
    }

    message TToken {
        optional string type = 1;
        optional string value = 2;
    }

    oneof payload {
        TBasic basic = 1;
        TToken token = 2;
    }
}

// EGenericDataSourceKind enumerates the external data sources
// supported by the federated query system
enum EGenericDataSourceKind {
    DATA_SOURCE_KIND_UNSPECIFIED = 0;
    CLICKHOUSE = 1;
    POSTGRESQL = 2;
    S3 = 3;
    YDB = 4;
    MYSQL = 5;
    MS_SQL_SERVER = 6;
    GREENPLUM = 7;
    ORACLE = 8;
    LOGGING = 9;
    MONGO_DB = 10;
}

// EGenericProtocol generalizes various kinds of network protocols supported by different databases.
enum EGenericProtocol {
    PROTOCOL_UNSPECIFIED = 0;
    NATIVE = 1; // CLICKHOUSE, POSTGRESQL
    HTTP = 2;   // CLICKHOUSE, S3
}

// TPostgreSQLDataSourceOptions represents settings specific to PostgreSQL
message TPostgreSQLDataSourceOptions {
    // PostgreSQL schema
    optional string schema = 1;
}

// TClickhouseDataSourceOptions represents settings specific to Clickhouse
message TClickhouseDataSourceOptions {
}

// TS3DataSourceOptions represents settings specific to S3 (Simple Storage Service)
message TS3DataSourceOptions {
    // the region where data is stored
    optional string region = 1;
    // the bucket the object belongs to
    optional string bucket = 2;
}

// TGreenplumDataSourceOptions represents settings specific to Greenplum
message TGreenplumDataSourceOptions {
    // Greenplum schema
    optional string schema = 1;
}

// TOracleDataSourceOptions represents settings specific to Oracle
message TOracleDataSourceOptions {
    // Oracle service_name - alias to SID of oracle INSTANCE, or SID, or PDB.
    //  More about connection options in Oracle docs:
    //  https://docs.oracle.com/en/database/other-databases/essbase/21/essoa/connection-string-formats.html
    optional string service_name = 1;
}

// TLoggingDataSourceOptions represents settings specific to Logging
message TLoggingDataSourceOptions {
    optional string folder_id = 1;
}

// TMongoDbDataSourceOptions represents settings specific to MongoDB
message TMongoDbDataSourceOptions {
    enum EReadingMode {
        READING_MODE_UNSPECIFIED = 0;
        // Returns each top level field of the document deserialized into the corresponding YQL type; if the type of some field is ambiguous / inconsistent across several documents it is returned serialized as an YQL Utf8 value
        TABLE = 1;
    };
      
    // Ways of dealing with values read in ReadSplit whose types are inconsistent with types that were deduced in DescribeTable
    enum EUnexpectedTypeDisplayMode {
        UNEXPECTED_UNSPECIFIED = 0;
        UNEXPECTED_AS_NULL = 1;
        UNEXPECTED_AS_STRING = 2;
    };

    // Ways of dealing with unsupported data types
    enum EUnsupportedTypeDisplayMode {
        UNSUPPORTED_UNSPECIFIED = 0;
        UNSUPPORTED_OMIT = 1;
        UNSUPPORTED_AS_STRING = 2;
    };
    
    optional EReadingMode reading_mode = 1;
    optional EUnexpectedTypeDisplayMode unexpected_type_display_mode = 2;
    optional EUnsupportedTypeDisplayMode unsupported_type_display_mode = 3;
}

// TGenericDataSourceInstance helps to identify the instance of a data source to redirect request to.
message TGenericDataSourceInstance {
    // Data source kind
    optional EGenericDataSourceKind kind = 1;
    // Network address
    optional TGenericEndpoint endpoint = 2;
    // Database name
    optional string database = 3;
    // Credentials to access database
    optional TGenericCredentials credentials = 4;
    // If true, Connector server will use secure connections to access remote data sources.
    // Certificates will be obtained from the standard system paths.
    optional bool use_tls = 5;
    // Allows to specify network protocol that should be used between
    // during the connection between Connector and the remote data source
    optional EGenericProtocol protocol = 6;
    // Options specific to various data sources
    oneof options {
        TPostgreSQLDataSourceOptions pg_options = 7;
        TClickhouseDataSourceOptions ch_options = 8;
        TS3DataSourceOptions s3_options = 9;
        TGreenplumDataSourceOptions gp_options = 10;
        TOracleDataSourceOptions oracle_options = 11;
        TLoggingDataSourceOptions logging_options = 12;
        TMongoDbDataSourceOptions mongodb_options = 13;
    }
}

message TGenericClusterConfig {
    // Cluster name
    optional string Name = 1;

    // Data source kind
    optional EGenericDataSourceKind Kind = 8;

    // Location represents the network address of a data source instance we want to connect
    oneof Location {
        // Endpoint must be used for on-premise deployments.
        TGenericEndpoint Endpoint = 9;
        // DatabaseId must be used when the data source is deployed in cloud.
        // Data source FQDN and port will be resolved by MDB service.
        string DatabaseId = 4;
    }

    // Credentials used to access data source instance
    optional TGenericCredentials Credentials = 10;

    // Credentials used to access managed databases APIs.
    // When working with external data source instances deployed in clouds,
    // one should either set (ServiceAccountId, ServiceAccountIdSignature) pair
    // that will be resolved into IAM Token via Token Accessor,
    // or provide IAM Token directly.
    optional string ServiceAccountId = 6;
    optional string ServiceAccountIdSignature = 7;
    optional string Token = 11;

    // If true, the generic provider will ask connector server to use secure connections
    // to access remote data sources.
    optional bool UseSsl = 12;

    // Name of a particular database within a database cluster
    optional string DatabaseName = 13;

    // Transport protocol used to establish a network connection with database
    optional EGenericProtocol Protocol = 14;

    // Data source options specific to various data sources
    map<string, string> DataSourceOptions = 15;

    reserved 2, 3, 5;
}

message TGenericConnectorConfig {
    // There are two options to configure Connector network address:
    // 1. Set address statically via `Endpoint.Host` and `Endpoint.Port`;
    // 2. Ask YDB to set `Endpoint.Port` to the value of expression `./ydbd --ic-port + OffsetFromIcPort`,
    // while Connector's hostname will still be taken from `Endpoint.Host` (with 'localhost' as a default value).
    optional TGenericEndpoint Endpoint = 3;
    optional uint32 OffsetFromIcPort = 6;

    // If true, Connector GRPC Client will use TLS encryption.
    optional bool UseSsl = 4;
    // Path to the custom CA certificate to verify Connector's certs.
    // If empty, the default system CA certificate pool will be used.
    optional string SslCaCrt = 5;

    reserved 1, 2;
}

message TGenericGatewayConfig {
    // Connector service network endpoint
    // TODO: replace with map<DataSourceKind, TGenericConnectorConfig>
    optional TGenericConnectorConfig Connector = 5;

    // Database clusters supported by this particular instance
    repeated TGenericClusterConfig ClusterMapping = 3;

    // MDB API endpoint (no need to fill in case of on-prem deployment).
    optional string MdbGateway = 4;

    // YDB MVP API endpoint (no need to fill in case of on-prem deployment).
    // Expected format:
    // [http|https]://host:port/ydbc/cloud-prod/
    optional string YdbMvpEndpoint = 7;

    repeated TAttr DefaultSettings = 6;

    reserved 1, 2;
}

/////////////////////////////// Db Resolver ///////////////////////////////////

message TDbResolverConfig {
    // Ydb / Yds MVP endpoint.
    // Expected format:
    // [http|https]://host:port/ydbc/cloud-prod/
    optional string YdbMvpEndpoint = 2;
}

/////////////////////////////// Revision filter ///////////////////////////////

message TRevisionException {
    repeated string Revisions = 1;
    repeated string IncludeUsers = 2;
    repeated string ExcludeUsers = 3;
}

message TRevisionFilterConfig {
    repeated TRevisionException RevisionException = 1;
}

/////////////////////////////// Root ///////////////////////////////

message TGatewaysConfig {
    optional TYtGatewayConfig Yt = 1;
    optional TKikimrGatewayConfig Kikimr = 2;
    optional TClickHouseGatewayConfig ClickHouse = 3;
    optional TRtmrGatewayConfig Rtmr = 4;
    optional TKikimrMvpGatewayConfig KikimrMvp = 5;
    optional TStatGatewayConfig Stat = 6;
    optional TChytGatewayConfig Chyt = 7;
    optional TSolomonGatewayConfig Solomon = 8;
    optional TFileStorageAdditionalConfig Fs = 9;
    optional TYqlCoreConfig YqlCore = 10;
    optional TPostgresqlGatewayConfig Postgresql = 11;
    optional TSqlCoreConfig SqlCore = 12;
    optional TDqGatewayConfig Dq = 13;
    optional TMysqlGatewayConfig Mysql = 14;
    optional TYdbGatewayConfig Ydb = 15;
    optional TPqGatewayConfig Pq = 16;
    optional TS3GatewayConfig S3 = 17;
    optional THttpGatewayConfig HttpGateway = 18;
    optional TYtOrmGatewayConfig YtOrm = 19;
    optional TDbToolConfig DbTool = 20;
    optional TGenericGatewayConfig Generic = 21;
    optional TRevisionFilterConfig RevisionFilter = 22;
    optional TDbResolverConfig DbResolver = 23;
}