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

Sign up to get free protection for your applications and to get access to all the features.
Files changed (221) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -2
  3. data/ext/CMakeLists.txt +3 -1
  4. data/ext/build_version.hxx.in +1 -1
  5. data/ext/cmake/Testing.cmake +1 -0
  6. data/ext/cmake/ThirdPartyDependencies.cmake +6 -0
  7. data/ext/cmake/VersionInfo.cmake +3 -0
  8. data/ext/couchbase/bucket.hxx +47 -28
  9. data/ext/couchbase/cbsasl/client.h +1 -1
  10. data/ext/couchbase/cbsasl/context.cc +1 -1
  11. data/ext/couchbase/cbsasl/context.h +3 -3
  12. data/ext/couchbase/cbsasl/mechanism.cc +5 -8
  13. data/ext/couchbase/cbsasl/mechanism.h +1 -4
  14. data/ext/couchbase/cbsasl/plain/plain.cc +1 -1
  15. data/ext/couchbase/cbsasl/scram-sha/scram-sha.cc +30 -36
  16. data/ext/couchbase/cluster.hxx +40 -22
  17. data/ext/couchbase/cluster_options.hxx +7 -1
  18. data/ext/couchbase/configuration.hxx +37 -16
  19. data/ext/couchbase/couchbase.cxx +1145 -291
  20. data/ext/couchbase/error_map.hxx +1 -1
  21. data/ext/couchbase/errors.hxx +25 -17
  22. data/ext/couchbase/io/dns_client.hxx +3 -3
  23. data/ext/couchbase/io/dns_codec.hxx +4 -5
  24. data/ext/couchbase/io/dns_config.hxx +5 -6
  25. data/ext/couchbase/io/dns_message.hxx +3 -3
  26. data/ext/couchbase/io/http_command.hxx +70 -35
  27. data/ext/couchbase/io/http_session.hxx +4 -3
  28. data/ext/couchbase/io/http_session_manager.hxx +28 -19
  29. data/ext/couchbase/io/mcbp_command.hxx +51 -19
  30. data/ext/couchbase/io/mcbp_context.hxx +1 -1
  31. data/ext/couchbase/io/mcbp_parser.hxx +4 -4
  32. data/ext/couchbase/io/mcbp_session.hxx +91 -101
  33. data/ext/couchbase/io/query_cache.hxx +2 -2
  34. data/ext/couchbase/io/retry_orchestrator.hxx +2 -4
  35. data/ext/couchbase/io/retry_reason.hxx +2 -2
  36. data/ext/couchbase/io/retry_strategy.hxx +1 -6
  37. data/ext/couchbase/io/streams.hxx +7 -7
  38. data/ext/couchbase/metrics/logging_meter.hxx +228 -0
  39. data/ext/couchbase/metrics/logging_meter_options.hxx +28 -0
  40. data/ext/couchbase/metrics/meter.hxx +49 -0
  41. data/ext/couchbase/metrics/noop_meter.hxx +43 -0
  42. data/ext/couchbase/operations.hxx +4 -0
  43. data/ext/couchbase/operations/analytics_dataset_create.hxx +16 -12
  44. data/ext/couchbase/operations/analytics_dataset_drop.hxx +11 -11
  45. data/ext/couchbase/operations/analytics_dataset_get_all.hxx +6 -6
  46. data/ext/couchbase/operations/analytics_dataverse_create.hxx +10 -11
  47. data/ext/couchbase/operations/analytics_dataverse_drop.hxx +10 -11
  48. data/ext/couchbase/operations/analytics_get_pending_mutations.hxx +9 -11
  49. data/ext/couchbase/operations/analytics_index_create.hxx +14 -13
  50. data/ext/couchbase/operations/analytics_index_drop.hxx +18 -12
  51. data/ext/couchbase/operations/analytics_index_get_all.hxx +8 -6
  52. data/ext/couchbase/operations/analytics_link.hxx +39 -0
  53. data/ext/couchbase/operations/analytics_link_azure_blob_external.hxx +145 -0
  54. data/ext/couchbase/operations/analytics_link_connect.hxx +14 -12
  55. data/ext/couchbase/operations/analytics_link_couchbase_remote.hxx +220 -0
  56. data/ext/couchbase/operations/analytics_link_create.hxx +128 -0
  57. data/ext/couchbase/operations/analytics_link_disconnect.hxx +11 -12
  58. data/ext/couchbase/operations/analytics_link_drop.hxx +130 -0
  59. data/ext/couchbase/operations/analytics_link_get_all.hxx +160 -0
  60. data/ext/couchbase/operations/analytics_link_replace.hxx +128 -0
  61. data/ext/couchbase/operations/analytics_link_s3_external.hxx +122 -0
  62. data/ext/couchbase/operations/bucket_create.hxx +8 -8
  63. data/ext/couchbase/operations/bucket_drop.hxx +5 -5
  64. data/ext/couchbase/operations/bucket_flush.hxx +5 -5
  65. data/ext/couchbase/operations/bucket_get.hxx +7 -7
  66. data/ext/couchbase/operations/bucket_get_all.hxx +7 -5
  67. data/ext/couchbase/operations/bucket_settings.hxx +40 -49
  68. data/ext/couchbase/operations/bucket_update.hxx +8 -8
  69. data/ext/couchbase/operations/cluster_developer_preview_enable.hxx +7 -7
  70. data/ext/couchbase/operations/collection_create.hxx +11 -11
  71. data/ext/couchbase/operations/collection_drop.hxx +12 -10
  72. data/ext/couchbase/operations/collections_manifest_get.hxx +3 -3
  73. data/ext/couchbase/operations/design_document.hxx +2 -2
  74. data/ext/couchbase/operations/document_analytics.hxx +29 -36
  75. data/ext/couchbase/operations/document_append.hxx +3 -3
  76. data/ext/couchbase/operations/document_decrement.hxx +3 -3
  77. data/ext/couchbase/operations/document_exists.hxx +2 -2
  78. data/ext/couchbase/operations/document_get.hxx +3 -3
  79. data/ext/couchbase/operations/document_get_and_lock.hxx +5 -3
  80. data/ext/couchbase/operations/document_get_and_touch.hxx +5 -3
  81. data/ext/couchbase/operations/document_get_projected.hxx +10 -11
  82. data/ext/couchbase/operations/document_increment.hxx +3 -3
  83. data/ext/couchbase/operations/document_insert.hxx +3 -3
  84. data/ext/couchbase/operations/document_lookup_in.hxx +12 -18
  85. data/ext/couchbase/operations/document_mutate_in.hxx +13 -18
  86. data/ext/couchbase/operations/document_prepend.hxx +3 -3
  87. data/ext/couchbase/operations/document_query.hxx +39 -41
  88. data/ext/couchbase/operations/document_remove.hxx +3 -3
  89. data/ext/couchbase/operations/document_replace.hxx +3 -3
  90. data/ext/couchbase/operations/document_search.hxx +56 -61
  91. data/ext/couchbase/operations/document_touch.hxx +3 -3
  92. data/ext/couchbase/operations/document_unlock.hxx +3 -3
  93. data/ext/couchbase/operations/document_upsert.hxx +3 -3
  94. data/ext/couchbase/operations/document_view.hxx +23 -23
  95. data/ext/couchbase/operations/group_drop.hxx +5 -5
  96. data/ext/couchbase/operations/group_get.hxx +7 -7
  97. data/ext/couchbase/operations/group_get_all.hxx +6 -6
  98. data/ext/couchbase/operations/group_upsert.hxx +11 -11
  99. data/ext/couchbase/operations/http_noop.hxx +6 -6
  100. data/ext/couchbase/operations/mcbp_noop.hxx +3 -3
  101. data/ext/couchbase/operations/query_index_build_deferred.hxx +6 -6
  102. data/ext/couchbase/operations/query_index_create.hxx +10 -8
  103. data/ext/couchbase/operations/query_index_drop.hxx +8 -8
  104. data/ext/couchbase/operations/query_index_get_all.hxx +43 -39
  105. data/ext/couchbase/operations/rbac.hxx +40 -63
  106. data/ext/couchbase/operations/role_get_all.hxx +6 -6
  107. data/ext/couchbase/operations/scope_create.hxx +10 -10
  108. data/ext/couchbase/operations/scope_drop.hxx +9 -9
  109. data/ext/couchbase/operations/scope_get_all.hxx +8 -8
  110. data/ext/couchbase/operations/search_get_stats.hxx +5 -3
  111. data/ext/couchbase/operations/search_index.hxx +6 -15
  112. data/ext/couchbase/operations/search_index_analyze_document.hxx +11 -11
  113. data/ext/couchbase/operations/search_index_control_ingest.hxx +9 -9
  114. data/ext/couchbase/operations/search_index_control_plan_freeze.hxx +9 -9
  115. data/ext/couchbase/operations/search_index_control_query.hxx +9 -9
  116. data/ext/couchbase/operations/search_index_drop.hxx +11 -9
  117. data/ext/couchbase/operations/search_index_get.hxx +11 -9
  118. data/ext/couchbase/operations/search_index_get_all.hxx +11 -11
  119. data/ext/couchbase/operations/search_index_get_documents_count.hxx +10 -10
  120. data/ext/couchbase/operations/search_index_get_stats.hxx +10 -8
  121. data/ext/couchbase/operations/search_index_upsert.hxx +12 -10
  122. data/ext/couchbase/operations/user_drop.hxx +5 -5
  123. data/ext/couchbase/operations/user_get.hxx +7 -7
  124. data/ext/couchbase/operations/user_get_all.hxx +6 -6
  125. data/ext/couchbase/operations/user_upsert.hxx +9 -9
  126. data/ext/couchbase/operations/view_index_drop.hxx +10 -10
  127. data/ext/couchbase/operations/view_index_get.hxx +13 -15
  128. data/ext/couchbase/operations/view_index_get_all.hxx +17 -20
  129. data/ext/couchbase/operations/view_index_upsert.hxx +9 -7
  130. data/ext/couchbase/origin.hxx +14 -10
  131. data/ext/couchbase/platform/backtrace.c +1 -1
  132. data/ext/couchbase/platform/base64.cc +5 -5
  133. data/ext/couchbase/platform/base64.h +2 -5
  134. data/ext/couchbase/protocol/client_opcode.hxx +7 -4
  135. data/ext/couchbase/protocol/client_request.hxx +2 -2
  136. data/ext/couchbase/protocol/client_response.hxx +41 -16
  137. data/ext/couchbase/protocol/cmd_append.hxx +17 -16
  138. data/ext/couchbase/protocol/cmd_cluster_map_change_notification.hxx +4 -4
  139. data/ext/couchbase/protocol/cmd_decrement.hxx +10 -11
  140. data/ext/couchbase/protocol/cmd_exists.hxx +12 -15
  141. data/ext/couchbase/protocol/cmd_get.hxx +11 -14
  142. data/ext/couchbase/protocol/cmd_get_and_lock.hxx +10 -12
  143. data/ext/couchbase/protocol/cmd_get_and_touch.hxx +10 -12
  144. data/ext/couchbase/protocol/cmd_get_cluster_config.hxx +13 -18
  145. data/ext/couchbase/protocol/cmd_get_collection_id.hxx +12 -15
  146. data/ext/couchbase/protocol/cmd_get_collections_manifest.hxx +12 -16
  147. data/ext/couchbase/protocol/cmd_get_error_map.hxx +14 -17
  148. data/ext/couchbase/protocol/cmd_hello.hxx +8 -10
  149. data/ext/couchbase/protocol/cmd_increment.hxx +9 -10
  150. data/ext/couchbase/protocol/cmd_insert.hxx +9 -9
  151. data/ext/couchbase/protocol/cmd_lookup_in.hxx +12 -13
  152. data/ext/couchbase/protocol/cmd_mutate_in.hxx +11 -11
  153. data/ext/couchbase/protocol/cmd_noop.hxx +16 -20
  154. data/ext/couchbase/protocol/cmd_prepend.hxx +9 -10
  155. data/ext/couchbase/protocol/cmd_remove.hxx +10 -13
  156. data/ext/couchbase/protocol/cmd_replace.hxx +7 -7
  157. data/ext/couchbase/protocol/cmd_sasl_auth.hxx +8 -10
  158. data/ext/couchbase/protocol/cmd_sasl_list_mechs.hxx +10 -15
  159. data/ext/couchbase/protocol/cmd_sasl_step.hxx +10 -12
  160. data/ext/couchbase/protocol/cmd_select_bucket.hxx +14 -18
  161. data/ext/couchbase/protocol/cmd_touch.hxx +8 -11
  162. data/ext/couchbase/protocol/cmd_unlock.hxx +10 -14
  163. data/ext/couchbase/protocol/cmd_upsert.hxx +8 -8
  164. data/ext/couchbase/protocol/datatype.hxx +3 -3
  165. data/ext/couchbase/protocol/durability_level.hxx +2 -2
  166. data/ext/couchbase/protocol/frame_info_id.hxx +4 -4
  167. data/ext/couchbase/protocol/hello_feature.hxx +2 -2
  168. data/ext/couchbase/protocol/magic.hxx +2 -2
  169. data/ext/couchbase/protocol/server_opcode.hxx +2 -2
  170. data/ext/couchbase/protocol/server_request.hxx +1 -1
  171. data/ext/couchbase/protocol/status.hxx +4 -7
  172. data/ext/couchbase/protocol/unsigned_leb128.h +5 -20
  173. data/ext/couchbase/service_type.hxx +4 -4
  174. data/ext/couchbase/tracing/constants.hxx +261 -0
  175. data/ext/couchbase/tracing/noop_tracer.hxx +50 -0
  176. data/ext/couchbase/tracing/request_tracer.hxx +77 -0
  177. data/ext/couchbase/tracing/threshold_logging_options.hxx +64 -0
  178. data/ext/couchbase/tracing/threshold_logging_tracer.hxx +366 -0
  179. data/ext/couchbase/utils/byteswap.hxx +1 -1
  180. data/ext/couchbase/utils/connection_string.hxx +21 -1
  181. data/ext/couchbase/utils/name_codec.hxx +41 -0
  182. data/ext/couchbase/utils/url_codec.hxx +236 -0
  183. data/ext/couchbase/version.hxx +1 -1
  184. data/ext/test/CMakeLists.txt +1 -0
  185. data/ext/test/test_native_trivial_query.cxx +60 -0
  186. data/ext/third_party/hdr_histogram_c/CMakeLists.txt +84 -0
  187. data/ext/third_party/hdr_histogram_c/COPYING.txt +121 -0
  188. data/ext/third_party/hdr_histogram_c/LICENSE.txt +41 -0
  189. data/ext/third_party/hdr_histogram_c/config.cmake.in +6 -0
  190. data/ext/third_party/hdr_histogram_c/src/CMakeLists.txt +83 -0
  191. data/ext/third_party/hdr_histogram_c/src/hdr_atomic.h +146 -0
  192. data/ext/third_party/hdr_histogram_c/src/hdr_encoding.c +322 -0
  193. data/ext/third_party/hdr_histogram_c/src/hdr_encoding.h +79 -0
  194. data/ext/third_party/hdr_histogram_c/src/hdr_endian.h +116 -0
  195. data/ext/third_party/hdr_histogram_c/src/hdr_histogram.c +1196 -0
  196. data/ext/third_party/hdr_histogram_c/src/hdr_histogram.h +516 -0
  197. data/ext/third_party/hdr_histogram_c/src/hdr_histogram_log.c +1290 -0
  198. data/ext/third_party/hdr_histogram_c/src/hdr_histogram_log.h +236 -0
  199. data/ext/third_party/hdr_histogram_c/src/hdr_histogram_log_no_op.c +171 -0
  200. data/ext/third_party/hdr_histogram_c/src/hdr_interval_recorder.c +227 -0
  201. data/ext/third_party/hdr_histogram_c/src/hdr_interval_recorder.h +109 -0
  202. data/ext/third_party/hdr_histogram_c/src/hdr_malloc.h +19 -0
  203. data/ext/third_party/hdr_histogram_c/src/hdr_tests.h +22 -0
  204. data/ext/third_party/hdr_histogram_c/src/hdr_thread.c +108 -0
  205. data/ext/third_party/hdr_histogram_c/src/hdr_thread.h +55 -0
  206. data/ext/third_party/hdr_histogram_c/src/hdr_time.c +98 -0
  207. data/ext/third_party/hdr_histogram_c/src/hdr_time.h +49 -0
  208. data/ext/third_party/hdr_histogram_c/src/hdr_writer_reader_phaser.c +143 -0
  209. data/ext/third_party/hdr_histogram_c/src/hdr_writer_reader_phaser.h +51 -0
  210. data/lib/couchbase/cluster.rb +1 -0
  211. data/lib/couchbase/errors.rb +3 -0
  212. data/lib/couchbase/libcouchbase.bundle +0 -0
  213. data/lib/couchbase/management/analytics_index_manager.rb +920 -226
  214. data/lib/couchbase/management/bucket_manager.rb +207 -69
  215. data/lib/couchbase/management/collection_manager.rb +173 -61
  216. data/lib/couchbase/management/query_index_manager.rb +357 -169
  217. data/lib/couchbase/options.rb +75 -3
  218. data/lib/couchbase/scope.rb +102 -0
  219. data/lib/couchbase/utils/time.rb +4 -0
  220. data/lib/couchbase/version.rb +6 -6
  221. metadata +48 -5
