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.
- 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.hxx +4 -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/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/libcouchbase.bundle +0 -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 +48 -5
@@ -42,7 +42,7 @@ struct search_index_drop_request {
|
|
42
42
|
|
43
43
|
std::string index_name;
|
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 = "DELETE";
|
48
48
|
encoded.path = fmt::format("/api/index/{}", index_name);
|
@@ -51,16 +51,18 @@ struct search_index_drop_request {
|
|
51
51
|
};
|
52
52
|
|
53
53
|
search_index_drop_response
|
54
|
-
make_response(error_context::http&& ctx,
|
54
|
+
make_response(error_context::http&& ctx,
|
55
|
+
const search_index_drop_request& /* request */,
|
56
|
+
search_index_drop_request::encoded_response_type&& encoded)
|
55
57
|
{
|
56
|
-
search_index_drop_response response{ ctx };
|
58
|
+
search_index_drop_response response{ std::move(ctx) };
|
57
59
|
if (!response.ctx.ec) {
|
58
60
|
if (encoded.status_code == 200) {
|
59
61
|
tao::json::value payload{};
|
60
62
|
try {
|
61
63
|
payload = tao::json::from_string(encoded.body);
|
62
|
-
} catch (tao::json::pegtl::parse_error& e) {
|
63
|
-
response.ctx.ec =
|
64
|
+
} catch (const tao::json::pegtl::parse_error& e) {
|
65
|
+
response.ctx.ec = error::common_errc::parsing_failure;
|
64
66
|
return response;
|
65
67
|
}
|
66
68
|
response.status = payload.at("status").get_string();
|
@@ -71,18 +73,18 @@ make_response(error_context::http&& ctx, search_index_drop_request&, search_inde
|
|
71
73
|
tao::json::value payload{};
|
72
74
|
try {
|
73
75
|
payload = tao::json::from_string(encoded.body);
|
74
|
-
} catch (tao::json::pegtl::parse_error& e) {
|
75
|
-
response.ctx.ec =
|
76
|
+
} catch (const tao::json::pegtl::parse_error& e) {
|
77
|
+
response.ctx.ec = error::common_errc::parsing_failure;
|
76
78
|
return response;
|
77
79
|
}
|
78
80
|
response.status = payload.at("status").get_string();
|
79
81
|
response.error = payload.at("error").get_string();
|
80
82
|
if (response.error.find("index not found") != std::string::npos) {
|
81
|
-
response.ctx.ec =
|
83
|
+
response.ctx.ec = error::common_errc::index_not_found;
|
82
84
|
return response;
|
83
85
|
}
|
84
86
|
}
|
85
|
-
response.ctx.ec =
|
87
|
+
response.ctx.ec = error::common_errc::internal_server_failure;
|
86
88
|
}
|
87
89
|
return response;
|
88
90
|
}
|
@@ -44,7 +44,7 @@ struct search_index_get_request {
|
|
44
44
|
|
45
45
|
std::string index_name;
|
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 = "GET";
|
50
50
|
encoded.path = fmt::format("/api/index/{}", index_name);
|
@@ -53,16 +53,18 @@ struct search_index_get_request {
|
|
53
53
|
};
|
54
54
|
|
55
55
|
search_index_get_response
|
56
|
-
make_response(error_context::http&& ctx,
|
56
|
+
make_response(error_context::http&& ctx,
|
57
|
+
const search_index_get_request& /* request */,
|
58
|
+
search_index_get_request::encoded_response_type&& encoded)
|
57
59
|
{
|
58
|
-
search_index_get_response response{ ctx };
|
60
|
+
search_index_get_response response{ std::move(ctx) };
|
59
61
|
if (!response.ctx.ec) {
|
60
62
|
if (encoded.status_code == 200) {
|
61
63
|
tao::json::value payload{};
|
62
64
|
try {
|
63
65
|
payload = tao::json::from_string(encoded.body);
|
64
|
-
} catch (tao::json::pegtl::parse_error& e) {
|
65
|
-
response.ctx.ec =
|
66
|
+
} catch (const tao::json::pegtl::parse_error& e) {
|
67
|
+
response.ctx.ec = error::common_errc::parsing_failure;
|
66
68
|
return response;
|
67
69
|
}
|
68
70
|
response.status = payload.at("status").get_string();
|
@@ -74,18 +76,18 @@ make_response(error_context::http&& ctx, search_index_get_request&, search_index
|
|
74
76
|
tao::json::value payload{};
|
75
77
|
try {
|
76
78
|
payload = tao::json::from_string(encoded.body);
|
77
|
-
} catch (tao::json::pegtl::parse_error& e) {
|
78
|
-
response.ctx.ec =
|
79
|
+
} catch (const tao::json::pegtl::parse_error& e) {
|
80
|
+
response.ctx.ec = error::common_errc::parsing_failure;
|
79
81
|
return response;
|
80
82
|
}
|
81
83
|
response.status = payload.at("status").get_string();
|
82
84
|
response.error = payload.at("error").get_string();
|
83
85
|
if (response.error.find("index not found") != std::string::npos) {
|
84
|
-
response.ctx.ec =
|
86
|
+
response.ctx.ec = error::common_errc::index_not_found;
|
85
87
|
return response;
|
86
88
|
}
|
87
89
|
}
|
88
|
-
response.ctx.ec =
|
90
|
+
response.ctx.ec = error::common_errc::internal_server_failure;
|
89
91
|
}
|
90
92
|
return response;
|
91
93
|
}
|
@@ -44,7 +44,7 @@ struct search_index_get_all_request {
|
|
44
44
|
|
45
45
|
std::string index_name;
|
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 = "GET";
|
50
50
|
encoded.path = fmt::format("/api/index");
|
@@ -53,29 +53,29 @@ struct search_index_get_all_request {
|
|
53
53
|
};
|
54
54
|
|
55
55
|
search_index_get_all_response
|
56
|
-
make_response(error_context::http&& ctx,
|
56
|
+
make_response(error_context::http&& ctx,
|
57
|
+
const search_index_get_all_request& /* request */,
|
58
|
+
search_index_get_all_request::encoded_response_type&& encoded)
|
57
59
|
{
|
58
|
-
search_index_get_all_response response{ ctx };
|
60
|
+
search_index_get_all_response response{ std::move(ctx) };
|
59
61
|
if (!response.ctx.ec) {
|
60
62
|
if (encoded.status_code == 200) {
|
61
63
|
tao::json::value payload{};
|
62
64
|
try {
|
63
65
|
payload = tao::json::from_string(encoded.body);
|
64
|
-
} catch (tao::json::pegtl::parse_error& e) {
|
65
|
-
response.ctx.ec =
|
66
|
+
} catch (const tao::json::pegtl::parse_error& e) {
|
67
|
+
response.ctx.ec = error::common_errc::parsing_failure;
|
66
68
|
return response;
|
67
69
|
}
|
68
70
|
response.status = payload.at("status").get_string();
|
69
71
|
if (response.status == "ok") {
|
70
|
-
const auto* indexDefs = payload.find("indexDefs");
|
71
|
-
|
72
|
-
const auto* impl_ver = indexDefs->find("implVersion");
|
73
|
-
if (impl_ver != nullptr && impl_ver->is_string()) {
|
72
|
+
if (const auto* indexDefs = payload.find("indexDefs"); indexDefs != nullptr && indexDefs->is_object()) {
|
73
|
+
if (const auto* impl_ver = indexDefs->find("implVersion"); impl_ver != nullptr && impl_ver->is_string()) {
|
74
74
|
response.impl_version = impl_ver->get_string();
|
75
75
|
}
|
76
76
|
const auto* indexes = indexDefs->find("indexDefs");
|
77
|
-
for (const auto&
|
78
|
-
response.indexes.emplace_back(
|
77
|
+
for (const auto& [name, index] : indexes->get_object()) {
|
78
|
+
response.indexes.emplace_back(index.as<search_index>());
|
79
79
|
}
|
80
80
|
}
|
81
81
|
return response;
|
@@ -43,7 +43,7 @@ struct search_index_get_documents_count_request {
|
|
43
43
|
|
44
44
|
std::string index_name;
|
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("/api/index/{}/count", index_name);
|
@@ -53,18 +53,18 @@ struct search_index_get_documents_count_request {
|
|
53
53
|
|
54
54
|
search_index_get_documents_count_response
|
55
55
|
make_response(error_context::http&& ctx,
|
56
|
-
search_index_get_documents_count_request
|
56
|
+
const search_index_get_documents_count_request& /* request */,
|
57
57
|
search_index_get_documents_count_request::encoded_response_type&& encoded)
|
58
58
|
{
|
59
|
-
search_index_get_documents_count_response response{ ctx };
|
59
|
+
search_index_get_documents_count_response response{ std::move(ctx) };
|
60
60
|
if (!response.ctx.ec) {
|
61
61
|
switch (encoded.status_code) {
|
62
62
|
case 200: {
|
63
63
|
tao::json::value payload{};
|
64
64
|
try {
|
65
65
|
payload = tao::json::from_string(encoded.body);
|
66
|
-
} catch (tao::json::pegtl::parse_error& e) {
|
67
|
-
response.ctx.ec =
|
66
|
+
} catch (const tao::json::pegtl::parse_error& e) {
|
67
|
+
response.ctx.ec = error::common_errc::parsing_failure;
|
68
68
|
return response;
|
69
69
|
}
|
70
70
|
response.status = payload.at("status").get_string();
|
@@ -78,22 +78,22 @@ make_response(error_context::http&& ctx,
|
|
78
78
|
tao::json::value payload{};
|
79
79
|
try {
|
80
80
|
payload = tao::json::from_string(encoded.body);
|
81
|
-
} catch (tao::json::pegtl::parse_error& e) {
|
82
|
-
response.ctx.ec =
|
81
|
+
} catch (const tao::json::pegtl::parse_error& e) {
|
82
|
+
response.ctx.ec = error::common_errc::parsing_failure;
|
83
83
|
return response;
|
84
84
|
}
|
85
85
|
response.status = payload.at("status").get_string();
|
86
86
|
response.error = payload.at("error").get_string();
|
87
87
|
if (response.error.find("index not found") != std::string::npos) {
|
88
|
-
response.ctx.ec =
|
88
|
+
response.ctx.ec = error::common_errc::index_not_found;
|
89
89
|
return response;
|
90
90
|
} else if (response.error.find("no planPIndexes for indexName") != std::string::npos) {
|
91
|
-
response.ctx.ec =
|
91
|
+
response.ctx.ec = error::search_errc::index_not_ready;
|
92
92
|
return response;
|
93
93
|
}
|
94
94
|
} break;
|
95
95
|
}
|
96
|
-
response.ctx.ec =
|
96
|
+
response.ctx.ec = error::common_errc::internal_server_failure;
|
97
97
|
}
|
98
98
|
return response;
|
99
99
|
}
|
@@ -43,7 +43,7 @@ struct search_index_get_stats_request {
|
|
43
43
|
|
44
44
|
std::string index_name;
|
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("/api/stats/index/{}", index_name);
|
@@ -52,9 +52,11 @@ struct search_index_get_stats_request {
|
|
52
52
|
};
|
53
53
|
|
54
54
|
search_index_get_stats_response
|
55
|
-
make_response(error_context::http&& ctx,
|
55
|
+
make_response(error_context::http&& ctx,
|
56
|
+
const search_index_get_stats_request& /* request */,
|
57
|
+
search_index_get_stats_request::encoded_response_type&& encoded)
|
56
58
|
{
|
57
|
-
search_index_get_stats_response response{ ctx };
|
59
|
+
search_index_get_stats_response response{ std::move(ctx) };
|
58
60
|
if (!response.ctx.ec) {
|
59
61
|
switch (encoded.status_code) {
|
60
62
|
case 200:
|
@@ -65,22 +67,22 @@ make_response(error_context::http&& ctx, search_index_get_stats_request&, search
|
|
65
67
|
tao::json::value payload{};
|
66
68
|
try {
|
67
69
|
payload = tao::json::from_string(encoded.body);
|
68
|
-
} catch (tao::json::pegtl::parse_error& e) {
|
69
|
-
response.ctx.ec =
|
70
|
+
} catch (const tao::json::pegtl::parse_error& e) {
|
71
|
+
response.ctx.ec = error::common_errc::parsing_failure;
|
70
72
|
return response;
|
71
73
|
}
|
72
74
|
response.status = payload.at("status").get_string();
|
73
75
|
response.error = payload.at("error").get_string();
|
74
76
|
if (response.error.find("index not found") != std::string::npos) {
|
75
|
-
response.ctx.ec =
|
77
|
+
response.ctx.ec = error::common_errc::index_not_found;
|
76
78
|
return response;
|
77
79
|
} else if (response.error.find("no planPIndexes for indexName") != std::string::npos) {
|
78
|
-
response.ctx.ec =
|
80
|
+
response.ctx.ec = error::search_errc::index_not_ready;
|
79
81
|
return response;
|
80
82
|
}
|
81
83
|
} break;
|
82
84
|
}
|
83
|
-
response.ctx.ec =
|
85
|
+
response.ctx.ec = error::common_errc::internal_server_failure;
|
84
86
|
}
|
85
87
|
return response;
|
86
88
|
}
|
@@ -42,7 +42,7 @@ struct search_index_upsert_request {
|
|
42
42
|
|
43
43
|
search_index index;
|
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 = "PUT";
|
48
48
|
encoded.headers["cache-control"] = "no-cache";
|
@@ -77,16 +77,18 @@ struct search_index_upsert_request {
|
|
77
77
|
};
|
78
78
|
|
79
79
|
search_index_upsert_response
|
80
|
-
make_response(error_context::http&& ctx,
|
80
|
+
make_response(error_context::http&& ctx,
|
81
|
+
const search_index_upsert_request& /* request */,
|
82
|
+
search_index_upsert_request::encoded_response_type&& encoded)
|
81
83
|
{
|
82
|
-
search_index_upsert_response response{ ctx };
|
84
|
+
search_index_upsert_response response{ std::move(ctx) };
|
83
85
|
if (!response.ctx.ec) {
|
84
86
|
if (encoded.status_code == 200) {
|
85
87
|
tao::json::value payload{};
|
86
88
|
try {
|
87
89
|
payload = tao::json::from_string(encoded.body);
|
88
|
-
} catch (tao::json::pegtl::parse_error& e) {
|
89
|
-
response.ctx.ec =
|
90
|
+
} catch (const tao::json::pegtl::parse_error& e) {
|
91
|
+
response.ctx.ec = error::common_errc::parsing_failure;
|
90
92
|
return response;
|
91
93
|
}
|
92
94
|
response.status = payload.at("status").get_string();
|
@@ -97,21 +99,21 @@ make_response(error_context::http&& ctx, search_index_upsert_request&, search_in
|
|
97
99
|
tao::json::value payload{};
|
98
100
|
try {
|
99
101
|
payload = tao::json::from_string(encoded.body);
|
100
|
-
} catch (tao::json::pegtl::parse_error& e) {
|
101
|
-
response.ctx.ec =
|
102
|
+
} catch (const tao::json::pegtl::parse_error& e) {
|
103
|
+
response.ctx.ec = error::common_errc::parsing_failure;
|
102
104
|
return response;
|
103
105
|
}
|
104
106
|
response.status = payload.at("status").get_string();
|
105
107
|
response.error = payload.at("error").get_string();
|
106
108
|
if (response.error.find("index not found") != std::string::npos) {
|
107
|
-
response.ctx.ec =
|
109
|
+
response.ctx.ec = error::common_errc::index_not_found;
|
108
110
|
return response;
|
109
111
|
} else if (response.error.find("index with the same name already exists") != std::string::npos) {
|
110
|
-
response.ctx.ec =
|
112
|
+
response.ctx.ec = error::common_errc::index_exists;
|
111
113
|
return response;
|
112
114
|
}
|
113
115
|
}
|
114
|
-
response.ctx.ec =
|
116
|
+
response.ctx.ec = error::common_errc::internal_server_failure;
|
115
117
|
}
|
116
118
|
return response;
|
117
119
|
}
|
@@ -43,7 +43,7 @@ struct user_drop_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 = "DELETE";
|
49
49
|
encoded.path = fmt::format("/settings/rbac/users/{}/{}", domain, username);
|
@@ -52,18 +52,18 @@ struct user_drop_request {
|
|
52
52
|
};
|
53
53
|
|
54
54
|
user_drop_response
|
55
|
-
make_response(error_context::http&& ctx, user_drop_request
|
55
|
+
make_response(error_context::http&& ctx, const user_drop_request& /* request */, user_drop_request::encoded_response_type&& encoded)
|
56
56
|
{
|
57
|
-
user_drop_response response{ ctx };
|
57
|
+
user_drop_response response{ std::move(ctx) };
|
58
58
|
if (!response.ctx.ec) {
|
59
59
|
switch (encoded.status_code) {
|
60
60
|
case 200:
|
61
61
|
break;
|
62
62
|
case 404:
|
63
|
-
response.ctx.ec =
|
63
|
+
response.ctx.ec = error::management_errc::user_not_found;
|
64
64
|
break;
|
65
65
|
default:
|
66
|
-
response.ctx.ec =
|
66
|
+
response.ctx.ec = error::common_errc::internal_server_failure;
|
67
67
|
break;
|
68
68
|
}
|
69
69
|
}
|
@@ -44,7 +44,7 @@ struct user_get_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 = "GET";
|
50
50
|
encoded.path = fmt::format("/settings/rbac/users/{}/{}", domain, username);
|
@@ -54,24 +54,24 @@ struct user_get_request {
|
|
54
54
|
};
|
55
55
|
|
56
56
|
user_get_response
|
57
|
-
make_response(error_context::http&& ctx, user_get_request
|
57
|
+
make_response(error_context::http&& ctx, const user_get_request& /* request */, user_get_request::encoded_response_type&& encoded)
|
58
58
|
{
|
59
|
-
user_get_response response{ ctx };
|
59
|
+
user_get_response response{ std::move(ctx) };
|
60
60
|
if (!response.ctx.ec) {
|
61
61
|
switch (encoded.status_code) {
|
62
62
|
case 200: {
|
63
63
|
try {
|
64
64
|
response.user = tao::json::from_string(encoded.body).as<rbac::user_and_metadata>();
|
65
|
-
} catch (tao::json::pegtl::parse_error& e) {
|
66
|
-
response.ctx.ec =
|
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
|
case 404:
|
71
|
-
response.ctx.ec =
|
71
|
+
response.ctx.ec = error::management_errc::user_not_found;
|
72
72
|
break;
|
73
73
|
default:
|
74
|
-
response.ctx.ec =
|
74
|
+
response.ctx.ec = error::common_errc::internal_server_failure;
|
75
75
|
break;
|
76
76
|
}
|
77
77
|
}
|
@@ -43,7 +43,7 @@ struct user_get_all_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/users/{}", domain);
|
@@ -53,23 +53,23 @@ struct user_get_all_request {
|
|
53
53
|
};
|
54
54
|
|
55
55
|
user_get_all_response
|
56
|
-
make_response(error_context::http&& ctx, user_get_all_request
|
56
|
+
make_response(error_context::http&& ctx, const user_get_all_request& /* request */, user_get_all_request::encoded_response_type&& encoded)
|
57
57
|
{
|
58
|
-
user_get_all_response response{ ctx };
|
58
|
+
user_get_all_response response{ std::move(ctx) };
|
59
59
|
if (!response.ctx.ec) {
|
60
60
|
if (encoded.status_code == 200) {
|
61
61
|
tao::json::value payload{};
|
62
62
|
try {
|
63
63
|
payload = tao::json::from_string(encoded.body);
|
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
|
for (const auto& entry : payload.get_array()) {
|
69
69
|
response.users.emplace_back(entry.as<rbac::user_and_metadata>());
|
70
70
|
}
|
71
71
|
} else {
|
72
|
-
response.ctx.ec =
|
72
|
+
response.ctx.ec = error::common_errc::internal_server_failure;
|
73
73
|
}
|
74
74
|
}
|
75
75
|
return response;
|
@@ -48,7 +48,7 @@ struct user_upsert_request {
|
|
48
48
|
std::chrono::milliseconds timeout{ timeout_defaults::management_timeout };
|
49
49
|
std::string client_context_id{ uuid::to_string(uuid::random()) };
|
50
50
|
|
51
|
-
[[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, http_context&)
|
51
|
+
[[nodiscard]] std::error_code encode_to(encoded_request_type& encoded, http_context& /* context */) const
|
52
52
|
{
|
53
53
|
encoded.method = "PUT";
|
54
54
|
encoded.path = fmt::format("/settings/rbac/users/{}/{}", domain, user.username);
|
@@ -98,9 +98,9 @@ struct user_upsert_request {
|
|
98
98
|
};
|
99
99
|
|
100
100
|
user_upsert_response
|
101
|
-
make_response(error_context::http&& ctx, user_upsert_request
|
101
|
+
make_response(error_context::http&& ctx, const user_upsert_request& /* request */, user_upsert_request::encoded_response_type&& encoded)
|
102
102
|
{
|
103
|
-
user_upsert_response response{ ctx };
|
103
|
+
user_upsert_response response{ std::move(ctx) };
|
104
104
|
if (!response.ctx.ec) {
|
105
105
|
switch (encoded.status_code) {
|
106
106
|
case 200:
|
@@ -109,20 +109,20 @@ make_response(error_context::http&& ctx, user_upsert_request&, user_upsert_reque
|
|
109
109
|
tao::json::value payload{};
|
110
110
|
try {
|
111
111
|
payload = tao::json::from_string(encoded.body);
|
112
|
-
} catch (tao::json::pegtl::parse_error&
|
113
|
-
response.ctx.ec =
|
112
|
+
} catch (const tao::json::pegtl::parse_error&) {
|
113
|
+
response.ctx.ec = error::common_errc::parsing_failure;
|
114
114
|
return response;
|
115
115
|
}
|
116
|
-
response.ctx.ec =
|
116
|
+
response.ctx.ec = error::common_errc::invalid_argument;
|
117
117
|
const auto* errors = payload.find("errors");
|
118
118
|
if (errors != nullptr && errors->is_object()) {
|
119
|
-
for (const auto&
|
120
|
-
response.errors.emplace_back(fmt::format("{}: {}",
|
119
|
+
for (const auto& [code, message] : errors->get_object()) {
|
120
|
+
response.errors.emplace_back(fmt::format("{}: {}", code, message.get_string()));
|
121
121
|
}
|
122
122
|
}
|
123
123
|
} break;
|
124
124
|
default:
|
125
|
-
response.ctx.ec =
|
125
|
+
response.ctx.ec = error::common_errc::internal_server_failure;
|
126
126
|
break;
|
127
127
|
}
|
128
128
|
}
|