summaryrefslogtreecommitdiffstats
path: root/src/rgw/driver/rados/rgw_otp.h
blob: 885e8abb8e1d74d0f93fba05734f0120d33abddc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab ft=cpp

#pragma once

#include "rgw_sal_fwd.h"
#include "cls/otp/cls_otp_types.h"
#include "services/svc_meta_be_otp.h"

#include "rgw_basic_types.h"
#include "rgw_metadata.h"


class RGWObjVersionTracker;
class RGWMetadataHandler;
class RGWOTPMetadataHandler;
class RGWSI_Zone;
class RGWSI_OTP;
class RGWSI_MetaBackend;

class RGWOTPMetadataHandlerBase : public RGWMetadataHandler_GenericMetaBE {
public:
  virtual ~RGWOTPMetadataHandlerBase() {}
  virtual int init(RGWSI_Zone *zone,
		   RGWSI_MetaBackend *_meta_be,
		   RGWSI_OTP *_otp) = 0;
};

class RGWOTPMetaHandlerAllocator {
public:
  static RGWMetadataHandler *alloc();
};

struct RGWOTPInfo {
  rgw_user uid;
  otp_devices_list_t devices;
};


class RGWOTPCtl
{
  struct Svc {
    RGWSI_Zone *zone{nullptr};
    RGWSI_OTP *otp{nullptr};
  } svc;

  RGWOTPMetadataHandler *meta_handler;
  RGWSI_MetaBackend_Handler *be_handler;
  
public:
  RGWOTPCtl(RGWSI_Zone *zone_svc,
	    RGWSI_OTP *otp_svc);

  void init(RGWOTPMetadataHandler *_meta_handler);

  struct GetParams {
    RGWObjVersionTracker *objv_tracker{nullptr};
    ceph::real_time *mtime{nullptr};

    GetParams() {}

    GetParams& set_objv_tracker(RGWObjVersionTracker *_objv_tracker) {
      objv_tracker = _objv_tracker;
      return *this;
    }

    GetParams& set_mtime(ceph::real_time *_mtime) {
      mtime = _mtime;
      return *this;
    }
  };

  struct PutParams {
    RGWObjVersionTracker *objv_tracker{nullptr};
    ceph::real_time mtime;

    PutParams() {}

    PutParams& set_objv_tracker(RGWObjVersionTracker *_objv_tracker) {
      objv_tracker = _objv_tracker;
      return *this;
    }

    PutParams& set_mtime(const ceph::real_time& _mtime) {
      mtime = _mtime;
      return *this;
    }
  };

  struct RemoveParams {
    RGWObjVersionTracker *objv_tracker{nullptr};

    RemoveParams() {}

    RemoveParams& set_objv_tracker(RGWObjVersionTracker *_objv_tracker) {
      objv_tracker = _objv_tracker;
      return *this;
    }
  };

  int read_all(const rgw_user& uid, RGWOTPInfo *info, optional_yield y,
               const DoutPrefixProvider *dpp,
               const GetParams& params = {});
  int store_all(const DoutPrefixProvider *dpp, 
                const RGWOTPInfo& info, optional_yield y,
                const PutParams& params = {});
  int remove_all(const DoutPrefixProvider *dpp, 
                 const rgw_user& user, optional_yield y,
                 const RemoveParams& params = {});
};