@@ -0,0 +1,143 @@
1
+ /**
2
+ * hdr_writer_reader_phaser.h
3
+ * Written by Michael Barker and released to the public domain,
4
+ * as explained at http://creativecommons.org/publicdomain/zero/1.0/
5
+ */
6
+
7
+ #include <stdint.h>
8
+ #include <stdbool.h>
9
+ #include <errno.h>
10
+
11
+ #include "hdr_atomic.h"
12
+ #include "hdr_thread.h"
13
+
14
+ #include "hdr_writer_reader_phaser.h"
15
+
16
+ #ifndef HDR_MALLOC_INCLUDE
17
+ #define HDR_MALLOC_INCLUDE "hdr_malloc.h"
18
+ #endif
19
+
20
+ #include HDR_MALLOC_INCLUDE
21
+
22
+ static int64_t _hdr_phaser_get_epoch(int64_t* field)
23
+ {
24
+ return hdr_atomic_load_64(field);
25
+ }
26
+
27
+ static void _hdr_phaser_set_epoch(int64_t* field, int64_t val)
28
+ {
29
+ hdr_atomic_store_64(field, val);
30
+ }
31
+
32
+ static int64_t _hdr_phaser_reset_epoch(int64_t* field, int64_t initial_value)
33
+ {
34
+ return hdr_atomic_exchange_64(field, initial_value);
35
+ }
36
+
37
+ int hdr_writer_reader_phaser_init(struct hdr_writer_reader_phaser* p)
38
+ {
39
+ int rc;
40
+ if (NULL == p)
41
+ {
42
+ return EINVAL;
43
+ }
44
+
45
+ p->start_epoch = 0;
46
+ p->even_end_epoch = 0;
47
+ p->odd_end_epoch = INT64_MIN;
48
+ p->reader_mutex = hdr_mutex_alloc();
49
+
50
+ if (!p->reader_mutex)
51
+ {
52
+ return ENOMEM;
53
+ }
54
+
55
+ rc = hdr_mutex_init(p->reader_mutex);
56
+ if (0 != rc)
57
+ {
58
+ return rc;
59
+ }
60
+
61
+ /* TODO: Should I fence here. */
62
+
63
+ return 0;
64
+ }
65
+
66
+ void hdr_writer_reader_phaser_destroy(struct hdr_writer_reader_phaser* p)
67
+ {
68
+ hdr_mutex_destroy(p->reader_mutex);
69
+ hdr_mutex_free(p->reader_mutex);
70
+ }
71
+
72
+ int64_t hdr_phaser_writer_enter(struct hdr_writer_reader_phaser* p)
73
+ {
74
+ return hdr_atomic_add_fetch_64(&p->start_epoch, 1);
75
+ }
76
+
77
+ void hdr_phaser_writer_exit(
78
+ struct hdr_writer_reader_phaser* p, int64_t critical_value_at_enter)
79
+ {
80
+ int64_t* end_epoch =
81
+ (critical_value_at_enter < 0) ? &p->odd_end_epoch : &p->even_end_epoch;
82
+ hdr_atomic_add_fetch_64(end_epoch, 1);
83
+ }
84
+
85
+ void hdr_phaser_reader_lock(struct hdr_writer_reader_phaser* p)
86
+ {
87
+ hdr_mutex_lock(p->reader_mutex);
88
+ }
89
+
90
+ void hdr_phaser_reader_unlock(struct hdr_writer_reader_phaser* p)
91
+ {
92
+ hdr_mutex_unlock(p->reader_mutex);
93
+ }
94
+
95
+ void hdr_phaser_flip_phase(
96
+ struct hdr_writer_reader_phaser* p, int64_t sleep_time_ns)
97
+ {
98
+ bool caught_up;
99
+ int64_t start_value_at_flip;
100
+ /* TODO: is_held_by_current_thread */
101
+ unsigned int sleep_time_us = sleep_time_ns < 1000000000 ? (unsigned int) (sleep_time_ns / 1000) : 1000000;
102
+
103
+ int64_t start_epoch = _hdr_phaser_get_epoch(&p->start_epoch);
104
+
105
+ bool next_phase_is_even = (start_epoch < 0);
106
+
107
+ /* Clear currently used phase end epoch.*/
108
+ int64_t initial_start_value;
109
+ if (next_phase_is_even)
110
+ {
111
+ initial_start_value = 0;
112
+ _hdr_phaser_set_epoch(&p->even_end_epoch, initial_start_value);
113
+ }
114
+ else
115
+ {
116
+ initial_start_value = INT64_MIN;
117
+ _hdr_phaser_set_epoch(&p->odd_end_epoch, initial_start_value);
118
+ }
119
+
120
+ /* Reset start value, indicating new phase.*/
121
+ start_value_at_flip = _hdr_phaser_reset_epoch(&p->start_epoch, initial_start_value);
122
+
123
+ do
124
+ {
125
+ int64_t* end_epoch =
126
+ next_phase_is_even ? &p->odd_end_epoch : &p->even_end_epoch;
127
+
128
+ caught_up = _hdr_phaser_get_epoch(end_epoch) == start_value_at_flip;
129
+
130
+ if (!caught_up)
131
+ {
132
+ if (sleep_time_us <= 0)
133
+ {
134
+ hdr_yield();
135
+ }
136
+ else
137
+ {
138
+ hdr_usleep(sleep_time_us);
139
+ }
140
+ }
141
+ }
142
+ while (!caught_up);
143
+ }
@@ -0,0 +1,51 @@
1
+ /**
2
+ * hdr_writer_reader_phaser.h
3
+ * Written by Michael Barker and released to the public domain,
4
+ * as explained at http://creativecommons.org/publicdomain/zero/1.0/
5
+ */
6
+
7
+ #ifndef HDR_WRITER_READER_PHASER_H
8
+ #define HDR_WRITER_READER_PHASER_H 1
9
+
10
+ #include <stdlib.h>
11
+ #include <stdbool.h>
12
+ #include <stdlib.h>
13
+ #include <errno.h>
14
+
15
+ #include "hdr_thread.h"
16
+
17
+ HDR_ALIGN_PREFIX(8)
18
+ struct hdr_writer_reader_phaser
19
+ {
20
+ int64_t start_epoch;
21
+ int64_t even_end_epoch;
22
+ int64_t odd_end_epoch;
23
+ hdr_mutex* reader_mutex;
24
+ }
25
+ HDR_ALIGN_SUFFIX(8);
26
+
27
+ #ifdef __cplusplus
28
+ extern "C" {
29
+ #endif
30
+
31
+ int hdr_writer_reader_phaser_init(struct hdr_writer_reader_phaser* p);
32
+
33
+ void hdr_writer_reader_phaser_destroy(struct hdr_writer_reader_phaser* p);
34
+
35
+ int64_t hdr_phaser_writer_enter(struct hdr_writer_reader_phaser* p);
36
+
37
+ void hdr_phaser_writer_exit(
38
+ struct hdr_writer_reader_phaser* p, int64_t critical_value_at_enter);
39
+
40
+ void hdr_phaser_reader_lock(struct hdr_writer_reader_phaser* p);
41
+
42
+ void hdr_phaser_reader_unlock(struct hdr_writer_reader_phaser* p);
43
+
44
+ void hdr_phaser_flip_phase(
45
+ struct hdr_writer_reader_phaser* p, int64_t sleep_time_ns);
46
+
47
+ #ifdef __cplusplus
48
+ }
49
+ #endif
50
+
51
+ #endif
@@ -387,6 +387,7 @@ module Couchbase
387
387
 
