couchbase 3.1.1 → 3.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/ext/CMakeLists.txt +3 -1
- data/ext/build_version.hxx.in +1 -1
- data/ext/cmake/Testing.cmake +1 -0
- data/ext/cmake/ThirdPartyDependencies.cmake +6 -0
- data/ext/cmake/VersionInfo.cmake +3 -0
- data/ext/couchbase/bucket.hxx +47 -28
- data/ext/couchbase/cbsasl/client.h +1 -1
- data/ext/couchbase/cbsasl/context.cc +1 -1
- data/ext/couchbase/cbsasl/context.h +3 -3
- data/ext/couchbase/cbsasl/mechanism.cc +5 -8
- data/ext/couchbase/cbsasl/mechanism.h +1 -4
- data/ext/couchbase/cbsasl/plain/plain.cc +1 -1
- data/ext/couchbase/cbsasl/scram-sha/scram-sha.cc +30 -36
- data/ext/couchbase/cluster.hxx +40 -22
- data/ext/couchbase/cluster_options.hxx +7 -1
- data/ext/couchbase/configuration.hxx +37 -16
- data/ext/couchbase/couchbase.cxx +1145 -291
- data/ext/couchbase/error_map.hxx +1 -1
- data/ext/couchbase/errors.hxx +25 -17
- data/ext/couchbase/io/dns_client.hxx +3 -3
- data/ext/couchbase/io/dns_codec.hxx +4 -5
- data/ext/couchbase/io/dns_config.hxx +5 -6
- data/ext/couchbase/io/dns_message.hxx +3 -3
- data/ext/couchbase/io/http_command.hxx +70 -35
- data/ext/couchbase/io/http_session.hxx +4 -3
- data/ext/couchbase/io/http_session_manager.hxx +28 -19
- data/ext/couchbase/io/mcbp_command.hxx +51 -19
- data/ext/couchbase/io/mcbp_context.hxx +1 -1
- data/ext/couchbase/io/mcbp_parser.hxx +4 -4
- data/ext/couchbase/io/mcbp_session.hxx +91 -101
- data/ext/couchbase/io/query_cache.hxx +2 -2
- data/ext/couchbase/io/retry_orchestrator.hxx +2 -4
- data/ext/couchbase/io/retry_reason.hxx +2 -2
- data/ext/couchbase/io/retry_strategy.hxx +1 -6
- data/ext/couchbase/io/streams.hxx +7 -7
- data/ext/couchbase/metrics/logging_meter.hxx +228 -0
- data/ext/couchbase/metrics/logging_meter_options.hxx +28 -0
- data/ext/couchbase/metrics/meter.hxx +49 -0
- data/ext/couchbase/metrics/noop_meter.hxx +43 -0
- data/ext/couchbase/operations/analytics_dataset_create.hxx +16 -12
- data/ext/couchbase/operations/analytics_dataset_drop.hxx +11 -11
- data/ext/couchbase/operations/analytics_dataset_get_all.hxx +6 -6
- data/ext/couchbase/operations/analytics_dataverse_create.hxx +10 -11
- data/ext/couchbase/operations/analytics_dataverse_drop.hxx +10 -11
- data/ext/couchbase/operations/analytics_get_pending_mutations.hxx +9 -11
- data/ext/couchbase/operations/analytics_index_create.hxx +14 -13
- data/ext/couchbase/operations/analytics_index_drop.hxx +18 -12
- data/ext/couchbase/operations/analytics_index_get_all.hxx +8 -6
- data/ext/couchbase/operations/analytics_link.hxx +39 -0
- data/ext/couchbase/operations/analytics_link_azure_blob_external.hxx +145 -0
- data/ext/couchbase/operations/analytics_link_connect.hxx +14 -12
- data/ext/couchbase/operations/analytics_link_couchbase_remote.hxx +220 -0
- data/ext/couchbase/operations/analytics_link_create.hxx +128 -0
- data/ext/couchbase/operations/analytics_link_disconnect.hxx +11 -12
- data/ext/couchbase/operations/analytics_link_drop.hxx +130 -0
- data/ext/couchbase/operations/analytics_link_get_all.hxx +160 -0
- data/ext/couchbase/operations/analytics_link_replace.hxx +128 -0
- data/ext/couchbase/operations/analytics_link_s3_external.hxx +122 -0
- data/ext/couchbase/operations/bucket_create.hxx +8 -8
- data/ext/couchbase/operations/bucket_drop.hxx +5 -5
- data/ext/couchbase/operations/bucket_flush.hxx +5 -5
- data/ext/couchbase/operations/bucket_get.hxx +7 -7
- data/ext/couchbase/operations/bucket_get_all.hxx +7 -5
- data/ext/couchbase/operations/bucket_settings.hxx +40 -49
- data/ext/couchbase/operations/bucket_update.hxx +8 -8
- data/ext/couchbase/operations/cluster_developer_preview_enable.hxx +7 -7
- data/ext/couchbase/operations/collection_create.hxx +11 -11
- data/ext/couchbase/operations/collection_drop.hxx +12 -10
- data/ext/couchbase/operations/collections_manifest_get.hxx +3 -3
- data/ext/couchbase/operations/design_document.hxx +2 -2
- data/ext/couchbase/operations/document_analytics.hxx +29 -36
- data/ext/couchbase/operations/document_append.hxx +3 -3
- data/ext/couchbase/operations/document_decrement.hxx +3 -3
- data/ext/couchbase/operations/document_exists.hxx +2 -2
- data/ext/couchbase/operations/document_get.hxx +3 -3
- data/ext/couchbase/operations/document_get_and_lock.hxx +5 -3
- data/ext/couchbase/operations/document_get_and_touch.hxx +5 -3
- data/ext/couchbase/operations/document_get_projected.hxx +10 -11
- data/ext/couchbase/operations/document_increment.hxx +3 -3
- data/ext/couchbase/operations/document_insert.hxx +3 -3
- data/ext/couchbase/operations/document_lookup_in.hxx +12 -18
- data/ext/couchbase/operations/document_mutate_in.hxx +13 -18
- data/ext/couchbase/operations/document_prepend.hxx +3 -3
- data/ext/couchbase/operations/document_query.hxx +39 -41
- data/ext/couchbase/operations/document_remove.hxx +3 -3
- data/ext/couchbase/operations/document_replace.hxx +3 -3
- data/ext/couchbase/operations/document_search.hxx +56 -61
- data/ext/couchbase/operations/document_touch.hxx +3 -3
- data/ext/couchbase/operations/document_unlock.hxx +3 -3
- data/ext/couchbase/operations/document_upsert.hxx +3 -3
- data/ext/couchbase/operations/document_view.hxx +23 -23
- data/ext/couchbase/operations/group_drop.hxx +5 -5
- data/ext/couchbase/operations/group_get.hxx +7 -7
- data/ext/couchbase/operations/group_get_all.hxx +6 -6
- data/ext/couchbase/operations/group_upsert.hxx +11 -11
- data/ext/couchbase/operations/http_noop.hxx +6 -6
- data/ext/couchbase/operations/mcbp_noop.hxx +3 -3
- data/ext/couchbase/operations/query_index_build_deferred.hxx +6 -6
- data/ext/couchbase/operations/query_index_create.hxx +10 -8
- data/ext/couchbase/operations/query_index_drop.hxx +8 -8
- data/ext/couchbase/operations/query_index_get_all.hxx +43 -39
- data/ext/couchbase/operations/rbac.hxx +40 -63
- data/ext/couchbase/operations/role_get_all.hxx +6 -6
- data/ext/couchbase/operations/scope_create.hxx +10 -10
- data/ext/couchbase/operations/scope_drop.hxx +9 -9
- data/ext/couchbase/operations/scope_get_all.hxx +8 -8
- data/ext/couchbase/operations/search_get_stats.hxx +5 -3
- data/ext/couchbase/operations/search_index.hxx +6 -15
- data/ext/couchbase/operations/search_index_analyze_document.hxx +11 -11
- data/ext/couchbase/operations/search_index_control_ingest.hxx +9 -9
- data/ext/couchbase/operations/search_index_control_plan_freeze.hxx +9 -9
- data/ext/couchbase/operations/search_index_control_query.hxx +9 -9
- data/ext/couchbase/operations/search_index_drop.hxx +11 -9
- data/ext/couchbase/operations/search_index_get.hxx +11 -9
- data/ext/couchbase/operations/search_index_get_all.hxx +11 -11
- data/ext/couchbase/operations/search_index_get_documents_count.hxx +10 -10
- data/ext/couchbase/operations/search_index_get_stats.hxx +10 -8
- data/ext/couchbase/operations/search_index_upsert.hxx +12 -10
- data/ext/couchbase/operations/user_drop.hxx +5 -5
- data/ext/couchbase/operations/user_get.hxx +7 -7
- data/ext/couchbase/operations/user_get_all.hxx +6 -6
- data/ext/couchbase/operations/user_upsert.hxx +9 -9
- data/ext/couchbase/operations/view_index_drop.hxx +10 -10
- data/ext/couchbase/operations/view_index_get.hxx +13 -15
- data/ext/couchbase/operations/view_index_get_all.hxx +17 -20
- data/ext/couchbase/operations/view_index_upsert.hxx +9 -7
- data/ext/couchbase/operations.hxx +4 -0
- data/ext/couchbase/origin.hxx +14 -10
- data/ext/couchbase/platform/backtrace.c +1 -1
- data/ext/couchbase/platform/base64.cc +5 -5
- data/ext/couchbase/platform/base64.h +2 -5
- data/ext/couchbase/protocol/client_opcode.hxx +7 -4
- data/ext/couchbase/protocol/client_request.hxx +2 -2
- data/ext/couchbase/protocol/client_response.hxx +41 -16
- data/ext/couchbase/protocol/cmd_append.hxx +17 -16
- data/ext/couchbase/protocol/cmd_cluster_map_change_notification.hxx +4 -4
- data/ext/couchbase/protocol/cmd_decrement.hxx +10 -11
- data/ext/couchbase/protocol/cmd_exists.hxx +12 -15
- data/ext/couchbase/protocol/cmd_get.hxx +11 -14
- data/ext/couchbase/protocol/cmd_get_and_lock.hxx +10 -12
- data/ext/couchbase/protocol/cmd_get_and_touch.hxx +10 -12
- data/ext/couchbase/protocol/cmd_get_cluster_config.hxx +13 -18
- data/ext/couchbase/protocol/cmd_get_collection_id.hxx +12 -15
- data/ext/couchbase/protocol/cmd_get_collections_manifest.hxx +12 -16
- data/ext/couchbase/protocol/cmd_get_error_map.hxx +14 -17
- data/ext/couchbase/protocol/cmd_hello.hxx +8 -10
- data/ext/couchbase/protocol/cmd_increment.hxx +9 -10
- data/ext/couchbase/protocol/cmd_insert.hxx +9 -9
- data/ext/couchbase/protocol/cmd_lookup_in.hxx +12 -13
- data/ext/couchbase/protocol/cmd_mutate_in.hxx +11 -11
- data/ext/couchbase/protocol/cmd_noop.hxx +16 -20
- data/ext/couchbase/protocol/cmd_prepend.hxx +9 -10
- data/ext/couchbase/protocol/cmd_remove.hxx +10 -13
- data/ext/couchbase/protocol/cmd_replace.hxx +7 -7
- data/ext/couchbase/protocol/cmd_sasl_auth.hxx +8 -10
- data/ext/couchbase/protocol/cmd_sasl_list_mechs.hxx +10 -15
- data/ext/couchbase/protocol/cmd_sasl_step.hxx +10 -12
- data/ext/couchbase/protocol/cmd_select_bucket.hxx +14 -18
- data/ext/couchbase/protocol/cmd_touch.hxx +8 -11
- data/ext/couchbase/protocol/cmd_unlock.hxx +10 -14
- data/ext/couchbase/protocol/cmd_upsert.hxx +8 -8
- data/ext/couchbase/protocol/datatype.hxx +3 -3
- data/ext/couchbase/protocol/durability_level.hxx +2 -2
- data/ext/couchbase/protocol/frame_info_id.hxx +4 -4
- data/ext/couchbase/protocol/hello_feature.hxx +2 -2
- data/ext/couchbase/protocol/magic.hxx +2 -2
- data/ext/couchbase/protocol/server_opcode.hxx +2 -2
- data/ext/couchbase/protocol/server_request.hxx +1 -1
- data/ext/couchbase/protocol/status.hxx +4 -7
- data/ext/couchbase/protocol/unsigned_leb128.h +5 -20
- data/ext/couchbase/service_type.hxx +4 -4
- data/ext/couchbase/tracing/constants.hxx +261 -0
- data/ext/couchbase/tracing/noop_tracer.hxx +50 -0
- data/ext/couchbase/tracing/request_tracer.hxx +77 -0
- data/ext/couchbase/tracing/threshold_logging_options.hxx +64 -0
- data/ext/couchbase/tracing/threshold_logging_tracer.hxx +366 -0
- data/ext/couchbase/utils/byteswap.hxx +1 -1
- data/ext/couchbase/utils/connection_string.hxx +21 -1
- data/ext/couchbase/utils/name_codec.hxx +41 -0
- data/ext/couchbase/utils/url_codec.hxx +236 -0
- data/ext/couchbase/version.hxx +1 -1
- data/ext/test/CMakeLists.txt +1 -0
- data/ext/test/test_native_trivial_query.cxx +60 -0
- data/ext/third_party/hdr_histogram_c/CMakeLists.txt +84 -0
- data/ext/third_party/hdr_histogram_c/COPYING.txt +121 -0
- data/ext/third_party/hdr_histogram_c/LICENSE.txt +41 -0
- data/ext/third_party/hdr_histogram_c/config.cmake.in +6 -0
- data/ext/third_party/hdr_histogram_c/src/CMakeLists.txt +83 -0
- data/ext/third_party/hdr_histogram_c/src/hdr_atomic.h +146 -0
- data/ext/third_party/hdr_histogram_c/src/hdr_encoding.c +322 -0
- data/ext/third_party/hdr_histogram_c/src/hdr_encoding.h +79 -0
- data/ext/third_party/hdr_histogram_c/src/hdr_endian.h +116 -0
- data/ext/third_party/hdr_histogram_c/src/hdr_histogram.c +1196 -0
- data/ext/third_party/hdr_histogram_c/src/hdr_histogram.h +516 -0
- data/ext/third_party/hdr_histogram_c/src/hdr_histogram_log.c +1290 -0
- data/ext/third_party/hdr_histogram_c/src/hdr_histogram_log.h +236 -0
- data/ext/third_party/hdr_histogram_c/src/hdr_histogram_log_no_op.c +171 -0
- data/ext/third_party/hdr_histogram_c/src/hdr_interval_recorder.c +227 -0
- data/ext/third_party/hdr_histogram_c/src/hdr_interval_recorder.h +109 -0
- data/ext/third_party/hdr_histogram_c/src/hdr_malloc.h +19 -0
- data/ext/third_party/hdr_histogram_c/src/hdr_tests.h +22 -0
- data/ext/third_party/hdr_histogram_c/src/hdr_thread.c +108 -0
- data/ext/third_party/hdr_histogram_c/src/hdr_thread.h +55 -0
- data/ext/third_party/hdr_histogram_c/src/hdr_time.c +98 -0
- data/ext/third_party/hdr_histogram_c/src/hdr_time.h +49 -0
- data/ext/third_party/hdr_histogram_c/src/hdr_writer_reader_phaser.c +143 -0
- data/ext/third_party/hdr_histogram_c/src/hdr_writer_reader_phaser.h +51 -0
- data/lib/couchbase/cluster.rb +1 -0
- data/lib/couchbase/errors.rb +3 -0
- data/lib/couchbase/management/analytics_index_manager.rb +920 -226
- data/lib/couchbase/management/bucket_manager.rb +207 -69
- data/lib/couchbase/management/collection_manager.rb +173 -61
- data/lib/couchbase/management/query_index_manager.rb +357 -169
- data/lib/couchbase/options.rb +75 -3
- data/lib/couchbase/scope.rb +102 -0
- data/lib/couchbase/utils/time.rb +4 -0
- data/lib/couchbase/version.rb +6 -6
- metadata +50 -7
@@ -43,7 +43,7 @@ struct group_get_request {
|
|
43
43
|
std::chrono::milliseconds timeout{ timeout_defaults::management_timeout };
|
44
44
|
std::string client_context_id{ uuid::to_string(uuid::random()) };
|
45
45
|
|
46
|
-
[[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, http_context&)
|
46
|
+
[[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, http_context& /* context */) const
|
47
47
|
{
|
48
48
|
encoded.method = "GET";
|
49
49
|
encoded.path = fmt::format("/settings/rbac/groups/{}", name);
|
@@ -53,24 +53,24 @@ struct group_get_request {
|
|
53
53
|
};
|
54
54
|
|
55
55
|
group_get_response
|
56
|
-
make_response(error_context::http&& ctx, group_get_request
|
56
|
+
make_response(error_context::http&& ctx, const group_get_request& /* request */, group_get_request::encoded_response_type&& encoded)
|
57
57
|
{
|
58
|
-
group_get_response response{ ctx };
|
58
|
+
group_get_response response{ std::move(ctx) };
|
59
59
|
if (!response.ctx.ec) {
|
60
60
|
switch (encoded.status_code) {
|
61
61
|
case 200: {
|
62
62
|
try {
|
63
63
|
response.group = tao::json::from_string(encoded.body).as<rbac::group>();
|
64
|
-
} catch (tao::json::pegtl::parse_error& e) {
|
65
|
-
response.ctx.ec =
|
64
|
+
} catch (const tao::json::pegtl::parse_error& e) {
|
65
|
+
response.ctx.ec = error::common_errc::parsing_failure;
|
66
66
|
return response;
|
67
67
|
}
|
68
68
|
} break;
|
69
69
|
case 404:
|
70
|
-
response.ctx.ec =
|
70
|
+
response.ctx.ec = error::management_errc::group_not_found;
|
71
71
|
break;
|
72
72
|
default:
|
73
|
-
response.ctx.ec =
|
73
|
+
response.ctx.ec = error::common_errc::internal_server_failure;
|
74
74
|
break;
|
75
75
|
}
|
76
76
|
}
|
@@ -42,7 +42,7 @@ struct group_get_all_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("/settings/rbac/groups");
|
@@ -52,23 +52,23 @@ struct group_get_all_request {
|
|
52
52
|
};
|
53
53
|
|
54
54
|
group_get_all_response
|
55
|
-
make_response(error_context::http&& ctx, group_get_all_request
|
55
|
+
make_response(error_context::http&& ctx, const group_get_all_request& /* request */, group_get_all_request::encoded_response_type&& encoded)
|
56
56
|
{
|
57
|
-
group_get_all_response response{ ctx };
|
57
|
+
group_get_all_response response{ std::move(ctx) };
|
58
58
|
if (!response.ctx.ec) {
|
59
59
|
if (encoded.status_code == 200) {
|
60
60
|
tao::json::value payload{};
|
61
61
|
try {
|
62
62
|
payload = tao::json::from_string(encoded.body);
|
63
|
-
} catch (tao::json::pegtl::parse_error& e) {
|
64
|
-
response.ctx.ec =
|
63
|
+
} catch (const tao::json::pegtl::parse_error& e) {
|
64
|
+
response.ctx.ec = error::common_errc::parsing_failure;
|
65
65
|
return response;
|
66
66
|
}
|
67
67
|
for (const auto& entry : payload.get_array()) {
|
68
68
|
response.groups.emplace_back(entry.as<rbac::group>());
|
69
69
|
}
|
70
70
|
} else {
|
71
|
-
response.ctx.ec =
|
71
|
+
response.ctx.ec = error::common_errc::internal_server_failure;
|
72
72
|
}
|
73
73
|
}
|
74
74
|
return response;
|
@@ -47,7 +47,7 @@ struct group_upsert_request {
|
|
47
47
|
std::chrono::milliseconds timeout{ timeout_defaults::management_timeout };
|
48
48
|
std::string client_context_id{ uuid::to_string(uuid::random()) };
|
49
49
|
|
50
|
-
[[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, http_context&)
|
50
|
+
[[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, http_context& /* context */) const
|
51
51
|
{
|
52
52
|
encoded.method = "PUT";
|
53
53
|
encoded.path = fmt::format("/settings/rbac/groups/{}", group.name);
|
@@ -91,31 +91,31 @@ struct group_upsert_request {
|
|
91
91
|
};
|
92
92
|
|
93
93
|
group_upsert_response
|
94
|
-
make_response(error_context::http&& ctx, group_upsert_request
|
94
|
+
make_response(error_context::http&& ctx, const group_upsert_request& /* request */, group_upsert_request::encoded_response_type&& encoded)
|
95
95
|
{
|
96
|
-
group_upsert_response response{ ctx };
|
96
|
+
group_upsert_response response{ std::move(ctx) };
|
97
97
|
if (!response.ctx.ec) {
|
98
98
|
switch (encoded.status_code) {
|
99
99
|
case 200:
|
100
100
|
break;
|
101
101
|
case 400: {
|
102
|
-
response.ctx.ec =
|
102
|
+
response.ctx.ec = error::common_errc::invalid_argument;
|
103
103
|
tao::json::value payload{};
|
104
104
|
try {
|
105
105
|
payload = tao::json::from_string(encoded.body);
|
106
|
-
} catch (tao::json::pegtl::parse_error&
|
107
|
-
response.ctx.ec =
|
106
|
+
} catch (const tao::json::pegtl::parse_error&) {
|
107
|
+
response.ctx.ec = error::common_errc::parsing_failure;
|
108
108
|
return response;
|
109
109
|
}
|
110
|
-
|
111
|
-
if (errors != nullptr && errors->is_object()) {
|
112
|
-
for (const auto&
|
113
|
-
response.errors.emplace_back(fmt::format("{}: {}",
|
110
|
+
|
111
|
+
if (const auto* errors = payload.find("errors"); errors != nullptr && errors->is_object()) {
|
112
|
+
for (const auto& [code, message] : errors->get_object()) {
|
113
|
+
response.errors.emplace_back(fmt::format("{}: {}", code, message.get_string()));
|
114
114
|
}
|
115
115
|
}
|
116
116
|
} break;
|
117
117
|
default:
|
118
|
-
response.ctx.ec =
|
118
|
+
response.ctx.ec = error::common_errc::internal_server_failure;
|
119
119
|
break;
|
120
120
|
}
|
121
121
|
}
|
@@ -39,7 +39,7 @@ struct http_noop_request {
|
|
39
39
|
|
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 */)
|
43
43
|
{
|
44
44
|
encoded.headers["connection"] = "keep-alive";
|
45
45
|
encoded.method = "GET";
|
@@ -56,22 +56,22 @@ struct http_noop_request {
|
|
56
56
|
timeout = timeout_defaults::search_timeout;
|
57
57
|
encoded.path = "/api/ping";
|
58
58
|
break;
|
59
|
-
case service_type::
|
59
|
+
case service_type::view:
|
60
60
|
timeout = timeout_defaults::view_timeout;
|
61
61
|
encoded.path = "/";
|
62
62
|
break;
|
63
63
|
case service_type::management:
|
64
|
-
case service_type::
|
65
|
-
return
|
64
|
+
case service_type::key_value:
|
65
|
+
return error::common_errc::feature_not_available;
|
66
66
|
}
|
67
67
|
return {};
|
68
68
|
}
|
69
69
|
};
|
70
70
|
|
71
71
|
http_noop_response
|
72
|
-
make_response(error_context::http&& ctx, http_noop_request
|
72
|
+
make_response(error_context::http&& ctx, const http_noop_request& /* request */, http_noop_request::encoded_response_type&&)
|
73
73
|
{
|
74
|
-
http_noop_response response{ ctx };
|
74
|
+
http_noop_response response{ std::move(ctx) };
|
75
75
|
return response;
|
76
76
|
}
|
77
77
|
|
@@ -37,7 +37,7 @@ struct mcbp_noop_request {
|
|
37
37
|
std::chrono::milliseconds timeout{ timeout_defaults::key_value_timeout };
|
38
38
|
io::retry_context<io::retry_strategy::best_effort> retries{ true };
|
39
39
|
|
40
|
-
[[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, mcbp_context&&)
|
40
|
+
[[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, mcbp_context&& /* context */) const
|
41
41
|
{
|
42
42
|
encoded.opaque(opaque);
|
43
43
|
encoded.partition(partition);
|
@@ -46,9 +46,9 @@ struct mcbp_noop_request {
|
|
46
46
|
};
|
47
47
|
|
48
48
|
mcbp_noop_response
|
49
|
-
make_response(error_context::key_value&& ctx, mcbp_noop_request
|
49
|
+
make_response(error_context::key_value&& ctx, const mcbp_noop_request& /* request */, mcbp_noop_request::encoded_response_type&&)
|
50
50
|
{
|
51
|
-
mcbp_noop_response response{ ctx };
|
51
|
+
mcbp_noop_response response{ std::move(ctx) };
|
52
52
|
return response;
|
53
53
|
}
|
54
54
|
|
@@ -45,7 +45,7 @@ struct query_index_build_deferred_request {
|
|
45
45
|
std::string bucket_name;
|
46
46
|
std::chrono::milliseconds timeout{ timeout_defaults::management_timeout };
|
47
47
|
|
48
|
-
[[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, http_context&)
|
48
|
+
[[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, http_context& /* context */) const
|
49
49
|
{
|
50
50
|
encoded.headers["content-type"] = "application/json";
|
51
51
|
tao::json::value body{
|
@@ -64,16 +64,16 @@ struct query_index_build_deferred_request {
|
|
64
64
|
|
65
65
|
query_index_build_deferred_response
|
66
66
|
make_response(error_context::http&& ctx,
|
67
|
-
query_index_build_deferred_request
|
67
|
+
const query_index_build_deferred_request& /* request */,
|
68
68
|
query_index_build_deferred_request::encoded_response_type&& encoded)
|
69
69
|
{
|
70
|
-
query_index_build_deferred_response response{ ctx };
|
70
|
+
query_index_build_deferred_response response{ std::move(ctx) };
|
71
71
|
if (!response.ctx.ec) {
|
72
72
|
tao::json::value payload{};
|
73
73
|
try {
|
74
74
|
payload = tao::json::from_string(encoded.body);
|
75
|
-
} catch (tao::json::pegtl::parse_error& e) {
|
76
|
-
response.ctx.ec =
|
75
|
+
} catch (const tao::json::pegtl::parse_error& e) {
|
76
|
+
response.ctx.ec = error::common_errc::parsing_failure;
|
77
77
|
return response;
|
78
78
|
}
|
79
79
|
response.status = payload.at("status").get_string();
|
@@ -84,7 +84,7 @@ make_response(error_context::http&& ctx,
|
|
84
84
|
error.message = entry.at("msg").get_string();
|
85
85
|
response.errors.emplace_back(error);
|
86
86
|
}
|
87
|
-
response.ctx.ec =
|
87
|
+
response.ctx.ec = error::common_errc::internal_server_failure;
|
88
88
|
}
|
89
89
|
}
|
90
90
|
return response;
|
@@ -55,7 +55,7 @@ struct query_index_create_request {
|
|
55
55
|
std::optional<int> num_replicas{};
|
56
56
|
std::chrono::milliseconds timeout{ timeout_defaults::management_timeout };
|
57
57
|
|
58
|
-
[[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, http_context&)
|
58
|
+
[[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, http_context& /* context */) const
|
59
59
|
{
|
60
60
|
encoded.headers["content-type"] = "application/json";
|
61
61
|
tao::json::value with{};
|
@@ -100,15 +100,17 @@ struct query_index_create_request {
|
|
100
100
|
};
|
101
101
|
|
102
102
|
query_index_create_response
|
103
|
-
make_response(error_context::http&& ctx,
|
103
|
+
make_response(error_context::http&& ctx,
|
104
|
+
const query_index_create_request& request,
|
105
|
+
query_index_create_request::encoded_response_type&& encoded)
|
104
106
|
{
|
105
|
-
query_index_create_response response{ ctx };
|
107
|
+
query_index_create_response response{ std::move(ctx) };
|
106
108
|
if (!response.ctx.ec) {
|
107
109
|
tao::json::value payload{};
|
108
110
|
try {
|
109
111
|
payload = tao::json::from_string(encoded.body);
|
110
|
-
} catch (tao::json::pegtl::parse_error& e) {
|
111
|
-
response.ctx.ec =
|
112
|
+
} catch (const tao::json::pegtl::parse_error& e) {
|
113
|
+
response.ctx.ec = error::common_errc::parsing_failure;
|
112
114
|
return response;
|
113
115
|
}
|
114
116
|
response.status = payload.at("status").get_string();
|
@@ -137,12 +139,12 @@ make_response(error_context::http&& ctx, query_index_create_request& request, qu
|
|
137
139
|
}
|
138
140
|
if (index_already_exists) {
|
139
141
|
if (!request.ignore_if_exists) {
|
140
|
-
response.ctx.ec =
|
142
|
+
response.ctx.ec = error::common_errc::index_exists;
|
141
143
|
}
|
142
144
|
} else if (bucket_not_found) {
|
143
|
-
response.ctx.ec =
|
145
|
+
response.ctx.ec = error::common_errc::bucket_not_found;
|
144
146
|
} else if (!response.errors.empty()) {
|
145
|
-
response.ctx.ec =
|
147
|
+
response.ctx.ec = error::common_errc::internal_server_failure;
|
146
148
|
}
|
147
149
|
}
|
148
150
|
}
|
@@ -51,7 +51,7 @@ struct query_index_drop_request {
|
|
51
51
|
bool ignore_if_does_not_exist{ false };
|
52
52
|
std::chrono::milliseconds timeout{ timeout_defaults::management_timeout };
|
53
53
|
|
54
|
-
[[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, http_context&)
|
54
|
+
[[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, http_context& /* context */) const
|
55
55
|
{
|
56
56
|
encoded.headers["content-type"] = "application/json";
|
57
57
|
std::string keyspace = fmt::format("`{}`", bucket_name);
|
@@ -73,15 +73,15 @@ struct query_index_drop_request {
|
|
73
73
|
};
|
74
74
|
|
75
75
|
query_index_drop_response
|
76
|
-
make_response(error_context::http&& ctx, query_index_drop_request& request, query_index_drop_request::encoded_response_type&& encoded)
|
76
|
+
make_response(error_context::http&& ctx, const query_index_drop_request& request, query_index_drop_request::encoded_response_type&& encoded)
|
77
77
|
{
|
78
|
-
query_index_drop_response response{ ctx };
|
78
|
+
query_index_drop_response response{ std::move(ctx) };
|
79
79
|
if (!response.ctx.ec) {
|
80
80
|
tao::json::value payload{};
|
81
81
|
try {
|
82
82
|
payload = tao::json::from_string(encoded.body);
|
83
|
-
} catch (tao::json::pegtl::parse_error& e) {
|
84
|
-
response.ctx.ec =
|
83
|
+
} catch (const tao::json::pegtl::parse_error& e) {
|
84
|
+
response.ctx.ec = error::common_errc::parsing_failure;
|
85
85
|
return response;
|
86
86
|
}
|
87
87
|
response.status = payload.at("status").get_string();
|
@@ -111,12 +111,12 @@ make_response(error_context::http&& ctx, query_index_drop_request& request, quer
|
|
111
111
|
}
|
112
112
|
if (index_not_found) {
|
113
113
|
if (!request.ignore_if_does_not_exist) {
|
114
|
-
response.ctx.ec =
|
114
|
+
response.ctx.ec = error::common_errc::index_not_found;
|
115
115
|
}
|
116
116
|
} else if (bucket_not_found) {
|
117
|
-
response.ctx.ec =
|
117
|
+
response.ctx.ec = error::common_errc::bucket_not_found;
|
118
118
|
} else if (!response.errors.empty()) {
|
119
|
-
response.ctx.ec =
|
119
|
+
response.ctx.ec = error::common_errc::internal_server_failure;
|
120
120
|
}
|
121
121
|
}
|
122
122
|
}
|
@@ -35,6 +35,7 @@ struct query_index_get_all_response {
|
|
35
35
|
std::string collection_name;
|
36
36
|
std::string type;
|
37
37
|
std::vector<std::string> index_key{};
|
38
|
+
std::optional<std::string> partition{};
|
38
39
|
std::optional<std::string> condition{};
|
39
40
|
std::optional<std::string> bucket_id{};
|
40
41
|
std::optional<std::string> scope_id{};
|
@@ -56,7 +57,7 @@ struct query_index_get_all_request {
|
|
56
57
|
std::string bucket_name;
|
57
58
|
std::chrono::milliseconds timeout{ timeout_defaults::management_timeout };
|
58
59
|
|
59
|
-
[[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, http_context&)
|
60
|
+
[[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, http_context& /* context */) const
|
60
61
|
{
|
61
62
|
encoded.headers["content-type"] = "application/json";
|
62
63
|
tao::json::value body{
|
@@ -75,46 +76,49 @@ struct query_index_get_all_request {
|
|
75
76
|
};
|
76
77
|
|
77
78
|
query_index_get_all_response
|
78
|
-
make_response(error_context::http&& ctx,
|
79
|
+
make_response(error_context::http&& ctx,
|
80
|
+
const query_index_get_all_request& /* request */,
|
81
|
+
query_index_get_all_request::encoded_response_type&& encoded)
|
79
82
|
{
|
80
|
-
query_index_get_all_response response{ ctx };
|
81
|
-
if (!response.ctx.ec) {
|
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
|
-
|
83
|
+
query_index_get_all_response response{ std::move(ctx) };
|
84
|
+
if (!response.ctx.ec && encoded.status_code == 200) {
|
85
|
+
tao::json::value payload{};
|
86
|
+
try {
|
87
|
+
payload = tao::json::from_string(encoded.body);
|
88
|
+
} catch (const tao::json::pegtl::parse_error& e) {
|
89
|
+
response.ctx.ec = error::common_errc::parsing_failure;
|
90
|
+
return response;
|
91
|
+
}
|
92
|
+
response.status = payload.at("status").get_string();
|
93
|
+
if (response.status == "success") {
|
94
|
+
for (const auto& entry : payload.at("results").get_array()) {
|
95
|
+
query_index_get_all_response::query_index index;
|
96
|
+
index.id = entry.at("id").get_string();
|
97
|
+
index.datastore_id = entry.at("datastore_id").get_string();
|
98
|
+
index.namespace_id = entry.at("namespace_id").get_string();
|
99
|
+
index.keyspace_id = entry.at("keyspace_id").get_string();
|
100
|
+
index.type = entry.at("using").get_string();
|
101
|
+
index.name = entry.at("name").get_string();
|
102
|
+
index.state = entry.at("state").get_string();
|
103
|
+
if (const auto* prop = entry.find("bucket_id")) {
|
104
|
+
index.bucket_id = prop->get_string();
|
105
|
+
}
|
106
|
+
if (const auto* prop = entry.find("scope_id")) {
|
107
|
+
index.scope_id = prop->get_string();
|
108
|
+
}
|
109
|
+
if (const auto* prop = entry.find("is_primary")) {
|
110
|
+
index.is_primary = prop->get_boolean();
|
111
|
+
}
|
112
|
+
if (const auto* prop = entry.find("condition")) {
|
113
|
+
index.condition = prop->get_string();
|
114
|
+
}
|
115
|
+
if (const auto* prop = entry.find("partition")) {
|
116
|
+
index.partition = prop->get_string();
|
117
|
+
}
|
118
|
+
for (const auto& key : entry.at("index_key").get_array()) {
|
119
|
+
index.index_key.emplace_back(key.get_string());
|
117
120
|
}
|
121
|
+
response.indexes.emplace_back(index);
|
118
122
|
}
|
119
123
|
}
|
120
124
|
}
|
@@ -84,8 +84,7 @@ struct traits<couchbase::operations::rbac::user_and_metadata> {
|
|
84
84
|
static couchbase::operations::rbac::user_and_metadata as(const tao::json::basic_value<Traits>& v)
|
85
85
|
{
|
86
86
|
couchbase::operations::rbac::user_and_metadata result;
|
87
|
-
std::string domain = v.at("domain").get_string();
|
88
|
-
if (domain == "local") {
|
87
|
+
if (const std::string& domain = v.at("domain").get_string(); domain == "local") {
|
89
88
|
result.domain = couchbase::operations::rbac::auth_domain::local;
|
90
89
|
} else if (domain == "external") {
|
91
90
|
result.domain = couchbase::operations::rbac::auth_domain::external;
|
@@ -93,78 +92,56 @@ struct traits<couchbase::operations::rbac::user_and_metadata> {
|
|
93
92
|
spdlog::error(R"("unexpected domain for user with metadata: "{}")", domain);
|
94
93
|
}
|
95
94
|
result.username = v.at("id").get_string();
|
96
|
-
{
|
97
|
-
|
98
|
-
if (display_name != nullptr && !display_name->get_string().empty()) {
|
99
|
-
result.display_name = display_name->get_string();
|
100
|
-
}
|
95
|
+
if (const auto* display_name = v.find("name"); display_name != nullptr && !display_name->get_string().empty()) {
|
96
|
+
result.display_name = display_name->get_string();
|
101
97
|
}
|
102
98
|
result.password_changed = v.template optional<std::string>("password_change_date");
|
103
|
-
{
|
104
|
-
const auto
|
105
|
-
|
106
|
-
for (const auto& group : external_groups->get_array()) {
|
107
|
-
result.external_groups.insert(group.get_string());
|
108
|
-
}
|
99
|
+
if (const auto* external_groups = v.find("external_groups"); external_groups != nullptr) {
|
100
|
+
for (const auto& group : external_groups->get_array()) {
|
101
|
+
result.external_groups.insert(group.get_string());
|
109
102
|
}
|
110
103
|
}
|
111
|
-
{
|
112
|
-
const auto
|
113
|
-
|
114
|
-
for (const auto& group : groups->get_array()) {
|
115
|
-
result.groups.insert(group.get_string());
|
116
|
-
}
|
104
|
+
if (const auto* groups = v.find("groups"); groups != nullptr) {
|
105
|
+
for (const auto& group : groups->get_array()) {
|
106
|
+
result.groups.insert(group.get_string());
|
117
107
|
}
|
118
108
|
}
|
119
|
-
{
|
120
|
-
const auto
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
role.
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
109
|
+
if (const auto* roles = v.find("roles"); roles != nullptr) {
|
110
|
+
for (const auto& entry : roles->get_array()) {
|
111
|
+
couchbase::operations::rbac::role_and_origins role{};
|
112
|
+
role.name = entry.at("role").get_string();
|
113
|
+
if (const auto* bucket = entry.find("bucket_name"); bucket != nullptr && !bucket->get_string().empty()) {
|
114
|
+
role.bucket = bucket->get_string();
|
115
|
+
}
|
116
|
+
if (const auto* scope = entry.find("scope_name"); scope != nullptr && !scope->get_string().empty()) {
|
117
|
+
role.scope = scope->get_string();
|
118
|
+
}
|
119
|
+
|
120
|
+
if (const auto* collection = entry.find("collection_name"); collection != nullptr && !collection->get_string().empty()) {
|
121
|
+
role.collection = collection->get_string();
|
122
|
+
}
|
123
|
+
|
124
|
+
if (const auto* origins = entry.find("origins"); origins != nullptr) {
|
125
|
+
bool has_user_origin = false;
|
126
|
+
for (const auto& ent : origins->get_array()) {
|
127
|
+
couchbase::operations::rbac::origin origin{};
|
128
|
+
origin.type = ent.at("type").get_string();
|
129
|
+
if (origin.type == "user") {
|
130
|
+
has_user_origin = true;
|
135
131
|
}
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
if (collection != nullptr && !collection->get_string().empty()) {
|
140
|
-
role.collection = collection->get_string();
|
132
|
+
const auto* name = ent.find("name");
|
133
|
+
if (name != nullptr) {
|
134
|
+
origin.name = name->get_string();
|
141
135
|
}
|
136
|
+
role.origins.push_back(origin);
|
142
137
|
}
|
143
|
-
{
|
144
|
-
|
145
|
-
if (origins != nullptr) {
|
146
|
-
bool has_user_origin = false;
|
147
|
-
for (const auto& ent : origins->get_array()) {
|
148
|
-
couchbase::operations::rbac::origin origin{};
|
149
|
-
origin.type = ent.at("type").get_string();
|
150
|
-
if (origin.type == "user") {
|
151
|
-
has_user_origin = true;
|
152
|
-
}
|
153
|
-
const auto* name = ent.find("name");
|
154
|
-
if (name != nullptr) {
|
155
|
-
origin.name = name->get_string();
|
156
|
-
}
|
157
|
-
role.origins.push_back(origin);
|
158
|
-
}
|
159
|
-
if (has_user_origin) {
|
160
|
-
result.roles.push_back(role);
|
161
|
-
}
|
162
|
-
} else {
|
163
|
-
result.roles.push_back(role);
|
164
|
-
}
|
138
|
+
if (has_user_origin) {
|
139
|
+
result.roles.push_back(role);
|
165
140
|
}
|
166
|
-
|
141
|
+
} else {
|
142
|
+
result.roles.push_back(role);
|
167
143
|
}
|
144
|
+
result.effective_roles.push_back(role);
|
168
145
|
}
|
169
146
|
}
|
170
147
|
return result;
|