/* * @project The CERN Tape Archive (CTA) * @copyright Copyright © 2021-2023 CERN * @license This program is free software, distributed under the terms of the GNU General Public * Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". You can * redistribute it and/or modify it under the terms of the GPL Version 3, or (at your * option) any later version. * * This program is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU General Public License for more details. * * In applying this licence, CERN does not waive the privileges and immunities * granted to it by virtue of its status as an Intergovernmental Organization or * submit itself to any jurisdiction. */ #include "RequestMessage.hpp" #include "cmdline/CtaAdminCmdParse.hpp" cta::frontend::grpc::request::RequestMessage::RequestMessage(const cta::frontend::rpc::AdminRequest &request) { importOptions(request.admincmd()); } void cta::frontend::grpc::request::RequestMessage::importOptions(const cta::admin::AdminCmd &admincmd) { // Validate the Protocol Buffer cta::admin::validateCmd(admincmd); // Import Boolean options for(auto opt_it = admincmd.option_bool().begin(); opt_it != admincmd.option_bool().end(); ++opt_it) { m_option_bool.insert(std::make_pair(opt_it->key(), opt_it->value())); } // Import UInt64 options for(auto opt_it = admincmd.option_uint64().begin(); opt_it != admincmd.option_uint64().end(); ++opt_it) { m_option_uint64.insert(std::make_pair(opt_it->key(), opt_it->value())); } // Import String options for(auto opt_it = admincmd.option_str().begin(); opt_it != admincmd.option_str().end(); ++opt_it) { m_option_str.insert(std::make_pair(opt_it->key(), opt_it->value())); } // Import String List options for(auto opt_it = admincmd.option_str_list().begin(); opt_it != admincmd.option_str_list().end(); ++opt_it) { std::vector items; for(auto item_it = opt_it->item().begin(); item_it != opt_it->item().end(); ++item_it) { items.push_back(*item_it); } m_option_str_list.insert(std::make_pair(opt_it->key(), items)); } }