388
388
  open_options[:allowed_sasl_mechanisms] = PasswordAuthenticator::DEFAULT_SASL_MECHANISMS
389
389
  when Options::Cluster
390
+ open_options = options&.to_backend || {}
390
391
  authenticator = options&.authenticator
391
392
  case authenticator
392
393
  when PasswordAuthenticator
@@ -293,6 +293,9 @@ module Couchbase
293
293
  class LinkNotFound < CouchbaseError
294
294
  end
295
295
 
296
+ class LinkExists < CouchbaseError
297
+ end
298
+
296
299
  # Search exceptions
297
300
 
298
301
  class IndexNotReady < CouchbaseError
Binary file
@@ -13,9 +13,616 @@
13
13
  # limitations under the License.
14
14
 
15
15
  require "couchbase/errors"
16
+ require "couchbase/options"
16
17
 
17
18
  module Couchbase
18
19
  module Management
20
+ module Options
21
+ module Analytics
22
+ # Options for {AnalyticsIndexManager#create_dataverse}
23
+ class CreateDataverse < ::Couchbase::Options::Base
24
+ attr_accessor :ignore_if_exists # @return [Boolean]
25
+
26
+ # Creates an instance of options for {AnalyticsIndexManager#create_dataverse}
27
+ #
28
+ # @param [Boolean] ignore_if_exists if +true+, the exception {Error::DataverseExists} will not be raised if the
29
+ # dataverse with the specified name already exists.
30
+ #
31
+ # @param [Integer, #in_milliseconds, nil] timeout the time in milliseconds allowed for the operation to complete
32
+ # @param [Proc, nil] retry_strategy the custom retry strategy, if set
33
+ # @param [Hash, nil] client_context the client context data, if set
34
+ # @param [Span, nil] parent_span if set holds the parent span, that should be used for this request
35
+ #
36
+ # @yieldparam [CreateDataverse] self
37
+ def initialize(ignore_if_exists: false,
38
+ timeout: nil,
39
+ retry_strategy: nil,
40
+ client_context: nil,
41
+ parent_span: nil)
42
+ super(timeout: timeout, retry_strategy: retry_strategy, client_context: client_context, parent_span: parent_span)
43
+ @ignore_if_exists = ignore_if_exists
44
+ yield self if block_given?
45
+ end
46
+
47
+ # @api private
48
+ def to_backend
49
+ {
50
+ timeout: @timeout.respond_to?(:in_milliseconds) ? @timeout.public_send(:in_milliseconds) : @timeout,
51
+ ignore_if_exists: @ignore_if_exists,
52
+ }
53
+ end
54
+ end
55
+
56
+ # Options for {AnalyticsIndexManager#drop_dataverse}
57
+ class DropDataverse < ::Couchbase::Options::Base
58
+ attr_accessor :ignore_if_does_not_exist # @return [Boolean]
59
+
60
+ # Creates an instance of options for {AnalyticsIndexManager#create_dataverse}
61
+ #
62
+ # @param [Boolean] ignore_if_does_not_exist if +true+, the exception {Error::DataverseNotFound} will not be raised
63
+ # if the dataverse with the specified name does not exist.
64
+ #
65
+ # @param [Integer, #in_milliseconds, nil] timeout the time in milliseconds allowed for the operation to complete
66
+ # @param [Proc, nil] retry_strategy the custom retry strategy, if set
67
+ # @param [Hash, nil] client_context the client context data, if set
68
+ # @param [Span, nil] parent_span if set holds the parent span, that should be used for this request
69
+ #
70
+ # @yieldparam [DropDataverse] self
71
+ def initialize(ignore_if_does_not_exist: false,
72
+ timeout: nil,
73
+ retry_strategy: nil,
74
+ client_context: nil,
75
+ parent_span: nil)
76
+ super(timeout: timeout, retry_strategy: retry_strategy, client_context: client_context, parent_span: parent_span)
77
+ @ignore_if_does_not_exist = ignore_if_does_not_exist
78
+ yield self if block_given?
79
+ end
80
+
81
+ # @api private
82
+ def to_backend
83
+ {
84
+ timeout: @timeout.respond_to?(:in_milliseconds) ? @timeout.public_send(:in_milliseconds) : @timeout,
85
+ ignore_if_does_not_exist: @ignore_if_does_not_exist,
86
+ }
87
+ end
88
+ end
89
+
90
+ # Options for {AnalyticsIndexManager#create_dataset}
91
+ class CreateDataset < ::Couchbase::Options::Base
92
+ attr_accessor :ignore_if_exists # @return [Boolean]
93
+ attr_accessor :condition # @return [String]
94
+ attr_accessor :dataverse_name # @return [String]
95
+
96
+ # Creates an instance of options for {AnalyticsIndexManager#create_dataset}
97
+ #
98
+ # @param [Boolean] ignore_if_exists if +true+, the exception {Error::DatasetExists} will not be raised
99
+ # if the dataset with the specified name already exists.
100
+ # @param [String] condition WHERE clause to use for creating dataset
101
+ # @param [String] dataverse_name the name of the dataverse to use (defaults to +nil+)
102
+ #
103
+ # @param [Integer, #in_milliseconds, nil] timeout the time in milliseconds allowed for the operation to complete
104
+ # @param [Proc, nil] retry_strategy the custom retry strategy, if set
105
+ # @param [Hash, nil] client_context the client context data, if set
106
+ # @param [Span, nil] parent_span if set holds the parent span, that should be used for this request
107
+ #
108
+ # @yieldparam [CreateDataset] self
109
+ def initialize(ignore_if_exists: false,
110
+ condition: nil,
111
+ dataverse_name: nil,
112
+ timeout: nil,
113
+ retry_strategy: nil,
114
+ client_context: nil,
115
+ parent_span: nil)
116
+ super(timeout: timeout, retry_strategy: retry_strategy, client_context: client_context, parent_span: parent_span)
117
+ @ignore_if_exists = ignore_if_exists
118
+ @condition = condition
119
+ @dataverse_name = dataverse_name
120
+ yield self if block_given?
121
+ end
122
+
123
+ # @api private
124
+ def to_backend
125
+ {
126
+ timeout: @timeout.respond_to?(:in_milliseconds) ? @timeout.public_send(:in_milliseconds) : @timeout,
127
+ condition: @condition,
128
+ dataverse_name: @dataverse_name,
129
+ ignore_if_exists: @ignore_if_exists,
130
+ }
131
+ end
132
+ end
133
+
134
+ # Options for {AnalyticsIndexManager#drop_dataset}
135
+ class DropDataset < ::Couchbase::Options::Base
136
+ attr_accessor :ignore_if_does_not_exist # @return [Boolean]
137
+ attr_accessor :dataverse_name # @return [String]
138
+
139
+ # Creates an instance of options for {AnalyticsIndexManager#drop_dataset}
140
+ #
141
+ # @param [Boolean] ignore_if_does_not_exist if +true+, the exception {Error::DatasetNotFound} will not be raised
142
+ # if the dataset with the specified name does not exist.
143
+ # @param [String] dataverse_name the name of the dataverse to use (defaults to +nil+)
144
+ #
145
+ # @param [Integer, #in_milliseconds, nil] timeout the time in milliseconds allowed for the operation to complete
146
+ # @param [Proc, nil] retry_strategy the custom retry strategy, if set
147
+ # @param [Hash, nil] client_context the client context data, if set
148
+ # @param [Span, nil] parent_span if set holds the parent span, that should be used for this request
149
+ #
150
+ # @yieldparam [DropDataset] self
151
+ def initialize(ignore_if_does_not_exist: false,
152
+ dataverse_name: nil,
153
+ timeout: nil,
154
+ retry_strategy: nil,
155
+ client_context: nil,
156
+ parent_span: nil)
157
+ super(timeout: timeout, retry_strategy: retry_strategy, client_context: client_context, parent_span: parent_span)
158
+ @ignore_if_does_not_exist = ignore_if_does_not_exist
159
+ @dataverse_name = dataverse_name
160
+ yield self if block_given?
161
+ end
162
+
163
+ # @api private
164
+ def to_backend
165
+ {
166
+ timeout: @timeout.respond_to?(:in_milliseconds) ? @timeout.public_send(:in_milliseconds) : @timeout,
167
+ dataverse_name: @dataverse_name,
168
+ ignore_if_does_not_exist: @ignore_if_does_not_exist,
169
+ }
170
+ end
171
+ end
172
+
173
+ # Options for {AnalyticsIndexManager#get_all_datasets}
174
+ class GetAllDatasets < ::Couchbase::Options::Base
175
+ # Creates an instance of options for {AnalyticsIndexManager#get_all_datasets}
176
+ #
177
+ # @param [Integer, #in_milliseconds, nil] timeout the time in milliseconds allowed for the operation to complete
178
+ # @param [Proc, nil] retry_strategy the custom retry strategy, if set
179
+ # @param [Hash, nil] client_context the client context data, if set
180
+ # @param [Span, nil] parent_span if set holds the parent span, that should be used for this request
181
+ #
182
+ # @yieldparam [GetAllDatasets] self
183
+ def initialize(timeout: nil,
184
+ retry_strategy: nil,
185
+ client_context: nil,
186
+ parent_span: nil)
187
+ super
188
+ yield self if block_given?
189
+ end
190
+ end
191
+
192
+ # Options for {AnalyticsIndexManager#create_index}
193
+ class CreateIndex < ::Couchbase::Options::Base
194
+ attr_accessor :ignore_if_exists # @return [Boolean]
195
+ attr_accessor :dataverse_name # @return [String]
196
+
197
+ # Creates an instance of options for {AnalyticsIndexManager#create_index}
198
+ #
199
+ # @param [Boolean] ignore_if_exists if +true+, the exception {Error::DatasetExists} will not be raised
200
+ # if the dataset with the specified name already exists.
201
+ # @param [String] dataverse_name the name of the dataverse to use (defaults to +nil+)
202
+ #
203
+ # @param [Integer, #in_milliseconds, nil] timeout the time in milliseconds allowed for the operation to complete
204
+ # @param [Proc, nil] retry_strategy the custom retry strategy, if set
205
+ # @param [Hash, nil] client_context the client context data, if set
206
+ # @param [Span, nil] parent_span if set holds the parent span, that should be used for this request
207
+ #
208
+ # @yieldparam [CreateIndex] self
209
+ def initialize(ignore_if_exists: false,
210
+ dataverse_name: nil,
211
+ timeout: nil,
212
+ retry_strategy: nil,
213
+ client_context: nil,
214
+ parent_span: nil)
215
+ super(timeout: timeout, retry_strategy: retry_strategy, client_context: client_context, parent_span: parent_span)
216
+ @ignore_if_exists = ignore_if_exists
217
+ @dataverse_name = dataverse_name
218
+ yield self if block_given?
219
+ end
220
+
221
+ # @api private
222
+ def to_backend
223
+ {
224
+ timeout: @timeout.respond_to?(:in_milliseconds) ? @timeout.public_send(:in_milliseconds) : @timeout,
225
+ dataverse_name: @dataverse_name,
226
+ ignore_if_exists: @ignore_if_exists,
227
+ }
228
+ end
229
+ end
230
+
231
+ # Options for {AnalyticsIndexManager#drop_index}
232
+ class DropIndex < ::Couchbase::Options::Base
233
+ attr_accessor :ignore_if_does_not_exist # @return [Boolean]
234
+ attr_accessor :dataverse_name # @return [String]
235
+
236
+ # Creates an instance of options for {AnalyticsIndexManager#drop_index}
237
+ #
238
+ # @param [Boolean] ignore_if_does_not_exist if +true+, the exception {Error::DatasetNotFound} will not be raised
239
+ # if the dataset with the specified name does not exist.
240
+ # @param [String] dataverse_name the name of the dataverse to use (defaults to +nil+)
241
+ #
242
+ # @param [Integer, #in_milliseconds, nil] timeout the time in milliseconds allowed for the operation to complete
243
+ # @param [Proc, nil] retry_strategy the custom retry strategy, if set
244
+ # @param [Hash, nil] client_context the client context data, if set
245
+ # @param [Span, nil] parent_span if set holds the parent span, that should be used for this request
246
+ #
247
+ # @yieldparam [DropIndex] self
248
+ def initialize(ignore_if_does_not_exist: false,
249
+ dataverse_name: nil,
250
+ timeout: nil,
251
+ retry_strategy: nil,
252
+ client_context: nil,
253
+ parent_span: nil)
254
+ super(timeout: timeout, retry_strategy: retry_strategy, client_context: client_context, parent_span: parent_span)
255
+ @ignore_if_does_not_exist = ignore_if_does_not_exist
256
+ @dataverse_name = dataverse_name
257
+ yield self if block_given?
258
+ end
259
+
260
+ # @api private
261
+ def to_backend
262
+ {
263
+ timeout: @timeout.respond_to?(:in_milliseconds) ? @timeout.public_send(:in_milliseconds) : @timeout,
264
+ dataverse_name: @dataverse_name,
265
+ ignore_if_does_not_exist: @ignore_if_does_not_exist,
266
+ }
267
+ end
268
+ end
269
+
270
+ # Options for {AnalyticsIndexManager#get_all_indexes}
271
+ class GetAllIndexes < ::Couchbase::Options::Base
272
+ # Creates an instance of options for {AnalyticsIndexManager#get_all_indexes}
273
+ #
274
+ # @param [Integer, #in_milliseconds, nil] timeout the time in milliseconds allowed for the operation to complete
275
+ # @param [Proc, nil] retry_strategy the custom retry strategy, if set
276
+ # @param [Hash, nil] client_context the client context data, if set
277
+ # @param [Span, nil] parent_span if set holds the parent span, that should be used for this request
278
+ #
279
+ # @yieldparam [GetAllIndexes] self
280
+ def initialize(timeout: nil,
281
+ retry_strategy: nil,
282
+ client_context: nil,
283
+ parent_span: nil)
284
+ super
285
+ yield self if block_given?
286
+ end
287
+ end
288
+
289
+ # Options for {AnalyticsIndexManager#connect_link}
290
+ class ConnectLink < ::Couchbase::Options::Base
291
+ attr_accessor :link_name # @return [String]
292
+ attr_accessor :force # @return [Boolean]
293
+ attr_accessor :dataverse_name # @return [String]
294
+
295
+ # Creates an instance of options for {AnalyticsIndexManager#connect_link}
296
+ #
297
+ # @param [String] link_name the name of the link
298
+ # @param [Boolean] force if +true+, link creation will be forced even if the bucket UUID changed, for example
299
+ # due to the bucket being deleted and recreated
300
+ # @param [String] dataverse_name the name of the dataverse to use (defaults to +nil+)
301
+ #
302
+ # @param [Integer, #in_milliseconds, nil] timeout the time in milliseconds allowed for the operation to complete
303
+ # @param [Proc, nil] retry_strategy the custom retry strategy, if set
304
+ # @param [Hash, nil] client_context the client context data, if set
305
+ # @param [Span, nil] parent_span if set holds the parent span, that should be used for this request
306
+ #
307
+ # @yieldparam [ConnectLink] self
308
+ def initialize(link_name: "Local",
309
+ force: false,
310
+ dataverse_name: nil,
311
+ timeout: nil,
312
+ retry_strategy: nil,
313
+ client_context: nil,
314
+ parent_span: nil)
315
+ super(timeout: timeout, retry_strategy: retry_strategy, client_context: client_context, parent_span: parent_span)
316
+ @link_name = link_name
317
+ @force = force
318
+ @dataverse_name = dataverse_name
319
+ yield self if block_given?
320
+ end
321
+
322
+ # @api private
323
+ def to_backend
324
+ {
325
+ timeout: @timeout.respond_to?(:in_milliseconds) ? @timeout.public_send(:in_milliseconds) : @timeout,
326
+ link_name: @link_name,
327
+ force: @force,
328
+ dataverse_name: @dataverse_name,
329
+ }
330
+ end
331
+ end
332
+
333
+ # Options for {AnalyticsIndexManager#connect_link}
334
+ class DisconnectLink < ::Couchbase::Options::Base
335
+ attr_accessor :link_name # @return [String]
336
+ attr_accessor :dataverse_name # @return [String]
337
+
338
+ # Creates an instance of options for {AnalyticsIndexManager#disconnect_link}
339
+ #
340
+ # @param [String] link_name the name of the link
341
+ # @param [String] dataverse_name the name of the dataverse to use (defaults to +nil+)
342
+ #
343
+ # @param [Integer, #in_milliseconds, nil] timeout the time in milliseconds allowed for the operation to complete
344
+ # @param [Proc, nil] retry_strategy the custom retry strategy, if set
345
+ # @param [Hash, nil] client_context the client context data, if set
346
+ # @param [Span, nil] parent_span if set holds the parent span, that should be used for this request
347
+ #
348
+ # @yieldparam [DisconnectLink] self
349
+ def initialize(link_name: "Local",
350
+ dataverse_name: nil,
351
+ timeout: nil,
352
+ retry_strategy: nil,
353
+ client_context: nil,
354
+ parent_span: nil)
355
+ super(timeout: timeout, retry_strategy: retry_strategy, client_context: client_context, parent_span: parent_span)
356
+ @link_name = link_name
357
+ @dataverse_name = dataverse_name
358
+ yield self if block_given?
359
+ end
360
+
361
+ # @api private
362
+ def to_backend
363
+ {
364
+ timeout: @timeout.respond_to?(:in_milliseconds) ? @timeout.public_send(:in_milliseconds) : @timeout,
365
+ link_name: @link_name,
366
+ dataverse_name: @dataverse_name,
367
+ }
368
+ end
369
+ end
370
+
371
+ # Options for {AnalyticsIndexManager#get_pending_mutations}
372
+ class GetPendingMutations < ::Couchbase::Options::Base
373
+ # Creates an instance of options for {AnalyticsIndexManager#get_pending_mutations}
374
+ #
375
+ # @param [Integer, #in_milliseconds, nil] timeout the time in milliseconds allowed for the operation to complete
376
+ # @param [Proc, nil] retry_strategy the custom retry strategy, if set
377
+ # @param [Hash, nil] client_context the client context data, if set
378
+ # @param [Span, nil] parent_span if set holds the parent span, that should be used for this request
379
+ #
380
+ # @yieldparam [GetPendingMutations] self
381
+ def initialize(timeout: nil,
382
+ retry_strategy: nil,
383
+ client_context: nil,
384
+ parent_span: nil)
385
+ super
386
+ yield self if block_given?
387
+ end
388
+ end
389
+
390
+ # Options for {AnalyticsIndexManager#create_link}
391
+ class CreateLink < ::Couchbase::Options::Base
392
+ # Creates an instance of options for {AnalyticsIndexManager#create_link}
393
+ #
394
+ # @param [Integer, #in_milliseconds, nil] timeout the time in milliseconds allowed for the operation to complete
395
+ # @param [Proc, nil] retry_strategy the custom retry strategy, if set
396
+ # @param [Hash, nil] client_context the client context data, if set
397
+ # @param [Span, nil] parent_span if set holds the parent span, that should be used for this request
398
+ #
399
+ # @yieldparam [CreateLink] self
400
+ def initialize(timeout: nil,
401
+ retry_strategy: nil,
402
+ client_context: nil,
403
+ parent_span: nil)
404
+ super
405
+ yield self if block_given?
406
+ end
407
+
408
+ # @api private
409
+ def to_backend
410
+ {
411
+ timeout: @timeout.respond_to?(:in_milliseconds) ? @timeout.public_send(:in_milliseconds) : @timeout,
412
+ }
413
+ end
414
+ end
415
+
416
+ # Options for {AnalyticsIndexManager#replace_link}
417
+ class ReplaceLink < ::Couchbase::Options::Base
418
+ # Creates an instance of options for {AnalyticsIndexManager#replace_link}
419
+ #
420
+ # @param [Integer, #in_milliseconds, nil] timeout the time in milliseconds allowed for the operation to complete
421
+ # @param [Proc, nil] retry_strategy the custom retry strategy, if set
422
+ # @param [Hash, nil] client_context the client context data, if set
423
+ # @param [Span, nil] parent_span if set holds the parent span, that should be used for this request
424
+ #
425
+ # @yieldparam [ReplaceLink] self
426
+ def initialize(timeout: nil,
427
+ retry_strategy: nil,
428
+ client_context: nil,
429
+ parent_span: nil)
430
+ super
431
+ yield self if block_given?
432
+ end
433
+
434
+ # @api private
435
+ def to_backend
436
+ {
437
+ timeout: @timeout.respond_to?(:in_milliseconds) ? @timeout.public_send(:in_milliseconds) : @timeout,
438
+ }
439
+ end
440
+ end
441
+
442
+ # Options for {AnalyticsIndexManager#drop_link}
443
+ class DropLink < ::Couchbase::Options::Base
444
+ # Creates an instance of options for {AnalyticsIndexManager#drop_link}
445
+ #
446
+ # @param [Integer, #in_milliseconds, nil] timeout the time in milliseconds allowed for the operation to complete
447
+ # @param [Proc, nil] retry_strategy the custom retry strategy, if set
448
+ # @param [Hash, nil] client_context the client context data, if set
449
+ # @param [Span, nil] parent_span if set holds the parent span, that should be used for this request
450
+ #
451
+ # @yieldparam [DropLink] self
452
+ def initialize(timeout: nil,
453
+ retry_strategy: nil,
454
+ client_context: nil,
455
+ parent_span: nil)
456
+ super
457
+ yield self if block_given?
458
+ end
459
+
460
+ # @api private
461
+ def to_backend
462
+ {
463
+ timeout: @timeout.respond_to?(:in_milliseconds) ? @timeout.public_send(:in_milliseconds) : @timeout,
464
+ }
465
+ end
466
+ end
467
+
468
+ # Options for {AnalyticsIndexManager#get_links}
469
+ class GetLinks < ::Couchbase::Options::Base
470
+ attr_accessor :dataverse # @return [String, nil]
471
+ attr_accessor :link_type # @return [Symbol, nil]
472
+ attr_accessor :name # @return [String, nil]
473
+
474
+ # Creates an instance of options for {AnalyticsIndexManager#get_links}
475
+ #
476
+ # @param [:s3, :azureblob, :couchbase, nil] link_type restricts the results to the given link type.
477
+ # @param [String, nil] dataverse restricts the results to a given dataverse, can be given in the form of
478
+ # "namepart" or "namepart1/namepart2".
479
+ # @param [String, nil] name restricts the results to the link with the specified name. If set then dataverse
480
+ # must also be set.
481
+ #
482
+ # @param [Integer, #in_milliseconds, nil] timeout the time in milliseconds allowed for the operation to
483
+ # complete
484
+ # @param [Proc, nil] retry_strategy the custom retry strategy, if set
485
+ # @param [Hash, nil] client_context the client context data, if set
486
+ # @param [Span, nil] parent_span if set holds the parent span, that should be used for this request
487
+ #
488
+ # @yieldparam [GetLinks] self
489
+ def initialize(link_type: nil,
490
+ dataverse: nil,
491
+ name: nil,
492
+ timeout: nil,
493
+ retry_strategy: nil,
494
+ client_context: nil,
495
+ parent_span: nil)
496
+ super(timeout: timeout, retry_strategy: retry_strategy, client_context: client_context, parent_span: parent_span)
497
+ @link_type = link_type
498
+ @dataverse = dataverse
499
+ @name = name
500
+ yield self if block_given?
501
+ end
502
+
503
+ # @api private
504
+ def to_backend
505
+ {
506
+ timeout: @timeout.respond_to?(:in_milliseconds) ? @timeout.public_send(:in_milliseconds) : @timeout,
507
+ link_type: @link_type.to_s,
508
+ dataverse: @dataverse,
509
+ name: @name,
510
+ }
511
+ end
512
+ end
513
+
514
+ # rubocop:disable Naming/MethodName constructor shortcuts
515
+ module_function
516
+
517
+ # Construct {CreateDataverse} options for {AnalyticsIndexManager#create_dataverse}
518
+ #
519
+ # @return [CreateDataverse]
520
+ def CreateDataverse(**args)
521
+ CreateDataverse.new(**args)
522
+ end
523
+
524
+ # Construct {DropDataverse} options for {AnalyticsIndexManager#drop_dataverse}
525
+ #
526
+ # @return [DropDataverse]
527
+ def DropDataverse(**args)
528
+ DropDataverse.new(**args)
529
+ end
530
+
531
+ # Construct {CreateDataset} options for {AnalyticsIndexManager#create_dataset}
532
+ #
533
+ # @return [CreateDataset]
534
+ def CreateDataset(**args)
535
+ CreateDataset.new(**args)
536
+ end
537
+
538
+ # Construct {DropDataset} options for {AnalyticsIndexManager#drop_dataset}
539
+ #
540
+ # @return [DropDataset]
541
+ def DropDataset(**args)
542
+ DropDataset.new(**args)
543
+ end
544
+
545
+ # Construct {GetAllDatasets} options for {AnalyticsIndexManager#get_all_datasets}
546
+ #
547
+ # @return [GetAllDatasets]
548
+ def GetAllDatasets(**args)
549
+ GetAllDatasets.new(**args)
550
+ end
551
+
552
+ # Construct {CreateIndex} options for {AnalyticsIndexManager#create_index}
553
+ #
554
+ # @return [CreateIndex]
555
+ def CreateIndex(**args)
556
+ CreateIndex.new(**args)
557
+ end
558
+
559
+ # Construct {DropIndex} options for {AnalyticsIndexManager#drop_index}
560
+ #
561
+ # @return [DropIndex]
562
+ def DropIndex(**args)
563
+ DropIndex.new(**args)
564
+ end
565
+
566
+ # Construct {GetAllIndexes} options for {AnalyticsIndexManager#get_all_indexes}
567
+ #
568
+ # @return [GetAllIndexes]
569
+ def GetAllIndexes(**args)
570
+ GetAllIndexes.new(**args)
571
+ end
572
+
573
+ # Construct {ConnectLink} options for {AnalyticsIndexManager#connect_link}
574
+ #
575
+ # @return [ConnectLink]
576
+ def ConnectLink(**args)
577
+ ConnectLink.new(**args)
578
+ end
579
+
580
+ # Construct {DisconnectLink} options for {AnalyticsIndexManager#disconnect_link}
581
+ #
582
+ # @return [DisconnectLink]
583
+ def DisconnectLink(**args)
584
+ DisconnectLink.new(**args)
585
+ end
586
+
587
+ # Construct {GetPendingMutations} options for {AnalyticsIndexManager#get_pending_mutations}
588
+ #
589
+ # @return [GetPendingMutations]
590
+ def GetPendingMutations(**args)
591
+ GetPendingMutations.new(**args)
592
+ end
593
+
594
+ # Construct {CreateLink} options for {AnalyticsIndexManager#create_link}
595
+ #
596
+ # @return [CreateLink]
597
+ def CreateLink(**args)
598
+ CreateLink.new(**args)
599
+ end
600
+
601
+ # Construct {ReplaceLink} options for {AnalyticsIndexManager#replace_link}
602
+ #
603
+ # @return [ReplaceLink]
604
+ def ReplaceLink(**args)
605
+ ReplaceLink.new(**args)
606
+ end
607
+
608
+ # Construct {DropLink} options for {AnalyticsIndexManager#drop_link}
609
+ #
610
+ # @return [DropLink]
611
+ def DropLink(**args)
612
+ DropLink.new(**args)
613
+ end
614
+
615
+ # Construct {GetLinks} options for {AnalyticsIndexManager#get_links}
616
+ #
617
+ # @return [GetLinks]
618
+ def GetLinks(**args)
619
+ GetLinks.new(**args)
620
+ end
621
+
622
+ # rubocop:enable Naming/MethodName
623
+ end
624
+ end
625
+
19
626
  class AnalyticsIndexManager
