couchbase 4.2.9 → 4.2.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. package/deps/couchbase-cxx-client/CMakeLists.txt +4 -0
  2. package/deps/couchbase-cxx-client/cmake/CompilerWarnings.cmake +7 -3
  3. package/deps/couchbase-cxx-client/cmake/OpenSSL.cmake +1 -0
  4. package/deps/couchbase-cxx-client/core/bucket.cxx +52 -2
  5. package/deps/couchbase-cxx-client/core/bucket.hxx +1 -1
  6. package/deps/couchbase-cxx-client/core/cluster.cxx +38 -0
  7. package/deps/couchbase-cxx-client/core/impl/bucket.cxx +24 -0
  8. package/deps/couchbase-cxx-client/core/impl/cluster.cxx +73 -0
  9. package/deps/couchbase-cxx-client/core/impl/diagnostics.cxx +294 -0
  10. package/deps/couchbase-cxx-client/core/impl/diagnostics.hxx +39 -0
  11. package/deps/couchbase-cxx-client/core/impl/scope.cxx +19 -4
  12. package/deps/couchbase-cxx-client/core/impl/search.cxx +75 -2
  13. package/deps/couchbase-cxx-client/core/impl/search.hxx +8 -0
  14. package/deps/couchbase-cxx-client/core/impl/search_index_manager.cxx +261 -18
  15. package/deps/couchbase-cxx-client/core/impl/search_request.cxx +139 -0
  16. package/deps/couchbase-cxx-client/core/impl/vector_query.cxx +42 -0
  17. package/deps/couchbase-cxx-client/core/impl/vector_search.cxx +40 -0
  18. package/deps/couchbase-cxx-client/core/io/http_session.hxx +6 -3
  19. package/deps/couchbase-cxx-client/core/io/mcbp_session.cxx +24 -32
  20. package/deps/couchbase-cxx-client/core/io/mcbp_session.hxx +1 -0
  21. package/deps/couchbase-cxx-client/core/logger/logger.cxx +1 -1
  22. package/deps/couchbase-cxx-client/core/meta/features.hxx +10 -0
  23. package/deps/couchbase-cxx-client/core/operations/document_query.cxx +6 -1
  24. package/deps/couchbase-cxx-client/core/operations/document_search.cxx +37 -1
  25. package/deps/couchbase-cxx-client/core/operations/document_search.hxx +11 -0
  26. package/deps/couchbase-cxx-client/core/operations/management/collection_create.cxx +7 -6
  27. package/deps/couchbase-cxx-client/core/operations/management/collection_create.hxx +1 -1
  28. package/deps/couchbase-cxx-client/core/operations/management/collection_update.cxx +7 -8
  29. package/deps/couchbase-cxx-client/core/operations/management/collection_update.hxx +1 -1
  30. package/deps/couchbase-cxx-client/core/operations/management/error_utils.cxx +3 -0
  31. package/deps/couchbase-cxx-client/core/operations/management/search_index_analyze_document.cxx +17 -1
  32. package/deps/couchbase-cxx-client/core/operations/management/search_index_analyze_document.hxx +3 -0
  33. package/deps/couchbase-cxx-client/core/operations/management/search_index_control_ingest.cxx +21 -1
  34. package/deps/couchbase-cxx-client/core/operations/management/search_index_control_ingest.hxx +3 -0
  35. package/deps/couchbase-cxx-client/core/operations/management/search_index_control_plan_freeze.cxx +21 -1
  36. package/deps/couchbase-cxx-client/core/operations/management/search_index_control_plan_freeze.hxx +3 -0
  37. package/deps/couchbase-cxx-client/core/operations/management/search_index_control_query.cxx +21 -1
  38. package/deps/couchbase-cxx-client/core/operations/management/search_index_control_query.hxx +3 -0
  39. package/deps/couchbase-cxx-client/core/operations/management/search_index_drop.cxx +17 -1
  40. package/deps/couchbase-cxx-client/core/operations/management/search_index_drop.hxx +3 -0
  41. package/deps/couchbase-cxx-client/core/operations/management/search_index_get.cxx +17 -1
  42. package/deps/couchbase-cxx-client/core/operations/management/search_index_get.hxx +2 -0
  43. package/deps/couchbase-cxx-client/core/operations/management/search_index_get_all.cxx +39 -22
  44. package/deps/couchbase-cxx-client/core/operations/management/search_index_get_all.hxx +3 -0
  45. package/deps/couchbase-cxx-client/core/operations/management/search_index_get_documents_count.cxx +18 -1
  46. package/deps/couchbase-cxx-client/core/operations/management/search_index_get_documents_count.hxx +3 -0
  47. package/deps/couchbase-cxx-client/core/operations/management/search_index_upsert.cxx +17 -1
  48. package/deps/couchbase-cxx-client/core/operations/management/search_index_upsert.hxx +3 -0
  49. package/deps/couchbase-cxx-client/core/topology/collections_manifest.hxx +1 -1
  50. package/deps/couchbase-cxx-client/core/topology/collections_manifest_json.hxx +1 -1
  51. package/deps/couchbase-cxx-client/core/transactions/internal/utils.hxx +4 -0
  52. package/deps/couchbase-cxx-client/core/vector_query_combination.hxx +23 -0
  53. package/deps/couchbase-cxx-client/couchbase/bucket.hxx +29 -0
  54. package/deps/couchbase-cxx-client/couchbase/cluster.hxx +110 -0
  55. package/deps/couchbase-cxx-client/couchbase/codec/json_transcoder.hxx +1 -1
  56. package/deps/couchbase-cxx-client/couchbase/codec/raw_binary_transcoder.hxx +2 -1
  57. package/deps/couchbase-cxx-client/couchbase/codec/raw_json_transcoder.hxx +78 -0
  58. package/deps/couchbase-cxx-client/couchbase/codec/raw_string_transcoder.hxx +72 -0
  59. package/deps/couchbase-cxx-client/couchbase/create_collection_options.hxx +29 -1
  60. package/deps/couchbase-cxx-client/couchbase/diagnostics_options.hxx +75 -0
  61. package/deps/couchbase-cxx-client/couchbase/diagnostics_result.hxx +124 -0
  62. package/deps/couchbase-cxx-client/couchbase/endpoint_diagnostics.hxx +206 -0
  63. package/deps/couchbase-cxx-client/couchbase/endpoint_ping_report.hxx +205 -0
  64. package/deps/couchbase-cxx-client/couchbase/get_options.hxx +1 -6
  65. package/deps/couchbase-cxx-client/couchbase/management/collection_spec.hxx +1 -1
  66. package/deps/couchbase-cxx-client/couchbase/ping_options.hxx +93 -0
  67. package/deps/couchbase-cxx-client/couchbase/ping_result.hxx +118 -0
  68. package/deps/couchbase-cxx-client/couchbase/scope.hxx +24 -8
  69. package/deps/couchbase-cxx-client/couchbase/scope_search_index_manager.hxx +291 -0
  70. package/deps/couchbase-cxx-client/couchbase/search_request.hxx +120 -0
  71. package/deps/couchbase-cxx-client/couchbase/service_type.hxx +58 -0
  72. package/deps/couchbase-cxx-client/couchbase/update_collection_options.hxx +32 -3
  73. package/deps/couchbase-cxx-client/couchbase/vector_query.hxx +99 -0
  74. package/deps/couchbase-cxx-client/couchbase/vector_search.hxx +85 -0
  75. package/deps/couchbase-cxx-client/couchbase/vector_search_options.hxx +76 -0
  76. package/dist/binding.d.ts +9 -0
  77. package/dist/binding.js +4 -1
  78. package/dist/bindingutilities.d.ts +6 -1
  79. package/dist/bindingutilities.js +15 -1
  80. package/dist/cluster.d.ts +12 -1
  81. package/dist/cluster.js +22 -0
  82. package/dist/couchbase.d.ts +1 -0
  83. package/dist/couchbase.js +1 -0
  84. package/dist/searchexecutor.d.ts +2 -2
  85. package/dist/searchexecutor.js +19 -3
  86. package/dist/searchtypes.d.ts +46 -0
  87. package/dist/searchtypes.js +81 -1
  88. package/dist/vectorsearch.d.ts +99 -0
  89. package/dist/vectorsearch.js +132 -0
  90. package/package.json +7 -7
  91. package/src/constants.cpp +11 -0
  92. package/src/jstocbpp_autogen.hpp +24 -7
  93. package/tools/gen-bindings-json.py +2 -0
