aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAleksandr Gaev <krock21rus@gmail.com>2023-12-07 20:11:45 +0300
committerrobot-piglet <robot-piglet@yandex-team.com>2023-12-07 21:09:44 +0300
commita29b3b6dfb2483d132bc46f4948b186b2e781fb2 (patch)
treec73e5cb9c67fcca077bfcc4e3bd9e998a1950c3e
parent36105b0b71b37cd6ed00e664cecd5dc1f329d5fa (diff)
downloadydb-a29b3b6dfb2483d132bc46f4948b186b2e781fb2.tar.gz
Add access control to query tracker and queries APIs #175
Implementing access control for query tracker according to #175 proposal I hereby agree to the terms of the CLA available at: https://yandex.ru/legal/cla/?lang=en --- Pull Request resolved: https://github.com/ytsaurus/ytsaurus/pull/190
-rw-r--r--yt/yt/client/api/query_tracker_client.cpp3
-rw-r--r--yt/yt/client/api/query_tracker_client.h3
-rw-r--r--yt/yt/client/driver/query_commands.cpp14
3 files changed, 19 insertions, 1 deletions
diff --git a/yt/yt/client/api/query_tracker_client.cpp b/yt/yt/client/api/query_tracker_client.cpp
index ea77e44726..48f8ea8d22 100644
--- a/yt/yt/client/api/query_tracker_client.cpp
+++ b/yt/yt/client/api/query_tracker_client.cpp
@@ -24,7 +24,7 @@ void TQueryFile::Register(TRegistrar registrar)
void Serialize(const TQuery& query, NYson::IYsonConsumer* consumer)
{
- static_assert(pfr::tuple_size<TQuery>::value == 14);
+ static_assert(pfr::tuple_size<TQuery>::value == 15);
BuildYsonFluently(consumer)
.BeginMap()
.OptionalItem("id", query.Id)
@@ -35,6 +35,7 @@ void Serialize(const TQuery& query, NYson::IYsonConsumer* consumer)
.OptionalItem("finish_time", query.FinishTime)
.OptionalItem("settings", query.Settings)
.OptionalItem("user", query.User)
+ .OptionalItem("access_control_object", query.AccessControlObject)
.OptionalItem("state", query.State)
.OptionalItem("result_count", query.ResultCount)
.OptionalItem("progress", query.Progress)
diff --git a/yt/yt/client/api/query_tracker_client.h b/yt/yt/client/api/query_tracker_client.h
index 1850c30711..a0a7a99216 100644
--- a/yt/yt/client/api/query_tracker_client.h
+++ b/yt/yt/client/api/query_tracker_client.h
@@ -42,6 +42,7 @@ struct TStartQueryOptions
bool Draft = false;
NYTree::IMapNodePtr Annotations;
std::vector<TQueryFilePtr> Files;
+ std::optional<TString> AccessControlObject;
};
struct TAbortQueryOptions
@@ -101,6 +102,7 @@ struct TQuery
std::optional<TInstant> FinishTime;
NYson::TYsonString Settings;
std::optional<TString> User;
+ std::optional<TString> AccessControlObject;
std::optional<NQueryTrackerClient::EQueryState> State;
std::optional<i64> ResultCount;
NYson::TYsonString Progress;
@@ -135,6 +137,7 @@ struct TAlterQueryOptions
, public TQueryTrackerOptions
{
NYTree::IMapNodePtr Annotations;
+ std::optional<TString> AccessControlObject;
};
////////////////////////////////////////////////////////////////////////////////
diff --git a/yt/yt/client/driver/query_commands.cpp b/yt/yt/client/driver/query_commands.cpp
index 419871d5c7..bae75fc2ae 100644
--- a/yt/yt/client/driver/query_commands.cpp
+++ b/yt/yt/client/driver/query_commands.cpp
@@ -62,6 +62,13 @@ void TStartQueryCommand::Register(TRegistrar registrar)
return command->Options.Annotations;
})
.Optional(/*init*/ false);
+
+ registrar.ParameterWithUniversalAccessor<std::optional<TString>>(
+ "access_control_object",
+ [] (TThis* command) -> auto& {
+ return command->Options.AccessControlObject;
+ })
+ .Optional(/*init*/ false);
}
void TStartQueryCommand::DoExecute(ICommandContextPtr context)
@@ -316,6 +323,13 @@ void TAlterQueryCommand::Register(TRegistrar registrar)
return command->Options.Annotations;
})
.Optional(/*init*/ false);
+
+ registrar.ParameterWithUniversalAccessor<std::optional<TString>>(
+ "access_control_object",
+ [] (TThis* command) -> auto& {
+ return command->Options.AccessControlObject;
+ })
+ .Optional(/*init*/ false);
}
void TAlterQueryCommand::DoExecute(ICommandContextPtr context)