Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / src / cls / timeindex / cls_timeindex_ops.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_CLS_TIMEINDEX_OPS_H
5 #define CEPH_CLS_TIMEINDEX_OPS_H
6
7 #include "cls_timeindex_types.h"
8
9 struct cls_timeindex_add_op {
10   list<cls_timeindex_entry> entries;
11
12   cls_timeindex_add_op() {}
13
14   void encode(bufferlist& bl) const {
15     ENCODE_START(1, 1, bl);
16     ::encode(entries, bl);
17     ENCODE_FINISH(bl);
18   }
19
20   void decode(bufferlist::iterator& bl) {
21     DECODE_START(1, bl);
22     ::decode(entries, bl);
23     DECODE_FINISH(bl);
24   }
25 };
26 WRITE_CLASS_ENCODER(cls_timeindex_add_op)
27
28 struct cls_timeindex_list_op {
29   utime_t from_time;
30   string marker; /* if not empty, overrides from_time */
31   utime_t to_time; /* not inclusive */
32   int max_entries; /* upperbound to returned num of entries
33                       might return less than that and still be truncated */
34
35   cls_timeindex_list_op() : max_entries(0) {}
36
37   void encode(bufferlist& bl) const {
38     ENCODE_START(1, 1, bl);
39     ::encode(from_time, bl);
40     ::encode(marker, bl);
41     ::encode(to_time, bl);
42     ::encode(max_entries, bl);
43     ENCODE_FINISH(bl);
44   }
45
46   void decode(bufferlist::iterator& bl) {
47     DECODE_START(1, bl);
48     ::decode(from_time, bl);
49     ::decode(marker, bl);
50     ::decode(to_time, bl);
51     ::decode(max_entries, bl);
52     DECODE_FINISH(bl);
53   }
54 };
55 WRITE_CLASS_ENCODER(cls_timeindex_list_op)
56
57 struct cls_timeindex_list_ret {
58   list<cls_timeindex_entry> entries;
59   string marker;
60   bool truncated;
61
62   cls_timeindex_list_ret() : truncated(false) {}
63
64   void encode(bufferlist& bl) const {
65     ENCODE_START(1, 1, bl);
66     ::encode(entries, bl);
67     ::encode(marker, bl);
68     ::encode(truncated, bl);
69     ENCODE_FINISH(bl);
70   }
71
72   void decode(bufferlist::iterator& bl) {
73     DECODE_START(1, bl);
74     ::decode(entries, bl);
75     ::decode(marker, bl);
76     ::decode(truncated, bl);
77     DECODE_FINISH(bl);
78   }
79 };
80 WRITE_CLASS_ENCODER(cls_timeindex_list_ret)
81
82
83 /*
84  * operation will return 0 when successfully removed but not done. Will return
85  * -ENODATA when done, so caller needs to repeat sending request until that.
86  */
87 struct cls_timeindex_trim_op {
88   utime_t from_time;
89   utime_t to_time; /* inclusive */
90   string from_marker;
91   string to_marker;
92
93   cls_timeindex_trim_op() {}
94
95   void encode(bufferlist& bl) const {
96     ENCODE_START(1, 1, bl);
97     ::encode(from_time, bl);
98     ::encode(to_time, bl);
99     ::encode(from_marker, bl);
100     ::encode(to_marker, bl);
101     ENCODE_FINISH(bl);
102   }
103
104   void decode(bufferlist::iterator& bl) {
105     DECODE_START(1, bl);
106     ::decode(from_time, bl);
107     ::decode(to_time, bl);
108     ::decode(from_marker, bl);
109     ::decode(to_marker, bl);
110     DECODE_FINISH(bl);
111   }
112 };
113 WRITE_CLASS_ENCODER(cls_timeindex_trim_op)
114
115 #endif /* CEPH_CLS_TIMEINDEX_OPS_H */