@@ -0,0 +1,206 @@
1
+ /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright 2023-Present 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 <couchbase/service_type.hxx>
21
+
22
+ #include <chrono>
23
+ #include <optional>
24
+ #include <string>
25
+ #include <utility>
26
+
27
+ namespace couchbase
28
+ {
29
+ enum class endpoint_state {
30
+ /**
31
+ * The endpoint is connected and ready.
32
+ *
33
+ * @since 1.0.0
34
+ * @committed
35
+ */
36
+ connected,
37
+
38
+ /**
39
+ * The endpoint is disconnected but trying to connect right now.
40
+ *
41
+ * @since 1.0.0
42
+ * @committed
43
+ */
44
+ connecting,
45
+
46
+ /**
47
+ * The endpoint is disconnected (not reachable) and not trying to connect.
48
+ *
49
+ * @since 1.0.0
50
+ * @committed
51
+ */
52
+ disconnected,
53
+
54
+ /**
55
+ * The endpoint is currently disconnecting.
56
+ *
57
+ * @since 1.0.0
58
+ * @committed
59
+ */
60
+ disconnecting,
61
+ };
62
+
63
+ class endpoint_diagnostics
64
+ {
65
+ public:
66
+ endpoint_diagnostics() = default;
67
+
68
+ /**
69
+ * @since 1.0.0
70
+ * @internal
71
+ */
72
+ endpoint_diagnostics(service_type type,
73
+ std::string id,
74
+ std::optional<std::chrono::microseconds> last_activity,
75
+ std::string local,
76
+ std::string remote,
77
+ std::optional<std::string> endpoint_namespace,
78
+ endpoint_state state,
79
+ std::optional<std::string> details)
80
+ : type_{ type }
81
+ , id_{ std::move(id) }
82
+ , last_activity_{ last_activity }
83
+ , local_{ std::move(local) }
84
+ , remote_{ std::move(remote) }
85
+ , namespace_{ std::move(endpoint_namespace) }
86
+ , state_{ state }
87
+ , details_{ std::move(details) }
88
+ {
89
+ }
90
+
91
+ /**
92
+ * Returns the service type for this endpoint.
93
+ *
94
+ * @return the service type.
95
+ *
96
+ * @since 1.0.0
97
+ * @committed
98
+ */
99
+ [[nodiscard]] auto type() const -> service_type
100
+ {
101
+ return type_;
102
+ }
103
+
104
+ /**
105
+ *
106
+ * Returns the ID for this endpoint.
107
+ *
108
+ * @return the endpoint ID.
109
+ *
110
+ * @since 1.0.0
111
+ * @committed
112
+ */
113
+ [[nodiscard]] auto id() const -> std::string
114
+ {
115
+ return id_;
116
+ }
117
+
118
+ /**
119
+ * Returns the time since the last activity, if there has been one.
120
+ *
121
+ * @return the duration since the last activity.
122
+ *
123
+ * @since 1.0.0
124
+ * @committed
125
+ */
126
+ [[nodiscard]] auto last_activity() const -> std::optional<std::chrono::microseconds>
127
+ {
128
+ return last_activity_;
129
+ }
130
+
131
+ /**
132
+ * Returns the local socket address for this endpoint.
133
+ *
134
+ * @return the local socket address.
135
+ *
136
+ * @since 1.0.0
137
+ * @committed
138
+ */
139
+ [[nodiscard]] auto local() const -> std::string
140
+ {
141
+ return local_;
142
+ }
143
+
144
+ /**
145
+ * Returns the remote socket address for this endpoint.
146
+ *
147
+ * @return the remote socket address.
148
+ *
149
+ * @since 1.0.0
150
+ * @committed
151
+ */
152
+ [[nodiscard]] auto remote() const -> std::string
153
+ {
154
+ return remote_;
155
+ }
156
+
157
+ /**
158
+ * Returns the namespace of this endpoint (likely the bucket name if present).
159
+ *
160
+ * @return the namespace.
161
+ *
162
+ * @since 1.0.0
163
+ * @committed
164
+ */
165
+ [[nodiscard]] auto endpoint_namespace() const -> std::optional<std::string>
166
+ {
167
+ return namespace_;
168
+ }
169
+
170
+ /**
171
+ * Returns the current state of the endpoint.
172
+ *
173
+ * @return the endpoint state.
174
+ *
175
+ * @since 1.0.0
176
+ * @committed
177
+ */
178
+ [[nodiscard]] auto state() const -> endpoint_state
179
+ {
180
+ return state_;
181
+ }
182
+
183
+ /**
184
+ * Returns any additional details about the endpoint, if available.
185
+ *
186
+ * @return endpoint details.
187
+ *
188
+ * @since 1.0.0
189
+ * @committed
190
+ */
191
+ [[nodiscard]] auto details() const -> std::optional<std::string>
192
+ {
193
+ return details_;
194
+ }
195
+
196
+ private:
197
+ service_type type_{};
198
+ std::string id_{};
199
+ std::optional<std::chrono::microseconds> last_activity_{};
200
+ std::string local_{};
201
+ std::string remote_{};
202
+ std::optional<std::string> namespace_{};
203
+ endpoint_state state_{};
204
+ std::optional<std::string> details_{};
205
+ };
206
+ } // namespace couchbase
@@ -0,0 +1,205 @@
1
+ /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright 2023-present 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 <chrono>
21
+ #include <cstdint>
22
+ #include <map>
23
+ #include <optional>
24
+ #include <string>
25
+
26
+ #include <couchbase/codec/tao_json_serializer.hxx>
27
+ #include <couchbase/endpoint_ping_report.hxx>
28
+ #include <couchbase/service_type.hxx>
29
+
30
+ namespace couchbase
31
+ {
32
+ enum class ping_state {
33
+ /**
34
+ * Indicates that the ping operation was successful.
35
+ *
36
+ * @since 1.0.0
37
+ * @committed
38
+ */
39
+ ok,
40
+
41
+ /**
42
+ * Indicates that the ping operation timed out.
43
+ *
44
+ * @since 1.0.0
45
+ * @committed
46
+ */
47
+ timeout,
48
+
49
+ /**
50
+ * Indicates that the ping operation failed.
51
+ *
52
+ * @since 1.0.0
53
+ * @committed
54
+ */
55
+ error,
56
+ };
57
+
58
+ class endpoint_ping_report
59
+ {
60
+ public:
61
+ /**
62
+ * @since 1.0.0
63
+ * @internal
64
+ */
65
+ endpoint_ping_report() = default;
66
+
67
+ /**
68
+ * @since 1.0.0
69
+ * @internal
70
+ */
71
+ endpoint_ping_report(service_type type,
72
+ std::string id,
73
+ std::string local,
74
+ std::string remote,
75
+ ping_state state,
76
+ std::optional<std::string> error,
77
+ std::optional<std::string> endpoint_namespace,
78
+ std::chrono::microseconds latency)
79
+ : type_{ type }
80
+ , id_{ std::move(id) }
81
+ , local_{ std::move(local) }
82
+ , remote_{ std::move(remote) }
83
+ , state_{ state }
84
+ , error_{ std::move(error) }
85
+ , namespace_{ std::move(endpoint_namespace) }
86
+ , latency_{ latency }
87
+ {
88
+ }
89
+
90
+ /**
91
+ * Returns the service type for this endpoint.
92
+ *
93
+ * @return the service type.
94
+ *
95
+ * @since 1.0.0
96
+ * @committed
97
+ */
98
+ [[nodiscard]] auto type() const -> service_type
99
+ {
100
+ return type_;
101
+ }
102
+
103
+ /**
104
+ * Returns the ID for this endpoint.
105
+ *
106
+ * @return the endpoint ID.
107
+ *
108
+ * @since 1.0.0
109
+ * @committed
110
+ */
111
+ [[nodiscard]] auto id() const -> std::string
112
+ {
113
+ return id_;
114
+ }
115
+
116
+ /**
117
+ * Returns the local socket address for this endpoint.
118
+ *
119
+ * @return the local socket address.
120
+ *
121
+ * @since 1.0.0
122
+ * @committed
123
+ */
124
+ [[nodiscard]] auto local() const -> std::string
125
+ {
126
+ return local_;
127
+ }
128
+
129
+ /**
130
+ * Returns the remote socket address for this endpoint.
131
+ *
132
+ * @return the remote socket address.
133
+ *
134
+ * @since 1.0.0
135
+ * @committed
136
+ */
137
+ [[nodiscard]] auto remote() const -> std::string
138
+ {
139
+ return remote_;
140
+ }
141
+
142
+ /**
143
+ * Returns the state of this ping when assembling the report.
144
+ *
145
+ * @return the ping state.
146
+ *
147
+ * @since 1.0.0
148
+ * @committed
149
+ */
150
+ [[nodiscard]] auto state() const -> ping_state
151
+ {
152
+ return state_;
153
+ }
154
+
155
+ /**
156
+ * Returns the reason this ping did not succeed, if applicable.
157
+ *
158
+ * @return error description.
159
+ *
160
+ * @since 1.0.0
161
+ * @committed
162
+ */
163
+ [[nodiscard]] auto error() const -> std::optional<std::string>
164
+ {
165
+ return error_;
166
+ }
167
+
168
+ /**
169
+ * Returns the namespace of this endpoint (likely the bucket name if present).
170
+ *
171
+ * @return the namespace.
172
+ *
173
+ * @since 1.0.0
174
+ * @committed
175
+ */
176
+ [[nodiscard]] auto endpoint_namespace() const -> std::optional<std::string>
177
+ {
178
+ return namespace_;
179
+ }
180
+
181
+ /**
182
+ * Returns the latency of this ping.
183
+ *
184
+ * @return the latency in microseconds.
185
+ *
186
+ * @since 1.0.0
187
+ * @committed
188
+ */
189
+ [[nodiscard]] auto latency() const -> std::chrono::microseconds
190
+ {
191
+ return latency_;
192
+ }
193
+
194
+ private:
195
+ service_type type_;
196
+ std::string id_;
197
+ std::string local_;
198
+ std::string remote_;
199
+ ping_state state_;
200
+ std::optional<std::string> error_{};
201
+ std::optional<std::string> namespace_{};
202
+ std::chrono::microseconds latency_;
203
+ };
204
+
205
+ } // namespace couchbase
@@ -46,8 +46,6 @@ struct get_options : public common_options<get_options> {
46
46
  const std::vector<std::string> projections;
47
47
  };
