couchbase 3.9.0-aarch64-linux-musl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (149) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +202 -0
  3. data/README.md +154 -0
  4. data/ext/extconf.rb +0 -0
  5. data/lib/active_support/cache/couchbase_store.rb +407 -0
  6. data/lib/couchbase/3.2/libcouchbase.so +0 -0
  7. data/lib/couchbase/3.3/libcouchbase.so +0 -0
  8. data/lib/couchbase/3.4/libcouchbase.so +0 -0
  9. data/lib/couchbase/4.0/libcouchbase.so +0 -0
  10. data/lib/couchbase/analytics_options.rb +109 -0
  11. data/lib/couchbase/authenticator.rb +80 -0
  12. data/lib/couchbase/binary_collection.rb +145 -0
  13. data/lib/couchbase/binary_collection_options.rb +26 -0
  14. data/lib/couchbase/bucket.rb +173 -0
  15. data/lib/couchbase/cluster.rb +555 -0
  16. data/lib/couchbase/cluster_registry.rb +49 -0
  17. data/lib/couchbase/collection.rb +770 -0
  18. data/lib/couchbase/collection_options.rb +401 -0
  19. data/lib/couchbase/config_profiles.rb +57 -0
  20. data/lib/couchbase/configuration.rb +58 -0
  21. data/lib/couchbase/datastructures/couchbase_list.rb +192 -0
  22. data/lib/couchbase/datastructures/couchbase_map.rb +231 -0
  23. data/lib/couchbase/datastructures/couchbase_queue.rb +161 -0
  24. data/lib/couchbase/datastructures/couchbase_set.rb +145 -0
  25. data/lib/couchbase/datastructures.rb +26 -0
  26. data/lib/couchbase/deprecations.rb +61 -0
  27. data/lib/couchbase/diagnostics.rb +183 -0
  28. data/lib/couchbase/errors.rb +438 -0
  29. data/lib/couchbase/fork_hooks.rb +41 -0
  30. data/lib/couchbase/get_replica_strategy.rb +89 -0
  31. data/lib/couchbase/json_transcoder.rb +41 -0
  32. data/lib/couchbase/key_value_scan.rb +119 -0
  33. data/lib/couchbase/libcouchbase.rb +6 -0
  34. data/lib/couchbase/logger.rb +87 -0
  35. data/lib/couchbase/management/analytics_index_manager.rb +1160 -0
  36. data/lib/couchbase/management/bucket_manager.rb +479 -0
  37. data/lib/couchbase/management/collection_manager.rb +515 -0
  38. data/lib/couchbase/management/collection_query_index_manager.rb +247 -0
  39. data/lib/couchbase/management/query_index_manager.rb +671 -0
  40. data/lib/couchbase/management/scope_search_index_manager.rb +267 -0
  41. data/lib/couchbase/management/search_index_manager.rb +649 -0
  42. data/lib/couchbase/management/user_manager.rb +639 -0
  43. data/lib/couchbase/management/view_index_manager.rb +332 -0
  44. data/lib/couchbase/management.rb +31 -0
  45. data/lib/couchbase/metrics/logging_meter.rb +108 -0
  46. data/lib/couchbase/metrics/logging_value_recorder.rb +50 -0
  47. data/lib/couchbase/metrics/meter.rb +27 -0
  48. data/lib/couchbase/metrics/noop_meter.rb +30 -0
  49. data/lib/couchbase/metrics/noop_value_recorder.rb +27 -0
  50. data/lib/couchbase/metrics/value_recorder.rb +25 -0
  51. data/lib/couchbase/mutation_state.rb +65 -0
  52. data/lib/couchbase/options.rb +3097 -0
  53. data/lib/couchbase/protostellar/binary_collection.rb +55 -0
  54. data/lib/couchbase/protostellar/bucket.rb +59 -0
  55. data/lib/couchbase/protostellar/client.rb +97 -0
  56. data/lib/couchbase/protostellar/cluster.rb +182 -0
  57. data/lib/couchbase/protostellar/collection.rb +156 -0
  58. data/lib/couchbase/protostellar/connect_options.rb +63 -0
  59. data/lib/couchbase/protostellar/error_handling.rb +204 -0
  60. data/lib/couchbase/protostellar/generated/admin/analytics/v1/analytics_pb.rb +54 -0
  61. data/lib/couchbase/protostellar/generated/admin/analytics/v1/analytics_services_pb.rb +51 -0
  62. data/lib/couchbase/protostellar/generated/admin/bucket/v1/bucket_pb.rb +42 -0
  63. data/lib/couchbase/protostellar/generated/admin/bucket/v1/bucket_services_pb.rb +51 -0
  64. data/lib/couchbase/protostellar/generated/admin/collection/v1/collection_pb.rb +38 -0
  65. data/lib/couchbase/protostellar/generated/admin/collection/v1/collection_services_pb.rb +52 -0
  66. data/lib/couchbase/protostellar/generated/admin/query/v1/query_pb.rb +42 -0
  67. data/lib/couchbase/protostellar/generated/admin/query/v1/query_services_pb.rb +55 -0
  68. data/lib/couchbase/protostellar/generated/admin/search/v1/search_pb.rb +51 -0
  69. data/lib/couchbase/protostellar/generated/admin/search/v1/search_services_pb.rb +67 -0
  70. data/lib/couchbase/protostellar/generated/analytics/v1/analytics_pb.rb +31 -0
  71. data/lib/couchbase/protostellar/generated/analytics/v1/analytics_services_pb.rb +40 -0
  72. data/lib/couchbase/protostellar/generated/internal/hooks/v1/hooks_pb.rb +51 -0
  73. data/lib/couchbase/protostellar/generated/internal/hooks/v1/hooks_services_pb.rb +54 -0
  74. data/lib/couchbase/protostellar/generated/internal/xdcr/v1/xdcr_pb.rb +46 -0
  75. data/lib/couchbase/protostellar/generated/internal/xdcr/v1/xdcr_services_pb.rb +56 -0
  76. data/lib/couchbase/protostellar/generated/kv/v1/kv_pb.rb +74 -0
  77. data/lib/couchbase/protostellar/generated/kv/v1/kv_services_pb.rb +93 -0
  78. data/lib/couchbase/protostellar/generated/query/v1/query_pb.rb +35 -0
  79. data/lib/couchbase/protostellar/generated/query/v1/query_services_pb.rb +40 -0
  80. data/lib/couchbase/protostellar/generated/routing/v2/routing_pb.rb +26 -0
  81. data/lib/couchbase/protostellar/generated/routing/v2/routing_services_pb.rb +43 -0
  82. data/lib/couchbase/protostellar/generated/search/v1/search_pb.rb +78 -0
  83. data/lib/couchbase/protostellar/generated/search/v1/search_services_pb.rb +41 -0
  84. data/lib/couchbase/protostellar/generated/transactions/v1/transactions_pb.rb +36 -0
  85. data/lib/couchbase/protostellar/generated/transactions/v1/transactions_services_pb.rb +66 -0
  86. data/lib/couchbase/protostellar/generated/view/v1/view_pb.rb +30 -0
  87. data/lib/couchbase/protostellar/generated/view/v1/view_services_pb.rb +39 -0
  88. data/lib/couchbase/protostellar/generated.rb +9 -0
  89. data/lib/couchbase/protostellar/management/bucket_manager.rb +67 -0
  90. data/lib/couchbase/protostellar/management/collection_manager.rb +94 -0
  91. data/lib/couchbase/protostellar/management/collection_query_index_manager.rb +124 -0
  92. data/lib/couchbase/protostellar/management/query_index_manager.rb +112 -0
  93. data/lib/couchbase/protostellar/management.rb +24 -0
  94. data/lib/couchbase/protostellar/request.rb +79 -0
  95. data/lib/couchbase/protostellar/request_behaviour.rb +42 -0
  96. data/lib/couchbase/protostellar/request_generator/admin/bucket.rb +124 -0
  97. data/lib/couchbase/protostellar/request_generator/admin/collection.rb +96 -0
  98. data/lib/couchbase/protostellar/request_generator/admin/query.rb +132 -0
  99. data/lib/couchbase/protostellar/request_generator/admin.rb +24 -0
  100. data/lib/couchbase/protostellar/request_generator/kv.rb +488 -0
  101. data/lib/couchbase/protostellar/request_generator/query.rb +133 -0
  102. data/lib/couchbase/protostellar/request_generator/search.rb +403 -0
  103. data/lib/couchbase/protostellar/request_generator.rb +26 -0
  104. data/lib/couchbase/protostellar/response_converter/admin/bucket.rb +55 -0
  105. data/lib/couchbase/protostellar/response_converter/admin/collection.rb +42 -0
  106. data/lib/couchbase/protostellar/response_converter/admin/query.rb +59 -0
  107. data/lib/couchbase/protostellar/response_converter/admin.rb +24 -0
  108. data/lib/couchbase/protostellar/response_converter/kv.rb +151 -0
  109. data/lib/couchbase/protostellar/response_converter/query.rb +84 -0
  110. data/lib/couchbase/protostellar/response_converter/search.rb +136 -0
  111. data/lib/couchbase/protostellar/response_converter.rb +26 -0
  112. data/lib/couchbase/protostellar/retry/action.rb +38 -0
  113. data/lib/couchbase/protostellar/retry/orchestrator.rb +61 -0
  114. data/lib/couchbase/protostellar/retry/reason.rb +67 -0
  115. data/lib/couchbase/protostellar/retry/strategies/best_effort.rb +49 -0
  116. data/lib/couchbase/protostellar/retry/strategies/fail_fast.rb +33 -0
  117. data/lib/couchbase/protostellar/retry/strategies.rb +27 -0
  118. data/lib/couchbase/protostellar/retry.rb +28 -0
  119. data/lib/couchbase/protostellar/scope.rb +61 -0
  120. data/lib/couchbase/protostellar/timeout_defaults.rb +30 -0
  121. data/lib/couchbase/protostellar/timeouts.rb +83 -0
  122. data/lib/couchbase/protostellar.rb +29 -0
  123. data/lib/couchbase/query_options.rb +122 -0
  124. data/lib/couchbase/railtie.rb +47 -0
  125. data/lib/couchbase/raw_binary_transcoder.rb +39 -0
  126. data/lib/couchbase/raw_json_transcoder.rb +40 -0
  127. data/lib/couchbase/raw_string_transcoder.rb +42 -0
  128. data/lib/couchbase/scope.rb +272 -0
  129. data/lib/couchbase/search_options.rb +1744 -0
  130. data/lib/couchbase/subdoc.rb +293 -0
  131. data/lib/couchbase/tracing/noop_span.rb +29 -0
  132. data/lib/couchbase/tracing/noop_tracer.rb +29 -0
  133. data/lib/couchbase/tracing/request_span.rb +34 -0
  134. data/lib/couchbase/tracing/request_tracer.rb +28 -0
  135. data/lib/couchbase/tracing/threshold_logging_span.rb +112 -0
  136. data/lib/couchbase/tracing/threshold_logging_tracer.rb +231 -0
  137. data/lib/couchbase/transcoder_flags.rb +64 -0
  138. data/lib/couchbase/utils/generic_logger_adapter.rb +40 -0
  139. data/lib/couchbase/utils/hdr_histogram.rb +55 -0
  140. data/lib/couchbase/utils/observability.rb +263 -0
  141. data/lib/couchbase/utils/observability_constants.rb +200 -0
  142. data/lib/couchbase/utils/stdlib_logger_adapter.rb +65 -0
  143. data/lib/couchbase/utils/time.rb +71 -0
  144. data/lib/couchbase/utils.rb +23 -0
  145. data/lib/couchbase/version.rb +25 -0
  146. data/lib/couchbase/view_options.rb +67 -0
  147. data/lib/couchbase.rb +32 -0
  148. data/lib/rails/generators/couchbase/config/config_generator.rb +29 -0
  149. metadata +228 -0