20
627
  alias inspect to_s
21
628
 
@@ -27,84 +634,64 @@ module Couchbase
27
634
  # Creates a new dataverse
28
635
  #
29
636
  # @param [String] dataverse_name
30
- # @param [CreateDataverseOptions] options
637
+ # @param [Options::Analytics::CreateDataverse] options
31
638
  #
32
639
  # @return [void]
33
640
  #
34
641
  # @raise [ArgumentError]
35
642
  # @raise [Error::DataverseExists]
36
- def create_dataverse(dataverse_name, options = CreateDataverseOptions.new)
37
- @backend.analytics_dataverse_create(
38
- dataverse_name,
39
- options.ignore_if_exists,
40
- options.timeout
41
- )
643
+ def create_dataverse(dataverse_name, options = Options::Analytics::CreateDataverse.new)
644
+ @backend.analytics_dataverse_create(dataverse_name, options.to_backend)
42
645
  end
43
646
 
44
647
  # Drops a dataverse
45
648
  #
46
649
  # @param [String] dataverse_name name of the dataverse
47
- # @param [DropDataverseOptions] options
650
+ # @param [Options::Analytics::DropDataverse] options
48
651
  #
49
652
  # @return [void]
50
653
  #
51
654
  # @raise [ArgumentError]
52
655
  # @raise [Error::DataverseNotFound]
