couchbase 3.1.1-universal-darwin-20 → 3.2.0-universal-darwin-20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (221) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -2
  3. data/ext/CMakeLists.txt +3 -1
  4. data/ext/build_version.hxx.in +1 -1
  5. data/ext/cmake/Testing.cmake +1 -0
  6. data/ext/cmake/ThirdPartyDependencies.cmake +6 -0
  7. data/ext/cmake/VersionInfo.cmake +3 -0
  8. data/ext/couchbase/bucket.hxx +47 -28
  9. data/ext/couchbase/cbsasl/client.h +1 -1
  10. data/ext/couchbase/cbsasl/context.cc +1 -1
  11. data/ext/couchbase/cbsasl/context.h +3 -3
  12. data/ext/couchbase/cbsasl/mechanism.cc +5 -8
  13. data/ext/couchbase/cbsasl/mechanism.h +1 -4
  14. data/ext/couchbase/cbsasl/plain/plain.cc +1 -1
  15. data/ext/couchbase/cbsasl/scram-sha/scram-sha.cc +30 -36
  16. data/ext/couchbase/cluster.hxx +40 -22
  17. data/ext/couchbase/cluster_options.hxx +7 -1
  18. data/ext/couchbase/configuration.hxx +37 -16
  19. data/ext/couchbase/couchbase.cxx +1145 -291
  20. data/ext/couchbase/error_map.hxx +1 -1
  21. data/ext/couchbase/errors.hxx +25 -17
  22. data/ext/couchbase/io/dns_client.hxx +3 -3
  23. data/ext/couchbase/io/dns_codec.hxx +4 -5
  24. data/ext/couchbase/io/dns_config.hxx +5 -6
  25. data/ext/couchbase/io/dns_message.hxx +3 -3
  26. data/ext/couchbase/io/http_command.hxx +70 -35
  27. data/ext/couchbase/io/http_session.hxx +4 -3
  28. data/ext/couchbase/io/http_session_manager.hxx +28 -19
  29. data/ext/couchbase/io/mcbp_command.hxx +51 -19
  30. data/ext/couchbase/io/mcbp_context.hxx +1 -1
  31. data/ext/couchbase/io/mcbp_parser.hxx +4 -4
  32. data/ext/couchbase/io/mcbp_session.hxx +91 -101
  33. data/ext/couchbase/io/query_cache.hxx +2 -2
  34. data/ext/couchbase/io/retry_orchestrator.hxx +2 -4
  35. data/ext/couchbase/io/retry_reason.hxx +2 -2
  36. data/ext/couchbase/io/retry_strategy.hxx +1 -6
  37. data/ext/couchbase/io/streams.hxx +7 -7
  38. data/ext/couchbase/metrics/logging_meter.hxx +228 -0
  39. data/ext/couchbase/metrics/logging_meter_options.hxx +28 -0
  40. data/ext/couchbase/metrics/meter.hxx +49 -0
  41. data/ext/couchbase/metrics/noop_meter.hxx +43 -0
  42. data/ext/couchbase/operations.hxx +4 -0
  43. data/ext/couchbase/operations/analytics_dataset_create.hxx +16 -12
  44. data/ext/couchbase/operations/analytics_dataset_drop.hxx +11 -11
  45. data/ext/couchbase/operations/analytics_dataset_get_all.hxx +6 -6
  46. data/ext/couchbase/operations/analytics_dataverse_create.hxx +10 -11
  47. data/ext/couchbase/operations/analytics_dataverse_drop.hxx +10 -11
  48. data/ext/couchbase/operations/analytics_get_pending_mutations.hxx +9 -11
  49. data/ext/couchbase/operations/analytics_index_create.hxx +14 -13
  50. data/ext/couchbase/operations/analytics_index_drop.hxx +18 -12
  51. data/ext/couchbase/operations/analytics_index_get_all.hxx +8 -6
  52. data/ext/couchbase/operations/analytics_link.hxx +39 -0
  53. data/ext/couchbase/operations/analytics_link_azure_blob_external.hxx +145 -0
  54. data/ext/couchbase/operations/analytics_link_connect.hxx +14 -12
  55. data/ext/couchbase/operations/analytics_link_couchbase_remote.hxx +220 -0
  56. data/ext/couchbase/operations/analytics_link_create.hxx +128 -0
  57. data/ext/couchbase/operations/analytics_link_disconnect.hxx +11 -12
  58. data/ext/couchbase/operations/analytics_link_drop.hxx +130 -0
  59. data/ext/couchbase/operations/analytics_link_get_all.hxx +160 -0
  60. data/ext/couchbase/operations/analytics_link_replace.hxx +128 -0
  61. data/ext/couchbase/operations/analytics_link_s3_external.hxx +122 -0
  62. data/ext/couchbase/operations/bucket_create.hxx +8 -8
  63. data/ext/couchbase/operations/bucket_drop.hxx +5 -5
  64. data/ext/couchbase/operations/bucket_flush.hxx +5 -5
  65. data/ext/couchbase/operations/bucket_get.hxx +7 -7
  66. data/ext/couchbase/operations/bucket_get_all.hxx +7 -5
  67. data/ext/couchbase/operations/bucket_settings.hxx +40 -49
  68. data/ext/couchbase/operations/bucket_update.hxx +8 -8
  69. data/ext/couchbase/operations/cluster_developer_preview_enable.hxx +7 -7
  70. data/ext/couchbase/operations/collection_create.hxx +11 -11
  71. data/ext/couchbase/operations/collection_drop.hxx +12 -10
  72. data/ext/couchbase/operations/collections_manifest_get.hxx +3 -3
  73. data/ext/couchbase/operations/design_document.hxx +2 -2
  74. data/ext/couchbase/operations/document_analytics.hxx +29 -36
  75. data/ext/couchbase/operations/document_append.hxx +3 -3
  76. data/ext/couchbase/operations/document_decrement.hxx +3 -3
  77. data/ext/couchbase/operations/document_exists.hxx +2 -2
  78. data/ext/couchbase/operations/document_get.hxx +3 -3
  79. data/ext/couchbase/operations/document_get_and_lock.hxx +5 -3
  80. data/ext/couchbase/operations/document_get_and_touch.hxx +5 -3
  81. data/ext/couchbase/operations/document_get_projected.hxx +10 -11
  82. data/ext/couchbase/operations/document_increment.hxx +3 -3
  83. data/ext/couchbase/operations/document_insert.hxx +3 -3
  84. data/ext/couchbase/operations/document_lookup_in.hxx +12 -18
  85. data/ext/couchbase/operations/document_mutate_in.hxx +13 -18
  86. data/ext/couchbase/operations/document_prepend.hxx +3 -3
  87. data/ext/couchbase/operations/document_query.hxx +39 -41
  88. data/ext/couchbase/operations/document_remove.hxx +3 -3
  89. data/ext/couchbase/operations/document_replace.hxx +3 -3
  90. data/ext/couchbase/operations/document_search.hxx +56 -61
  91. data/ext/couchbase/operations/document_touch.hxx +3 -3
  92. data/ext/couchbase/operations/document_unlock.hxx +3 -3
  93. data/ext/couchbase/operations/document_upsert.hxx +3 -3
  94. data/ext/couchbase/operations/document_view.hxx +23 -23
  95. data/ext/couchbase/operations/group_drop.hxx +5 -5
  96. data/ext/couchbase/operations/group_get.hxx +7 -7
  97. data/ext/couchbase/operations/group_get_all.hxx +6 -6
  98. data/ext/couchbase/operations/group_upsert.hxx +11 -11
  99. data/ext/couchbase/operations/http_noop.hxx +6 -6
  100. data/ext/couchbase/operations/mcbp_noop.hxx +3 -3
  101. data/ext/couchbase/operations/query_index_build_deferred.hxx +6 -6
  102. data/ext/couchbase/operations/query_index_create.hxx +10 -8
  103. data/ext/couchbase/operations/query_index_drop.hxx +8 -8
  104. data/ext/couchbase/operations/query_index_get_all.hxx +43 -39
  105. data/ext/couchbase/operations/rbac.hxx +40 -63
  106. data/ext/couchbase/operations/role_get_all.hxx +6 -6
  107. data/ext/couchbase/operations/scope_create.hxx +10 -10
  108. data/ext/couchbase/operations/scope_drop.hxx +9 -9
  109. data/ext/couchbase/operations/scope_get_all.hxx +8 -8
  110. data/ext/couchbase/operations/search_get_stats.hxx +5 -3
  111. data/ext/couchbase/operations/search_index.hxx +6 -15
  112. data/ext/couchbase/operations/search_index_analyze_document.hxx +11 -11
  113. data/ext/couchbase/operations/search_index_control_ingest.hxx +9 -9
  114. data/ext/couchbase/operations/search_index_control_plan_freeze.hxx +9 -9
  115. data/ext/couchbase/operations/search_index_control_query.hxx +9 -9
  116. data/ext/couchbase/operations/search_index_drop.hxx +11 -9
  117. data/ext/couchbase/operations/search_index_get.hxx +11 -9
  118. data/ext/couchbase/operations/search_index_get_all.hxx +11 -11
  119. data/ext/couchbase/operations/search_index_get_documents_count.hxx +10 -10
  120. data/ext/couchbase/operations/search_index_get_stats.hxx +10 -8
  121. data/ext/couchbase/operations/search_index_upsert.hxx +12 -10
  122. data/ext/couchbase/operations/user_drop.hxx +5 -5
  123. data/ext/couchbase/operations/user_get.hxx +7 -7
  124. data/ext/couchbase/operations/user_get_all.hxx +6 -6
  125. data/ext/couchbase/operations/user_upsert.hxx +9 -9
  126. data/ext/couchbase/operations/view_index_drop.hxx +10 -10
  127. data/ext/couchbase/operations/view_index_get.hxx +13 -15
  128. data/ext/couchbase/operations/view_index_get_all.hxx +17 -20
  129. data/ext/couchbase/operations/view_index_upsert.hxx +9 -7
  130. data/ext/couchbase/origin.hxx +14 -10
  131. data/ext/couchbase/platform/backtrace.c +1 -1
  132. data/ext/couchbase/platform/base64.cc +5 -5
  133. data/ext/couchbase/platform/base64.h +2 -5
  134. data/ext/couchbase/protocol/client_opcode.hxx +7 -4
  135. data/ext/couchbase/protocol/client_request.hxx +2 -2
  136. data/ext/couchbase/protocol/client_response.hxx +41 -16
  137. data/ext/couchbase/protocol/cmd_append.hxx +17 -16
  138. data/ext/couchbase/protocol/cmd_cluster_map_change_notification.hxx +4 -4
  139. data/ext/couchbase/protocol/cmd_decrement.hxx +10 -11
  140. data/ext/couchbase/protocol/cmd_exists.hxx +12 -15
  141. data/ext/couchbase/protocol/cmd_get.hxx +11 -14
  142. data/ext/couchbase/protocol/cmd_get_and_lock.hxx +10 -12
  143. data/ext/couchbase/protocol/cmd_get_and_touch.hxx +10 -12
  144. data/ext/couchbase/protocol/cmd_get_cluster_config.hxx +13 -18
  145. data/ext/couchbase/protocol/cmd_get_collection_id.hxx +12 -15
  146. data/ext/couchbase/protocol/cmd_get_collections_manifest.hxx +12 -16
  147. data/ext/couchbase/protocol/cmd_get_error_map.hxx +14 -17
  148. data/ext/couchbase/protocol/cmd_hello.hxx +8 -10
  149. data/ext/couchbase/protocol/cmd_increment.hxx +9 -10
  150. data/ext/couchbase/protocol/cmd_insert.hxx +9 -9
  151. data/ext/couchbase/protocol/cmd_lookup_in.hxx +12 -13
  152. data/ext/couchbase/protocol/cmd_mutate_in.hxx +11 -11
  153. data/ext/couchbase/protocol/cmd_noop.hxx +16 -20
  154. data/ext/couchbase/protocol/cmd_prepend.hxx +9 -10
  155. data/ext/couchbase/protocol/cmd_remove.hxx +10 -13
  156. data/ext/couchbase/protocol/cmd_replace.hxx +7 -7
  157. data/ext/couchbase/protocol/cmd_sasl_auth.hxx +8 -10
  158. data/ext/couchbase/protocol/cmd_sasl_list_mechs.hxx +10 -15
  159. data/ext/couchbase/protocol/cmd_sasl_step.hxx +10 -12
  160. data/ext/couchbase/protocol/cmd_select_bucket.hxx +14 -18
  161. data/ext/couchbase/protocol/cmd_touch.hxx +8 -11
  162. data/ext/couchbase/protocol/cmd_unlock.hxx +10 -14
  163. data/ext/couchbase/protocol/cmd_upsert.hxx +8 -8
  164. data/ext/couchbase/protocol/datatype.hxx +3 -3
  165. data/ext/couchbase/protocol/durability_level.hxx +2 -2
  166. data/ext/couchbase/protocol/frame_info_id.hxx +4 -4
  167. data/ext/couchbase/protocol/hello_feature.hxx +2 -2
  168. data/ext/couchbase/protocol/magic.hxx +2 -2
  169. data/ext/couchbase/protocol/server_opcode.hxx +2 -2
  170. data/ext/couchbase/protocol/server_request.hxx +1 -1
  171. data/ext/couchbase/protocol/status.hxx +4 -7
  172. data/ext/couchbase/protocol/unsigned_leb128.h +5 -20
  173. data/ext/couchbase/service_type.hxx +4 -4
  174. data/ext/couchbase/tracing/constants.hxx +261 -0
  175. data/ext/couchbase/tracing/noop_tracer.hxx +50 -0
  176. data/ext/couchbase/tracing/request_tracer.hxx +77 -0
  177. data/ext/couchbase/tracing/threshold_logging_options.hxx +64 -0
  178. data/ext/couchbase/tracing/threshold_logging_tracer.hxx +366 -0
  179. data/ext/couchbase/utils/byteswap.hxx +1 -1
  180. data/ext/couchbase/utils/connection_string.hxx +21 -1
  181. data/ext/couchbase/utils/name_codec.hxx +41 -0
  182. data/ext/couchbase/utils/url_codec.hxx +236 -0
  183. data/ext/couchbase/version.hxx +1 -1
  184. data/ext/test/CMakeLists.txt +1 -0
  185. data/ext/test/test_native_trivial_query.cxx +60 -0
  186. data/ext/third_party/hdr_histogram_c/CMakeLists.txt +84 -0
  187. data/ext/third_party/hdr_histogram_c/COPYING.txt +121 -0
  188. data/ext/third_party/hdr_histogram_c/LICENSE.txt +41 -0
  189. data/ext/third_party/hdr_histogram_c/config.cmake.in +6 -0
  190. data/ext/third_party/hdr_histogram_c/src/CMakeLists.txt +83 -0
  191. data/ext/third_party/hdr_histogram_c/src/hdr_atomic.h +146 -0
  192. data/ext/third_party/hdr_histogram_c/src/hdr_encoding.c +322 -0
  193. data/ext/third_party/hdr_histogram_c/src/hdr_encoding.h +79 -0
  194. data/ext/third_party/hdr_histogram_c/src/hdr_endian.h +116 -0
  195. data/ext/third_party/hdr_histogram_c/src/hdr_histogram.c +1196 -0
  196. data/ext/third_party/hdr_histogram_c/src/hdr_histogram.h +516 -0
  197. data/ext/third_party/hdr_histogram_c/src/hdr_histogram_log.c +1290 -0
  198. data/ext/third_party/hdr_histogram_c/src/hdr_histogram_log.h +236 -0
  199. data/ext/third_party/hdr_histogram_c/src/hdr_histogram_log_no_op.c +171 -0
  200. data/ext/third_party/hdr_histogram_c/src/hdr_interval_recorder.c +227 -0
  201. data/ext/third_party/hdr_histogram_c/src/hdr_interval_recorder.h +109 -0
  202. data/ext/third_party/hdr_histogram_c/src/hdr_malloc.h +19 -0
  203. data/ext/third_party/hdr_histogram_c/src/hdr_tests.h +22 -0
  204. data/ext/third_party/hdr_histogram_c/src/hdr_thread.c +108 -0
  205. data/ext/third_party/hdr_histogram_c/src/hdr_thread.h +55 -0
  206. data/ext/third_party/hdr_histogram_c/src/hdr_time.c +98 -0
  207. data/ext/third_party/hdr_histogram_c/src/hdr_time.h +49 -0
  208. data/ext/third_party/hdr_histogram_c/src/hdr_writer_reader_phaser.c +143 -0
  209. data/ext/third_party/hdr_histogram_c/src/hdr_writer_reader_phaser.h +51 -0
  210. data/lib/couchbase/cluster.rb +1 -0
  211. data/lib/couchbase/errors.rb +3 -0
  212. data/lib/couchbase/libcouchbase.bundle +0 -0
  213. data/lib/couchbase/management/analytics_index_manager.rb +920 -226
  214. data/lib/couchbase/management/bucket_manager.rb +207 -69
  215. data/lib/couchbase/management/collection_manager.rb +173 -61
  216. data/lib/couchbase/management/query_index_manager.rb +357 -169
  217. data/lib/couchbase/options.rb +75 -3
  218. data/lib/couchbase/scope.rb +102 -0
  219. data/lib/couchbase/utils/time.rb +4 -0
  220. data/lib/couchbase/version.rb +6 -6
  221. metadata +48 -5
