summaryrefslogtreecommitdiffstats
path: root/yt/cpp/mapreduce/raw_client/raw_client.cpp
diff options
context:
space:
mode:
authorhiddenpath <[email protected]>2024-12-13 15:22:36 +0300
committerhiddenpath <[email protected]>2024-12-13 17:04:18 +0300
commit09c88b035d29fac5fd49de2fbc3c71e2d2a80754 (patch)
treea84b5b2de4dcdf85c3b22b9cac7e984aebb8b68d /yt/cpp/mapreduce/raw_client/raw_client.cpp
parent615edba542d9394b0eae47ef957ec2257549cfdd (diff)
yt/cpp/mapreduce: move Get, TryGet, Exists, MultisetAttributes to THttpRawClient
commit_hash:bd2228f98fa92de408ca850f9bc1608fdf99e7f5
Diffstat (limited to 'yt/cpp/mapreduce/raw_client/raw_client.cpp')
-rw-r--r--yt/cpp/mapreduce/raw_client/raw_client.cpp53
1 files changed, 53 insertions, 0 deletions
diff --git a/yt/cpp/mapreduce/raw_client/raw_client.cpp b/yt/cpp/mapreduce/raw_client/raw_client.cpp
index 9a8a9fca845..cc096823774 100644
--- a/yt/cpp/mapreduce/raw_client/raw_client.cpp
+++ b/yt/cpp/mapreduce/raw_client/raw_client.cpp
@@ -3,6 +3,7 @@
#include "rpc_parameters_serialization.h"
#include <yt/cpp/mapreduce/http/http.h>
+#include <yt/cpp/mapreduce/http/requests.h>
#include <yt/cpp/mapreduce/http/retry_request.h>
#include <library/cpp/yson/node/node_io.h>
@@ -15,6 +16,33 @@ THttpRawClient::THttpRawClient(const TClientContext& context)
: Context_(context)
{ }
+TNode THttpRawClient::Get(
+ TMutationId& mutationId,
+ const TTransactionId& transactionId,
+ const TYPath& path,
+ const TGetOptions& options)
+{
+ THttpHeader header("GET", "get");
+ header.MergeParameters(NRawClient::SerializeParamsForGet(transactionId, Context_.Config->Prefix, path, options));
+ return NodeFromYsonString(RequestWithoutRetry(Context_, mutationId, header).Response);
+}
+
+TNode THttpRawClient::TryGet(
+ TMutationId& mutationId,
+ const TTransactionId& transactionId,
+ const TYPath& path,
+ const TGetOptions& options)
+{
+ try {
+ return Get(mutationId, transactionId, path, options);
+ } catch (const TErrorResponse& error) {
+ if (!error.IsResolveError()) {
+ throw;
+ }
+ return TNode();
+ }
+}
+
void THttpRawClient::Set(
TMutationId& mutationId,
const TTransactionId& transactionId,
@@ -28,6 +56,31 @@ void THttpRawClient::Set(
RequestWithoutRetry(Context_, mutationId, header, body);
}
+bool THttpRawClient::Exists(
+ TMutationId& mutationId,
+ const TTransactionId& transactionId,
+ const TYPath& path,
+ const TExistsOptions& options)
+{
+ THttpHeader header("GET", "exists");
+ header.MergeParameters(NRawClient::SerializeParamsForExists(transactionId, Context_.Config->Prefix, path, options));
+ return ParseBoolFromResponse(RequestWithoutRetry(Context_, mutationId, header).Response);
+}
+
+void THttpRawClient::MultisetAttributes(
+ TMutationId& mutationId,
+ const TTransactionId& transactionId,
+ const TYPath& path,
+ const TNode::TMapType& value,
+ const TMultisetAttributesOptions& options)
+{
+ THttpHeader header("PUT", "api/v4/multiset_attributes", false);
+ header.AddMutationId();
+ header.MergeParameters(NRawClient::SerializeParamsForMultisetAttributes(transactionId, Context_.Config->Prefix, path, options));
+ auto body = NodeToYsonString(value);
+ RequestWithoutRetry(Context_, mutationId, header, body);
+}
+
////////////////////////////////////////////////////////////////////////////////
} // namespace NYT::NDetail