53
- def drop_dataverse(dataverse_name, options = DropDataverseOptions.new)
54
- @backend.analytics_dataverse_drop(
55
- dataverse_name,
56
- options.ignore_if_does_not_exist,
57
- options.timeout
58
- )
656
+ def drop_dataverse(dataverse_name, options = Options::Analytics::DropDataverse.new)
657
+ @backend.analytics_dataverse_drop(dataverse_name, options.to_backend)
59
658
  end
60
659
 
61
660
  # Creates a new dataset
62
661
  #
63
662
  # @param [String] dataset_name name of dataset
64
663
  # @param [String] bucket_name name of the bucket
65
- # @param [CreateDatasetOptions] options
664
+ # @param [Options::Analytics::CreateDataset] options
66
665
  #
67
666
  # @return [void]
68
667
  #
69
668
  # @raise [ArgumentError]
70
669
  # @raise [Error::DatasetExists]
71
670
  # @raise [Error::LinkNotFound]
72
- def create_dataset(dataset_name, bucket_name, options = CreateDatasetOptions.new)
73
- @backend.analytics_dataset_create(
74
- dataset_name,
75
- bucket_name,
76
- options.condition,
77
- options.dataverse_name,
78
- options.ignore_if_exists,
79
- options.timeout
80
- )
671
+ def create_dataset(dataset_name, bucket_name, options = Options::Analytics::CreateDataset.new)
672
+ @backend.analytics_dataset_create(dataset_name, bucket_name, options.to_backend)
81
673
  end
