Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / src / rgw / rgw_policy_s3.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3
4 #ifndef CEPH_RGW_POLICY_H
5 #define CEPH_RGW_POLICY_H
6
7 #include <limits.h>
8
9 #include <map>
10 #include <list>
11 #include <string>
12
13 #include "include/utime.h"
14
15 #include "rgw_string.h"
16
17
18 class RGWPolicyEnv {
19   std::map<std::string, std::string, ltstr_nocase> vars;
20
21 public:
22   void add_var(const string& name, const string& value);
23   bool get_var(const string& name, string& val);
24   bool get_value(const string& s, string& val, std::map<std::string, bool, ltstr_nocase>& checked_vars);
25   bool match_policy_vars(map<string, bool, ltstr_nocase>& policy_vars, string& err_msg);
26 };
27
28 class RGWPolicyCondition;
29
30
31 class RGWPolicy {
32   uint64_t expires;
33   string expiration_str;
34   std::list<RGWPolicyCondition *> conditions;
35   std::list<pair<std::string, std::string> > var_checks;
36   std::map<std::string, bool, ltstr_nocase> checked_vars;
37
38 public:
39   off_t min_length;
40   off_t max_length;
41
42   RGWPolicy() : expires(0), min_length(0), max_length(LLONG_MAX) {}
43   ~RGWPolicy();
44
45   int set_expires(const string& e);
46
47   void set_var_checked(const std::string& var) {
48     checked_vars[var] = true;
49   }
50
51   int add_condition(const std::string& op, const std::string& first, const std::string& second, string& err_msg);
52   void add_simple_check(const std::string& var, const std::string& value) {
53     var_checks.push_back(pair<string, string>(var, value));
54   }
55
56   int check(RGWPolicyEnv *env, string& err_msg);
57   int from_json(bufferlist& bl, string& err_msg);
58 };
59 #endif