@@ -0,0 +1,1160 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2020-2021 Couchbase, Inc.
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ require "couchbase/errors"
18
+ require "couchbase/options"
19
+
20
+ module Couchbase
21
+ module Management
22
+ module Options
23
+ module Analytics
24
+ # Options for {AnalyticsIndexManager#create_dataverse}
25
+ class CreateDataverse < ::Couchbase::Options::Base
26
+ attr_accessor :ignore_if_exists # @return [Boolean]
27
+
28
+ # Creates an instance of options for {AnalyticsIndexManager#create_dataverse}
29
+ #
30
+ # @param [Boolean] ignore_if_exists if +true+, the exception {Error::DataverseExists} will not be raised if the
31
+ # dataverse with the specified name already exists.
32
+ #
33
+ # @param [Integer, #in_milliseconds, nil] timeout the time in milliseconds allowed for the operation to complete
34
+ # @param [Symbol, nil] retry_strategy ignored by this operation
35
+ # @param [Hash, nil] client_context the client context data, if set
36
+ # @param [Span, nil] parent_span if set holds the parent span, that should be used for this request
37
+ #
38
+ # @yieldparam [CreateDataverse] self
39
+ def initialize(ignore_if_exists: false,
40
+ timeout: nil,
41
+ retry_strategy: nil,
42
+ client_context: nil,
43
+ parent_span: nil)
44
+ super(timeout: timeout, retry_strategy: retry_strategy, client_context: client_context, parent_span: parent_span)
45
+ @ignore_if_exists = ignore_if_exists
46
+ yield self if block_given?
47
+ end
48
+
49
+ # @api private
50
+ def to_backend
51
+ {
52
+ timeout: Utils::Time.extract_duration(@timeout),
53
+ ignore_if_exists: @ignore_if_exists,
54
+ }
55
+ end
56
+ end
57
+
58
+ # Options for {AnalyticsIndexManager#drop_dataverse}
59
+ class DropDataverse < ::Couchbase::Options::Base
60
+ attr_accessor :ignore_if_does_not_exist # @return [Boolean]
61
+
62
+ # Creates an instance of options for {AnalyticsIndexManager#create_dataverse}
63
+ #
64
+ # @param [Boolean] ignore_if_does_not_exist if +true+, the exception {Error::DataverseNotFound} will not be raised
65
+ # if the dataverse with the specified name does not exist.
66
+ #
67
+ # @param [Integer, #in_milliseconds, nil] timeout the time in milliseconds allowed for the operation to complete
68
+ # @param [Symbol, nil] retry_strategy ignored by this operation
69
+ # @param [Hash, nil] client_context the client context data, if set
70
+ # @param [Span, nil] parent_span if set holds the parent span, that should be used for this request
71
+ #
72
+ # @yieldparam [DropDataverse] self
73
+ def initialize(ignore_if_does_not_exist: false,
74
+ timeout: nil,
75
+ retry_strategy: nil,
76
+ client_context: nil,
77
+ parent_span: nil)
78
+ super(timeout: timeout, retry_strategy: retry_strategy, client_context: client_context, parent_span: parent_span)
79
+ @ignore_if_does_not_exist = ignore_if_does_not_exist
80
+ yield self if block_given?
81
+ end
82
+
83
+ # @api private
84
+ def to_backend
85
+ {
86
+ timeout: Utils::Time.extract_duration(@timeout),
87
+ ignore_if_does_not_exist: @ignore_if_does_not_exist,
88
+ }
89
+ end
90
+ end
91
+
92
+ # Options for {AnalyticsIndexManager#create_dataset}
93
+ class CreateDataset < ::Couchbase::Options::Base
94
+ attr_accessor :ignore_if_exists # @return [Boolean]
95
+ attr_accessor :condition # @return [String]
96
+ attr_accessor :dataverse_name # @return [String]
97
+
98
+ # Creates an instance of options for {AnalyticsIndexManager#create_dataset}
99
+ #
100
+ # @param [Boolean] ignore_if_exists if +true+, the exception {Error::DatasetExists} will not be raised
101
+ # if the dataset with the specified name already exists.
102
+ # @param [String] condition WHERE clause to use for creating dataset
103
+ # @param [String] dataverse_name the name of the dataverse to use (defaults to +nil+)
104
+ #
105
+ # @param [Integer, #in_milliseconds, nil] timeout the time in milliseconds allowed for the operation to complete
106
+ # @param [Symbol, nil] retry_strategy ignored by this operation
107
+ # @param [Hash, nil] client_context the client context data, if set
108
+ # @param [Span, nil] parent_span if set holds the parent span, that should be used for this request
109
+ #
110
+ # @yieldparam [CreateDataset] self
111
+ def initialize(ignore_if_exists: false,
112
+ condition: nil,
113
+ dataverse_name: nil,
114
+ timeout: nil,
115
+ retry_strategy: nil,
116
+ client_context: nil,
117
+ parent_span: nil)
118
+ super(timeout: timeout, retry_strategy: retry_strategy, client_context: client_context, parent_span: parent_span)
119
+ @ignore_if_exists = ignore_if_exists
120
+ @condition = condition
121
+ @dataverse_name = dataverse_name
122
+ yield self if block_given?
123
+ end
124
+
125
+ # @api private
126
+ def to_backend
127
+ {
128
+ timeout: Utils::Time.extract_duration(@timeout),
129
+ condition: @condition,
130
+ dataverse_name: @dataverse_name,
131
+ ignore_if_exists: @ignore_if_exists,
132
+ }
133
+ end
134
+ end
135
+
136
+ # Options for {AnalyticsIndexManager#drop_dataset}
137
+ class DropDataset < ::Couchbase::Options::Base
138
+ attr_accessor :ignore_if_does_not_exist # @return [Boolean]
139
+ attr_accessor :dataverse_name # @return [String]
140
+
141
+ # Creates an instance of options for {AnalyticsIndexManager#drop_dataset}
142
+ #
143
+ # @param [Boolean] ignore_if_does_not_exist if +true+, the exception {Error::DatasetNotFound} will not be raised
144
+ # if the dataset with the specified name does not exist.
145
+ # @param [String] dataverse_name the name of the dataverse to use (defaults to +nil+)
146
+ #
147
+ # @param [Integer, #in_milliseconds, nil] timeout the time in milliseconds allowed for the operation to complete
148
+ # @param [Symbol, nil] retry_strategy ignored by this operation
149
+ # @param [Hash, nil] client_context the client context data, if set
150
+ # @param [Span, nil] parent_span if set holds the parent span, that should be used for this request
151
+ #
152
+ # @yieldparam [DropDataset] self
153
+ def initialize(ignore_if_does_not_exist: false,
154
+ dataverse_name: nil,
155
+ timeout: nil,
156
+ retry_strategy: nil,
157
+ client_context: nil,
158
+ parent_span: nil)
159
+ super(timeout: timeout, retry_strategy: retry_strategy, client_context: client_context, parent_span: parent_span)
160
+ @ignore_if_does_not_exist = ignore_if_does_not_exist
161
+ @dataverse_name = dataverse_name
162
+ yield self if block_given?
163
+ end
164
+
165
+ # @api private
166
+ def to_backend
167
+ {
168
+ timeout: Utils::Time.extract_duration(@timeout),
169
+ dataverse_name: @dataverse_name,
170
+ ignore_if_does_not_exist: @ignore_if_does_not_exist,
171
+ }
172
+ end
173
+ end
174
+
175
+ # Options for {AnalyticsIndexManager#get_all_datasets}
176
+ class GetAllDatasets < ::Couchbase::Options::Base
177
+ # Creates an instance of options for {AnalyticsIndexManager#get_all_datasets}
178
+ #
179
+ # @param [Integer, #in_milliseconds, nil] timeout the time in milliseconds allowed for the operation to complete
180
+ # @param [Symbol, nil] retry_strategy ignored by this operation
181
+ # @param [Hash, nil] client_context the client context data, if set
182
+ # @param [Span, nil] parent_span if set holds the parent span, that should be used for this request
183
+ #
184
+ # @yieldparam [GetAllDatasets] self
185
+ def initialize(timeout: nil,
186
+ retry_strategy: nil,
187
+ client_context: nil,
188
+ parent_span: nil)
189
+ super
190
+ yield self if block_given?
191
+ end
192
+ end
193
+
194
+ # Options for {AnalyticsIndexManager#create_index}
195
+ class CreateIndex < ::Couchbase::Options::Base
196
+ attr_accessor :ignore_if_exists # @return [Boolean]
197
+ attr_accessor :dataverse_name # @return [String]
198
+
199
+ # Creates an instance of options for {AnalyticsIndexManager#create_index}
200
+ #
201
+ # @param [Boolean] ignore_if_exists if +true+, the exception {Error::DatasetExists} will not be raised
202
+ # if the dataset with the specified name already exists.
203
+ # @param [String] dataverse_name the name of the dataverse to use (defaults to +nil+)
204
+ #
205
+ # @param [Integer, #in_milliseconds, nil] timeout the time in milliseconds allowed for the operation to complete
206
+ # @param [Symbol, nil] retry_strategy ignored by this operation
207
+ # @param [Hash, nil] client_context the client context data, if set
208
+ # @param [Span, nil] parent_span if set holds the parent span, that should be used for this request
209
+ #
210
+ # @yieldparam [CreateIndex] self
211
+ def initialize(ignore_if_exists: false,
212
+ dataverse_name: nil,
213
+ timeout: nil,
214
+ retry_strategy: nil,
215
+ client_context: nil,
216
+ parent_span: nil)
217
+ super(timeout: timeout, retry_strategy: retry_strategy, client_context: client_context, parent_span: parent_span)
218
+ @ignore_if_exists = ignore_if_exists
219
+ @dataverse_name = dataverse_name
220
+ yield self if block_given?
221
+ end
222
+
223
+ # @api private
224
+ def to_backend
225
+ {
226
+ timeout: Utils::Time.extract_duration(@timeout),
227
+ dataverse_name: @dataverse_name,
228
+ ignore_if_exists: @ignore_if_exists,
229
+ }
230
+ end
231
+ end
232
+
233
+ # Options for {AnalyticsIndexManager#drop_index}
234
+ class DropIndex < ::Couchbase::Options::Base
235
+ attr_accessor :ignore_if_does_not_exist # @return [Boolean]
236
+ attr_accessor :dataverse_name # @return [String]
237
+
238
+ # Creates an instance of options for {AnalyticsIndexManager#drop_index}
239
+ #
240
+ # @param [Boolean] ignore_if_does_not_exist if +true+, the exception {Error::DatasetNotFound} will not be raised
241
+ # if the dataset with the specified name does not exist.
242
+ # @param [String] dataverse_name the name of the dataverse to use (defaults to +nil+)
243
+ #
244
+ # @param [Integer, #in_milliseconds, nil] timeout the time in milliseconds allowed for the operation to complete
245
+ # @param [Symbol, nil] retry_strategy ignored by this operation
246
+ # @param [Hash, nil] client_context the client context data, if set
247
+ # @param [Span, nil] parent_span if set holds the parent span, that should be used for this request
248
+ #
249
+ # @yieldparam [DropIndex] self
250
+ def initialize(ignore_if_does_not_exist: false,
251
+ dataverse_name: nil,
252
+ timeout: nil,
253
+ retry_strategy: nil,
254
+ client_context: nil,
255
+ parent_span: nil)
256
+ super(timeout: timeout, retry_strategy: retry_strategy, client_context: client_context, parent_span: parent_span)
257
+ @ignore_if_does_not_exist = ignore_if_does_not_exist
258
+ @dataverse_name = dataverse_name
259
+ yield self if block_given?
260
+ end
261
+
262
+ # @api private
263
+ def to_backend
264
+ {
265
+ timeout: Utils::Time.extract_duration(@timeout),
266
+ dataverse_name: @dataverse_name,
267
+ ignore_if_does_not_exist: @ignore_if_does_not_exist,
268
+ }
269
+ end
270
+ end
271
+
272
+ # Options for {AnalyticsIndexManager#get_all_indexes}
273
+ class GetAllIndexes < ::Couchbase::Options::Base
274
+ # Creates an instance of options for {AnalyticsIndexManager#get_all_indexes}
275
+ #
276
+ # @param [Integer, #in_milliseconds, nil] timeout the time in milliseconds allowed for the operation to complete
277
+ # @param [Symbol, nil] retry_strategy ignored by this operation
278
+ # @param [Hash, nil] client_context the client context data, if set
279
+ # @param [Span, nil] parent_span if set holds the parent span, that should be used for this request
280
+ #
281
+ # @yieldparam [GetAllIndexes] self
282
+ def initialize(timeout: nil,
283
+ retry_strategy: nil,
284
+ client_context: nil,
285
+ parent_span: nil)
286
+ super
287
+ yield self if block_given?
288
+ end
289
+ end
290
+
291
+ # Options for {AnalyticsIndexManager#connect_link}
292
+ class ConnectLink < ::Couchbase::Options::Base
293
+ attr_accessor :link_name # @return [String]
294
+ attr_accessor :force # @return [Boolean]
295
+ attr_accessor :dataverse_name # @return [String]
296
+
297
+ # Creates an instance of options for {AnalyticsIndexManager#connect_link}
298
+ #
299
+ # @param [String] link_name the name of the link
300
+ # @param [Boolean] force if +true+, link creation will be forced even if the bucket UUID changed, for example
301
+ # due to the bucket being deleted and recreated
302
+ # @param [String] dataverse_name the name of the dataverse to use (defaults to +nil+)
303
+ #
304
+ # @param [Integer, #in_milliseconds, nil] timeout the time in milliseconds allowed for the operation to complete
305
+ # @param [Symbol, nil] retry_strategy ignored by this operation
306
+ # @param [Hash, nil] client_context the client context data, if set
307
+ # @param [Span, nil] parent_span if set holds the parent span, that should be used for this request
308
+ #
309
+ # @yieldparam [ConnectLink] self
310
+ def initialize(link_name: "Local",
311
+ force: false,
312
+ dataverse_name: nil,
313
+ timeout: nil,
314
+ retry_strategy: nil,
315
+ client_context: nil,
316
+ parent_span: nil)
317
+ super(timeout: timeout, retry_strategy: retry_strategy, client_context: client_context, parent_span: parent_span)
318
+ @link_name = link_name
319
+ @force = force
320
+ @dataverse_name = dataverse_name
321
+ yield self if block_given?
322
+ end
323
+
324
+ # @api private
325
+ def to_backend
326
+ {
327
+ timeout: Utils::Time.extract_duration(@timeout),
328
+ link_name: @link_name,
329
+ force: @force,
330
+ dataverse_name: @dataverse_name,
331
+ }
332
+ end
333
+ end
334
+
335
+ # Options for {AnalyticsIndexManager#connect_link}
336
+ class DisconnectLink < ::Couchbase::Options::Base
337
+ attr_accessor :link_name # @return [String]
338
+ attr_accessor :dataverse_name # @return [String]
339
+
340
+ # Creates an instance of options for {AnalyticsIndexManager#disconnect_link}
341
+ #
342
+ # @param [String] link_name the name of the link
343
+ # @param [String] dataverse_name the name of the dataverse to use (defaults to +nil+)
344
+ #
345
+ # @param [Integer, #in_milliseconds, nil] timeout the time in milliseconds allowed for the operation to complete
346
+ # @param [Symbol, nil] retry_strategy ignored by this operation
347
+ # @param [Hash, nil] client_context the client context data, if set
348
+ # @param [Span, nil] parent_span if set holds the parent span, that should be used for this request
349
+ #
350
+ # @yieldparam [DisconnectLink] self
351
+ def initialize(link_name: "Local",
352
+ dataverse_name: nil,
353
+ timeout: nil,
354
+ retry_strategy: nil,
355
+ client_context: nil,
356
+ parent_span: nil)
357
+ super(timeout: timeout, retry_strategy: retry_strategy, client_context: client_context, parent_span: parent_span)
358
+ @link_name = link_name
359
+ @dataverse_name = dataverse_name
360
+ yield self if block_given?
361
+ end
362
+
363
+ # @api private
364
+ def to_backend
365
+ {
366
+ timeout: Utils::Time.extract_duration(@timeout),
367
+ link_name: @link_name,
368
+ dataverse_name: @dataverse_name,
369
+ }
370
+ end
371
+ end
372
+
373
+ # Options for {AnalyticsIndexManager#get_pending_mutations}
374
+ class GetPendingMutations < ::Couchbase::Options::Base
375
+ # Creates an instance of options for {AnalyticsIndexManager#get_pending_mutations}
376
+ #
377
+ # @param [Integer, #in_milliseconds, nil] timeout the time in milliseconds allowed for the operation to complete
378
+ # @param [Symbol, nil] retry_strategy ignored by this operation
379
+ # @param [Hash, nil] client_context the client context data, if set
380
+ # @param [Span, nil] parent_span if set holds the parent span, that should be used for this request
381
+ #
382
+ # @yieldparam [GetPendingMutations] self
383
+ def initialize(timeout: nil,
384
+ retry_strategy: nil,
385
+ client_context: nil,
386
+ parent_span: nil)
387
+ super
388
+ yield self if block_given?
389
+ end
390
+ end
391
+
392
+ # Options for {AnalyticsIndexManager#create_link}
393
+ class CreateLink < ::Couchbase::Options::Base
394
+ # Creates an instance of options for {AnalyticsIndexManager#create_link}
395
+ #
396
+ # @param [Integer, #in_milliseconds, nil] timeout the time in milliseconds allowed for the operation to complete
397
+ # @param [Symbol, nil] retry_strategy ignored by this operation
398
+ # @param [Hash, nil] client_context the client context data, if set
399
+ # @param [Span, nil] parent_span if set holds the parent span, that should be used for this request
400
+ #
401
+ # @yieldparam [CreateLink] self
402
+ def initialize(timeout: nil,
403
+ retry_strategy: nil,
404
+ client_context: nil,
405
+ parent_span: nil)
406
+ super
407
+ yield self if block_given?
408
+ end
409
+
410
+ # @api private
411
+ def to_backend
412
+ {
413
+ timeout: Utils::Time.extract_duration(@timeout),
414
+ }
415
+ end
416
+ end
417
+
418
+ # Options for {AnalyticsIndexManager#replace_link}
419
+ class ReplaceLink < ::Couchbase::Options::Base
420
+ # Creates an instance of options for {AnalyticsIndexManager#replace_link}
421
+ #
422
+ # @param [Integer, #in_milliseconds, nil] timeout the time in milliseconds allowed for the operation to complete
423
+ # @param [Symbol, nil] retry_strategy ignored by this operation
424
+ # @param [Hash, nil] client_context the client context data, if set
425
+ # @param [Span, nil] parent_span if set holds the parent span, that should be used for this request
426
+ #
427
+ # @yieldparam [ReplaceLink] self
428
+ def initialize(timeout: nil,
429
+ retry_strategy: nil,
430
+ client_context: nil,
431
+ parent_span: nil)
432
+ super
433
+ yield self if block_given?
434
+ end
435
+
436
+ # @api private
437
+ def to_backend
438
+ {
439
+ timeout: Utils::Time.extract_duration(@timeout),
440
+ }
441
+ end
442
+ end
443
+
444
+ # Options for {AnalyticsIndexManager#drop_link}
445
+ class DropLink < ::Couchbase::Options::Base
446
+ # Creates an instance of options for {AnalyticsIndexManager#drop_link}
447
+ #
448
+ # @param [Integer, #in_milliseconds, nil] timeout the time in milliseconds allowed for the operation to complete
449
+ # @param [Symbol, nil] retry_strategy ignored by this operation
450
+ # @param [Hash, nil] client_context the client context data, if set
451
+ # @param [Span, nil] parent_span if set holds the parent span, that should be used for this request
452
+ #
453
+ # @yieldparam [DropLink] self
454
+ def initialize(timeout: nil,
455
+ retry_strategy: nil,
456
+ client_context: nil,
457
+ parent_span: nil)
458
+ super
459
+ yield self if block_given?
460
+ end
461
+
462
+ # @api private
463
+ def to_backend
464
+ {
465
+ timeout: Utils::Time.extract_duration(@timeout),
466
+ }
467
+ end
468
+ end
469
+
470
+ # Options for {AnalyticsIndexManager#get_links}
471
+ class GetLinks < ::Couchbase::Options::Base
472
+ attr_accessor :dataverse # @return [String, nil]
473
+ attr_accessor :link_type # @return [Symbol, nil]
474
+ attr_accessor :name # @return [String, nil]
475
+
476
+ # Creates an instance of options for {AnalyticsIndexManager#get_links}
477
+ #
478
+ # @param [:s3, :azureblob, :couchbase, nil] link_type restricts the results to the given link type.
479
+ # @param [String, nil] dataverse restricts the results to a given dataverse, can be given in the form of
480
+ # "namepart" or "namepart1/namepart2".
481
+ # @param [String, nil] name restricts the results to the link with the specified name. If set then dataverse
482
+ # must also be set.
483
+ #
484
+ # @param [Integer, #in_milliseconds, nil] timeout the time in milliseconds allowed for the operation to
485
+ # complete
486
+ # @param [Symbol, nil] retry_strategy ignored by this operation
487
+ # @param [Hash, nil] client_context the client context data, if set
488
+ # @param [Span, nil] parent_span if set holds the parent span, that should be used for this request
489
+ #
490
+ # @yieldparam [GetLinks] self
491
+ def initialize(link_type: nil,
492
+ dataverse: nil,
493
+ name: nil,
494
+ timeout: nil,
495
+ retry_strategy: nil,
496
+ client_context: nil,
497
+ parent_span: nil)
498
+ super(timeout: timeout, retry_strategy: retry_strategy, client_context: client_context, parent_span: parent_span)
499
+ @link_type = link_type
500
+ @dataverse = dataverse
501
+ @name = name
502
+ yield self if block_given?
503
+ end
504
+
505
+ # @api private
506
+ def to_backend
507
+ {
508
+ timeout: Utils::Time.extract_duration(@timeout),
509
+ link_type: @link_type.to_s,
510
+ dataverse: @dataverse,
511
+ name: @name,
512
+ }
513
+ end
514
+ end
515
+
516
+ # rubocop:disable Naming/MethodName -- constructor shortcuts
517
+ module_function
518
+
519
+ # Construct {CreateDataverse} options for {AnalyticsIndexManager#create_dataverse}
520
+ #
521
+ # @return [CreateDataverse]
522
+ def CreateDataverse(**args)
523
+ CreateDataverse.new(**args)
524
+ end
525
+
526
+ # Construct {DropDataverse} options for {AnalyticsIndexManager#drop_dataverse}
527
+ #
528
+ # @return [DropDataverse]
529
+ def DropDataverse(**args)
530
+ DropDataverse.new(**args)
531
+ end
532
+
533
+ # Construct {CreateDataset} options for {AnalyticsIndexManager#create_dataset}
534
+ #
535
+ # @return [CreateDataset]
536
+ def CreateDataset(**args)
537
+ CreateDataset.new(**args)
538
+ end
539
+
540
+ # Construct {DropDataset} options for {AnalyticsIndexManager#drop_dataset}
541
+ #
542
+ # @return [DropDataset]
543
+ def DropDataset(**args)
544
+ DropDataset.new(**args)
545
+ end
546
+
547
+ # Construct {GetAllDatasets} options for {AnalyticsIndexManager#get_all_datasets}
548
+ #
549
+ # @return [GetAllDatasets]
550
+ def GetAllDatasets(**args)
551
+ GetAllDatasets.new(**args)
552
+ end
553
+
554
+ # Construct {CreateIndex} options for {AnalyticsIndexManager#create_index}
555
+ #
556
+ # @return [CreateIndex]
557
+ def CreateIndex(**args)
558
+ CreateIndex.new(**args)
559
+ end
560
+
561
+ # Construct {DropIndex} options for {AnalyticsIndexManager#drop_index}
562
+ #
563
+ # @return [DropIndex]
564
+ def DropIndex(**args)
565
+ DropIndex.new(**args)
566
+ end
567
+
568
+ # Construct {GetAllIndexes} options for {AnalyticsIndexManager#get_all_indexes}
569
+ #
570
+ # @return [GetAllIndexes]
571
+ def GetAllIndexes(**args)
572
+ GetAllIndexes.new(**args)
573
+ end
574
+
575
+ # Construct {ConnectLink} options for {AnalyticsIndexManager#connect_link}
576
+ #
577
+ # @return [ConnectLink]
578
+ def ConnectLink(**args)
579
+ ConnectLink.new(**args)
580
+ end
581
+
582
+ # Construct {DisconnectLink} options for {AnalyticsIndexManager#disconnect_link}
583
+ #
584
+ # @return [DisconnectLink]
585
+ def DisconnectLink(**args)
586
+ DisconnectLink.new(**args)
587
+ end
588
+
589
+ # Construct {GetPendingMutations} options for {AnalyticsIndexManager#get_pending_mutations}
590
+ #
591
+ # @return [GetPendingMutations]
592
+ def GetPendingMutations(**args)
593
+ GetPendingMutations.new(**args)
594
+ end
595
+
596
+ # Construct {CreateLink} options for {AnalyticsIndexManager#create_link}
597
+ #
598
+ # @return [CreateLink]
599
+ def CreateLink(**args)
600
+ CreateLink.new(**args)
601
+ end
602
+
603
+ # Construct {ReplaceLink} options for {AnalyticsIndexManager#replace_link}
604
+ #
605
+ # @return [ReplaceLink]
606
+ def ReplaceLink(**args)
607
+ ReplaceLink.new(**args)
608
+ end
609
+
610
+ # Construct {DropLink} options for {AnalyticsIndexManager#drop_link}
611
+ #
612
+ # @return [DropLink]
613
+ def DropLink(**args)
614
+ DropLink.new(**args)
615
+ end
616
+
617
+ # Construct {GetLinks} options for {AnalyticsIndexManager#get_links}
618
+ #
619
+ # @return [GetLinks]
620
+ def GetLinks(**args)
621
+ GetLinks.new(**args)
622
+ end
623
+
624
+ # rubocop:enable Naming/MethodName
625
+ end
626
+ end
627
+
628
+ class AnalyticsIndexManager
629
+ alias inspect to_s
630
+
631
+ # @param [Couchbase::Backend] backend
632
+ def initialize(backend, observability)
633
+ @backend = backend
634
+ @observability = observability
635
+ end
636
+
637
+ # Creates a new dataverse
638
+ #
639
+ # @param [String] dataverse_name
640
+ # @param [Options::Analytics::CreateDataverse] options
641
+ #
642
+ # @return [void]
643
+ #
644
+ # @raise [ArgumentError]
645
+ # @raise [Error::DataverseExists]
646
+ def create_dataverse(dataverse_name, options = Options::Analytics::CreateDataverse.new)
647
+ @observability.record_operation(Observability::OP_AM_CREATE_DATAVERSE, options.parent_span, self, :analytics) do |obs_handler|
648
+ @backend.analytics_dataverse_create(dataverse_name, options.to_backend, obs_handler)
649
+ end
650
+ end
651
+
652
+ # Drops a dataverse
653
+ #
654
+ # @param [String] dataverse_name name of the dataverse
655
+ # @param [Options::Analytics::DropDataverse] options
656
+ #
657
+ # @return [void]
658
+ #
659
+ # @raise [ArgumentError]
660
+ # @raise [Error::DataverseNotFound]
661
+ def drop_dataverse(dataverse_name, options = Options::Analytics::DropDataverse.new)
662
+ @observability.record_operation(Observability::OP_AM_DROP_DATAVERSE, options.parent_span, self, :analytics) do |obs_handler|
663
+ @backend.analytics_dataverse_drop(dataverse_name, options.to_backend, obs_handler)
664
+ end
665
+ end
666
+
667
+ # Creates a new dataset
668
+ #
669
+ # @param [String] dataset_name name of dataset
670
+ # @param [String] bucket_name name of the bucket
671
+ # @param [Options::Analytics::CreateDataset] options
672
+ #
673
+ # @return [void]
674
+ #
675
+ # @raise [ArgumentError]
676
+ # @raise [Error::DatasetExists]
677
+ # @raise [Error::LinkNotFound]
678
+ def create_dataset(dataset_name, bucket_name, options = Options::Analytics::CreateDataset.new)
679
+ @observability.record_operation(Observability::OP_AM_CREATE_DATASET, options.parent_span, self, :analytics) do |_obs_handler|
680
+ @backend.analytics_dataset_create(dataset_name, bucket_name, options.to_backend)
681
+ end
682
+ end
683
+
684
+ # Drops a dataset
685
+ #
686
+ # @param [String] dataset_name name of the dataset
687
+ # @param [Options::Analytics::DropDataset] options
688
+ #
689
+ # @return [void]
690
+ #
691
+ # @raise [ArgumentError]
692
+ # @raise [Error::DatasetNotFound]
693
+ def drop_dataset(dataset_name, options = Options::Analytics::DropDataset.new)
694
+ @observability.record_operation(Observability::OP_AM_DROP_DATASET, options.parent_span, self, :analytics) do |obs_handler|
695
+ @backend.analytics_dataset_drop(dataset_name, options.to_backend, obs_handler)
696
+ end
697
+ end
698
+
699
+ # Gets all datasets
700
+ #
701
+ # @param [Options::Analytics::GetAllDatasets] options
702
+ #
703
+ # @return [Array<AnalyticsDataset>]
704
+ def get_all_datasets(options = Options::Analytics::GetAllDatasets.new)
705
+ @observability.record_operation(Observability::OP_AM_GET_ALL_DATASETS, options.parent_span, self, :analytics) do |obs_handler|
706
+ resp = @backend.analytics_dataset_get_all(options.to_backend, obs_handler)
707
+ resp.map do |entry|
708
+ AnalyticsDataset.new do |dataset|
709
+ dataset.name = entry[:name]
710
+ dataset.dataverse_name = entry[:dataverse_name]
711
+ dataset.link_name = entry[:link_name]
712
+ dataset.bucket_name = entry[:bucket_name]
713
+ end
714
+ end
715
+ end
716
+ end
717
+
718
+ # Creates a new index
719
+ #
720
+ # @param [String] index_name name of the index
721
+ # @param [String] dataset_name name of the dataset
722
+ # @param [Hash<String => String>] fields mapping of the field name to field type
723
+ # @param [Options::Analytics::CreateIndex] options
724
+ #
725
+ # @return [void]
726
+ #
727
+ # @raise [ArgumentError]
728
+ # @raise [Error::IndexExists]
729
+ def create_index(index_name, dataset_name, fields, options = Options::Analytics::CreateIndex.new)
730
+ @observability.record_operation(Observability::OP_AM_CREATE_INDEX, options.parent_span, self, :analytics) do |obs_handler|
731
+ @backend.analytics_index_create(index_name, dataset_name, fields.entries, options.to_backend, obs_handler)
732
+ end
733
+ end
734
+
735
+ # Drops an index
736
+ #
737
+ # @param [String] index_name name of the index
738
+ # @param [String] dataset_name name of the dataset
739
+ # @param [Options::Analytics::DropIndex] options
740
+ #
741
+ # @return [void]
742
+ #
743
+ # @raise [ArgumentError]
744
+ # @raise [Error::IndexNotFound]
745
+ def drop_index(index_name, dataset_name, options = Options::Analytics::DropIndex.new)
746
+ @observability.record_operation(Observability::OP_AM_DROP_INDEX, options.parent_span, self, :analytics) do |obs_handler|
747
+ @backend.analytics_index_drop(index_name, dataset_name, options.to_backend, obs_handler)
748
+ end
749
+ end
750
+
751
+ # Gets all indexes
752
+ #
753
+ # @param [Options::Analytics::GetAllIndexes] options
754
+ #
755
+ # @return [Array<AnalyticsIndex>]
756
+ def get_all_indexes(options = Options::Analytics::GetAllIndexes.new)
757
+ @observability.record_operation(Observability::OP_AM_GET_ALL_INDEXES, options.parent_span, self, :analytics) do |obs_handler|
758
+ resp = @backend.analytics_index_get_all(options.to_backend, obs_handler)
759
+ resp.map do |entry|
760
+ AnalyticsIndex.new do |dataset|
761
+ dataset.name = entry[:name]
762
+ dataset.dataverse_name = entry[:dataverse_name]
763
+ dataset.dataset_name = entry[:dataset_name]
764
+ dataset.is_primary = entry[:is_primary]
765
+ end
766
+ end
767
+ end
768
+ end
769
+
770
+ # Connects a link
771
+ #
772
+ # @param [Options::Analytics::ConnectLink] options
773
+ #
774
+ # @return [void]
775
+ #
776
+ # @raise [ArgumentError]
777
+ # @raise [Error::LinkNotFound]
778
+ def connect_link(options = Options::Analytics::ConnectLink.new)
779
+ @observability.record_operation(Observability::OP_AM_CONNECT_LINK, options.parent_span, self, :analytics) do |obs_handler|
780
+ @backend.analytics_link_connect(options.to_backend, obs_handler)
781
+ end
782
+ end
783
+
784
+ # Disconnects a link,
785
+ #
786
+ # @param [Options::Analytics::DisconnectLink] options
787
+ #
788
+ # @return [void]
789
+ #
790
+ # @raise [ArgumentError]
791
+ # @raise [Error::LinkNotFound]
792
+ def disconnect_link(options = Options::Analytics::DisconnectLink.new)
793
+ @observability.record_operation(Observability::OP_AM_DISCONNECT_LINK, options.parent_span, self, :analytics) do |obs_handler|
794
+ @backend.analytics_link_disconnect(options.to_backend, obs_handler)
795
+ end
796
+ end
797
+
798
+ # Gets the pending mutations for all datasets.
799
+ #
800
+ # @note If a link is disconnected then it will return no results. If all links are disconnected, then
801
+ # an empty object is returned.
802
+ #
803
+ # @param [Options::Analytics::GetPendingMutations] options
804
+ #
805
+ # @return [Hash<String => Integer>] dictionary, where keys are dataset coordinates encoded as +"dataverse.dataset"+
806
+ # and values are number of mutations for given dataset.
807
+ def get_pending_mutations(options = Options::Analytics::GetPendingMutations.new)
808
+ @observability.record_operation(Observability::OP_AM_GET_PENDING_MUTATIONS, options.parent_span, self, :analytics) do |obs_handler|
809
+ @backend.analytics_get_pending_mutations(options.to_backend, obs_handler)
810
+ end
811
+ end
812
+
813
+ # Creates a link
814
+ #
815
+ # @param [CouchbaseRemoteAnalyticsLink, AzureBlobExternalAnalyticsLink, S3ExternalAnalyticsLink] link
816
+ # @param [Options::Analytics::CreateLink] options
817
+ #
818
+ # @return [void]
819
+ #
820
+ # @raise [ArgumentError]
821
+ # @raise [Error::LinkExists]
822
+ def create_link(link, options = Options::Analytics::CreateLink.new)
823
+ @observability.record_operation(Observability::OP_AM_CREATE_LINK, options.parent_span, self, :analytics) do |obs_handler|
824
+ @backend.analytics_link_create(link.to_backend, options.to_backend, obs_handler)
825
+ end
826
+ end
827
+
828
+ # Replaces the link
829
+ #
830
+ # @param [CouchbaseRemoteAnalyticsLink, AzureBlobExternalAnalyticsLink, S3ExternalAnalyticsLink] link
831
+ # @param [Options::Analytics::ReplaceLink] options
832
+ #
833
+ # @return [void]
834
+ #
835
+ # @raise [ArgumentError]
836
+ # @raise [Error::LinkNotFound]
837
+ def replace_link(link, options = Options::Analytics::ReplaceLink.new)
838
+ @observability.record_operation(Observability::OP_AM_REPLACE_LINK, options.parent_span, self, :analytics) do |obs_handler|
839
+ @backend.analytics_link_replace(link.to_backend, options.to_backend, obs_handler)
840
+ end
841
+ end
842
+
843
+ # Drops the link
844
+ #
845
+ # @param [String] link_name name of the link
846
+ # @param [String] dataverse_name dataverse where the link belongs
847
+ # @param [Options::Analytics::DropLink] options
848
+ #
849
+ # @return [void]
850
+ #
851
+ # @raise [ArgumentError]
852
+ # @raise [Error::LinkNotFound]
853
+ def drop_link(link_name, dataverse_name, options = Options::Analytics::DropLink.new)
854
+ @observability.record_operation(Observability::OP_AM_DROP_LINK, options.parent_span, self, :analytics) do |obs_handler|
855
+ @backend.analytics_link_drop(link_name, dataverse_name, options.to_backend, obs_handler)
856
+ end
857
+ end
858
+
859
+ # Retrieves the links
860
+ #
861
+ # @param [Options::Analytics::GetLinks] options
862
+ #
863
+ # @return [void]
864
+ #
865
+ # @raise [ArgumentError]
866
+ # @raise [Error::LinkNotFound]
867
+ def get_links(options = Options::Analytics::GetLinks.new)
868
+ @observability.record_operation(Observability::OP_AM_GET_LINKS, options.parent_span, self, :analytics) do |obs_handler|
869
+ resp = @backend.analytics_link_get_all(options.to_backend, obs_handler)
870
+ resp.map do |entry|
871
+ case entry[:type]
872
+ when :s3
873
+ S3ExternalAnalyticsLink.new(
874
+ entry[:link_name],
875
+ entry[:dataverse],
876
+ entry[:access_key_id],
877
+ nil,
878
+ entry[:region],
879
+ service_endpoint: entry[:service_endpoint],
880
+ )
881
+ when :couchbase
882
+ CouchbaseRemoteAnalyticsLink.new(
883
+ entry[:link_name],
884
+ entry[:dataverse],
885
+ entry[:hostname],
886
+ username: entry[:username],
887
+ encryption: EncryptionSettings.new(
888
+ level: entry[:encryption_level],
889
+ certificate: entry[:certificate],
890
+ client_certificate: entry[:client_certificate],
891
+ ),
892
+ )
893
+ when :azureblob
894
+ AzureBlobExternalAnalyticsLink.new(
895
+ entry[:link_name],
896
+ entry[:dataverse],
897
+ account_name: entry[:account_name],
898
+ blob_endpoint: entry[:blob_endpoint],
899
+ endpoint_suffix: entry[:endpoint_suffix],
900
+ )
901
+ end
902
+ end
903
+ end
904
+ end
905
+
906
+ # @api private
907
+ # TODO: deprecate after 3.2
908
+ CreateDataverseOptions = ::Couchbase::Management::Options::Analytics::CreateDataverse
909
+
910
+ # @api private
911
+ # TODO: deprecate after 3.2
912
+ DropDataverseOptions = ::Couchbase::Management::Options::Analytics::DropDataverse
913
+
914
+ # @api private
915
+ # TODO: deprecate after 3.2
916
+ CreateDatasetOptions = ::Couchbase::Management::Options::Analytics::CreateDataset
917
+
918
+ # @api private
919
+ # TODO: deprecate after 3.2
920
+ DropDatasetOptions = ::Couchbase::Management::Options::Analytics::DropDataset
921
+
922
+ # @api private
923
+ # TODO: deprecate after 3.2
924
+ GetAllDatasetsOptions = ::Couchbase::Management::Options::Analytics::GetAllDatasets
925
+
926
+ # @api private
927
+ # TODO: deprecate after 3.2
928
+ CreateIndexOptions = ::Couchbase::Management::Options::Analytics::CreateIndex
929
+
930
+ # @api private
931
+ # TODO: deprecate after 3.2
932
+ DropIndexOptions = ::Couchbase::Management::Options::Analytics::DropIndex
933
+
934
+ # @api private
935
+ # TODO: deprecate after 3.2
936
+ GetAllIndexesOptions = ::Couchbase::Management::Options::Analytics::GetAllIndexes
937
+
938
+ # @api private
939
+ # TODO: deprecate after 3.2
940
+ ConnectLinkOptions = ::Couchbase::Management::Options::Analytics::ConnectLink
941
+
942
+ # @api private
943
+ # TODO: deprecate after 3.2
944
+ GetPendingMutationsOptions = ::Couchbase::Management::Options::Analytics::GetPendingMutations
945
+ end
946
+
947
+ class AnalyticsDataset
948
+ # @return [String]
949
+ attr_accessor :name
950
+
951
+ # @return [String]
952
+ attr_accessor :dataverse_name
953
+
954
+ # @return [String]
955
+ attr_accessor :link_name
956
+
957
+ # @return [String]
958
+ attr_accessor :bucket_name
959
+
960
+ # @yieldparam [AnalyticsDataset]
961
+ def initialize
962
+ yield self if block_given?
963
+ end
964
+ end
965
+
966
+ class AnalyticsIndex
967
+ # @return [String]
968
+ attr_accessor :name
969
+
970
+ # @return [String]
971
+ attr_accessor :dataset_name
972
+
973
+ # @return [String]
974
+ attr_accessor :dataverse_name
975
+
976
+ # @return [Boolean]
977
+ attr_accessor :is_primary
978
+ alias primary? is_primary
979
+
980
+ # @yieldparam [AnalyticsIndex]
981
+ def initialize
982
+ yield self if block_given?
983
+ end
984
+ end
985
+
986
+ class EncryptionSettings
987
+ attr_accessor :level # @return [Symbol]
988
+ attr_accessor :certificate # @return [String, nil]
989
+ attr_accessor :client_certificate # @return [String, nil]
990
+ attr_accessor :client_key # @return [String, nil]
991
+
992
+ # @param [:none, :half, :full] level Specifies what level of encryption should be used.
993
+ # @param [String, nil] certificate
994
+ # @param [String, nil] client_certificate
995
+ # @param [String, nil] client_key
996
+ #
997
+ # @yieldparam [EncryptionSettings] self
998
+ def initialize(level: :none,
999
+ certificate: nil,
1000
+ client_certificate: nil,
1001
+ client_key: nil)
1002
+ @level = level
1003
+ @certificate = certificate
1004
+ @client_certificate = client_certificate
1005
+ @client_key = client_key
1006
+ yield self if block_given?
1007
+ end
1008
+ end
1009
+
1010
+ class CouchbaseRemoteAnalyticsLink
1011
+ attr_accessor :name # @return [String]
1012
+ attr_accessor :dataverse # @return [String]
1013
+ attr_accessor :hostname # @return [String]
1014
+ attr_accessor :username # @return [String, nil]
1015
+ attr_accessor :password # @return [String, nil]
1016
+ attr_accessor :encryption # @return [EncryptionSettings]
1017
+
1018
+ # @param [String] name the name of this link
1019
+ # @param [String] dataverse the dataverse this link belongs to
1020
+ # @param [String] hostname the hostname of the target Couchbase cluster
1021
+ # @param [String, nil] username the username to use for authentication with the remote cluster. Optional if
1022
+ # client-certificate authentication is being used.
1023
+ # @param [String, nil] password the password to use for authentication with the remote cluster. Optional if
1024
+ # client-certificate authentication is being used.
1025
+ # @param [EncryptionSettings] encryption settings for connection encryption
1026
+ #
1027
+ # @yieldparam [CouchbaseRemoteLink] self
1028
+ def initialize(name, dataverse, hostname,
1029
+ username: nil,
1030
+ password: nil,
1031
+ encryption: EncryptionSettings.new)
1032
+ @name = name
1033
+ @dataverse = dataverse
1034
+ @hostname = hostname
1035
+ @username = username
1036
+ @password = password
1037
+ @encryption = encryption
1038
+ yield self if block_given?
1039
+ end
1040
+
1041
+ # @api private
1042
+ def to_backend
1043
+ {
1044
+ type: :couchbase,
1045
+ link_name: @name,
1046
+ dataverse: @dataverse,
1047
+ hostname: @hostname,
1048
+ username: @username,
1049
+ password: @password,
1050
+ encryption_level: @encryption.level,
1051
+ certificate: @encryption.certificate,
1052
+ client_certificate: @encryption.client_certificate,
1053
+ client_key: @encryption.client_key,
1054
+ }
1055
+ end
1056
+ end
1057
+
1058
+ class AzureBlobExternalAnalyticsLink
1059
+ attr_accessor :name # @return [String]
1060
+ attr_accessor :dataverse # @return [String]
1061
+ attr_accessor :connection_string # @return [String, nil]
1062
+ attr_accessor :account_name # @return [String, nil]
1063
+ attr_accessor :account_key # @return [String, nil]
1064
+ attr_accessor :shared_access_signature # @return [String, nil]
1065
+ attr_accessor :blob_endpoint # @return [String, nil]
1066
+ attr_accessor :endpoint_suffix # @return [String, nil]
1067
+
1068
+ # @param [String] name the name of this link
1069
+ # @param [String] dataverse the dataverse this link belongs to
1070
+ # @param [String, nil] connection_string the connection string can be used as an authentication method,
1071
+ # +connection_string+ contains other authentication methods embedded inside the string. Only a single
1072
+ # authentication method can be used. (e.g. "AccountName=myAccountName;AccountKey=myAccountKey").
1073
+ # @param [String, nil] account_name Azure blob storage account name
1074
+ # @param [String, nil] account_key Azure blob storage account key
1075
+ # @param [String, nil] shared_access_signature token that can be used for authentication
1076
+ # @param [String, nil] blob_endpoint Azure blob storage endpoint
1077
+ # @param [String, nil] endpoint_suffix Azure blob endpoint suffix
1078
+ #
1079
+ # @yieldparam [AzureBlobExternalAnalyticsLink] self
1080
+ def initialize(name, dataverse,
1081
+ connection_string: nil,
1082
+ account_name: nil,
1083
+ account_key: nil,
1084
+ shared_access_signature: nil,
1085
+ blob_endpoint: nil,
1086
+ endpoint_suffix: nil)
1087
+ @name = name
1088
+ @dataverse = dataverse
1089
+ @connection_string = connection_string
1090
+ @account_name = account_name
1091
+ @account_key = account_key
1092
+ @shared_access_signature = shared_access_signature
1093
+ @blob_endpoint = blob_endpoint
1094
+ @endpoint_suffix = endpoint_suffix
1095
+ yield self if block_given?
1096
+ end
1097
+
1098
+ # @api private
1099
+ def to_backend
1100
+ {
1101
+ type: :azureblob,
1102
+ link_name: @name,
1103
+ dataverse: @dataverse,
1104
+ connection_string: @connection_string,
1105
+ account_name: @account_name,
1106
+ account_key: @account_key,
1107
+ shared_access_signature: @shared_access_signature,
1108
+ blob_endpoint: @blob_endpoint,
1109
+ endpoint_suffix: @endpoint_suffix,
1110
+ }
1111
+ end
1112
+ end
1113
+
1114
+ class S3ExternalAnalyticsLink
1115
+ attr_accessor :name # @return [String]
1116
+ attr_accessor :dataverse # @return [String]
1117
+ attr_accessor :access_key_id # @return [String]
1118
+ attr_accessor :secret_access_key # @return [String]
1119
+ attr_accessor :session_token # @return [String, nil]
1120
+ attr_accessor :region # @return [String]
1121
+ attr_accessor :service_endpoint # @return [String, nil]
1122
+
1123
+ # @param [String] name the name of this link
1124
+ # @param [String] dataverse the dataverse this link belongs to
1125
+ # @param [String] access_key_id AWS S3 access key ID
1126
+ # @param [String] secret_access_key AWS S3 secret key
1127
+ # @param [String] region AWS S3 region
1128
+ # @param [String, nil] session_token AWS S3 token if temporary credentials are provided. Only available in 7.0+
1129
+ # @param [String, nil] service_endpoint AWS S3 service endpoint
1130
+ #
1131
+ # @yieldparam [S3ExternalAnalyticsLink] self
1132
+ def initialize(name, dataverse, access_key_id, secret_access_key, region,
1133
+ session_token: nil,
1134
+ service_endpoint: nil)
1135
+ @name = name
1136
+ @dataverse = dataverse
1137
+ @access_key_id = access_key_id
1138
+ @secret_access_key = secret_access_key
1139
+ @session_token = session_token
1140
+ @region = region
1141
+ @service_endpoint = service_endpoint
1142
+ yield self if block_given?
1143
+ end
1144
+
1145
+ # @api private
1146
+ def to_backend
1147
+ {
1148
+ type: :s3,
1149
+ link_name: @name,
1150
+ dataverse: @dataverse,
1151
+ access_key_id: @access_key_id,
1152
+ secret_access_key: @secret_access_key,
1153
+ session_token: @session_token,
1154
+ region: @region,
1155
+ service_endpoint: @service_endpoint,
1156
+ }
1157
+ end
1158
+ end
1159
+ end
1160
+ end