]> git.proxmox.com Git - ceph.git/blame - ceph/src/rgw/rgw_lua.h
import ceph pacific 16.2.5
[ceph.git] / ceph / src / rgw / rgw_lua.h
CommitLineData
f67539c2
TL
1#pragma once
2
3#include <string>
4#include "common/async/yield_context.h"
5
6class lua_State;
7class rgw_user;
8namespace rgw::sal {
9 class RGWRadosStore;
10}
11
12namespace rgw::lua {
13
14enum 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
23context to_context(const std::string& s);
24
25// verify a lua script
26bool verify(const std::string& script, std::string& err_msg);
27
28// store a lua script in a context
b3b6e05e 29int 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
32int 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 35int 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
40using packages_t = std::set<std::string>;
41
42// add a lua package to the allowlist
b3b6e05e 43int 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 46int 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 49int 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 53int 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