From e72e17c438f6e5f4bd388ac9ed990fe648a5ed5d Mon Sep 17 00:00:00 2001
From: Bulat Gayazov <bylatgr@gmail.com>
Date: Tue, 3 Dec 2024 18:33:13 +0000
Subject: [PATCH] Update protos and return TAtomicSharedPtr in metric extension

---
 .../extensions/solomon_stats/pull_connector.h | 11 ++++++
 src/api/protos/draft/fq.proto                 |  7 ++++
 src/api/protos/ydb_cms.proto                  | 37 +++++++++++--------
 src/api/protos/ydb_table.proto                |  1 +
 4 files changed, 40 insertions(+), 16 deletions(-)

diff --git a/include/ydb-cpp-sdk/client/extensions/solomon_stats/pull_connector.h b/include/ydb-cpp-sdk/client/extensions/solomon_stats/pull_connector.h
index 35d41919cc..46734fab58 100644
--- a/include/ydb-cpp-sdk/client/extensions/solomon_stats/pull_connector.h
+++ b/include/ydb-cpp-sdk/client/extensions/solomon_stats/pull_connector.h
@@ -16,6 +16,9 @@ class TMetricRegistryConnector: public NYdb::IExtension {
         return p.get();
     }
 
+    static NMonitoring::IMetricRegistry* ToRawPtr(TAtomicSharedPtr<NMonitoring::IMetricRegistry> p) {
+        return p.Get();
+    }
 
 public:
     using IApi = NYdb::NSdkStats::IStatApi;
@@ -57,4 +60,12 @@ inline void AddMetricRegistry(NYdb::TDriver& driver, std::shared_ptr<NMonitoring
     driver.AddExtension<TConnector>(TConnector::TParams(ptr));
 }
 
+inline void AddMetricRegistry(NYdb::TDriver& driver, TAtomicSharedPtr<NMonitoring::IMetricRegistry> ptr) {
+    if (!ptr)
+        return;
+    using TConnector = TMetricRegistryConnector<TAtomicSharedPtr<NMonitoring::IMetricRegistry>>;
+
+    driver.AddExtension<TConnector>(TConnector::TParams(ptr));
+}
+
 } // namespace NSolomonStatExtension
diff --git a/src/api/protos/draft/fq.proto b/src/api/protos/draft/fq.proto
index d9effa63eb..16103753b9 100644
--- a/src/api/protos/draft/fq.proto
+++ b/src/api/protos/draft/fq.proto
@@ -515,6 +515,11 @@ message MySQLCluster {
     IamAuth auth = 5;
 }
 
+message Logging {
+    string folder_id = 1;
+    IamAuth auth = 2;
+}
+
 message ConnectionSetting {
     enum ConnectionType {
         CONNECTION_TYPE_UNSPECIFIED = 0;
@@ -526,6 +531,7 @@ message ConnectionSetting {
         POSTGRESQL_CLUSTER = 6;
         GREENPLUM_CLUSTER = 7;
         MYSQL_CLUSTER = 8;
+        LOGGING = 9;
     }
 
     oneof connection {
@@ -537,6 +543,7 @@ message ConnectionSetting {
         PostgreSQLCluster postgresql_cluster = 6;
         GreenplumCluster greenplum_cluster = 7;
         MySQLCluster mysql_cluster = 8;
+        Logging logging = 9;
     }
 }
 
diff --git a/src/api/protos/ydb_cms.proto b/src/api/protos/ydb_cms.proto
index 14b639104d..29e8b3f596 100644
--- a/src/api/protos/ydb_cms.proto
+++ b/src/api/protos/ydb_cms.proto
@@ -106,23 +106,28 @@ message DatabaseQuotas {
     repeated StorageQuotas storage_quotas = 6;
 }
 
-// A policy that is used for resource scale recommendation. If multiple are used,
-// recommender combines them to recommend the largest scale.
-message ScaleRecommenderPolicy {
-    // Policy that tracks metric and reactively recommend to adjust resources scale
-    // to keep metric close to the specified target value.
-    message TargetTrackingPolicy {
-        oneof target {
-            // A percentage of compute resources' average CPU utilization.
-            uint32 average_cpu_utilization_percent = 1; 
+message ScaleRecommenderPolicies {
+    // A policy that is used for resource scale recommendation. If multiple are used,
+    // recommender combines them to recommend the largest scale.
+    message ScaleRecommenderPolicy {
+        // Policy that tracks metric and reactively recommend to adjust resources scale
+        // to keep metric close to the specified target value.
+        message TargetTrackingPolicy {
+            oneof target {
+                // A percentage of compute resources' average CPU utilization.
+                uint32 average_cpu_utilization_percent = 1; 
+            }
         }
-    }
 
-    oneof policy {
-        TargetTrackingPolicy target_tracking_policy = 1;
+        oneof policy {
+            TargetTrackingPolicy target_tracking_policy = 1;
+        }
     }
+
+    repeated ScaleRecommenderPolicy policies = 1;
 }
 
+
 // Request to create a new database. For successfull creation
 // specified database shouldn't exist. At least one storage
 // unit should be requested for the database.
@@ -149,7 +154,7 @@ message CreateDatabaseRequest {
     // Optional quotas for the database
     DatabaseQuotas database_quotas = 10;
     // Optional scale recommender policies
-    repeated ScaleRecommenderPolicy scale_recommender_policies = 11;
+    ScaleRecommenderPolicies scale_recommender_policies = 11;
 }
 
 message CreateDatabaseResponse {
@@ -201,7 +206,7 @@ message GetDatabaseStatusResult {
     // Current quotas for the database
     DatabaseQuotas database_quotas = 10;
     // Current scale recommender policies
-    repeated ScaleRecommenderPolicy scale_recommender_policies = 11;
+    ScaleRecommenderPolicies scale_recommender_policies = 11;
 }
 
 // Change resources allocated for database.
@@ -230,8 +235,8 @@ message AlterDatabaseRequest {
     DatabaseQuotas database_quotas = 11;
     // Alter attributes. Leave the value blank to drop an attribute.
     map<string, string> alter_attributes = 12;
-    // Alter scale recommender policies.
-    repeated ScaleRecommenderPolicy scale_recommender_policies = 13;
+    // Change scale recommender policies.
+    ScaleRecommenderPolicies scale_recommender_policies = 13;
 }
 
 message AlterDatabaseResponse {
diff --git a/src/api/protos/ydb_table.proto b/src/api/protos/ydb_table.proto
index a394a466e7..38988c4a12 100644
--- a/src/api/protos/ydb_table.proto
+++ b/src/api/protos/ydb_table.proto
@@ -518,6 +518,7 @@ message ColumnFamily {
         COMPRESSION_UNSPECIFIED = 0;
         COMPRESSION_NONE = 1;
         COMPRESSION_LZ4 = 2;
+        COMPRESSION_ZSTD = 3;
     }
 
     // Name of the column family, the name "default" must be used for the