summaryrefslogtreecommitdiffstats
path: root/src/rgw/driver/dbstore/config/sqlite.h
blob: d79e040728c268740d6219ff98549ca87ac75b07 (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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab ft=cpp

/*
 * Ceph - scalable distributed file system
 *
 * Copyright (C) 2022 Red Hat, Inc.
 *
 * This is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License version 2.1, as published by the Free Software
 * Foundation. See file COPYING.
 *
 */

#pragma once

#include "rgw_sal_config.h"

class DoutPrefixProvider;

namespace rgw::dbstore::config {

struct SQLiteImpl;

class SQLiteConfigStore : public sal::ConfigStore {
 public:
  explicit SQLiteConfigStore(std::unique_ptr<SQLiteImpl> impl);
  ~SQLiteConfigStore() override;

  int write_default_realm_id(const DoutPrefixProvider* dpp,
                             optional_yield y, bool exclusive,
                             std::string_view realm_id) override;
  int read_default_realm_id(const DoutPrefixProvider* dpp,
                            optional_yield y,
                            std::string& realm_id) override;
  int delete_default_realm_id(const DoutPrefixProvider* dpp,
                              optional_yield y) override;

  int create_realm(const DoutPrefixProvider* dpp,
                   optional_yield y, bool exclusive,
                   const RGWRealm& info,
                   std::unique_ptr<sal::RealmWriter>* writer) override;
  int read_realm_by_id(const DoutPrefixProvider* dpp,
                       optional_yield y,
                       std::string_view realm_id,
                       RGWRealm& info,
                       std::unique_ptr<sal::RealmWriter>* writer) override;
  int read_realm_by_name(const DoutPrefixProvider* dpp,
                         optional_yield y,
                         std::string_view realm_name,
                         RGWRealm& info,
                         std::unique_ptr<sal::RealmWriter>* writer) override;
  int read_default_realm(const DoutPrefixProvider* dpp,
                         optional_yield y,
                         RGWRealm& info,
                         std::unique_ptr<sal::RealmWriter>* writer) override;
  int read_realm_id(const DoutPrefixProvider* dpp,
                    optional_yield y, std::string_view realm_name,
                    std::string& realm_id) override;
  int realm_notify_new_period(const DoutPrefixProvider* dpp,
                              optional_yield y,
                              const RGWPeriod& period) override;
  int list_realm_names(const DoutPrefixProvider* dpp,
                       optional_yield y, const std::string& marker,
                       std::span<std::string> entries,
                       sal::ListResult<std::string>& result) override;

  int create_period(const DoutPrefixProvider* dpp,
                    optional_yield y, bool exclusive,
                    const RGWPeriod& info) override;
  int read_period(const DoutPrefixProvider* dpp,
                  optional_yield y, std::string_view period_id,
                  std::optional<uint32_t> epoch, RGWPeriod& info) override;
  int delete_period(const DoutPrefixProvider* dpp,
                    optional_yield y,
                    std::string_view period_id) override;
  int list_period_ids(const DoutPrefixProvider* dpp,
                      optional_yield y, const std::string& marker,
                      std::span<std::string> entries,
                      sal::ListResult<std::string>& result) override;

  int write_default_zonegroup_id(const DoutPrefixProvider* dpp,
                                 optional_yield y, bool exclusive,
                                 std::string_view realm_id,
                                 std::string_view zonegroup_id) override;
  int read_default_zonegroup_id(const DoutPrefixProvider* dpp,
                                optional_yield y,
                                std::string_view realm_id,
                                std::string& zonegroup_id) override;
  int delete_default_zonegroup_id(const DoutPrefixProvider* dpp,
                                  optional_yield y,
                                  std::string_view realm_id) override;

  int create_zonegroup(const DoutPrefixProvider* dpp,
                       optional_yield y, bool exclusive,
                       const RGWZoneGroup& info,
                       std::unique_ptr<sal::ZoneGroupWriter>* writer) override;
  int read_zonegroup_by_id(const DoutPrefixProvider* dpp,
                           optional_yield y,
                           std::string_view zonegroup_id,
                           RGWZoneGroup& info,
                           std::unique_ptr<sal::ZoneGroupWriter>* writer) override;
  int read_zonegroup_by_name(const DoutPrefixProvider* dpp,
                             optional_yield y,
                             std::string_view zonegroup_name,
                             RGWZoneGroup& info,
                             std::unique_ptr<sal::ZoneGroupWriter>* writer) override;
  int read_default_zonegroup(const DoutPrefixProvider* dpp,
                             optional_yield y,
                             std::string_view realm_id,
                             RGWZoneGroup& info,
                             std::unique_ptr<sal::ZoneGroupWriter>* writer) override;
  int list_zonegroup_names(const DoutPrefixProvider* dpp,
                           optional_yield y, const std::string& marker,
                           std::span<std::string> entries,
                           sal::ListResult<std::string>& result) override;

  int write_default_zone_id(const DoutPrefixProvider* dpp,
                            optional_yield y, bool exclusive,
                            std::string_view realm_id,
                            std::string_view zone_id) override;
  int read_default_zone_id(const DoutPrefixProvider* dpp,
                           optional_yield y,
                           std::string_view realm_id,
                           std::string& zone_id) override;
  int delete_default_zone_id(const DoutPrefixProvider* dpp,
                             optional_yield y,
                             std::string_view realm_id) override;

  int create_zone(const DoutPrefixProvider* dpp,
                  optional_yield y, bool exclusive,
                  const RGWZoneParams& info,
                  std::unique_ptr<sal::ZoneWriter>* writer) override;
  int read_zone_by_id(const DoutPrefixProvider* dpp,
                      optional_yield y,
                      std::string_view zone_id,
                      RGWZoneParams& info,
                      std::unique_ptr<sal::ZoneWriter>* writer) override;
  int read_zone_by_name(const DoutPrefixProvider* dpp,
                        optional_yield y,
                        std::string_view zone_name,
                        RGWZoneParams& info,
                        std::unique_ptr<sal::ZoneWriter>* writer) override;
  int read_default_zone(const DoutPrefixProvider* dpp,
                        optional_yield y,
                        std::string_view realm_id,
                        RGWZoneParams& info,
                        std::unique_ptr<sal::ZoneWriter>* writer) override;
  int list_zone_names(const DoutPrefixProvider* dpp,
                      optional_yield y, const std::string& marker,
                      std::span<std::string> entries,
                      sal::ListResult<std::string>& result) override;

  int read_period_config(const DoutPrefixProvider* dpp,
                         optional_yield y,
                         std::string_view realm_id,
                         RGWPeriodConfig& info) override;
  int write_period_config(const DoutPrefixProvider* dpp,
                          optional_yield y, bool exclusive,
                          std::string_view realm_id,
                          const RGWPeriodConfig& info) override;

 private:
  std::unique_ptr<SQLiteImpl> impl;
}; // SQLiteConfigStore


auto create_sqlite_store(const DoutPrefixProvider* dpp, const std::string& uri)
  -> std::unique_ptr<config::SQLiteConfigStore>;

} // namespace rgw::dbstore::config