82
674
 
83
675
  # Drops a dataset
84
676
  #
85
677
  # @param [String] dataset_name name of the dataset
86
- # @param [DropDatasetOptions] options
678
+ # @param [Options::Analytics::DropDataset] options
87
679
  #
88
680
  # @return [void]
89
681
  #
90
682
  # @raise [ArgumentError]
91
683
  # @raise [Error::DatasetNotFound]
92
- def drop_dataset(dataset_name, options = DropDatasetOptions.new)
93
- @backend.analytics_dataset_drop(
94
- dataset_name,
95
- options.dataverse_name,
96
- options.ignore_if_does_not_exist,
97
- options.timeout
98
- )
684
+ def drop_dataset(dataset_name, options = Options::Analytics::DropDataset.new)
685
+ @backend.analytics_dataset_drop(dataset_name, options.to_backend)
99
686
  end
100
687
 
101
688
  # Gets all datasets
102
689
  #
103
- # @param [GetAllDatasetsOptions] options
690
+ # @param [Options::Analytics::GetAllDatasets] options
104
691
  #
105
692
  # @return [Array<AnalyticsDataset>]
106
- def get_all_datasets(options = GetAllDatasetsOptions.new)
107
- resp = @backend.analytics_dataset_get_all(options.timeout)
693
+ def get_all_datasets(options = Options::Analytics::GetAllDatasets.new)
694
+ resp = @backend.analytics_dataset_get_all(options.to_backend)
108
695
  resp.map do |entry|
109
696
  AnalyticsDataset.new do |dataset|
110
697
  dataset.name = entry[:name]
@@ -120,50 +707,37 @@ module Couchbase
120
707
  # @param [String] index_name name of the index
121
708
  # @param [String] dataset_name name of the dataset
122
709
  # @param [Hash<String => String>] fields mapping of the field name to field type
123
- # @param [CreateIndexOptions] options
710
+ # @param [Options::Analytics::CreateIndex] options
124
711
  #
125
712
  # @return [void]
126
713
  #
127
714
  # @raise [ArgumentError]
128
715
  # @raise [Error::IndexExists]
129
- def create_index(index_name, dataset_name, fields, options = CreateIndexOptions.new)
130
- @backend.analytics_index_create(
131
- index_name,
132
- dataset_name,
133
- fields.entries,
134
- options.dataverse_name,
135
- options.ignore_if_exists,
136
- options.timeout
137
- )
716
+ def create_index(index_name, dataset_name, fields, options = Options::Analytics::CreateIndex.new)
717
+ @backend.analytics_index_create(index_name, dataset_name, fields.entries, options.to_backend)
138
718
  end
139
719
 
140
720
  # Drops an index
141
721
  #
142
722
  # @param [String] index_name name of the index
143
723
  # @param [String] dataset_name name of the dataset
144
- # @param [DropIndexOptions] options
724
+ # @param [Options::Analytics::DropIndex] options
145
725
  #
146
726
  # @return [void]
147
727
  #
148
728
  # @raise [ArgumentError]
149
729
  # @raise [Error::IndexNotFound]
150
- def drop_index(index_name, dataset_name, options = DropIndexOptions.new)
151
- @backend.analytics_index_drop(
152
- index_name,
153
- dataset_name,
154
- options.dataverse_name,
155
- options.ignore_if_does_not_exist,
156
- options.timeout
157
- )
730
+ def drop_index(index_name, dataset_name, options = Options::Analytics::DropIndex.new)
731
+ @backend.analytics_index_drop(index_name, dataset_name, options.to_backend)
158
732
  end
159
733
 
160
734
  # Gets all indexes
161
735
  #
162
- # @param [GetAllIndexesOptions] options
736
+ # @param [Options::Analytics::GetAllIndexes] options
163
737
  #
164
738
  # @return [Array<AnalyticsIndex>]
165
- def get_all_indexes(options = GetAllIndexesOptions.new)
166
- resp = @backend.analytics_index_get_all(options.timeout)
739
+ def get_all_indexes(options = Options::Analytics::GetAllIndexes.new)
740
+ resp = @backend.analytics_index_get_all(options.to_backend)
167
741
  resp.map do |entry|
168
742
  AnalyticsIndex.new do |dataset|
169
743
  dataset.name = entry[:name]
@@ -176,35 +750,26 @@ module Couchbase
176
750
 
177
751
  # Connects a link
178
752
  #
179
- # @param [ConnectLinkOptions] options
753
+ # @param [Options::Analytics::ConnectLink] options
180
754
  #
181
755
  # @return [void]
182
756
  #
183
757
  # @raise [ArgumentError]
184
758
  # @raise [Error::LinkNotFound]