@@ -0,0 +1,128 @@
1
+ /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright 2020-2021 Couchbase, Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+
18
+ #pragma once
19
+
20
+ #include <tao/json.hpp>
21
+
22
+ #include <operations/analytics_link.hxx>
23
+ #include <utils/name_codec.hxx>
24
+
25
+ namespace couchbase::operations
26
+ {
27
+ struct analytics_link_replace_response {
28
+ struct problem {
29
+ std::uint32_t code;
30
+ std::string message;
31
+ };
32
+
33
+ error_context::http ctx;
34
+ std::string status{};
35
+ std::vector<problem> errors{};
36
+ };
37
+
38
+ template<typename analytics_link_type>
39
+ struct analytics_link_replace_request {
40
+ using response_type = analytics_link_replace_response;
41
+ using encoded_request_type = io::http_request;
42
+ using encoded_response_type = io::http_response;
43
+ using error_context_type = error_context::http;
44
+
45
+ static const inline service_type type = service_type::analytics;
46
+
47
+ std::string client_context_id{ uuid::to_string(uuid::random()) };
48
+ std::chrono::milliseconds timeout{ timeout_defaults::management_timeout };
49
+
50
+ analytics_link_type link{};
51
+
52
+ [[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, http_context& /* context */) const
53
+ {
54
+ std::error_code ec = link.validate();
55
+ if (ec) {
56
+ return ec;
57
+ }
58
+ encoded.headers["content-type"] = "application/x-www-form-urlencoded";
59
+ encoded.headers["accept"] = "application/json";
60
+ encoded.method = "PUT";
61
+ encoded.path = analytics_link::endpoint_from_link(link);
62
+ encoded.body = link.encode();
63
+ return {};
64
+ }
65
+ };
66
+
67
+ template<typename analytics_link_type>
68
+ analytics_link_replace_response
69
+ make_response(error_context::http&& ctx,
70
+ const analytics_link_replace_request<analytics_link_type>& /* request */,
71
+ typename analytics_link_replace_request<analytics_link_type>::encoded_response_type&& encoded)
72
+ {
73
+ analytics_link_replace_response response{ std::move(ctx) };
74
+ if (!response.ctx.ec) {
75
+ if (encoded.body.empty() && response.ctx.http_status == 200) {
76
+ return response;
77
+ }
78
+ tao::json::value payload{};
79
+ try {
80
+ payload = tao::json::from_string(encoded.body);
81
+ } catch (const tao::json::pegtl::parse_error&) {
82
+ auto colon = encoded.body.find(':');
83
+ if (colon == std::string::npos) {
84
+ response.ctx.ec = error::common_errc::parsing_failure;
85
+ return response;
86
+ }
87
+ auto code = static_cast<std::uint32_t>(std::stoul(encoded.body, 0));
88
+ auto msg = encoded.body.substr(colon + 1);
89
+ response.errors.emplace_back(analytics_link_replace_response::problem{ code, msg });
90
+ }
91
+ if (payload) {
92
+ response.status = payload.at("status").get_string();
93
+ if (response.status != "success") {
94
+ if (auto* errors = payload.find("errors"); errors != nullptr && errors->is_array()) {
95
+ for (const auto& error : errors->get_array()) {
96
+ analytics_link_replace_response::problem err{
97
+ error.at("code").as<std::uint32_t>(),
98
+ error.at("msg").get_string(),
99
+ };
100
+ response.errors.emplace_back(err);
101
+ }
102
+ }
103
+ }
104
+ }
105
+ bool link_not_found = false;
106
+ bool dataverse_does_not_exist = false;
107
+ for (const auto& err : response.errors) {
108
+ switch (err.code) {
109
+ case 24006: /* Link [string] does not exist */
110
+ link_not_found = true;
111
+ break;
112
+ case 24034: /* Cannot find dataverse with name [string] */
113
+ dataverse_does_not_exist = true;
114
+ break;
115
+ }
116
+ }
117
+ if (dataverse_does_not_exist) {
118
+ response.ctx.ec = error::analytics_errc::dataverse_not_found;
119
+ } else if (link_not_found) {
120
+ response.ctx.ec = error::analytics_errc::link_not_found;
121
+ } else {
122
+ response.ctx.ec = error::common_errc::internal_server_failure;
123
+ }
124
+ }
125
+ return response;
126
+ }
127
+
128
+ } // namespace couchbase::operations
@@ -0,0 +1,122 @@
1
+ /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright 2020-2021 Couchbase, Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+
18
+ #pragma once
19
+
20
+ #include <optional>
21
+ #include <sstream>
22
+ #include <string>
23
+
24
+ #include <errors.hxx>
25
+ #include <utils/url_codec.hxx>
26
+
27
+ namespace couchbase::operations::analytics_link
28
+ {
29
+ /**
30
+ * An external analytics link which uses the AWS S3 service to access data.
31
+ */
32
+ struct s3_external {
33
+ /**
34
+ * The name of this link.
35
+ */
36
+ std::string link_name{};
37
+
38
+ /**
39
+ * The dataverse that this link belongs to.
40
+ */
41
+ std::string dataverse{};
42
+
43
+ /**
44
+ * AWS S3 access key ID
45
+ */
46
+ std::string access_key_id{};
47
+
48
+ /**
49
+ * AWS S3 secret key
50
+ */
51
+ std::string secret_access_key{};
52
+
53
+ /**
54
+ * AWS S3 token if temporary credentials are provided. Only available in 7.0+
55
+ */
56
+ std::optional<std::string> session_token{};
57
+
58
+ /**
59
+ * AWS S3 region
60
+ */
61
+ std::string region{};
62
+
63
+ /**
64
+ * AWS S3 service endpoint
65
+ */
66
+ std::optional<std::string> service_endpoint{};
67
+
68
+ [[nodiscard]] std::error_code validate() const
69
+ {
70
+ if (dataverse.empty() || link_name.empty() || access_key_id.empty() || secret_access_key.empty() || region.empty()) {
71
+ return error::common_errc::invalid_argument;
72
+ }
73
+ return {};
74
+ }
75
+
76
+ [[nodiscard]] std::string encode() const
77
+ {
78
+ std::map<std::string, std::string> values{
79
+ { "type", "s3" },
80
+ { "accessKeyId", access_key_id },
81
+ { "secretAccessKey", secret_access_key },
82
+ { "region", region },
83
+ };
84
+ if (std::count(dataverse.begin(), dataverse.end(), '/') == 0) {
85
+ values["dataverse"] = dataverse;
86
+ values["name"] = link_name;
87
+ }
88
+ if (session_token) {
89
+ values["sessionToken"] = session_token.value();
90
+ }
91
+ if (service_endpoint) {
92
+ values["serviceEndpoint"] = service_endpoint.value();
93
+ }
94
+ return utils::string_codec::v2::form_encode(values);
95
+ }
96
+ };
97
+ } // namespace couchbase::operations::analytics_link
98
+
99
+ namespace tao::json
100
+ {
101
+ template<>
102
+ struct traits<couchbase::operations::analytics_link::s3_external> {
103
+ template<template<typename...> class Traits>
104
+ static couchbase::operations::analytics_link::s3_external as(const tao::json::basic_value<Traits>& v)
105
+ {
106
+ couchbase::operations::analytics_link::s3_external result{};
107
+
108
+ result.link_name = v.at("name").get_string();
109
+ if (const auto* dataverse = v.find("dataverse"); dataverse != nullptr) {
110
+ result.dataverse = dataverse->get_string();
111
+ } else {
112
+ result.dataverse = v.at("scope").get_string();
113
+ }
114
+ result.access_key_id = v.at("accessKeyId").get_string();
115
+ result.region = v.at("region").get_string();
116
+ if (const auto* service_endpoint = v.find("serviceEndpoint"); service_endpoint != nullptr && service_endpoint->is_string()) {
117
+ result.service_endpoint.emplace(service_endpoint->get_string());
118
+ }
119
+ return result;
120
+ }
121
+ };
122
+ } // namespace tao::json
@@ -44,7 +44,7 @@ struct bucket_create_request {
44
44
  std::chrono::milliseconds timeout{ timeout_defaults::management_timeout };
45
45
  std::string client_context_id{ uuid::to_string(uuid::random()) };
46
46
 
47
- [[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, http_context&)
47
+ [[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, http_context& /* context */) const
48
48
  {
49
49
  encoded.method = "POST";
50
50
  encoded.path = fmt::format("/pools/default/buckets");
@@ -129,23 +129,23 @@ struct bucket_create_request {
129
129
  };
130
130
 
131
131
  bucket_create_response
132
- make_response(error_context::http&& ctx, bucket_create_request&, bucket_create_request::encoded_response_type&& encoded)
132
+ make_response(error_context::http&& ctx, const bucket_create_request& /* request */, bucket_create_request::encoded_response_type&& encoded)
133
133
  {
134
- bucket_create_response response{ ctx };
134
+ bucket_create_response response{ std::move(ctx) };
135
135
  if (!response.ctx.ec) {
136
136
  switch (encoded.status_code) {
137
137
  case 404:
138
- response.ctx.ec = std::make_error_code(error::common_errc::bucket_not_found);
138
+ response.ctx.ec = error::common_errc::bucket_not_found;
139
139
  break;
140
140
  case 400: {
141
141
  tao::json::value payload{};
142
142
  try {
143
143
  payload = tao::json::from_string(encoded.body);
144
- } catch (tao::json::pegtl::parse_error& e) {
145
- response.ctx.ec = std::make_error_code(error::common_errc::parsing_failure);
144
+ } catch (const tao::json::pegtl::parse_error& e) {
145
+ response.ctx.ec = error::common_errc::parsing_failure;
146
146
  return response;
147
147
  }
148
- response.ctx.ec = std::make_error_code(error::common_errc::invalid_argument);
148
+ response.ctx.ec = error::common_errc::invalid_argument;
149
149
  auto* errors = payload.find("errors");
150
150
  if (errors != nullptr) {
151
151
  std::vector<std::string> error_list{};
@@ -161,7 +161,7 @@ make_response(error_context::http&& ctx, bucket_create_request&, bucket_create_r
161
161
  case 202:
162
162
  break;
163
163
  default:
164
- response.ctx.ec = std::make_error_code(error::common_errc::internal_server_failure);
164
+ response.ctx.ec = error::common_errc::internal_server_failure;
165
165
  break;
166
166
  }
167
167
  }
@@ -39,7 +39,7 @@ struct bucket_drop_request {
39
39
  std::chrono::milliseconds timeout{ timeout_defaults::management_timeout };
40
40
  std::string client_context_id{ uuid::to_string(uuid::random()) };
41
41
 
42
- [[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, http_context&)
42
+ [[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, http_context& /* context */) const
43
43
  {
44
44
  encoded.method = "DELETE";
45
45
  encoded.path = fmt::format("/pools/default/buckets/{}", name);
@@ -48,19 +48,19 @@ struct bucket_drop_request {
48
48
  };
49
49
 
50
50
  bucket_drop_response
51
- make_response(error_context::http&& ctx, bucket_drop_request&, bucket_drop_request::encoded_response_type&& encoded)
51
+ make_response(error_context::http&& ctx, const bucket_drop_request& /* request */, bucket_drop_request::encoded_response_type&& encoded)
52
52
  {
53
- bucket_drop_response response{ ctx };
53
+ bucket_drop_response response{ std::move(ctx) };
54
54
  if (!response.ctx.ec) {
55
55
  switch (encoded.status_code) {
56
56
  case 404:
57
- response.ctx.ec = std::make_error_code(error::common_errc::bucket_not_found);
57
+ response.ctx.ec = error::common_errc::bucket_not_found;
58
58
  break;
59
59
  case 200:
60
60
  response.ctx.ec = {};
61
61
  break;
62
62
  default:
63
- response.ctx.ec = std::make_error_code(error::common_errc::internal_server_failure);
63
+ response.ctx.ec = error::common_errc::internal_server_failure;
64
64
  break;
65
65
  }
66
66
  }
@@ -38,7 +38,7 @@ struct bucket_flush_request {
38
38
  std::chrono::milliseconds timeout{ timeout_defaults::management_timeout };
39
39
  std::string client_context_id{ uuid::to_string(uuid::random()) };
40
40
 
41
- [[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, http_context&)
41
+ [[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, http_context& /* context */) const
42
42
  {
43
43
  encoded.method = "POST";
44
44
  encoded.path = fmt::format("/pools/default/buckets/{}/controller/doFlush", name);
@@ -47,19 +47,19 @@ struct bucket_flush_request {
47
47
  };
48
48
 
49
49
  bucket_flush_response
50
- make_response(error_context::http&& ctx, bucket_flush_request&, bucket_flush_request::encoded_response_type&& encoded)
50
+ make_response(error_context::http&& ctx, const bucket_flush_request& /* request */, bucket_flush_request::encoded_response_type&& encoded)
51
51
  {
52
- bucket_flush_response response{ ctx };
52
+ bucket_flush_response response{ std::move(ctx) };
53
53
  if (!response.ctx.ec) {
54
54
  switch (encoded.status_code) {
55
55
  case 404:
56
- response.ctx.ec = std::make_error_code(error::common_errc::bucket_not_found);
56
+ response.ctx.ec = error::common_errc::bucket_not_found;
57
57
  break;
58
58
  case 200:
59
59
  response.ctx.ec = {};
60
60
  break;
61
61
  default:
62
- response.ctx.ec = std::make_error_code(error::common_errc::internal_server_failure);
62
+ response.ctx.ec = error::common_errc::internal_server_failure;
63
63
  break;
64
64
  }
65
65
  }
@@ -42,7 +42,7 @@ struct bucket_get_request {
42
42
  std::chrono::milliseconds timeout{ timeout_defaults::management_timeout };
43
43
  std::string client_context_id{ uuid::to_string(uuid::random()) };
44
44
 
45
- [[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, http_context&)
45
+ [[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, http_context& /* context */) const
46
46
  {
47
47
  encoded.method = "GET";
48
48
  encoded.path = fmt::format("/pools/default/buckets/{}", name);
@@ -51,24 +51,24 @@ struct bucket_get_request {
51
51
  };
52
52
 
53
53
  bucket_get_response
54
- make_response(error_context::http&& ctx, bucket_get_request&, bucket_get_request::encoded_response_type&& encoded)
54
+ make_response(error_context::http&& ctx, const bucket_get_request& /* request */, bucket_get_request::encoded_response_type&& encoded)
55
55
  {
56
- bucket_get_response response{ ctx };
56
+ bucket_get_response response{ std::move(ctx) };
57
57
  if (!response.ctx.ec) {
58
58
  switch (encoded.status_code) {
59
59
  case 404:
60
- response.ctx.ec = std::make_error_code(error::common_errc::bucket_not_found);
60
+ response.ctx.ec = error::common_errc::bucket_not_found;
61
61
  break;
62
62
  case 200:
63
63
  try {
64
64
  response.bucket = tao::json::from_string(encoded.body).as<bucket_settings>();
65
- } catch (tao::json::pegtl::parse_error& e) {
66
- response.ctx.ec = std::make_error_code(error::common_errc::parsing_failure);
65
+ } catch (const tao::json::pegtl::parse_error& e) {
66
+ response.ctx.ec = error::common_errc::parsing_failure;
67
67
  return response;
68
68
  }
69
69
  break;
70
70
  default:
71
- response.ctx.ec = std::make_error_code(error::common_errc::internal_server_failure);
71
+ response.ctx.ec = error::common_errc::internal_server_failure;
72
72
  break;
73
73
  }
74
74
  }
@@ -41,7 +41,7 @@ struct bucket_get_all_request {
41
41
  std::chrono::milliseconds timeout{ timeout_defaults::management_timeout };
42
42
  std::string client_context_id{ uuid::to_string(uuid::random()) };
43
43
 
44
- [[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, http_context&)
44
+ [[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, http_context& /* context */) const
45
45
  {
46
46
  encoded.method = "GET";
47
47
  encoded.path = "/pools/default/buckets";
@@ -50,15 +50,17 @@ struct bucket_get_all_request {
50
50
  };
51
51
 
52
52
  bucket_get_all_response
53
- make_response(error_context::http&& ctx, bucket_get_all_request&, bucket_get_all_request::encoded_response_type&& encoded)
53
+ make_response(error_context::http&& ctx,
54
+ const bucket_get_all_request& /* request */,
55
+ bucket_get_all_request::encoded_response_type&& encoded)
54
56
  {
55
- bucket_get_all_response response{ ctx };
57
+ bucket_get_all_response response{ std::move(ctx) };
56
58
  if (!response.ctx.ec) {
57
59
  tao::json::value payload{};
58
60
  try {
59
61
  payload = tao::json::from_string(encoded.body);
60
- } catch (tao::json::pegtl::parse_error& e) {
61
- response.ctx.ec = std::make_error_code(error::common_errc::parsing_failure);
62
+ } catch (const tao::json::pegtl::parse_error& e) {
63
+ response.ctx.ec = error::common_errc::parsing_failure;
62
64
  return response;
63
65
  }
64
66
  const auto& entries = payload.get_array();
@@ -81,61 +81,52 @@ struct traits<couchbase::operations::bucket_settings> {
81
81
  result.ram_quota_mb = v.at("quota").at("rawRAM").get_unsigned() / megabyte;
82
82
  result.max_expiry = v.at("maxTTL").template as<std::uint32_t>();
83
83
  result.num_replicas = v.at("replicaNumber").template as<std::uint32_t>();
84
- {
85
- auto& str = v.at("bucketType").get_string();
86
- if (str == "couchbase" || str == "membase") {
87
- result.bucket_type = couchbase::operations::bucket_settings::bucket_type::couchbase;
88
- } else if (str == "ephemeral") {
89
- result.bucket_type = couchbase::operations::bucket_settings::bucket_type::ephemeral;
90
- } else if (str == "memcached") {
91
- result.bucket_type = couchbase::operations::bucket_settings::bucket_type::memcached;
92
- }
84
+
85
+ if (auto& str = v.at("bucketType").get_string(); str == "couchbase" || str == "membase") {
86
+ result.bucket_type = couchbase::operations::bucket_settings::bucket_type::couchbase;
87
+ } else if (str == "ephemeral") {
88
+ result.bucket_type = couchbase::operations::bucket_settings::bucket_type::ephemeral;
89
+ } else if (str == "memcached") {
90
+ result.bucket_type = couchbase::operations::bucket_settings::bucket_type::memcached;
93
91
  }
94
- {
95
- auto& str = v.at("compressionMode").get_string();
96
- if (str == "active") {
97
- result.compression_mode = couchbase::operations::bucket_settings::compression_mode::active;
98
- } else if (str == "passive") {
99
- result.compression_mode = couchbase::operations::bucket_settings::compression_mode::passive;
100
- } else if (str == "off") {
101
- result.compression_mode = couchbase::operations::bucket_settings::compression_mode::off;
102
- }
92
+
93
+ if (auto& str = v.at("compressionMode").get_string(); str == "active") {
94
+ result.compression_mode = couchbase::operations::bucket_settings::compression_mode::active;
95
+ } else if (str == "passive") {
96
+ result.compression_mode = couchbase::operations::bucket_settings::compression_mode::passive;
97
+ } else if (str == "off") {
98
+ result.compression_mode = couchbase::operations::bucket_settings::compression_mode::off;
103
99
  }
104
- {
105
- auto& str = v.at("evictionPolicy").get_string();
106
- if (str == "valueOnly") {
107
- result.eviction_policy = couchbase::operations::bucket_settings::eviction_policy::value_only;
108
- } else if (str == "fullEviction") {
109
- result.eviction_policy = couchbase::operations::bucket_settings::eviction_policy::full;
110
- } else if (str == "noEviction") {
111
- result.eviction_policy = couchbase::operations::bucket_settings::eviction_policy::no_eviction;
112
- } else if (str == "nruEviction") {
113
- result.eviction_policy = couchbase::operations::bucket_settings::eviction_policy::not_recently_used;
114
- }
100
+
101
+ if (auto& str = v.at("evictionPolicy").get_string(); str == "valueOnly") {
102
+ result.eviction_policy = couchbase::operations::bucket_settings::eviction_policy::value_only;
103
+ } else if (str == "fullEviction") {
104
+ result.eviction_policy = couchbase::operations::bucket_settings::eviction_policy::full;
105
+ } else if (str == "noEviction") {
106
+ result.eviction_policy = couchbase::operations::bucket_settings::eviction_policy::no_eviction;
107
+ } else if (str == "nruEviction") {
108
+ result.eviction_policy = couchbase::operations::bucket_settings::eviction_policy::not_recently_used;
115
109
  }
116
- {
117
- auto* min_level = v.find("durabilityMinLevel");
118
- if (min_level != nullptr) {
119
- auto& str = min_level->get_string();
120
- if (str == "none") {
121
- result.minimum_durability_level = couchbase::protocol::durability_level::none;
122
- } else if (str == "majority") {
123
- result.minimum_durability_level = couchbase::protocol::durability_level::majority;
124
- } else if (str == "majorityAndPersistActive") {
125
- result.minimum_durability_level = couchbase::protocol::durability_level::majority_and_persist_to_active;
126
- } else if (str == "persistToMajority") {
127
- result.minimum_durability_level = couchbase::protocol::durability_level::persist_to_majority;
128
- }
110
+
111
+ if (auto* min_level = v.find("durabilityMinLevel"); min_level != nullptr) {
112
+ auto& str = min_level->get_string();
113
+ if (str == "none") {
114
+ result.minimum_durability_level = couchbase::protocol::durability_level::none;
115
+ } else if (str == "majority") {
116
+ result.minimum_durability_level = couchbase::protocol::durability_level::majority;
117
+ } else if (str == "majorityAndPersistActive") {
118
+ result.minimum_durability_level = couchbase::protocol::durability_level::majority_and_persist_to_active;
119
+ } else if (str == "persistToMajority") {
120
+ result.minimum_durability_level = couchbase::protocol::durability_level::persist_to_majority;
129
121
  }
130
122
  }
131
- {
132
- auto& str = v.at("conflictResolutionType").get_string();
133
- if (str == "lww") {
134
- result.conflict_resolution_type = couchbase::operations::bucket_settings::conflict_resolution_type::timestamp;
135
- } else if (str == "seqno") {
136
- result.conflict_resolution_type = couchbase::operations::bucket_settings::conflict_resolution_type::sequence_number;
137
- }
123
+
124
+ if (auto& str = v.at("conflictResolutionType").get_string(); str == "lww") {
125
+ result.conflict_resolution_type = couchbase::operations::bucket_settings::conflict_resolution_type::timestamp;
126
+ } else if (str == "seqno") {
127
+ result.conflict_resolution_type = couchbase::operations::bucket_settings::conflict_resolution_type::sequence_number;
138
128
  }
129
+
139
130
  result.flush_enabled = v.at("controllers").find("flush") != nullptr;
140
131
  const auto ri = v.find("replicaIndex");
141
132
  if (ri) {