]>
Commit | Line | Data |
---|---|---|
f67539c2 TL |
1 | #pragma once |
2 | ||
3 | #include <string> | |
4 | #include "common/async/yield_context.h" | |
5 | ||
6 | class lua_State; | |
7 | class rgw_user; | |
8 | namespace rgw::sal { | |
9 | class RGWRadosStore; | |
10 | } | |
11 | ||
12 | namespace rgw::lua { | |
13 | ||
14 | enum class context { | |
15 | preRequest, | |
16 | postRequest, | |
17 | none | |
18 | }; | |
19 | ||
20 | // get context enum from string | |
21 | // the expected string the same as the enum (case insensitive) | |
22 | // return "none" if not matched | |
23 | context to_context(const std::string& s); | |
24 | ||
25 | // verify a lua script | |
26 | bool verify(const std::string& script, std::string& err_msg); | |
27 | ||
28 | // store a lua script in a context | |
b3b6e05e | 29 | int write_script(const DoutPrefixProvider *dpp, rgw::sal::RGWRadosStore* store, const std::string& tenant, optional_yield y, context ctx, const std::string& script); |
f67539c2 TL |
30 | |
31 | // read the stored lua script from a context | |
32 | int read_script(rgw::sal::RGWRadosStore* store, const std::string& tenant, optional_yield y, context ctx, std::string& script); | |
33 | ||
34 | // delete the stored lua script from a context | |
b3b6e05e | 35 | int delete_script(const DoutPrefixProvider *dpp, rgw::sal::RGWRadosStore* store, const std::string& tenant, optional_yield y, context ctx); |
f67539c2 TL |
36 | |
37 | #ifdef WITH_RADOSGW_LUA_PACKAGES | |
38 | #include <set> | |
39 | ||
40 | using packages_t = std::set<std::string>; | |
41 | ||
42 | // add a lua package to the allowlist | |
b3b6e05e | 43 | int add_package(const DoutPrefixProvider *dpp, rgw::sal::RGWRadosStore* store, optional_yield y, const std::string& package_name, bool allow_compilation); |
f67539c2 TL |
44 | |
45 | // remove a lua package from the allowlist | |
b3b6e05e | 46 | int remove_package(const DoutPrefixProvider *dpp, rgw::sal::RGWRadosStore* store, optional_yield y, const std::string& package_name); |
f67539c2 TL |
47 | |
48 | // list lua packages in the allowlist | |
b3b6e05e | 49 | int list_packages(const DoutPrefixProvider *dpp, rgw::sal::RGWRadosStore* store, optional_yield y, packages_t& packages); |
f67539c2 TL |
50 | |
51 | // install all packages from the allowlist | |
52 | // return the list of packages that failed to install and the output of the install command | |
b3b6e05e | 53 | int install_packages(const DoutPrefixProvider *dpp, rgw::sal::RGWRadosStore* store, optional_yield y, packages_t& failed_packages, std::string& output); |
f67539c2 TL |
54 | #endif |
55 | } | |
56 |