14
14
#include < aos/iam/certhandler.hpp>
15
15
16
16
#include < pbconvert/common.hpp>
17
+ #include < pbconvert/iam.hpp>
17
18
18
19
#include " logger/logmodule.hpp"
19
20
#include " protectedmessagehandler.hpp"
20
- #include " utils/convert.hpp"
21
21
22
22
/* **********************************************************************************************************************
23
23
* Constants
@@ -101,7 +101,7 @@ grpc::Status ProtectedMessageHandler::PauseNode([[maybe_unused]] grpc::ServerCon
101
101
if (auto status = RequestWithRetry ([&]() {
102
102
auto handler = GetNodeController ()->GetNodeStreamHandler (nodeID);
103
103
if (!handler) {
104
- return utils ::ConvertAosErrorToGrpcStatus (cStreamNotFoundError);
104
+ return aos::common::pbconvert ::ConvertAosErrorToGrpcStatus (cStreamNotFoundError);
105
105
}
106
106
107
107
return handler->PauseNode (request, response, cDefaultTimeout);
@@ -131,7 +131,7 @@ grpc::Status ProtectedMessageHandler::ResumeNode([[maybe_unused]] grpc::ServerCo
131
131
if (auto status = RequestWithRetry ([&]() {
132
132
auto handler = GetNodeController ()->GetNodeStreamHandler (nodeID);
133
133
if (!handler) {
134
- return utils ::ConvertAosErrorToGrpcStatus (cStreamNotFoundError);
134
+ return aos::common::pbconvert ::ConvertAosErrorToGrpcStatus (cStreamNotFoundError);
135
135
}
136
136
137
137
return handler->ResumeNode (request, response, cDefaultTimeout);
@@ -165,7 +165,7 @@ grpc::Status ProtectedMessageHandler::GetCertTypes([[maybe_unused]] grpc::Server
165
165
return RequestWithRetry ([&]() {
166
166
auto handler = GetNodeController ()->GetNodeStreamHandler (nodeID);
167
167
if (!handler) {
168
- return utils ::ConvertAosErrorToGrpcStatus (cStreamNotFoundError);
168
+ return aos::common::pbconvert ::ConvertAosErrorToGrpcStatus (cStreamNotFoundError);
169
169
}
170
170
171
171
return handler->GetCertTypes (request, response, cDefaultTimeout);
@@ -179,10 +179,12 @@ grpc::Status ProtectedMessageHandler::GetCertTypes([[maybe_unused]] grpc::Server
179
179
if (!err.IsNone ()) {
180
180
LOG_ERR () << " Get certificate types error: " << AOS_ERROR_WRAP (err);
181
181
182
- return utils ::ConvertAosErrorToGrpcStatus (cStreamNotFoundError);
182
+ return aos::common::pbconvert ::ConvertAosErrorToGrpcStatus (cStreamNotFoundError);
183
183
}
184
184
185
- utils::ConvertToProto (certTypes, *response->mutable_types ());
185
+ for (const auto & type : certTypes) {
186
+ response->add_types (type.CStr ());
187
+ }
186
188
187
189
return grpc::Status::OK;
188
190
}
@@ -198,7 +200,7 @@ grpc::Status ProtectedMessageHandler::StartProvisioning([[maybe_unused]] grpc::S
198
200
return RequestWithRetry ([&]() {
199
201
auto handler = GetNodeController ()->GetNodeStreamHandler (nodeID);
200
202
if (!handler) {
201
- return utils ::ConvertAosErrorToGrpcStatus (cStreamNotFoundError);
203
+ return aos::common::pbconvert ::ConvertAosErrorToGrpcStatus (cStreamNotFoundError);
202
204
}
203
205
204
206
return handler->StartProvisioning (request, response, cProvisioningTimeout);
@@ -225,7 +227,7 @@ grpc::Status ProtectedMessageHandler::FinishProvisioning([[maybe_unused]] grpc::
225
227
if (auto status = RequestWithRetry ([&]() {
226
228
auto handler = GetNodeController ()->GetNodeStreamHandler (nodeID);
227
229
if (!handler) {
228
- return utils ::ConvertAosErrorToGrpcStatus (cStreamNotFoundError);
230
+ return aos::common::pbconvert ::ConvertAosErrorToGrpcStatus (cStreamNotFoundError);
229
231
}
230
232
231
233
return handler->FinishProvisioning (request, response, cProvisioningTimeout);
@@ -263,7 +265,7 @@ grpc::Status ProtectedMessageHandler::Deprovision([[maybe_unused]] grpc::ServerC
263
265
if (auto status = RequestWithRetry ([&]() {
264
266
auto handler = GetNodeController ()->GetNodeStreamHandler (nodeID);
265
267
if (!handler) {
266
- return utils ::ConvertAosErrorToGrpcStatus (cStreamNotFoundError);
268
+ return aos::common::pbconvert ::ConvertAosErrorToGrpcStatus (cStreamNotFoundError);
267
269
}
268
270
269
271
return handler->Deprovision (request, response, cProvisioningTimeout);
@@ -331,7 +333,7 @@ grpc::Status ProtectedMessageHandler::CreateKey([[maybe_unused]] grpc::ServerCon
331
333
return RequestWithRetry ([&]() {
332
334
auto handler = GetNodeController ()->GetNodeStreamHandler (nodeID);
333
335
if (!handler) {
334
- return utils ::ConvertAosErrorToGrpcStatus (cStreamNotFoundError);
336
+ return aos::common::pbconvert ::ConvertAosErrorToGrpcStatus (cStreamNotFoundError);
335
337
}
336
338
337
339
iamproto::CreateKeyRequest keyRequest = *request;
@@ -375,7 +377,7 @@ grpc::Status ProtectedMessageHandler::ApplyCert([[maybe_unused]] grpc::ServerCon
375
377
return RequestWithRetry ([&]() {
376
378
auto handler = GetNodeController ()->GetNodeStreamHandler (nodeID);
377
379
if (!handler) {
378
- return utils ::ConvertAosErrorToGrpcStatus (cStreamNotFoundError);
380
+ return aos::common::pbconvert ::ConvertAosErrorToGrpcStatus (cStreamNotFoundError);
379
381
}
380
382
381
383
return handler->ApplyCert (request, response, cDefaultTimeout);
@@ -397,7 +399,7 @@ grpc::Status ProtectedMessageHandler::ApplyCert([[maybe_unused]] grpc::ServerCon
397
399
aos::Error err;
398
400
std::string serial;
399
401
400
- Tie (serial, err) = utils ::ConvertSerialToProto (certInfo.mSerial );
402
+ Tie (serial, err) = aos::common::pbconvert ::ConvertSerialToProto (certInfo.mSerial );
401
403
if (!err.IsNone ()) {
402
404
LOG_ERR () << " Convert serial failed: error=" << err;
403
405
@@ -432,7 +434,7 @@ grpc::Status ProtectedMessageHandler::RegisterInstance([[maybe_unused]] grpc::Se
432
434
if (err = aosPermissions->EmplaceBack (); !err.IsNone ()) {
433
435
LOG_ERR () << " Failed to push back permissions: error=" << err;
434
436
435
- return utils ::ConvertAosErrorToGrpcStatus (err);
437
+ return aos::common::pbconvert ::ConvertAosErrorToGrpcStatus (err);
436
438
}
437
439
438
440
aos::FunctionServicePermissions& servicePerm = aosPermissions->Back ();
@@ -442,7 +444,7 @@ grpc::Status ProtectedMessageHandler::RegisterInstance([[maybe_unused]] grpc::Se
442
444
if (err = servicePerm.mPermissions .PushBack ({key.c_str (), val.c_str ()}); !err.IsNone ()) {
443
445
LOG_ERR () << " Failed to push back permissions: error=" << err;
444
446
445
- return utils ::ConvertAosErrorToGrpcStatus (err);
447
+ return aos::common::pbconvert ::ConvertAosErrorToGrpcStatus (err);
446
448
}
447
449
}
448
450
}
@@ -453,7 +455,7 @@ grpc::Status ProtectedMessageHandler::RegisterInstance([[maybe_unused]] grpc::Se
453
455
if (!err.IsNone ()) {
454
456
LOG_ERR () << " Register instance failed: error=" << err;
455
457
456
- return utils ::ConvertAosErrorToGrpcStatus (err);
458
+ return aos::common::pbconvert ::ConvertAosErrorToGrpcStatus (err);
457
459
}
458
460
459
461
response->set_secret (secret.CStr ());
@@ -472,7 +474,7 @@ grpc::Status ProtectedMessageHandler::UnregisterInstance([[maybe_unused]] grpc::
472
474
if (auto err = GetPermHandler ()->UnregisterInstance (instance); !err.IsNone ()) {
473
475
LOG_ERR () << " Unregister instance failed: error=" << err;
474
476
475
- return utils ::ConvertAosErrorToGrpcStatus (err);
477
+ return aos::common::pbconvert ::ConvertAosErrorToGrpcStatus (err);
476
478
}
477
479
478
480
return grpc::Status::OK;
0 commit comments