From a78a20f7473b02ece63caacf25416c7fb3db6d0d Mon Sep 17 00:00:00 2001 From: canon <87342612+caton-hpg@users.noreply.github.com> Date: Thu, 25 Apr 2024 16:25:02 +0800 Subject: [PATCH] Authenticate for scan (#133) * authenticate for scan * fix code --- examples/StorageClientExample.cpp | 113 ++++--- include/nebula/sclient/StorageClient.h | 16 +- src/interface/common.thrift | 1 + src/interface/gen-cpp2/common_data.cpp | 6 +- src/interface/gen-cpp2/common_data.h | 2 +- src/interface/gen-cpp2/common_types.h | 3 +- src/interface/gen-cpp2/storage_data.cpp | 30 +- src/interface/gen-cpp2/storage_data.h | 4 +- .../gen-cpp2/storage_for_each_field.h | 6 + src/interface/gen-cpp2/storage_metadata.cpp | 6 + src/interface/gen-cpp2/storage_types.cpp | 76 ++++- src/interface/gen-cpp2/storage_types.h | 290 +++++++++++++++++- src/interface/gen-cpp2/storage_types.tcc | 216 +++++++++++++ .../storage_visit_by_thrift_field_metadata.h | 12 + src/interface/storage.thrift | 6 + src/sclient/StorageClient.cpp | 16 +- 16 files changed, 731 insertions(+), 72 deletions(-) diff --git a/examples/StorageClientExample.cpp b/examples/StorageClientExample.cpp index ae77caf0..5cd3b2dc 100644 --- a/examples/StorageClientExample.cpp +++ b/examples/StorageClientExample.cpp @@ -3,57 +3,80 @@ * This source code is licensed under Apache 2.0 License. */ +#include +#include +#include + #include #include #include #include -#include -#include -#include #include "common/graph/Response.h" +void scanEdge(nebula::StorageClient& c, + bool auth = false, + const std::string& username = "", + const std::string& password = "") { + auto scanEdgeIter = c.scanEdgeWithPart("nba", + 1, + "like", + std::vector{"likeness"}, + 10, + 0, + std::numeric_limits::max(), + "", + true, + true, + auth, + username, + password); + std::cout << "scan edge..." << std::endl; + while (scanEdgeIter.hasNext()) { + std::cout << "-------------------------" << std::endl; + std::pair res = scanEdgeIter.next(); + std::cout << res.first << std::endl; + std::cout << res.second << std::endl; + std::cout << "+++++++++++++++++++++++++" << std::endl; + } +} + +void scanVertex(nebula::StorageClient& c, + bool auth = false, + const std::string& username = "", + const std::string& password = "") { + nebula::ScanVertexIter scanVertexIter = + c.scanVertexWithPart("nba", + 1, + {{"player", std::vector{"name"}}}, + 10, + 0, + std::numeric_limits::max(), + "", + true, + true, + auth, + username, + password); + std::cout << "scan vertex..." << std::endl; + while (scanVertexIter.hasNext()) { + std::cout << "-------------------------" << std::endl; + std::pair res = scanVertexIter.next(); + std::cout << res.first << std::endl; + std::cout << res.second << std::endl; + std::cout << "+++++++++++++++++++++++++" << std::endl; + } +} + int main(int argc, char* argv[]) { - nebula::init(&argc, &argv); - - nebula::StorageClient c({"127.0.0.1:9559"}); - - nebula::ScanEdgeIter scanEdgeIter = c.scanEdgeWithPart("nba", - 1, - "like", - std::vector{"likeness"}, - 10, - 0, - std::numeric_limits::max(), - "", - true, - true); - std::cout << "scan edge..." << std::endl; - while (scanEdgeIter.hasNext()) { - std::cout << "-------------------------" << std::endl; - std::pair res = scanEdgeIter.next(); - std::cout << res.first << std::endl; - std::cout << res.second << std::endl; - std::cout << "+++++++++++++++++++++++++" << std::endl; - } - - nebula::ScanVertexIter scanVertexIter = c.scanVertexWithPart("nba", - 1, - {{"player", std::vector{"name"}}}, - 10, - 0, - std::numeric_limits::max(), - "", - true, - true); - std::cout << "scan vertex..." << std::endl; - while (scanVertexIter.hasNext()) { - std::cout << "-------------------------" << std::endl; - std::pair res = scanVertexIter.next(); - std::cout << res.first << std::endl; - std::cout << res.second << std::endl; - std::cout << "+++++++++++++++++++++++++" << std::endl; - } - - return 0; + nebula::init(&argc, &argv); + nebula::StorageClient c({"127.0.0.1:9559"}); + + scanVertex(c); + scanEdge(c); + + scanVertex(c, true, "root", "nebula"); + scanEdge(c, true, "root", "nebula"); + + return 0; } diff --git a/include/nebula/sclient/StorageClient.h b/include/nebula/sclient/StorageClient.h index 5916470d..d80be7ce 100644 --- a/include/nebula/sclient/StorageClient.h +++ b/include/nebula/sclient/StorageClient.h @@ -13,12 +13,12 @@ #include "ScanEdgeIter.h" #include "common/datatypes/HostAddr.h" +#include "common/graph/Response.h" #include "common/thrift/ThriftTypes.h" #include "nebula/mclient/MetaClient.h" #include "nebula/sclient/SConfig.h" #include "nebula/sclient/ScanEdgeIter.h" #include "nebula/sclient/ScanVertexIter.h" -#include "common/graph/Response.h" namespace folly { class IOThreadPoolExecutor; @@ -69,7 +69,7 @@ class StorageClient { ~StorageClient(); - std::vector getParts(const std::string& spaceName); // plato needed + std::vector getParts(const std::string& spaceName); ScanEdgeIter scanEdgeWithPart(std::string spaceName, int32_t partID, @@ -80,7 +80,10 @@ class StorageClient { int64_t endTime = DEFAULT_END_TIME, std::string filter = "", bool onlyLatestVersion = false, - bool enableReadFromFollower = true); // plato needed + bool enableReadFromFollower = true, + bool needAuth = false, + const std::string& username = "", + const std::string& password = ""); ScanVertexIter scanVertexWithPart( std::string spaceName, @@ -92,7 +95,10 @@ class StorageClient { int64_t endTime = DEFAULT_END_TIME, std::string filter = "", bool onlyLatestVersion = false, - bool enableReadFromFollower = true); // plato needed + bool enableReadFromFollower = true, + bool needAuth = false, + const std::string& username = "", + const std::string& password = ""); MetaClient* getMetaClient() { return mClient_.get(); @@ -106,7 +112,7 @@ class StorageClient { const storage::cpp2::ScanVertexRequest& req); template - void getResponse(std::pair&& request, + void getResponse(std::pair&& request, RemoteFunc&& remoteFunc, folly::Promise> pro); diff --git a/src/interface/common.thrift b/src/interface/common.thrift index 7a87b1fb..722d541f 100644 --- a/src/interface/common.thrift +++ b/src/interface/common.thrift @@ -400,6 +400,7 @@ enum ErrorCode { E_PRIVILEGE_NOT_EXIST = -2037, // remove un-exist privilege[only ent] E_PRIVILEGE_NEED_BASIC_ROLE = -2038, // only basic role support tag/edge privilege[only ent] E_PRIVILEGE_ACTION_INVALID = -2039, // only add and drop now.[only ent] + E_STORAGE_ENABLE_AUTH = -2058, // Storage has enable auth, but the request disable auth.[only ent] // Admin Failure E_SNAPSHOT_FAILURE = -2040, // Failed to generate a snapshot diff --git a/src/interface/gen-cpp2/common_data.cpp b/src/interface/gen-cpp2/common_data.cpp index 2f2a4f08..7bc0a79e 100644 --- a/src/interface/gen-cpp2/common_data.cpp +++ b/src/interface/gen-cpp2/common_data.cpp @@ -72,7 +72,7 @@ const std::array TEnumDataStorage<::nebula::cpp2::Proper "GEOGRAPHY", }}; -const std::array<::nebula::cpp2::ErrorCode, 196> TEnumDataStorage<::nebula::cpp2::ErrorCode>::values = {{ +const std::array<::nebula::cpp2::ErrorCode, 197> TEnumDataStorage<::nebula::cpp2::ErrorCode>::values = {{ type::SUCCEEDED, type::E_DISCONNECTED, type::E_FAIL_TO_CONNECT, @@ -157,6 +157,7 @@ const std::array<::nebula::cpp2::ErrorCode, 196> TEnumDataStorage<::nebula::cpp2 type::E_PRIVILEGE_NOT_EXIST, type::E_PRIVILEGE_NEED_BASIC_ROLE, type::E_PRIVILEGE_ACTION_INVALID, + type::E_STORAGE_ENABLE_AUTH, type::E_SNAPSHOT_FAILURE, type::E_SNAPSHOT_RUNNING_JOBS, type::E_SNAPSHOT_NOT_FOUND, @@ -270,7 +271,7 @@ const std::array<::nebula::cpp2::ErrorCode, 196> TEnumDataStorage<::nebula::cpp2 type::E_STORAGE_MEMORY_EXCEEDED, type::E_UNKNOWN, }}; -const std::array TEnumDataStorage<::nebula::cpp2::ErrorCode>::names = {{ +const std::array TEnumDataStorage<::nebula::cpp2::ErrorCode>::names = {{ "SUCCEEDED", "E_DISCONNECTED", "E_FAIL_TO_CONNECT", @@ -355,6 +356,7 @@ const std::array TEnumDataStorage<::nebula::cpp2::Error "E_PRIVILEGE_NOT_EXIST", "E_PRIVILEGE_NEED_BASIC_ROLE", "E_PRIVILEGE_ACTION_INVALID", + "E_STORAGE_ENABLE_AUTH", "E_SNAPSHOT_FAILURE", "E_SNAPSHOT_RUNNING_JOBS", "E_SNAPSHOT_NOT_FOUND", diff --git a/src/interface/gen-cpp2/common_data.h b/src/interface/gen-cpp2/common_data.h index d0afb32c..969b7085 100644 --- a/src/interface/gen-cpp2/common_data.h +++ b/src/interface/gen-cpp2/common_data.h @@ -28,7 +28,7 @@ template <> struct TEnumDataStorage<::nebula::cpp2::PropertyType> { template <> struct TEnumDataStorage<::nebula::cpp2::ErrorCode> { using type = ::nebula::cpp2::ErrorCode; - static constexpr const std::size_t size = 196; + static constexpr const std::size_t size = 197; static const std::array values; static const std::array names; }; diff --git a/src/interface/gen-cpp2/common_types.h b/src/interface/gen-cpp2/common_types.h index ce2e0658..f0043413 100644 --- a/src/interface/gen-cpp2/common_types.h +++ b/src/interface/gen-cpp2/common_types.h @@ -568,6 +568,7 @@ enum class ErrorCode { E_PRIVILEGE_NOT_EXIST = -2037, E_PRIVILEGE_NEED_BASIC_ROLE = -2038, E_PRIVILEGE_ACTION_INVALID = -2039, + E_STORAGE_ENABLE_AUTH = -2058, E_SNAPSHOT_FAILURE = -2040, E_SNAPSHOT_RUNNING_JOBS = -2056, E_SNAPSHOT_NOT_FOUND = -2057, @@ -745,7 +746,7 @@ template <> struct TEnumDataStorage<::nebula::cpp2::ErrorCode>; template <> struct TEnumTraits<::nebula::cpp2::ErrorCode> { using type = ::nebula::cpp2::ErrorCode; - static constexpr std::size_t const size = 196; + static constexpr std::size_t const size = 197; static folly::Range const values; static folly::Range const names; diff --git a/src/interface/gen-cpp2/storage_data.cpp b/src/interface/gen-cpp2/storage_data.cpp index d3bab567..9e9bad77 100644 --- a/src/interface/gen-cpp2/storage_data.cpp +++ b/src/interface/gen-cpp2/storage_data.cpp @@ -776,7 +776,7 @@ const std::array TStructDataStorage<::nebula::storage::cpp2: TType::T_STRING, }}; -const std::array TStructDataStorage<::nebula::storage::cpp2::ScanVertexRequest>::fields_names = {{ +const std::array TStructDataStorage<::nebula::storage::cpp2::ScanVertexRequest>::fields_names = {{ "space_id", "parts", "return_columns", @@ -787,8 +787,11 @@ const std::array TStructDataStorage<::nebula::storage::c "only_latest_version", "enable_read_from_follower", "common", + "username", + "password", + "need_authenticate", }}; -const std::array TStructDataStorage<::nebula::storage::cpp2::ScanVertexRequest>::fields_ids = {{ +const std::array TStructDataStorage<::nebula::storage::cpp2::ScanVertexRequest>::fields_ids = {{ 1, 2, 3, @@ -799,8 +802,11 @@ const std::array TStructDataStorage<::nebula::storage::cpp2::ScanVe 8, 9, 10, + 11, + 12, + 13, }}; -const std::array TStructDataStorage<::nebula::storage::cpp2::ScanVertexRequest>::fields_types = {{ +const std::array TStructDataStorage<::nebula::storage::cpp2::ScanVertexRequest>::fields_types = {{ TType::T_I32, TType::T_MAP, TType::T_LIST, @@ -811,9 +817,12 @@ const std::array TStructDataStorage<::nebula::storage::cpp2 TType::T_BOOL, TType::T_BOOL, TType::T_STRUCT, + TType::T_STRING, + TType::T_STRING, + TType::T_BOOL, }}; -const std::array TStructDataStorage<::nebula::storage::cpp2::ScanEdgeRequest>::fields_names = {{ +const std::array TStructDataStorage<::nebula::storage::cpp2::ScanEdgeRequest>::fields_names = {{ "space_id", "parts", "return_columns", @@ -824,8 +833,11 @@ const std::array TStructDataStorage<::nebula::storage::c "only_latest_version", "enable_read_from_follower", "common", + "username", + "password", + "need_authenticate", }}; -const std::array TStructDataStorage<::nebula::storage::cpp2::ScanEdgeRequest>::fields_ids = {{ +const std::array TStructDataStorage<::nebula::storage::cpp2::ScanEdgeRequest>::fields_ids = {{ 1, 2, 3, @@ -836,8 +848,11 @@ const std::array TStructDataStorage<::nebula::storage::cpp2::ScanEd 8, 9, 10, + 11, + 12, + 13, }}; -const std::array TStructDataStorage<::nebula::storage::cpp2::ScanEdgeRequest>::fields_types = {{ +const std::array TStructDataStorage<::nebula::storage::cpp2::ScanEdgeRequest>::fields_types = {{ TType::T_I32, TType::T_MAP, TType::T_LIST, @@ -848,6 +863,9 @@ const std::array TStructDataStorage<::nebula::storage::cpp2 TType::T_BOOL, TType::T_BOOL, TType::T_STRUCT, + TType::T_STRING, + TType::T_STRING, + TType::T_BOOL, }}; const std::array TStructDataStorage<::nebula::storage::cpp2::ScanResponse>::fields_names = {{ diff --git a/src/interface/gen-cpp2/storage_data.h b/src/interface/gen-cpp2/storage_data.h index 821309c3..8603c6f3 100644 --- a/src/interface/gen-cpp2/storage_data.h +++ b/src/interface/gen-cpp2/storage_data.h @@ -321,14 +321,14 @@ template <> struct TStructDataStorage<::nebula::storage::cpp2::ScanCursor> { }; template <> struct TStructDataStorage<::nebula::storage::cpp2::ScanVertexRequest> { - static constexpr const std::size_t fields_size = 10; + static constexpr const std::size_t fields_size = 13; static const std::array fields_names; static const std::array fields_ids; static const std::array fields_types; }; template <> struct TStructDataStorage<::nebula::storage::cpp2::ScanEdgeRequest> { - static constexpr const std::size_t fields_size = 10; + static constexpr const std::size_t fields_size = 13; static const std::array fields_names; static const std::array fields_ids; static const std::array fields_types; diff --git a/src/interface/gen-cpp2/storage_for_each_field.h b/src/interface/gen-cpp2/storage_for_each_field.h index 15d43131..69dcfc72 100644 --- a/src/interface/gen-cpp2/storage_for_each_field.h +++ b/src/interface/gen-cpp2/storage_for_each_field.h @@ -446,6 +446,9 @@ struct ForEachField<::nebula::storage::cpp2::ScanVertexRequest> { f(7, static_cast(t).only_latest_version_ref()...); f(8, static_cast(t).enable_read_from_follower_ref()...); f(9, static_cast(t).common_ref()...); + f(10, static_cast(t).username_ref()...); + f(11, static_cast(t).password_ref()...); + f(12, static_cast(t).need_authenticate_ref()...); } }; @@ -463,6 +466,9 @@ struct ForEachField<::nebula::storage::cpp2::ScanEdgeRequest> { f(7, static_cast(t).only_latest_version_ref()...); f(8, static_cast(t).enable_read_from_follower_ref()...); f(9, static_cast(t).common_ref()...); + f(10, static_cast(t).username_ref()...); + f(11, static_cast(t).password_ref()...); + f(12, static_cast(t).need_authenticate_ref()...); } }; diff --git a/src/interface/gen-cpp2/storage_metadata.cpp b/src/interface/gen-cpp2/storage_metadata.cpp index dc609fc4..3aa0abc9 100644 --- a/src/interface/gen-cpp2/storage_metadata.cpp +++ b/src/interface/gen-cpp2/storage_metadata.cpp @@ -1143,6 +1143,9 @@ StructMetadata<::nebula::storage::cpp2::ScanVertexRequest>::gen(ThriftMetadata& std::make_tuple(8, "only_latest_version", false, std::make_unique(ThriftPrimitiveType::THRIFT_BOOL_TYPE), std::vector{}), std::make_tuple(9, "enable_read_from_follower", false, std::make_unique(ThriftPrimitiveType::THRIFT_BOOL_TYPE), std::vector{}), std::make_tuple(10, "common", true, std::make_unique>("storage.RequestCommon"), std::vector{}), + std::make_tuple(11, "username", true, std::make_unique(ThriftPrimitiveType::THRIFT_BINARY_TYPE), std::vector{}), + std::make_tuple(12, "password", true, std::make_unique(ThriftPrimitiveType::THRIFT_BINARY_TYPE), std::vector{}), + std::make_tuple(13, "need_authenticate", true, std::make_unique(ThriftPrimitiveType::THRIFT_BOOL_TYPE), std::vector{}), }; for (const auto& f : storage_ScanVertexRequest_fields) { ::apache::thrift::metadata::ThriftField field; @@ -1176,6 +1179,9 @@ StructMetadata<::nebula::storage::cpp2::ScanEdgeRequest>::gen(ThriftMetadata& me std::make_tuple(8, "only_latest_version", false, std::make_unique(ThriftPrimitiveType::THRIFT_BOOL_TYPE), std::vector{}), std::make_tuple(9, "enable_read_from_follower", false, std::make_unique(ThriftPrimitiveType::THRIFT_BOOL_TYPE), std::vector{}), std::make_tuple(10, "common", true, std::make_unique>("storage.RequestCommon"), std::vector{}), + std::make_tuple(11, "username", true, std::make_unique(ThriftPrimitiveType::THRIFT_BINARY_TYPE), std::vector{}), + std::make_tuple(12, "password", true, std::make_unique(ThriftPrimitiveType::THRIFT_BINARY_TYPE), std::vector{}), + std::make_tuple(13, "need_authenticate", true, std::make_unique(ThriftPrimitiveType::THRIFT_BOOL_TYPE), std::vector{}), }; for (const auto& f : storage_ScanEdgeRequest_fields) { ::apache::thrift::metadata::ThriftField field; diff --git a/src/interface/gen-cpp2/storage_types.cpp b/src/interface/gen-cpp2/storage_types.cpp index 67da5952..5b1eaea3 100644 --- a/src/interface/gen-cpp2/storage_types.cpp +++ b/src/interface/gen-cpp2/storage_types.cpp @@ -5460,14 +5460,15 @@ ScanVertexRequest::ScanVertexRequest() : start_time(0), end_time(0), only_latest_version(false), - enable_read_from_follower(true) {} + enable_read_from_follower(true), + need_authenticate(0) {} THRIFT_IGNORE_ISSET_USE_WARNING_END ScanVertexRequest::~ScanVertexRequest() {} THRIFT_IGNORE_ISSET_USE_WARNING_BEGIN -ScanVertexRequest::ScanVertexRequest(apache::thrift::FragileConstructor, ::nebula::cpp2::GraphSpaceID space_id__arg, std::unordered_map< ::nebula::cpp2::PartitionID, ::nebula::storage::cpp2::ScanCursor> parts__arg, ::std::vector< ::nebula::storage::cpp2::VertexProp> return_columns__arg, int64_t limit__arg, int64_t start_time__arg, int64_t end_time__arg, ::std::string filter__arg, bool only_latest_version__arg, bool enable_read_from_follower__arg, ::nebula::storage::cpp2::RequestCommon common__arg) : +ScanVertexRequest::ScanVertexRequest(apache::thrift::FragileConstructor, ::nebula::cpp2::GraphSpaceID space_id__arg, std::unordered_map< ::nebula::cpp2::PartitionID, ::nebula::storage::cpp2::ScanCursor> parts__arg, ::std::vector< ::nebula::storage::cpp2::VertexProp> return_columns__arg, int64_t limit__arg, int64_t start_time__arg, int64_t end_time__arg, ::std::string filter__arg, bool only_latest_version__arg, bool enable_read_from_follower__arg, ::nebula::storage::cpp2::RequestCommon common__arg, ::std::string username__arg, ::std::string password__arg, bool need_authenticate__arg) : space_id(std::move(space_id__arg)), parts(std::move(parts__arg)), return_columns(std::move(return_columns__arg)), @@ -5477,7 +5478,10 @@ ScanVertexRequest::ScanVertexRequest(apache::thrift::FragileConstructor, ::nebu filter(std::move(filter__arg)), only_latest_version(std::move(only_latest_version__arg)), enable_read_from_follower(std::move(enable_read_from_follower__arg)), - common(std::move(common__arg)) { + common(std::move(common__arg)), + username(std::move(username__arg)), + password(std::move(password__arg)), + need_authenticate(std::move(need_authenticate__arg)) { __isset.space_id = true; __isset.parts = true; __isset.return_columns = true; @@ -5488,6 +5492,9 @@ ScanVertexRequest::ScanVertexRequest(apache::thrift::FragileConstructor, ::nebu __isset.only_latest_version = true; __isset.enable_read_from_follower = true; __isset.common = true; + __isset.username = true; + __isset.password = true; + __isset.need_authenticate = true; } THRIFT_IGNORE_ISSET_USE_WARNING_END void ScanVertexRequest::__clear() { @@ -5502,6 +5509,9 @@ void ScanVertexRequest::__clear() { only_latest_version = false; enable_read_from_follower = true; common.__clear(); + username = apache::thrift::StringTraits< std::string>::fromStringLiteral(""); + password = apache::thrift::StringTraits< std::string>::fromStringLiteral(""); + need_authenticate = 0; THRIFT_IGNORE_ISSET_USE_WARNING_BEGIN __isset = {}; THRIFT_IGNORE_ISSET_USE_WARNING_END @@ -5546,6 +5556,25 @@ bool ScanVertexRequest::operator==(const ScanVertexRequest& rhs) const { if (lhs.common_ref() != rhs.common_ref()) { return false; } + if (lhs.username_ref().has_value() != rhs.username_ref().has_value()) { + return false; + } + if (lhs.username_ref().has_value()) { + if (!apache::thrift::StringTraits::isEqual(lhs.username, rhs.username)) { + return false; + } + } + if (lhs.password_ref().has_value() != rhs.password_ref().has_value()) { + return false; + } + if (lhs.password_ref().has_value()) { + if (!apache::thrift::StringTraits::isEqual(lhs.password, rhs.password)) { + return false; + } + } + if (lhs.need_authenticate_ref() != rhs.need_authenticate_ref()) { + return false; + } return true; } @@ -5586,6 +5615,9 @@ void swap(ScanVertexRequest& a, ScanVertexRequest& b) { swap(a.only_latest_version_ref().value(), b.only_latest_version_ref().value()); swap(a.enable_read_from_follower_ref().value(), b.enable_read_from_follower_ref().value()); swap(a.common_ref().value_unchecked(), b.common_ref().value_unchecked()); + swap(a.username_ref().value_unchecked(), b.username_ref().value_unchecked()); + swap(a.password_ref().value_unchecked(), b.password_ref().value_unchecked()); + swap(a.need_authenticate_ref().value_unchecked(), b.need_authenticate_ref().value_unchecked()); THRIFT_IGNORE_ISSET_USE_WARNING_BEGIN swap(a.__isset, b.__isset); THRIFT_IGNORE_ISSET_USE_WARNING_END @@ -5670,14 +5702,15 @@ ScanEdgeRequest::ScanEdgeRequest() : start_time(0), end_time(0), only_latest_version(false), - enable_read_from_follower(true) {} + enable_read_from_follower(true), + need_authenticate(0) {} THRIFT_IGNORE_ISSET_USE_WARNING_END ScanEdgeRequest::~ScanEdgeRequest() {} THRIFT_IGNORE_ISSET_USE_WARNING_BEGIN -ScanEdgeRequest::ScanEdgeRequest(apache::thrift::FragileConstructor, ::nebula::cpp2::GraphSpaceID space_id__arg, std::unordered_map< ::nebula::cpp2::PartitionID, ::nebula::storage::cpp2::ScanCursor> parts__arg, ::std::vector< ::nebula::storage::cpp2::EdgeProp> return_columns__arg, int64_t limit__arg, int64_t start_time__arg, int64_t end_time__arg, ::std::string filter__arg, bool only_latest_version__arg, bool enable_read_from_follower__arg, ::nebula::storage::cpp2::RequestCommon common__arg) : +ScanEdgeRequest::ScanEdgeRequest(apache::thrift::FragileConstructor, ::nebula::cpp2::GraphSpaceID space_id__arg, std::unordered_map< ::nebula::cpp2::PartitionID, ::nebula::storage::cpp2::ScanCursor> parts__arg, ::std::vector< ::nebula::storage::cpp2::EdgeProp> return_columns__arg, int64_t limit__arg, int64_t start_time__arg, int64_t end_time__arg, ::std::string filter__arg, bool only_latest_version__arg, bool enable_read_from_follower__arg, ::nebula::storage::cpp2::RequestCommon common__arg, ::std::string username__arg, ::std::string password__arg, bool need_authenticate__arg) : space_id(std::move(space_id__arg)), parts(std::move(parts__arg)), return_columns(std::move(return_columns__arg)), @@ -5687,7 +5720,10 @@ ScanEdgeRequest::ScanEdgeRequest(apache::thrift::FragileConstructor, ::nebula:: filter(std::move(filter__arg)), only_latest_version(std::move(only_latest_version__arg)), enable_read_from_follower(std::move(enable_read_from_follower__arg)), - common(std::move(common__arg)) { + common(std::move(common__arg)), + username(std::move(username__arg)), + password(std::move(password__arg)), + need_authenticate(std::move(need_authenticate__arg)) { __isset.space_id = true; __isset.parts = true; __isset.return_columns = true; @@ -5698,6 +5734,9 @@ ScanEdgeRequest::ScanEdgeRequest(apache::thrift::FragileConstructor, ::nebula:: __isset.only_latest_version = true; __isset.enable_read_from_follower = true; __isset.common = true; + __isset.username = true; + __isset.password = true; + __isset.need_authenticate = true; } THRIFT_IGNORE_ISSET_USE_WARNING_END void ScanEdgeRequest::__clear() { @@ -5712,6 +5751,9 @@ void ScanEdgeRequest::__clear() { only_latest_version = false; enable_read_from_follower = true; common.__clear(); + username = apache::thrift::StringTraits< std::string>::fromStringLiteral(""); + password = apache::thrift::StringTraits< std::string>::fromStringLiteral(""); + need_authenticate = 0; THRIFT_IGNORE_ISSET_USE_WARNING_BEGIN __isset = {}; THRIFT_IGNORE_ISSET_USE_WARNING_END @@ -5756,6 +5798,25 @@ bool ScanEdgeRequest::operator==(const ScanEdgeRequest& rhs) const { if (lhs.common_ref() != rhs.common_ref()) { return false; } + if (lhs.username_ref().has_value() != rhs.username_ref().has_value()) { + return false; + } + if (lhs.username_ref().has_value()) { + if (!apache::thrift::StringTraits::isEqual(lhs.username, rhs.username)) { + return false; + } + } + if (lhs.password_ref().has_value() != rhs.password_ref().has_value()) { + return false; + } + if (lhs.password_ref().has_value()) { + if (!apache::thrift::StringTraits::isEqual(lhs.password, rhs.password)) { + return false; + } + } + if (lhs.need_authenticate_ref() != rhs.need_authenticate_ref()) { + return false; + } return true; } @@ -5796,6 +5857,9 @@ void swap(ScanEdgeRequest& a, ScanEdgeRequest& b) { swap(a.only_latest_version_ref().value(), b.only_latest_version_ref().value()); swap(a.enable_read_from_follower_ref().value(), b.enable_read_from_follower_ref().value()); swap(a.common_ref().value_unchecked(), b.common_ref().value_unchecked()); + swap(a.username_ref().value_unchecked(), b.username_ref().value_unchecked()); + swap(a.password_ref().value_unchecked(), b.password_ref().value_unchecked()); + swap(a.need_authenticate_ref().value_unchecked(), b.need_authenticate_ref().value_unchecked()); THRIFT_IGNORE_ISSET_USE_WARNING_BEGIN swap(a.__isset, b.__isset); THRIFT_IGNORE_ISSET_USE_WARNING_END diff --git a/src/interface/gen-cpp2/storage_types.h b/src/interface/gen-cpp2/storage_types.h index 0cf4ac45..74a4cdbe 100644 --- a/src/interface/gen-cpp2/storage_types.h +++ b/src/interface/gen-cpp2/storage_types.h @@ -171,6 +171,9 @@ struct filter; struct only_latest_version; struct enable_read_from_follower; struct common; +struct username; +struct password; +struct need_authenticate; struct space_id; struct parts; struct return_columns; @@ -181,6 +184,9 @@ struct filter; struct only_latest_version; struct enable_read_from_follower; struct common; +struct username; +struct password; +struct need_authenticate; struct result; struct props; struct cursors; @@ -888,6 +894,18 @@ APACHE_THRIFT_DEFINE_ACCESSOR(enable_read_from_follower); #define APACHE_THRIFT_ACCESSOR_common APACHE_THRIFT_DEFINE_ACCESSOR(common); #endif +#ifndef APACHE_THRIFT_ACCESSOR_username +#define APACHE_THRIFT_ACCESSOR_username +APACHE_THRIFT_DEFINE_ACCESSOR(username); +#endif +#ifndef APACHE_THRIFT_ACCESSOR_password +#define APACHE_THRIFT_ACCESSOR_password +APACHE_THRIFT_DEFINE_ACCESSOR(password); +#endif +#ifndef APACHE_THRIFT_ACCESSOR_need_authenticate +#define APACHE_THRIFT_ACCESSOR_need_authenticate +APACHE_THRIFT_DEFINE_ACCESSOR(need_authenticate); +#endif #ifndef APACHE_THRIFT_ACCESSOR_space_id #define APACHE_THRIFT_ACCESSOR_space_id APACHE_THRIFT_DEFINE_ACCESSOR(space_id); @@ -928,6 +946,18 @@ APACHE_THRIFT_DEFINE_ACCESSOR(enable_read_from_follower); #define APACHE_THRIFT_ACCESSOR_common APACHE_THRIFT_DEFINE_ACCESSOR(common); #endif +#ifndef APACHE_THRIFT_ACCESSOR_username +#define APACHE_THRIFT_ACCESSOR_username +APACHE_THRIFT_DEFINE_ACCESSOR(username); +#endif +#ifndef APACHE_THRIFT_ACCESSOR_password +#define APACHE_THRIFT_ACCESSOR_password +APACHE_THRIFT_DEFINE_ACCESSOR(password); +#endif +#ifndef APACHE_THRIFT_ACCESSOR_need_authenticate +#define APACHE_THRIFT_ACCESSOR_need_authenticate +APACHE_THRIFT_DEFINE_ACCESSOR(need_authenticate); +#endif #ifndef APACHE_THRIFT_ACCESSOR_result #define APACHE_THRIFT_ACCESSOR_result APACHE_THRIFT_DEFINE_ACCESSOR(result); @@ -10211,7 +10241,7 @@ THRIFT_IGNORE_ISSET_USE_WARNING_BEGIN // FragileConstructor for use in initialization lists only. [[deprecated("This constructor is deprecated")]] - ScanVertexRequest(apache::thrift::FragileConstructor, ::nebula::cpp2::GraphSpaceID space_id__arg, std::unordered_map< ::nebula::cpp2::PartitionID, ::nebula::storage::cpp2::ScanCursor> parts__arg, ::std::vector< ::nebula::storage::cpp2::VertexProp> return_columns__arg, int64_t limit__arg, int64_t start_time__arg, int64_t end_time__arg, ::std::string filter__arg, bool only_latest_version__arg, bool enable_read_from_follower__arg, ::nebula::storage::cpp2::RequestCommon common__arg); + ScanVertexRequest(apache::thrift::FragileConstructor, ::nebula::cpp2::GraphSpaceID space_id__arg, std::unordered_map< ::nebula::cpp2::PartitionID, ::nebula::storage::cpp2::ScanCursor> parts__arg, ::std::vector< ::nebula::storage::cpp2::VertexProp> return_columns__arg, int64_t limit__arg, int64_t start_time__arg, int64_t end_time__arg, ::std::string filter__arg, bool only_latest_version__arg, bool enable_read_from_follower__arg, ::nebula::storage::cpp2::RequestCommon common__arg, ::std::string username__arg, ::std::string password__arg, bool need_authenticate__arg); ScanVertexRequest(ScanVertexRequest&&) = default; @@ -10246,6 +10276,12 @@ THRIFT_IGNORE_ISSET_USE_WARNING_END bool enable_read_from_follower; private: ::nebula::storage::cpp2::RequestCommon common; + private: + ::std::string username; + private: + ::std::string password; + private: + bool need_authenticate; public: [[deprecated("__isset field is deprecated in Thrift struct. Use _ref() accessors instead.")]] @@ -10260,6 +10296,9 @@ THRIFT_IGNORE_ISSET_USE_WARNING_END bool only_latest_version; bool enable_read_from_follower; bool common; + bool username; + bool password; + bool need_authenticate; } __isset = {}; bool operator==(const ScanVertexRequest& rhs) const; #ifndef SWIG @@ -10500,6 +10539,72 @@ THRIFT_IGNORE_ISSET_USE_WARNING_BEGIN } THRIFT_IGNORE_ISSET_USE_WARNING_END +THRIFT_IGNORE_ISSET_USE_WARNING_BEGIN + template + FOLLY_ERASE ::apache::thrift::optional_field_ref username_ref() const& { + return {this->username, __isset.username}; + } + + template + FOLLY_ERASE ::apache::thrift::optional_field_ref username_ref() const&& { + return {std::move(this->username), __isset.username}; + } + + template + FOLLY_ERASE ::apache::thrift::optional_field_ref username_ref() & { + return {this->username, __isset.username}; + } + + template + FOLLY_ERASE ::apache::thrift::optional_field_ref username_ref() && { + return {std::move(this->username), __isset.username}; + } +THRIFT_IGNORE_ISSET_USE_WARNING_END + +THRIFT_IGNORE_ISSET_USE_WARNING_BEGIN + template + FOLLY_ERASE ::apache::thrift::optional_field_ref password_ref() const& { + return {this->password, __isset.password}; + } + + template + FOLLY_ERASE ::apache::thrift::optional_field_ref password_ref() const&& { + return {std::move(this->password), __isset.password}; + } + + template + FOLLY_ERASE ::apache::thrift::optional_field_ref password_ref() & { + return {this->password, __isset.password}; + } + + template + FOLLY_ERASE ::apache::thrift::optional_field_ref password_ref() && { + return {std::move(this->password), __isset.password}; + } +THRIFT_IGNORE_ISSET_USE_WARNING_END + +THRIFT_IGNORE_ISSET_USE_WARNING_BEGIN + template + FOLLY_ERASE ::apache::thrift::optional_field_ref need_authenticate_ref() const& { + return {this->need_authenticate, __isset.need_authenticate}; + } + + template + FOLLY_ERASE ::apache::thrift::optional_field_ref need_authenticate_ref() const&& { + return {std::move(this->need_authenticate), __isset.need_authenticate}; + } + + template + FOLLY_ERASE ::apache::thrift::optional_field_ref need_authenticate_ref() & { + return {this->need_authenticate, __isset.need_authenticate}; + } + + template + FOLLY_ERASE ::apache::thrift::optional_field_ref need_authenticate_ref() && { + return {std::move(this->need_authenticate), __isset.need_authenticate}; + } +THRIFT_IGNORE_ISSET_USE_WARNING_END + ::nebula::cpp2::GraphSpaceID get_space_id() const { return space_id; } @@ -10634,6 +10739,59 @@ THRIFT_IGNORE_ISSET_USE_WARNING_END return common; } + const ::std::string* get_username() const& { + return username_ref() ? std::addressof(username) : nullptr; + } + + ::std::string* get_username() & { + return username_ref() ? std::addressof(username) : nullptr; + } + ::std::string* get_username() && = delete; + + template + ::std::string& set_username(T_ScanVertexRequest_username_struct_setter&& username_) { + username = std::forward(username_); +THRIFT_IGNORE_ISSET_USE_WARNING_BEGIN + __isset.username = true; +THRIFT_IGNORE_ISSET_USE_WARNING_END + return username; + } + + const ::std::string* get_password() const& { + return password_ref() ? std::addressof(password) : nullptr; + } + + ::std::string* get_password() & { + return password_ref() ? std::addressof(password) : nullptr; + } + ::std::string* get_password() && = delete; + + template + ::std::string& set_password(T_ScanVertexRequest_password_struct_setter&& password_) { + password = std::forward(password_); +THRIFT_IGNORE_ISSET_USE_WARNING_BEGIN + __isset.password = true; +THRIFT_IGNORE_ISSET_USE_WARNING_END + return password; + } + + const bool* get_need_authenticate() const& { + return need_authenticate_ref() ? std::addressof(need_authenticate) : nullptr; + } + + bool* get_need_authenticate() & { + return need_authenticate_ref() ? std::addressof(need_authenticate) : nullptr; + } + bool* get_need_authenticate() && = delete; + + bool& set_need_authenticate(bool need_authenticate_) { + need_authenticate = need_authenticate_; +THRIFT_IGNORE_ISSET_USE_WARNING_BEGIN + __isset.need_authenticate = true; +THRIFT_IGNORE_ISSET_USE_WARNING_END + return need_authenticate; + } + template uint32_t read(Protocol_* iprot); template @@ -10682,7 +10840,7 @@ THRIFT_IGNORE_ISSET_USE_WARNING_BEGIN // FragileConstructor for use in initialization lists only. [[deprecated("This constructor is deprecated")]] - ScanEdgeRequest(apache::thrift::FragileConstructor, ::nebula::cpp2::GraphSpaceID space_id__arg, std::unordered_map< ::nebula::cpp2::PartitionID, ::nebula::storage::cpp2::ScanCursor> parts__arg, ::std::vector< ::nebula::storage::cpp2::EdgeProp> return_columns__arg, int64_t limit__arg, int64_t start_time__arg, int64_t end_time__arg, ::std::string filter__arg, bool only_latest_version__arg, bool enable_read_from_follower__arg, ::nebula::storage::cpp2::RequestCommon common__arg); + ScanEdgeRequest(apache::thrift::FragileConstructor, ::nebula::cpp2::GraphSpaceID space_id__arg, std::unordered_map< ::nebula::cpp2::PartitionID, ::nebula::storage::cpp2::ScanCursor> parts__arg, ::std::vector< ::nebula::storage::cpp2::EdgeProp> return_columns__arg, int64_t limit__arg, int64_t start_time__arg, int64_t end_time__arg, ::std::string filter__arg, bool only_latest_version__arg, bool enable_read_from_follower__arg, ::nebula::storage::cpp2::RequestCommon common__arg, ::std::string username__arg, ::std::string password__arg, bool need_authenticate__arg); ScanEdgeRequest(ScanEdgeRequest&&) = default; @@ -10717,6 +10875,12 @@ THRIFT_IGNORE_ISSET_USE_WARNING_END bool enable_read_from_follower; private: ::nebula::storage::cpp2::RequestCommon common; + private: + ::std::string username; + private: + ::std::string password; + private: + bool need_authenticate; public: [[deprecated("__isset field is deprecated in Thrift struct. Use _ref() accessors instead.")]] @@ -10731,6 +10895,9 @@ THRIFT_IGNORE_ISSET_USE_WARNING_END bool only_latest_version; bool enable_read_from_follower; bool common; + bool username; + bool password; + bool need_authenticate; } __isset = {}; bool operator==(const ScanEdgeRequest& rhs) const; #ifndef SWIG @@ -10971,6 +11138,72 @@ THRIFT_IGNORE_ISSET_USE_WARNING_BEGIN } THRIFT_IGNORE_ISSET_USE_WARNING_END +THRIFT_IGNORE_ISSET_USE_WARNING_BEGIN + template + FOLLY_ERASE ::apache::thrift::optional_field_ref username_ref() const& { + return {this->username, __isset.username}; + } + + template + FOLLY_ERASE ::apache::thrift::optional_field_ref username_ref() const&& { + return {std::move(this->username), __isset.username}; + } + + template + FOLLY_ERASE ::apache::thrift::optional_field_ref username_ref() & { + return {this->username, __isset.username}; + } + + template + FOLLY_ERASE ::apache::thrift::optional_field_ref username_ref() && { + return {std::move(this->username), __isset.username}; + } +THRIFT_IGNORE_ISSET_USE_WARNING_END + +THRIFT_IGNORE_ISSET_USE_WARNING_BEGIN + template + FOLLY_ERASE ::apache::thrift::optional_field_ref password_ref() const& { + return {this->password, __isset.password}; + } + + template + FOLLY_ERASE ::apache::thrift::optional_field_ref password_ref() const&& { + return {std::move(this->password), __isset.password}; + } + + template + FOLLY_ERASE ::apache::thrift::optional_field_ref password_ref() & { + return {this->password, __isset.password}; + } + + template + FOLLY_ERASE ::apache::thrift::optional_field_ref password_ref() && { + return {std::move(this->password), __isset.password}; + } +THRIFT_IGNORE_ISSET_USE_WARNING_END + +THRIFT_IGNORE_ISSET_USE_WARNING_BEGIN + template + FOLLY_ERASE ::apache::thrift::optional_field_ref need_authenticate_ref() const& { + return {this->need_authenticate, __isset.need_authenticate}; + } + + template + FOLLY_ERASE ::apache::thrift::optional_field_ref need_authenticate_ref() const&& { + return {std::move(this->need_authenticate), __isset.need_authenticate}; + } + + template + FOLLY_ERASE ::apache::thrift::optional_field_ref need_authenticate_ref() & { + return {this->need_authenticate, __isset.need_authenticate}; + } + + template + FOLLY_ERASE ::apache::thrift::optional_field_ref need_authenticate_ref() && { + return {std::move(this->need_authenticate), __isset.need_authenticate}; + } +THRIFT_IGNORE_ISSET_USE_WARNING_END + ::nebula::cpp2::GraphSpaceID get_space_id() const { return space_id; } @@ -11105,6 +11338,59 @@ THRIFT_IGNORE_ISSET_USE_WARNING_END return common; } + const ::std::string* get_username() const& { + return username_ref() ? std::addressof(username) : nullptr; + } + + ::std::string* get_username() & { + return username_ref() ? std::addressof(username) : nullptr; + } + ::std::string* get_username() && = delete; + + template + ::std::string& set_username(T_ScanEdgeRequest_username_struct_setter&& username_) { + username = std::forward(username_); +THRIFT_IGNORE_ISSET_USE_WARNING_BEGIN + __isset.username = true; +THRIFT_IGNORE_ISSET_USE_WARNING_END + return username; + } + + const ::std::string* get_password() const& { + return password_ref() ? std::addressof(password) : nullptr; + } + + ::std::string* get_password() & { + return password_ref() ? std::addressof(password) : nullptr; + } + ::std::string* get_password() && = delete; + + template + ::std::string& set_password(T_ScanEdgeRequest_password_struct_setter&& password_) { + password = std::forward(password_); +THRIFT_IGNORE_ISSET_USE_WARNING_BEGIN + __isset.password = true; +THRIFT_IGNORE_ISSET_USE_WARNING_END + return password; + } + + const bool* get_need_authenticate() const& { + return need_authenticate_ref() ? std::addressof(need_authenticate) : nullptr; + } + + bool* get_need_authenticate() & { + return need_authenticate_ref() ? std::addressof(need_authenticate) : nullptr; + } + bool* get_need_authenticate() && = delete; + + bool& set_need_authenticate(bool need_authenticate_) { + need_authenticate = need_authenticate_; +THRIFT_IGNORE_ISSET_USE_WARNING_BEGIN + __isset.need_authenticate = true; +THRIFT_IGNORE_ISSET_USE_WARNING_END + return need_authenticate; + } + template uint32_t read(Protocol_* iprot); template diff --git a/src/interface/gen-cpp2/storage_types.tcc b/src/interface/gen-cpp2/storage_types.tcc index 508305de..9f11a275 100644 --- a/src/interface/gen-cpp2/storage_types.tcc +++ b/src/interface/gen-cpp2/storage_types.tcc @@ -8705,6 +8705,51 @@ _readField_common: if (UNLIKELY(!_readState.advanceToNextField( iprot, 10, + 11, + apache::thrift::protocol::T_STRING))) { + goto _loop; + } +_readField_username: + { + ::apache::thrift::detail::pm::protocol_methods< ::apache::thrift::type_class::binary, ::std::string>::readWithContext(*iprot, this->username, _readState); + THRIFT_IGNORE_ISSET_USE_WARNING_BEGIN + this->__isset.username = true; + THRIFT_IGNORE_ISSET_USE_WARNING_END + } + + if (UNLIKELY(!_readState.advanceToNextField( + iprot, + 11, + 12, + apache::thrift::protocol::T_STRING))) { + goto _loop; + } +_readField_password: + { + ::apache::thrift::detail::pm::protocol_methods< ::apache::thrift::type_class::binary, ::std::string>::readWithContext(*iprot, this->password, _readState); + THRIFT_IGNORE_ISSET_USE_WARNING_BEGIN + this->__isset.password = true; + THRIFT_IGNORE_ISSET_USE_WARNING_END + } + + if (UNLIKELY(!_readState.advanceToNextField( + iprot, + 12, + 13, + apache::thrift::protocol::T_BOOL))) { + goto _loop; + } +_readField_need_authenticate: + { + ::apache::thrift::detail::pm::protocol_methods< ::apache::thrift::type_class::integral, bool>::readWithContext(*iprot, this->need_authenticate, _readState); + THRIFT_IGNORE_ISSET_USE_WARNING_BEGIN + this->__isset.need_authenticate = true; + THRIFT_IGNORE_ISSET_USE_WARNING_END + } + + if (UNLIKELY(!_readState.advanceToNextField( + iprot, + 13, 0, apache::thrift::protocol::T_STOP))) { goto _loop; @@ -8805,6 +8850,30 @@ _loop: goto _skip; } } + case 11: + { + if (LIKELY(_readState.isCompatibleWithType(iprot, apache::thrift::protocol::T_STRING))) { + goto _readField_username; + } else { + goto _skip; + } + } + case 12: + { + if (LIKELY(_readState.isCompatibleWithType(iprot, apache::thrift::protocol::T_STRING))) { + goto _readField_password; + } else { + goto _skip; + } + } + case 13: + { + if (LIKELY(_readState.isCompatibleWithType(iprot, apache::thrift::protocol::T_BOOL))) { + goto _readField_need_authenticate; + } else { + goto _skip; + } + } default: { _skip: @@ -8848,6 +8917,18 @@ uint32_t ScanVertexRequest::serializedSize(Protocol_ const* prot_) const { xfer += prot_->serializedFieldSize("common", apache::thrift::protocol::T_STRUCT, 10); xfer += ::apache::thrift::detail::pm::protocol_methods< ::apache::thrift::type_class::structure, ::nebula::storage::cpp2::RequestCommon>::serializedSize(*prot_, this->common); } + if (this->username_ref().has_value()) { + xfer += prot_->serializedFieldSize("username", apache::thrift::protocol::T_STRING, 11); + xfer += ::apache::thrift::detail::pm::protocol_methods< ::apache::thrift::type_class::binary, ::std::string>::serializedSize(*prot_, this->username); + } + if (this->password_ref().has_value()) { + xfer += prot_->serializedFieldSize("password", apache::thrift::protocol::T_STRING, 12); + xfer += ::apache::thrift::detail::pm::protocol_methods< ::apache::thrift::type_class::binary, ::std::string>::serializedSize(*prot_, this->password); + } + if (this->need_authenticate_ref().has_value()) { + xfer += prot_->serializedFieldSize("need_authenticate", apache::thrift::protocol::T_BOOL, 13); + xfer += ::apache::thrift::detail::pm::protocol_methods< ::apache::thrift::type_class::integral, bool>::serializedSize(*prot_, this->need_authenticate); + } xfer += prot_->serializedSizeStop(); return xfer; } @@ -8884,6 +8965,18 @@ uint32_t ScanVertexRequest::serializedSizeZC(Protocol_ const* prot_) const { xfer += prot_->serializedFieldSize("common", apache::thrift::protocol::T_STRUCT, 10); xfer += ::apache::thrift::detail::pm::protocol_methods< ::apache::thrift::type_class::structure, ::nebula::storage::cpp2::RequestCommon>::serializedSize(*prot_, this->common); } + if (this->username_ref().has_value()) { + xfer += prot_->serializedFieldSize("username", apache::thrift::protocol::T_STRING, 11); + xfer += ::apache::thrift::detail::pm::protocol_methods< ::apache::thrift::type_class::binary, ::std::string>::serializedSize(*prot_, this->username); + } + if (this->password_ref().has_value()) { + xfer += prot_->serializedFieldSize("password", apache::thrift::protocol::T_STRING, 12); + xfer += ::apache::thrift::detail::pm::protocol_methods< ::apache::thrift::type_class::binary, ::std::string>::serializedSize(*prot_, this->password); + } + if (this->need_authenticate_ref().has_value()) { + xfer += prot_->serializedFieldSize("need_authenticate", apache::thrift::protocol::T_BOOL, 13); + xfer += ::apache::thrift::detail::pm::protocol_methods< ::apache::thrift::type_class::integral, bool>::serializedSize(*prot_, this->need_authenticate); + } xfer += prot_->serializedSizeStop(); return xfer; } @@ -8930,6 +9023,21 @@ uint32_t ScanVertexRequest::write(Protocol_* prot_) const { xfer += ::apache::thrift::detail::pm::protocol_methods< ::apache::thrift::type_class::structure, ::nebula::storage::cpp2::RequestCommon>::write(*prot_, this->common); xfer += prot_->writeFieldEnd(); } + if (this->username_ref().has_value()) { + xfer += prot_->writeFieldBegin("username", apache::thrift::protocol::T_STRING, 11); + xfer += ::apache::thrift::detail::pm::protocol_methods< ::apache::thrift::type_class::binary, ::std::string>::write(*prot_, this->username); + xfer += prot_->writeFieldEnd(); + } + if (this->password_ref().has_value()) { + xfer += prot_->writeFieldBegin("password", apache::thrift::protocol::T_STRING, 12); + xfer += ::apache::thrift::detail::pm::protocol_methods< ::apache::thrift::type_class::binary, ::std::string>::write(*prot_, this->password); + xfer += prot_->writeFieldEnd(); + } + if (this->need_authenticate_ref().has_value()) { + xfer += prot_->writeFieldBegin("need_authenticate", apache::thrift::protocol::T_BOOL, 13); + xfer += ::apache::thrift::detail::pm::protocol_methods< ::apache::thrift::type_class::integral, bool>::write(*prot_, this->need_authenticate); + xfer += prot_->writeFieldEnd(); + } xfer += prot_->writeFieldStop(); xfer += prot_->writeStructEnd(); return xfer; @@ -9117,6 +9225,51 @@ _readField_common: if (UNLIKELY(!_readState.advanceToNextField( iprot, 10, + 11, + apache::thrift::protocol::T_STRING))) { + goto _loop; + } +_readField_username: + { + ::apache::thrift::detail::pm::protocol_methods< ::apache::thrift::type_class::binary, ::std::string>::readWithContext(*iprot, this->username, _readState); + THRIFT_IGNORE_ISSET_USE_WARNING_BEGIN + this->__isset.username = true; + THRIFT_IGNORE_ISSET_USE_WARNING_END + } + + if (UNLIKELY(!_readState.advanceToNextField( + iprot, + 11, + 12, + apache::thrift::protocol::T_STRING))) { + goto _loop; + } +_readField_password: + { + ::apache::thrift::detail::pm::protocol_methods< ::apache::thrift::type_class::binary, ::std::string>::readWithContext(*iprot, this->password, _readState); + THRIFT_IGNORE_ISSET_USE_WARNING_BEGIN + this->__isset.password = true; + THRIFT_IGNORE_ISSET_USE_WARNING_END + } + + if (UNLIKELY(!_readState.advanceToNextField( + iprot, + 12, + 13, + apache::thrift::protocol::T_BOOL))) { + goto _loop; + } +_readField_need_authenticate: + { + ::apache::thrift::detail::pm::protocol_methods< ::apache::thrift::type_class::integral, bool>::readWithContext(*iprot, this->need_authenticate, _readState); + THRIFT_IGNORE_ISSET_USE_WARNING_BEGIN + this->__isset.need_authenticate = true; + THRIFT_IGNORE_ISSET_USE_WARNING_END + } + + if (UNLIKELY(!_readState.advanceToNextField( + iprot, + 13, 0, apache::thrift::protocol::T_STOP))) { goto _loop; @@ -9217,6 +9370,30 @@ _loop: goto _skip; } } + case 11: + { + if (LIKELY(_readState.isCompatibleWithType(iprot, apache::thrift::protocol::T_STRING))) { + goto _readField_username; + } else { + goto _skip; + } + } + case 12: + { + if (LIKELY(_readState.isCompatibleWithType(iprot, apache::thrift::protocol::T_STRING))) { + goto _readField_password; + } else { + goto _skip; + } + } + case 13: + { + if (LIKELY(_readState.isCompatibleWithType(iprot, apache::thrift::protocol::T_BOOL))) { + goto _readField_need_authenticate; + } else { + goto _skip; + } + } default: { _skip: @@ -9260,6 +9437,18 @@ uint32_t ScanEdgeRequest::serializedSize(Protocol_ const* prot_) const { xfer += prot_->serializedFieldSize("common", apache::thrift::protocol::T_STRUCT, 10); xfer += ::apache::thrift::detail::pm::protocol_methods< ::apache::thrift::type_class::structure, ::nebula::storage::cpp2::RequestCommon>::serializedSize(*prot_, this->common); } + if (this->username_ref().has_value()) { + xfer += prot_->serializedFieldSize("username", apache::thrift::protocol::T_STRING, 11); + xfer += ::apache::thrift::detail::pm::protocol_methods< ::apache::thrift::type_class::binary, ::std::string>::serializedSize(*prot_, this->username); + } + if (this->password_ref().has_value()) { + xfer += prot_->serializedFieldSize("password", apache::thrift::protocol::T_STRING, 12); + xfer += ::apache::thrift::detail::pm::protocol_methods< ::apache::thrift::type_class::binary, ::std::string>::serializedSize(*prot_, this->password); + } + if (this->need_authenticate_ref().has_value()) { + xfer += prot_->serializedFieldSize("need_authenticate", apache::thrift::protocol::T_BOOL, 13); + xfer += ::apache::thrift::detail::pm::protocol_methods< ::apache::thrift::type_class::integral, bool>::serializedSize(*prot_, this->need_authenticate); + } xfer += prot_->serializedSizeStop(); return xfer; } @@ -9296,6 +9485,18 @@ uint32_t ScanEdgeRequest::serializedSizeZC(Protocol_ const* prot_) const { xfer += prot_->serializedFieldSize("common", apache::thrift::protocol::T_STRUCT, 10); xfer += ::apache::thrift::detail::pm::protocol_methods< ::apache::thrift::type_class::structure, ::nebula::storage::cpp2::RequestCommon>::serializedSize(*prot_, this->common); } + if (this->username_ref().has_value()) { + xfer += prot_->serializedFieldSize("username", apache::thrift::protocol::T_STRING, 11); + xfer += ::apache::thrift::detail::pm::protocol_methods< ::apache::thrift::type_class::binary, ::std::string>::serializedSize(*prot_, this->username); + } + if (this->password_ref().has_value()) { + xfer += prot_->serializedFieldSize("password", apache::thrift::protocol::T_STRING, 12); + xfer += ::apache::thrift::detail::pm::protocol_methods< ::apache::thrift::type_class::binary, ::std::string>::serializedSize(*prot_, this->password); + } + if (this->need_authenticate_ref().has_value()) { + xfer += prot_->serializedFieldSize("need_authenticate", apache::thrift::protocol::T_BOOL, 13); + xfer += ::apache::thrift::detail::pm::protocol_methods< ::apache::thrift::type_class::integral, bool>::serializedSize(*prot_, this->need_authenticate); + } xfer += prot_->serializedSizeStop(); return xfer; } @@ -9342,6 +9543,21 @@ uint32_t ScanEdgeRequest::write(Protocol_* prot_) const { xfer += ::apache::thrift::detail::pm::protocol_methods< ::apache::thrift::type_class::structure, ::nebula::storage::cpp2::RequestCommon>::write(*prot_, this->common); xfer += prot_->writeFieldEnd(); } + if (this->username_ref().has_value()) { + xfer += prot_->writeFieldBegin("username", apache::thrift::protocol::T_STRING, 11); + xfer += ::apache::thrift::detail::pm::protocol_methods< ::apache::thrift::type_class::binary, ::std::string>::write(*prot_, this->username); + xfer += prot_->writeFieldEnd(); + } + if (this->password_ref().has_value()) { + xfer += prot_->writeFieldBegin("password", apache::thrift::protocol::T_STRING, 12); + xfer += ::apache::thrift::detail::pm::protocol_methods< ::apache::thrift::type_class::binary, ::std::string>::write(*prot_, this->password); + xfer += prot_->writeFieldEnd(); + } + if (this->need_authenticate_ref().has_value()) { + xfer += prot_->writeFieldBegin("need_authenticate", apache::thrift::protocol::T_BOOL, 13); + xfer += ::apache::thrift::detail::pm::protocol_methods< ::apache::thrift::type_class::integral, bool>::write(*prot_, this->need_authenticate); + xfer += prot_->writeFieldEnd(); + } xfer += prot_->writeFieldStop(); xfer += prot_->writeStructEnd(); return xfer; diff --git a/src/interface/gen-cpp2/storage_visit_by_thrift_field_metadata.h b/src/interface/gen-cpp2/storage_visit_by_thrift_field_metadata.h index 53cdcce3..e4d286b9 100644 --- a/src/interface/gen-cpp2/storage_visit_by_thrift_field_metadata.h +++ b/src/interface/gen-cpp2/storage_visit_by_thrift_field_metadata.h @@ -759,6 +759,12 @@ struct VisitByThriftId<::nebula::storage::cpp2::ScanVertexRequest> { return f(8, static_cast(t).enable_read_from_follower_ref()); case 10: return f(9, static_cast(t).common_ref()); + case 11: + return f(10, static_cast(t).username_ref()); + case 12: + return f(11, static_cast(t).password_ref()); + case 13: + return f(12, static_cast(t).need_authenticate_ref()); default: throwInvalidThriftId(id, "::nebula::storage::cpp2::ScanVertexRequest"); } @@ -790,6 +796,12 @@ struct VisitByThriftId<::nebula::storage::cpp2::ScanEdgeRequest> { return f(8, static_cast(t).enable_read_from_follower_ref()); case 10: return f(9, static_cast(t).common_ref()); + case 11: + return f(10, static_cast(t).username_ref()); + case 12: + return f(11, static_cast(t).password_ref()); + case 13: + return f(12, static_cast(t).need_authenticate_ref()); default: throwInvalidThriftId(id, "::nebula::storage::cpp2::ScanEdgeRequest"); } diff --git a/src/interface/storage.thrift b/src/interface/storage.thrift index 2a95ba3e..f97c997a 100644 --- a/src/interface/storage.thrift +++ b/src/interface/storage.thrift @@ -609,6 +609,9 @@ struct ScanVertexRequest { // if set to false, forbid follower read 9: bool enable_read_from_follower = true, 10: optional RequestCommon common, + 11: optional binary username, + 12: optional binary password, + 13: optional bool need_authenticate, } struct ScanEdgeRequest { @@ -628,6 +631,9 @@ struct ScanEdgeRequest { // if set to false, forbid follower read 9: bool enable_read_from_follower = true, 10: optional RequestCommon common, + 11: optional binary username, + 12: optional binary password, + 13: optional bool need_authenticate, } struct ScanResponse { diff --git a/src/sclient/StorageClient.cpp b/src/sclient/StorageClient.cpp index bb9e7d52..d8b3bc5f 100644 --- a/src/sclient/StorageClient.cpp +++ b/src/sclient/StorageClient.cpp @@ -50,7 +50,10 @@ ScanEdgeIter StorageClient::scanEdgeWithPart(std::string spaceName, int64_t endTime, std::string filter, bool onlyLatestVersion, - bool enableReadFromFollower) { + bool enableReadFromFollower, + bool needAuth, + const std::string& username, + const std::string& password) { auto spaceIdResult = mClient_->getSpaceIdByNameFromCache(spaceName); if (!spaceIdResult.first) { return {nullptr, nullptr, false}; @@ -81,6 +84,9 @@ ScanEdgeIter StorageClient::scanEdgeWithPart(std::string spaceName, req->set_filter(filter); req->set_only_latest_version(onlyLatestVersion); req->set_enable_read_from_follower(enableReadFromFollower); + req->set_need_authenticate(needAuth); + req->set_username(username); + req->set_password(password); return {this, req}; } @@ -118,7 +124,10 @@ ScanVertexIter StorageClient::scanVertexWithPart( int64_t endTime, std::string filter, bool onlyLatestVersion, - bool enableReadFromFollower) { + bool enableReadFromFollower, + bool needAuth, + const std::string& username, + const std::string& password) { auto spaceIdResult = mClient_->getSpaceIdByNameFromCache(spaceName); if (!spaceIdResult.first) { return {nullptr, nullptr, false}; @@ -155,6 +164,9 @@ ScanVertexIter StorageClient::scanVertexWithPart( req->set_filter(filter); req->set_only_latest_version(onlyLatestVersion); req->set_enable_read_from_follower(enableReadFromFollower); + req->set_need_authenticate(needAuth); + req->set_username(username); + req->set_password(password); return {this, req}; }