CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
CondDBPyBind11Wrappers.cc
Go to the documentation of this file.
3 //
4 #include <cstdlib>
5 
6 namespace cond {
7 
8  std::tuple<std::string, std::string, std::string> getDbCredentials(const std::string& connectionString,
9  int accessType,
10  const std::string& authPath) {
11  std::string ap = authPath;
12  if (ap.empty()) {
13  ap = std::string(std::getenv(cond::auth::COND_AUTH_PATH));
14  }
15  auto ret = std::make_tuple(std::string(""), std::string(""), std::string(""));
16  if (!ap.empty()) {
17  CredentialStore credDb;
18  credDb.setUpForConnectionString(connectionString, ap);
20  auto creds = credDb.getUserCredentials(connectionString, role);
21  ret = std::tie(credDb.keyPrincipalName(), creds.first, creds.second);
22  }
23  return ret;
24  }
25 
26 } // namespace cond
27 
28 #include <pybind11/pybind11.h>
29 
30 namespace py = pybind11;
31 
32 PYBIND11_MODULE(libCondDBPyBind11Interface, m) {
33  m.def("get_credentials_from_db", &cond::getDbCredentials, "Get db credentials for a connection string");
34  m.attr("default_role") = pybind11::int_(int(cond::auth::DEFAULT_ROLE));
35  m.attr("reader_role") = pybind11::int_(int(cond::auth::READER_ROLE));
36  m.attr("writer_role") = pybind11::int_(int(cond::auth::WRITER_ROLE));
37  m.attr("admin_role") = pybind11::int_(int(cond::auth::ADMIN_ROLE));
38 }
std::pair< std::string, std::string > getUserCredentials(const std::string &connectionString, const std::string &role)
const std::string & keyPrincipalName()
tuple ret
prodAgent to be discontinued
std::tuple< std::string, std::string, std::string > getDbCredentials(const std::string &connectionString, int accessType, const std::string &authPath)
static constexpr const char *const COND_AUTH_PATH
Definition: Auth.h:11
std::string setUpForConnectionString(const std::string &connectionString, const std::string &authPath)
PYBIND11_MODULE(pluginTrackerAlignment_PayloadInspector, m)
static const std::pair< const char *, RoleCode > s_roleCodeArray[]
Definition: Auth.h:28