diff options
author | Aleksandr Khoroshilov <hor911@gmail.com> | 2022-04-13 18:15:01 +0300 |
---|---|---|
committer | Aleksandr Khoroshilov <hor911@gmail.com> | 2022-04-13 18:15:01 +0300 |
commit | e794c6d1d117804bd581a0b9d038d24597af7666 (patch) | |
tree | ef56adcb3ecf7261c5d6e082364a2d02beb149dc | |
parent | 82281b755a11a1d8756a74f61e984ad672eaa117 (diff) | |
download | ydb-e794c6d1d117804bd581a0b9d038d24597af7666.tar.gz |
Move code to where it is used
ref:43830635dfd30153b598e3c75e1f7b2727d86717
-rw-r--r-- | ydb/core/yq/libs/private_client/CMakeLists.txt | 1 | ||||
-rw-r--r-- | ydb/core/yq/libs/private_client/utils.cpp | 57 | ||||
-rw-r--r-- | ydb/core/yq/libs/private_client/utils.h | 12 | ||||
-rw-r--r-- | ydb/services/yq/ut_integration/yq_ut.cpp | 2 |
4 files changed, 1 insertions, 71 deletions
diff --git a/ydb/core/yq/libs/private_client/CMakeLists.txt b/ydb/core/yq/libs/private_client/CMakeLists.txt index 088994060d..adde298856 100644 --- a/ydb/core/yq/libs/private_client/CMakeLists.txt +++ b/ydb/core/yq/libs/private_client/CMakeLists.txt @@ -17,6 +17,5 @@ target_link_libraries(yq-libs-private_client PUBLIC cpp-client-ydb_table ) target_sources(yq-libs-private_client PRIVATE - ${CMAKE_SOURCE_DIR}/ydb/core/yq/libs/private_client/utils.cpp ${CMAKE_SOURCE_DIR}/ydb/core/yq/libs/private_client/private_client.cpp ) diff --git a/ydb/core/yq/libs/private_client/utils.cpp b/ydb/core/yq/libs/private_client/utils.cpp deleted file mode 100644 index f1ba5c7e22..0000000000 --- a/ydb/core/yq/libs/private_client/utils.cpp +++ /dev/null @@ -1,57 +0,0 @@ -#include "utils.h" -#include <library/cpp/protobuf/json/json2proto.h> -#include <library/cpp/protobuf/json/proto2json.h> -#include <ydb/public/lib/ydb_cli/commands/ydb_common.h> - -namespace NYq { - -using namespace NYdb::NYq; - -void UpdateConnections( - TClient& client, - const TString& folderId, - const TString& connectionsStr) { - NJson::TJsonValue value; - TStringStream in(connectionsStr); - NJson::ReadJsonTree(&in, &value); - YandexQuery::ListConnectionsRequest listConsRequest; - listConsRequest.set_limit(100); - auto result = client - .ListConnections(listConsRequest, CreateYqSettings<TListConnectionsSettings>(folderId)) - .ExtractValueSync(); - NYdb::NConsoleClient::ThrowOnError(result); - THashMap<TString, YandexQuery::Connection> connections; - for (const auto& connection : result.GetResult().connection()) { - if (!connection.content().name()) { - continue; - } - connections.emplace(connection.content().name(), connection); - } - for (auto conJson : value.GetArraySafe()) { - const auto& content = conJson["content"]; - const TString conName = content["name"].GetString(); - auto it = connections.find(conName); - if (it == connections.end()) { - Cerr << " Add " << conName << Endl; - YandexQuery::CreateConnectionRequest request; - NProtobufJson::Json2Proto(conJson, request); - const auto result = client - .CreateConnection(request, CreateYqSettings<TCreateConnectionSettings>(folderId)) - .ExtractValueSync(); - result.GetIssues().PrintTo(Cerr); - NYdb::NConsoleClient::ThrowOnError(result); - } else { - Cerr << " Update " << conName << Endl; - YandexQuery::ModifyConnectionRequest request; - conJson["connection_id"] = it->second.meta().id(); - NProtobufJson::Json2Proto(conJson, request); - const auto result = client - .ModifyConnection(request, CreateYqSettings<TModifyConnectionSettings>(folderId)) - .ExtractValueSync(); - result.GetIssues().PrintTo(Cerr); - NYdb::NConsoleClient::ThrowOnError(result); - } - } -} - -} //NYq diff --git a/ydb/core/yq/libs/private_client/utils.h b/ydb/core/yq/libs/private_client/utils.h deleted file mode 100644 index ff1b255c31..0000000000 --- a/ydb/core/yq/libs/private_client/utils.h +++ /dev/null @@ -1,12 +0,0 @@ -#pragma once -#include <ydb/public/lib/yq/yq.h> -#include <ydb/public/lib/yq/helpers.h> - -namespace NYq { - -void UpdateConnections( - NYdb::NYq::TClient& client, - const TString& folderId, - const TString& connectionsStr); - -} // NYq diff --git a/ydb/services/yq/ut_integration/yq_ut.cpp b/ydb/services/yq/ut_integration/yq_ut.cpp index d4a35f195e..5a129b8fa3 100644 --- a/ydb/services/yq/ut_integration/yq_ut.cpp +++ b/ydb/services/yq/ut_integration/yq_ut.cpp @@ -2,9 +2,9 @@ #include <ydb/public/sdk/cpp/client/ydb_driver/driver.h> #include <ydb/public/lib/yq/yq.h> +#include <ydb/public/lib/yq/helpers.h> #include <ydb/core/yq/libs/db_schema/db_schema.h> #include <ydb/core/yq/libs/mock/yql_mock.h> -#include <ydb/core/yq/libs/private_client/utils.h> #include <ydb/core/yq/libs/private_client/private_client.h> #include <ydb/core/yq/libs/control_plane_storage/message_builders.h> |