48
48
 
49
- static constexpr std::size_t maximum_number_of_projections{ 16U };
50
-
51
49
  /**
52
50
  * Validates options and returns them as an immutable value.
53
51
  *
@@ -60,10 +58,7 @@ struct get_options : public common_options<get_options> {
60
58
  */
61
59
  [[nodiscard]] auto build() const -> built
62
60
  {
63
- if (projections_.size() + (with_expiry_ ? 2 : 1) < maximum_number_of_projections) {
64
- return { build_common_options(), with_expiry_, projections_ };
65
- }
66
- return { build_common_options(), with_expiry_, {} };
61
+ return { build_common_options(), with_expiry_, projections_ };
67
62
  }
68
63
 
69
64
  /**
@@ -22,7 +22,7 @@ namespace couchbase::management::bucket
22
22
  struct collection_spec {
23
23
  std::string name;
24
24
  std::string scope_name;
25
- std::uint32_t max_expiry{};
25
+ std::int32_t max_expiry{};
26
26
  std::optional<bool> history{};
27
27
  };
28
28
 
@@ -0,0 +1,93 @@
1
+ /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright 2023-Present 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 <couchbase/common_options.hxx>
21
+ #include <couchbase/ping_result.hxx>
22
+ #include <couchbase/service_type.hxx>
23
+
24
+ #include <functional>
25
+ #include <memory>
26
+ #include <optional>
27
+ #include <set>
28
+ #include <string>
29
+
30
+ namespace couchbase
31
+ {
32
+ struct ping_options : public common_options<ping_options> {
33
+ /**
34
+ * Sets a custom report ID that will be used in the report. If no report ID is provided, the client will generate a
35
+ * unique one.
36
+ *
37
+ * @param report_id the report ID that should be used.
38
+ * @return reference to this object, for use in chaining.
39
+ *
40
+ * @since 1.0.0
41
+ * @committed
42
+ */
43
+ auto report_id(std::string report_id) -> ping_options&
44
+ {
45
+ report_id_ = std::move(report_id);
46
+ return self();
47
+ }
48
+
49
+ /**
50
+ * Customizes the set of services to ping.
51
+ *
52
+ * @param service_types the services to ping.
53
+ * @return reference to this object, for use in chaining.
54
+ */
55
+ auto service_types(std::set<service_type> service_types) -> ping_options&
56
+ {
57
+ service_types_ = std::move(service_types);
58
+ return self();
59
+ }
60
+
61
+ /**
62
+ * Immutable value object representing consistent options.
63
+ *
64
+ * @since 1.0.0
65
+ * @internal
66
+ */
67
+ struct built : public common_options<ping_options>::built {
68
+ std::optional<std::string> report_id;
69
+ std::set<service_type> service_types;
70
+ };
71
+
72
+ /**
73
+ * Validates the options and returns them as an immutable value.
74
+ *
75
+ * @return consistent options as an immutable value
76
+ *
77
+ * @exception std::system_error with code errc::common::invalid_argument if the options are not valid
78
+ *
79
+ * @since 1.0.0
80
+ * @internal
81
+ */
82
+ [[nodiscard]] auto build() const -> built
83
+ {
84
+ return { build_common_options(), report_id_, service_types_ };
85
+ }
86
+
87
+ private:
88
+ std::optional<std::string> report_id_{};
89
+ std::set<service_type> service_types_{};
90
+ };
91
+
92
+ using ping_handler = std::function<void(ping_result)>;
93
+ } // namespace couchbase
@@ -0,0 +1,118 @@
1
+ /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright 2023-present 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 <couchbase/codec/tao_json_serializer.hxx>
21
+ #include <couchbase/endpoint_ping_report.hxx>
22
+ #include <couchbase/service_type.hxx>
23
+
24
+ #include <cstdint>
25
+ #include <map>
26
+ #include <string>
27
+ #include <utility>
28
+ #include <vector>
29
+
30
+ namespace couchbase
31
+ {
32
+ class ping_result
33
+ {
34
+ public:
35
+ /**
36
+ * @since 1.0.0
37
+ * @internal
38
+ */
39
+ ping_result() = default;
40
+
41
+ /**
42
+ * @since 1.0.0
43
+ * @internal
44
+ */
45
+ ping_result(std::string id, std::uint16_t version, std::string sdk, std::map<service_type, std::vector<endpoint_ping_report>> endpoints)
46
+ : id_{ std::move(id) }
47
+ , version_{ version }
48
+ , sdk_{ std::move(sdk) }
49
+ , endpoints_{ std::move(endpoints) }
50
+ {
51
+ }
52
+
53
+ /**
54
+ * Returns the ID of this report.
55
+ *
56
+ * @return the report ID.
57
+ *
58
+ * @since 1.0.0
59
+ * @committed
60
+ */
61
+ [[nodiscard]] auto id() const -> std::string
62
+ {
63
+ return id_;
64
+ }
65
+
66
+ /**
67
+ * Returns the version of this report (useful when exporting to JSON).
68
+ *
69
+ * @return the report version.
70
+ *
71
+ * @since 1.0.0
72
+ * @committed
73
+ */
74
+ [[nodiscard]] auto version() const -> std::uint16_t
75
+ {
76
+ return version_;
77
+ }
78
+
79
+ /**
80
+ * Returns the identifier of this SDK (useful when exporting to JSON).
81
+ *
82
+ * @return the SDK identifier.
83
+ *
84
+ * @since 1.0.0
85
+ * @committed
86
+ */
87
+ [[nodiscard]] auto sdk() const -> std::string
88
+ {
89
+ return sdk_;
90
+ }
91
+
92
+ /**
93
+ * Returns the ping reports for each individual endpoint, organised by service type.
94
+ *
95
+ * @return the service type to ping reports map.
96
+ *
97
+ * @since 1.0.0
98
+ * @committed
99
+ */
100
+ [[nodiscard]] auto endpoints() const -> std::map<service_type, std::vector<endpoint_ping_report>>
101
+ {
102
+ return endpoints_;
103
+ }
104
+
105
+ /**
106
+ * Exports the ping report as JSON.
107
+ *
108
+ * @return the JSON report.
109
+ */
110
+ [[nodiscard]] auto as_json() const -> codec::tao_json_serializer::document_type;
111
+
112
+ private:
113
+ std::string id_{};
114
+ std::uint16_t version_{};
115
+ std::string sdk_{};
116
+ std::map<service_type, std::vector<endpoint_ping_report>> endpoints_{};
117
+ };
118
+ } // namespace couchbase