185
- def connect_link(options = ConnectLinkOptions.new)
186
- @backend.analytics_link_connect(
187
- options.link_name,
188
- options.force,
189
- options.dataverse_name,
190
- options.timeout
191
- )
759
+ def connect_link(options = Options::Analytics::ConnectLink.new)
760
+ @backend.analytics_link_connect(options.to_backend)
192
761
  end
193
762
 
194
763
  # Disconnects a link,
195
764
  #
196
- # @param [DisconnectLinkOptions] options
765
+ # @param [Options::Analytics::DisconnectLink] options
197
766
  #
198
767
  # @return [void]
199
768
  #
200
769
  # @raise [ArgumentError]
201
770
  # @raise [Error::LinkNotFound]
202
- def disconnect_link(options = DisconnectLinkOptions.new)
203
- @backend.analytics_link_disconnect(
204
- options.link_name,
205
- options.dataverse_name,
206
- options.timeout
207
- )
771
+ def disconnect_link(options = Options::Analytics::DisconnectLink.new)
772
+ @backend.analytics_link_disconnect(options.to_backend)
208
773
  end
209
774
 
210
775
  # Gets the pending mutations for all datasets.
@@ -212,183 +777,138 @@ module Couchbase
212
777
  # @note If a link is disconnected then it will return no results. If all links are disconnected, then
213
778
  # an empty object is returned.
214
779
  #
215
- # @param [GetPendingMutationsOptions] options
780
+ # @param [Options::Analytics::GetPendingMutations] options
216
781
  #
217
782
  # @return [Hash<String => Integer>] dictionary, where keys are dataset coordinates encoded as +"dataverse.dataset"+
218
783
  # and values are number of mutations for given dataset.
219
- def get_pending_mutations(options = GetPendingMutationsOptions.new)
220
- @backend.analytics_get_pending_mutations(
221
- options.timeout
222
- )
223
- end
224
-
225
- class CreateDataverseOptions
226
- # @return [Boolean] ignore if the dataverse already exists
227
- attr_accessor :ignore_if_exists
228
-
229
- # @return [Integer] the time in milliseconds allowed for the operation to complete
230
- attr_accessor :timeout
231
-
232
- # @yieldparam [CreateDataverseOptions]
233
- def initialize
234
- @ignore_if_exists = false
235
- yield self if block_given?
236
- end
237
- end
238
-
239
- class DropDataverseOptions
240
- # @return [Boolean] ignore if the dataverse does not exists
241
- attr_accessor :ignore_if_does_not_exist
242
-
243
- # @return [Integer] the time in milliseconds allowed for the operation to complete
244
- attr_accessor :timeout
245
-
246
- # @yieldparam [DropDataverseOptions]
247
- def initialize
248
- @ignore_if_exists = false
249
- yield self if block_given?
250
- end
251
- end
252
-
253
- class CreateDatasetOptions
254
- # @return [Boolean] ignore if the dataset already exists
255
- attr_accessor :ignore_if_exists
256
-
257
- # @return [String] WHERE clause to use for creating dataset
258
- attr_accessor :condition
259
-
260
- # @return [String] The name of the dataverse to use (defaults to +nil+)
261
- attr_accessor :dataverse_name
262
-
263
- # @return [Integer] the time in milliseconds allowed for the operation to complete
264
- attr_accessor :timeout
265
-
266
- # @yieldparam [CreateDatasetOptions]
267
- def initialize
268
- @ignore_if_exists = false
269
- yield self if block_given?
270
- end
271
- end
272
-
273
- class DropDatasetOptions
274
- # @return [Boolean] ignore if the dataset does not exists
275
- attr_accessor :ignore_if_does_not_exist
276
-
277
- # @return [String] The name of the dataverse to use (defaults to +nil+)
278
- attr_accessor :dataverse_name
279
-
280
- # @return [Integer] the time in milliseconds allowed for the operation to complete
281
- attr_accessor :timeout
282
-
283
- # @yieldparam [DropDatasetOptions]
284
- def initialize
285
- @ignore_if_does_not_exist = false
286
- yield self if block_given?
287
- end
784
+ def get_pending_mutations(options = Options::Analytics::GetPendingMutations.new)
785
+ @backend.analytics_get_pending_mutations(options.to_backend)
288
786
  end
289
787
 
290
- class GetAllDatasetsOptions
291
- # @return [Integer] the time in milliseconds allowed for the operation to complete
292
- attr_accessor :timeout
293
-
294
- # @yieldparam [GetAllDatasetsOptions]
295
- def initialize
296
- yield self if block_given?
297
- end
788
+ # Creates a link
789
+ #
790
+ # @param [CouchbaseRemoteAnalyticsLink, AzureBlobExternalAnalyticsLink, S3ExternalAnalyticsLink] link
791
+ # @param [Options::Analytics::CreateLink] options
792
+ #
793
+ # @return [void]
794
+ #
795
+ # @raise [ArgumentError]
796
+ # @raise [Error::LinkExists]
797
+ def create_link(link, options = Options::Analytics::CreateLink.new)
798
+ @backend.analytics_link_create(link.to_backend, options.to_backend)
298
799
  end
299
800
 
300
- class CreateIndexOptions
301
- # @return [Boolean] ignore if the index already exists
302
- attr_accessor :ignore_if_exists
303
-
304
- # @return [String] The name of the dataverse to use (defaults to +nil+)
305
- attr_accessor :dataverse_name
306
-
307
- # @return [Integer] the time in milliseconds allowed for the operation to complete
308
- attr_accessor :timeout
309
-
310
- # @yieldparam [CreateIndexOptions]
311
- def initialize
312
- @ignore_if_exists = false
313
- yield self if block_given?
314
- end
801
+ # Replaces the link
802
+ #
803
+ # @param [CouchbaseRemoteAnalyticsLink, AzureBlobExternalAnalyticsLink, S3ExternalAnalyticsLink] link
804
+ # @param [Options::Analytics::ReplaceLink] options
805
+ #
806
+ # @return [void]
807
+ #
808
+ # @raise [ArgumentError]
809
+ # @raise [Error::LinkNotFound]
810
+ def replace_link(link, options = Options::Analytics::ReplaceLink.new)
811
+ @backend.analytics_link_replace(link.to_backend, options.to_backend)
315
812
  end
316
813
 
317
- class DropIndexOptions
318
- # @return [Boolean] ignore if the index does not exists
319
- attr_accessor :ignore_if_does_not_exist
320
-
321
- # @return [String] The name of the dataverse to use (defaults to +nil+)
322
- attr_accessor :dataverse_name
323
-
324
- # @return [Integer] the time in milliseconds allowed for the operation to complete
325
- attr_accessor :timeout
326
-
327
- # @yieldparam [DropIndexOptions]
328
- def initialize
329
- @ignore_if_does_not_exist = false
330
- yield self if block_given?
331
- end
814
+ # Drops the link
815
+ #
816
+ # @param [String] link_name name of the link
817
+ # @param [String] dataverse_name dataverse where the link belongs
818
+ # @param [Options::Analytics::DropLink] options
819
+ #
820
+ # @return [void]
821
+ #
822
+ # @raise [ArgumentError]
823
+ # @raise [Error::LinkNotFound]
824
+ def drop_link(link_name, dataverse_name, options = Options::Analytics::DropLink.new)
825
+ @backend.analytics_link_drop(link_name, dataverse_name, options.to_backend)
332
826
  end
333
827
 
334
- class GetAllIndexesOptions
335
- # @return [Integer] the time in milliseconds allowed for the operation to complete
336
- attr_accessor :timeout
337
-
338
- # @yieldparam [GetAllIndexesOptions]
339
- def initialize
340
- yield self if block_given?
828
+ # Retrieves the links
829
+ #
830
+ # @param [Options::Analytics::GetLinks] options
831
+ #
832
+ # @return [void]
833
+ #
834
+ # @raise [ArgumentError]
835
+ # @raise [Error::LinkNotFound]
836
+ def get_links(options = Options::Analytics::GetLinks.new)
837
+ resp = @backend.analytics_link_get_all(options.to_backend)
838
+ resp.map do |entry|
839
+ case entry[:type]
840
+ when :s3
841
+ S3ExternalAnalyticsLink.new(
842
+ entry[:link_name],
843
+ entry[:dataverse],
844
+ entry[:access_key_id],
845
+ nil,
846
+ entry[:region],
847
+ service_endpoint: entry[:service_endpoint]
848
+ )
849
+ when :couchbase
850
+ CouchbaseRemoteAnalyticsLink.new(
851
+ entry[:link_name],
852
+ entry[:dataverse],
853
+ entry[:hostname],
854
+ username: entry[:username],
855
+ encryption: EncryptionSettings.new(
856
+ level: entry[:encryption_level],
857
+ certificate: entry[:certificate],
858
+ client_certificate: entry[:client_certificate]
859
+ )
860
+ )
861
+ when :azureblob
862
+ AzureBlobExternalAnalyticsLink.new(
863
+ entry[:link_name],
864
+ entry[:dataverse],
865
+ account_name: entry[:account_name],
866
+ blob_endpoint: entry[:blob_endpoint],
867
+ endpoint_suffix: entry[:endpoint_suffix]
868
+ )
869
+ end
341
870
  end
342
871
  end
343
872
 
344
- class ConnectLinkOptions
345
- # @return [String] The name of the link (defaults to +"Local"+)
346
- attr_accessor :link_name
873
+ # @api private
874
+ # TODO: deprecate after 3.2
875
+ CreateDataverseOptions = ::Couchbase::Management::Options::Analytics::CreateDataverse
347
876
 
348
- # @return [Boolean] Whether to force link creation even if the bucket UUID changed, for example due to the
349
- # bucket being deleted and recreated (defaults to +false+)
350
- attr_accessor :force
877
+ # @api private
878
+ # TODO: deprecate after 3.2
879
+ DropDataverseOptions = ::Couchbase::Management::Options::Analytics::DropDataverse
351
880
 
352
- # @return [String] The name of the dataverse to use (defaults to +nil+)
353
- attr_accessor :dataverse_name
881
+ # @api private
882
+ # TODO: deprecate after 3.2
883
+ CreateDatasetOptions = ::Couchbase::Management::Options::Analytics::CreateDataset
354
884
 
