Skip to content

Commit 01a4fbc

Browse files
committed
Moved commit "Add permissions to ydb tools dump" from ydb repo
1 parent a21ef5d commit 01a4fbc

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

include/ydb-cpp-sdk/client/scheme/scheme.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ namespace Ydb {
66
class VirtualTimestamp;
77
namespace Scheme {
88
class Entry;
9+
class ModifyPermissionsRequest;
10+
class Permissions;
911
}
1012
}
1113

@@ -24,6 +26,8 @@ struct TPermissions {
2426
{}
2527
std::string Subject;
2628
std::vector<std::string> PermissionNames;
29+
30+
void SerializeTo(::Ydb::Scheme::Permissions& proto) const;
2731
};
2832

2933
enum class ESchemeEntryType : i32 {
@@ -77,6 +81,9 @@ struct TSchemeEntry {
7781
TSchemeEntry(const ::Ydb::Scheme::Entry& proto);
7882

7983
void Out(IOutputStream& out) const;
84+
85+
// Fills ModifyPermissionsRequest proto from this entry
86+
void SerializeTo(::Ydb::Scheme::ModifyPermissionsRequest& request) const;
8087
};
8188

8289
////////////////////////////////////////////////////////////////////////////////

src/client/scheme/scheme.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ namespace NScheme {
1717
using namespace NThreading;
1818
using namespace Ydb::Scheme;
1919

20+
void TPermissions::SerializeTo(::Ydb::Scheme::Permissions& proto) const {
21+
proto.set_subject(Subject);
22+
for (const auto& name : PermissionNames) {
23+
*proto.mutable_permission_names()->Add() = name;
24+
}
25+
}
26+
2027
TVirtualTimestamp::TVirtualTimestamp(uint64_t planStep, uint64_t txId)
2128
: PlanStep(planStep)
2229
, TxId(txId)
@@ -120,6 +127,13 @@ void TSchemeEntry::Out(IOutputStream& out) const {
120127
<< " }";
121128
}
122129

130+
void TSchemeEntry::SerializeTo(::Ydb::Scheme::ModifyPermissionsRequest& request) const {
131+
request.mutable_actions()->Add()->set_change_owner(Owner);
132+
for (const auto& permission : Permissions) {
133+
permission.SerializeTo(*request.mutable_actions()->Add()->mutable_set());
134+
}
135+
}
136+
123137
class TSchemeClient::TImpl : public TClientImplCommon<TSchemeClient::TImpl> {
124138
public:
125139
TImpl(std::shared_ptr<TGRpcConnectionsImpl>&& connections, const TCommonClientSettings& settings)

0 commit comments

Comments
 (0)