355
- # @return [Integer] the time in milliseconds allowed for the operation to complete
356
- attr_accessor :timeout
885
+ # @api private
886
+ # TODO: deprecate after 3.2
887
+ DropDatasetOptions = ::Couchbase::Management::Options::Analytics::DropDataset
357
888
 
358
- # @yieldparam [ConnectLinkOptions]
359
- def initialize
360
- @link_name = "Local"
361
- @force = false
362
- yield self if block_given?
363
- end
364
- end
889
+ # @api private
890
+ # TODO: deprecate after 3.2
891
+ GetAllDatasetsOptions = ::Couchbase::Management::Options::Analytics::GetAllDatasets
365
892
 
366
- class DisconnectLinkOptions
367
- # @return [String] The name of the link (defaults to +"Local"+)
368
- attr_accessor :link_name
893
+ # @api private
894
+ # TODO: deprecate after 3.2
895
+ CreateIndexOptions = ::Couchbase::Management::Options::Analytics::CreateIndex
369
896
 
370
- # @return [String] The name of the dataverse to use (defaults to +nil+)
371
- attr_accessor :dataverse_name
897
+ # @api private
898
+ # TODO: deprecate after 3.2
899
+ DropIndexOptions = ::Couchbase::Management::Options::Analytics::DropIndex
372
900
 
373
- # @return [Integer] the time in milliseconds allowed for the operation to complete
374
- attr_accessor :timeout
375
-
376
- # @yieldparam [DisconnectLinkOptions]
377
- def initialize
378
- @link_name = "Local"
379
- yield self if block_given?
380
- end
381
- end
901
+ # @api private
902
+ # TODO: deprecate after 3.2
903
+ GetAllIndexesOptions = ::Couchbase::Management::Options::Analytics::GetAllIndexes
382
904
 
383
- class GetPendingMutationsOptions
384
- # @return [Integer] the time in milliseconds allowed for the operation to complete
385
- attr_accessor :timeout
905
+ # @api private
906
+ # TODO: deprecate after 3.2
907
+ ConnectLinkOptions = ::Couchbase::Management::Options::Analytics::ConnectLink
386
908
 
387
- # @yieldparam [GetPendingMutationsOptions]
388
- def initialize
389
- yield self if block_given?
390
- end
391
- end
909
+ # @api private
910
+ # TODO: deprecate after 3.2
911
+ GetPendingMutationsOptions = ::Couchbase::Management::Options::Analytics::GetPendingMutations
392
912
  end
393
913
 
394
914
  class AnalyticsDataset
@@ -429,5 +949,179 @@ module Couchbase
429
949
  yield self if block_given?
430
950
  end
431
951
  end
952
+
953
+ class EncryptionSettings
954
+ attr_accessor :level # @return [Symbol]
955
+ attr_accessor :certificate # @return [String, nil]
956
+ attr_accessor :client_certificate # @return [String, nil]
957
+ attr_accessor :client_key # @return [String, nil]
958
+
959
+ # @param [:none, :half, :full] level Specifies what level of encryption should be used.
960
+ # @param [String, nil] certificate
961
+ # @param [String, nil] client_certificate
962
+ # @param [String, nil] client_key
963
+ #
964
+ # @yieldparam [EncryptionSettings] self
965
+ def initialize(level: :none,
966
+ certificate: nil,
967
+ client_certificate: nil,
968
+ client_key: nil)
969
+ @level = level
970
+ @certificate = certificate
971
+ @client_certificate = client_certificate
972
+ @client_key = client_key
973
+ yield self if block_given?
974
+ end
975
+ end
976
+
977
+ class CouchbaseRemoteAnalyticsLink
978
+ attr_accessor :name # @return [String]
979
+ attr_accessor :dataverse # @return [String]
980
+ attr_accessor :hostname # @return [String]
981
+ attr_accessor :username # @return [String, nil]
982
+ attr_accessor :password # @return [String, nil]
983
+ attr_accessor :encryption # @return [EncryptionSettings]
984
+
985
+ # @param [String] name the name of this link
986
+ # @param [String] dataverse the dataverse this link belongs to
987
+ # @param [String] hostname the hostname of the target Couchbase cluster
988
+ # @param [String, nil] username the username to use for authentication with the remote cluster. Optional if
989
+ # client-certificate authentication is being used.
990
+ # @param [String, nil] password the password to use for authentication with the remote cluster. Optional if
991
+ # client-certificate authentication is being used.
992
+ # @param [EncryptionSettings] encryption settings for connection encryption
993
+ #
994
+ # @yieldparam [CouchbaseRemoteLink] self
995
+ def initialize(name, dataverse, hostname,
996
+ username: nil,
997
+ password: nil,
998
+ encryption: EncryptionSettings.new)
999
+ @name = name
1000
+ @dataverse = dataverse
1001
+ @hostname = hostname
1002
+ @username = username
1003
+ @password = password
1004
+ @encryption = encryption
1005
+ yield self if block_given?
1006
+ end
1007
+
1008
+ # @api private
1009
+ def to_backend
1010
+ {
1011
+ type: :couchbase,
1012
+ link_name: @name,
1013
+ dataverse: @dataverse,
1014
+ hostname: @hostname,
1015
+ username: @username,
1016
+ password: @password,
1017
+ encryption_level: @encryption.level,
1018
+ certificate: @encryption.certificate,
1019
+ client_certificate: @encryption.client_certificate,
1020
+ client_key: @encryption.client_key,
1021
+ }
1022
+ end
1023
+ end
1024
+
1025
+ class AzureBlobExternalAnalyticsLink
1026
+ attr_accessor :name # @return [String]
1027
+ attr_accessor :dataverse # @return [String]
1028
+ attr_accessor :connection_string # @return [String, nil]
1029
+ attr_accessor :account_name # @return [String, nil]
1030
+ attr_accessor :account_key # @return [String, nil]
1031
+ attr_accessor :shared_access_signature # @return [String, nil]
1032
+ attr_accessor :blob_endpoint # @return [String, nil]
1033
+ attr_accessor :endpoint_suffix # @return [String, nil]
1034
+
1035
+ # @param [String] name the name of this link
1036
+ # @param [String] dataverse the dataverse this link belongs to
1037
+ # @param [String, nil] connection_string the connection string can be used as an authentication method,
1038
+ # +connection_string+ contains other authentication methods embedded inside the string. Only a single
1039
+ # authentication method can be used. (e.g. "AccountName=myAccountName;AccountKey=myAccountKey").
1040
+ # @param [String, nil] account_name Azure blob storage account name
1041
+ # @param [String, nil] account_key Azure blob storage account key
1042
+ # @param [String, nil] shared_access_signature token that can be used for authentication
1043
+ # @param [String, nil] blob_endpoint Azure blob storage endpoint
1044
+ # @param [String, nil] endpoint_suffix Azure blob endpoint suffix
1045
+ #
1046
+ # @yieldparam [AzureBlobExternalAnalyticsLink] self
1047
+ def initialize(name, dataverse,
1048
+ connection_string: nil,
1049
+ account_name: nil,
1050
+ account_key: nil,
1051
+ shared_access_signature: nil,
1052
+ blob_endpoint: nil,
1053
+ endpoint_suffix: nil)
1054
+ @name = name
1055
+ @dataverse = dataverse
1056
+ @connection_string = connection_string
1057
+ @account_name = account_name
1058
+ @account_key = account_key
1059
+ @shared_access_signature = shared_access_signature
1060
+ @blob_endpoint = blob_endpoint
1061
+ @endpoint_suffix = endpoint_suffix
1062
+ yield self if block_given?
1063
+ end
1064
+
1065
+ # @api private
1066
+ def to_backend
1067
+ {
1068
+ type: :azureblob,
1069
+ link_name: @name,
1070
+ dataverse: @dataverse,
1071
+ connection_string: @connection_string,
1072
+ account_name: @account_name,
1073
+ account_key: @account_key,
1074
+ shared_access_signature: @shared_access_signature,
1075
+ blob_endpoint: @blob_endpoint,
1076
+ endpoint_suffix: @endpoint_suffix,
1077
+ }
1078
+ end
1079
+ end
1080
+
1081
+ class S3ExternalAnalyticsLink
1082
+ attr_accessor :name # @return [String]
1083
+ attr_accessor :dataverse # @return [String]
1084
+ attr_accessor :access_key_id # @return [String]
1085
+ attr_accessor :secret_access_key # @return [String]
1086
+ attr_accessor :session_token # @return [String, nil]
1087
+ attr_accessor :region # @return [String]
1088
+ attr_accessor :service_endpoint # @return [String, nil]
1089
+
1090
+ # @param [String] name the name of this link
1091
+ # @param [String] dataverse the dataverse this link belongs to
1092
+ # @param [String] access_key_id AWS S3 access key ID
1093
+ # @param [String] secret_access_key AWS S3 secret key
1094
+ # @param [String] region AWS S3 region
1095
+ # @param [String, nil] session_token AWS S3 token if temporary credentials are provided. Only available in 7.0+
1096
+ # @param [String, nil] service_endpoint AWS S3 service endpoint
1097
+ #
1098
+ # @yieldparam [S3ExternalAnalyticsLink] self
1099
+ def initialize(name, dataverse, access_key_id, secret_access_key, region,
1100
+ session_token: nil,
1101
+ service_endpoint: nil)
1102
+ @name = name
1103
+ @dataverse = dataverse
1104
+ @access_key_id = access_key_id
1105
+ @secret_access_key = secret_access_key
1106
+ @session_token = session_token
1107
+ @region = region
1108
+ @service_endpoint = service_endpoint
1109
+ yield self if block_given?
1110
+ end
1111
+
1112
+ # @api private
1113
+ def to_backend
1114
+ {
1115
+ type: :s3,
1116
+ link_name: @name,
1117
+ dataverse: @dataverse,
1118
+ access_key_id: @access_key_id,
1119
+ secret_access_key: @secret_access_key,
1120
+ session_token: @session_token,
1121
+ region: @region,
1122
+ service_endpoint: @service_endpoint,
1123
+ }
1124
+ end
1125
+ end
432
1126
  end
433
1127
  end