couchbase 3.5.0-arm64-darwin-23

Sign up to get free protection for your applications and to get access to all the features.
Files changed (126) 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 +339 -0
  6. data/lib/couchbase/3.0/libcouchbase.bundle +0 -0
  7. data/lib/couchbase/3.1/libcouchbase.bundle +0 -0
  8. data/lib/couchbase/3.2/libcouchbase.bundle +0 -0
  9. data/lib/couchbase/3.3/libcouchbase.bundle +0 -0
  10. data/lib/couchbase/analytics_options.rb +107 -0
  11. data/lib/couchbase/authenticator.rb +64 -0
  12. data/lib/couchbase/binary_collection.rb +128 -0
  13. data/lib/couchbase/binary_collection_options.rb +24 -0
  14. data/lib/couchbase/bucket.rb +144 -0
  15. data/lib/couchbase/cluster.rb +460 -0
  16. data/lib/couchbase/cluster_registry.rb +49 -0
  17. data/lib/couchbase/collection.rb +705 -0
  18. data/lib/couchbase/collection_options.rb +399 -0
  19. data/lib/couchbase/config_profiles.rb +55 -0
  20. data/lib/couchbase/configuration.rb +56 -0
  21. data/lib/couchbase/datastructures/couchbase_list.rb +160 -0
  22. data/lib/couchbase/datastructures/couchbase_map.rb +194 -0
  23. data/lib/couchbase/datastructures/couchbase_queue.rb +134 -0
  24. data/lib/couchbase/datastructures/couchbase_set.rb +128 -0
  25. data/lib/couchbase/datastructures.rb +24 -0
  26. data/lib/couchbase/diagnostics.rb +181 -0
  27. data/lib/couchbase/errors.rb +376 -0
  28. data/lib/couchbase/json_transcoder.rb +39 -0
  29. data/lib/couchbase/key_value_scan.rb +117 -0
  30. data/lib/couchbase/libcouchbase.rb +6 -0
  31. data/lib/couchbase/logger.rb +85 -0
  32. data/lib/couchbase/management/analytics_index_manager.rb +1127 -0
  33. data/lib/couchbase/management/bucket_manager.rb +443 -0
  34. data/lib/couchbase/management/collection_manager.rb +470 -0
  35. data/lib/couchbase/management/collection_query_index_manager.rb +222 -0
  36. data/lib/couchbase/management/query_index_manager.rb +617 -0
  37. data/lib/couchbase/management/scope_search_index_manager.rb +198 -0
  38. data/lib/couchbase/management/search_index_manager.rb +424 -0
  39. data/lib/couchbase/management/user_manager.rb +468 -0
  40. data/lib/couchbase/management/view_index_manager.rb +237 -0
  41. data/lib/couchbase/management.rb +29 -0
  42. data/lib/couchbase/mutation_state.rb +63 -0
  43. data/lib/couchbase/options.rb +2837 -0
  44. data/lib/couchbase/protostellar/binary_collection.rb +55 -0
  45. data/lib/couchbase/protostellar/bucket.rb +51 -0
  46. data/lib/couchbase/protostellar/client.rb +99 -0
  47. data/lib/couchbase/protostellar/cluster.rb +163 -0
  48. data/lib/couchbase/protostellar/collection.rb +152 -0
  49. data/lib/couchbase/protostellar/connect_options.rb +63 -0
  50. data/lib/couchbase/protostellar/error_handling.rb +203 -0
  51. data/lib/couchbase/protostellar/generated/admin/bucket/v1/bucket_pb.rb +61 -0
  52. data/lib/couchbase/protostellar/generated/admin/bucket/v1/bucket_services_pb.rb +35 -0
  53. data/lib/couchbase/protostellar/generated/admin/collection/v1/collection_pb.rb +57 -0
  54. data/lib/couchbase/protostellar/generated/admin/collection/v1/collection_services_pb.rb +36 -0
  55. data/lib/couchbase/protostellar/generated/admin/query/v1/query_pb.rb +61 -0
  56. data/lib/couchbase/protostellar/generated/admin/query/v1/query_services_pb.rb +37 -0
  57. data/lib/couchbase/protostellar/generated/admin/search/v1/search_pb.rb +72 -0
  58. data/lib/couchbase/protostellar/generated/admin/search/v1/search_services_pb.rb +44 -0
  59. data/lib/couchbase/protostellar/generated/analytics/v1/analytics_pb.rb +52 -0
  60. data/lib/couchbase/protostellar/generated/analytics/v1/analytics_services_pb.rb +30 -0
  61. data/lib/couchbase/protostellar/generated/internal/hooks/v1/hooks_pb.rb +70 -0
  62. data/lib/couchbase/protostellar/generated/internal/hooks/v1/hooks_services_pb.rb +36 -0
  63. data/lib/couchbase/protostellar/generated/kv/v1/kv_pb.rb +97 -0
  64. data/lib/couchbase/protostellar/generated/kv/v1/kv_services_pb.rb +46 -0
  65. data/lib/couchbase/protostellar/generated/query/v1/query_pb.rb +57 -0
  66. data/lib/couchbase/protostellar/generated/query/v1/query_services_pb.rb +30 -0
  67. data/lib/couchbase/protostellar/generated/routing/v1/routing_pb.rb +52 -0
  68. data/lib/couchbase/protostellar/generated/routing/v1/routing_services_pb.rb +30 -0
  69. data/lib/couchbase/protostellar/generated/search/v1/search_pb.rb +99 -0
  70. data/lib/couchbase/protostellar/generated/search/v1/search_services_pb.rb +30 -0
  71. data/lib/couchbase/protostellar/generated/transactions/v1/transactions_pb.rb +57 -0
  72. data/lib/couchbase/protostellar/generated/transactions/v1/transactions_services_pb.rb +36 -0
  73. data/lib/couchbase/protostellar/generated/view/v1/view_pb.rb +51 -0
  74. data/lib/couchbase/protostellar/generated/view/v1/view_services_pb.rb +30 -0
  75. data/lib/couchbase/protostellar/generated.rb +9 -0
  76. data/lib/couchbase/protostellar/management/bucket_manager.rb +67 -0
  77. data/lib/couchbase/protostellar/management/collection_manager.rb +94 -0
  78. data/lib/couchbase/protostellar/management/collection_query_index_manager.rb +124 -0
  79. data/lib/couchbase/protostellar/management/query_index_manager.rb +112 -0
  80. data/lib/couchbase/protostellar/management.rb +24 -0
  81. data/lib/couchbase/protostellar/request.rb +78 -0
  82. data/lib/couchbase/protostellar/request_behaviour.rb +42 -0
  83. data/lib/couchbase/protostellar/request_generator/admin/bucket.rb +124 -0
  84. data/lib/couchbase/protostellar/request_generator/admin/collection.rb +94 -0
  85. data/lib/couchbase/protostellar/request_generator/admin/query.rb +130 -0
  86. data/lib/couchbase/protostellar/request_generator/admin.rb +24 -0
  87. data/lib/couchbase/protostellar/request_generator/kv.rb +474 -0
  88. data/lib/couchbase/protostellar/request_generator/query.rb +133 -0
  89. data/lib/couchbase/protostellar/request_generator/search.rb +387 -0
  90. data/lib/couchbase/protostellar/request_generator.rb +26 -0
  91. data/lib/couchbase/protostellar/response_converter/admin/bucket.rb +55 -0
  92. data/lib/couchbase/protostellar/response_converter/admin/collection.rb +42 -0
  93. data/lib/couchbase/protostellar/response_converter/admin/query.rb +59 -0
  94. data/lib/couchbase/protostellar/response_converter/admin.rb +24 -0
  95. data/lib/couchbase/protostellar/response_converter/kv.rb +151 -0
  96. data/lib/couchbase/protostellar/response_converter/query.rb +84 -0
  97. data/lib/couchbase/protostellar/response_converter/search.rb +136 -0
  98. data/lib/couchbase/protostellar/response_converter.rb +26 -0
  99. data/lib/couchbase/protostellar/retry/action.rb +38 -0
  100. data/lib/couchbase/protostellar/retry/orchestrator.rb +60 -0
  101. data/lib/couchbase/protostellar/retry/reason.rb +67 -0
  102. data/lib/couchbase/protostellar/retry/strategies/best_effort.rb +49 -0
  103. data/lib/couchbase/protostellar/retry/strategies.rb +26 -0
  104. data/lib/couchbase/protostellar/retry.rb +28 -0
  105. data/lib/couchbase/protostellar/scope.rb +57 -0
  106. data/lib/couchbase/protostellar/timeout_defaults.rb +30 -0
  107. data/lib/couchbase/protostellar/timeouts.rb +83 -0
  108. data/lib/couchbase/protostellar.rb +29 -0
  109. data/lib/couchbase/query_options.rb +120 -0
  110. data/lib/couchbase/railtie.rb +45 -0
  111. data/lib/couchbase/raw_binary_transcoder.rb +37 -0
  112. data/lib/couchbase/raw_json_transcoder.rb +38 -0
  113. data/lib/couchbase/raw_string_transcoder.rb +40 -0
  114. data/lib/couchbase/scope.rb +256 -0
  115. data/lib/couchbase/search_options.rb +1622 -0
  116. data/lib/couchbase/subdoc.rb +290 -0
  117. data/lib/couchbase/transcoder_flags.rb +62 -0
  118. data/lib/couchbase/utils/generic_logger_adapter.rb +38 -0
  119. data/lib/couchbase/utils/stdlib_logger_adapter.rb +65 -0
  120. data/lib/couchbase/utils/time.rb +69 -0
  121. data/lib/couchbase/utils.rb +21 -0
  122. data/lib/couchbase/version.rb +23 -0
  123. data/lib/couchbase/view_options.rb +65 -0
  124. data/lib/couchbase.rb +28 -0
  125. data/lib/rails/generators/couchbase/config/config_generator.rb +27 -0
  126. metadata +191 -0
@@ -0,0 +1,1127 @@
1
+ # Copyright 2020-2021 Couchbase, Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ require "couchbase/errors"
16
+ require "couchbase/options"
17
+
18
+ module Couchbase
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: Utils::Time.extract_duration(@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: Utils::Time.extract_duration(@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: Utils::Time.extract_duration(@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: Utils::Time.extract_duration(@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: Utils::Time.extract_duration(@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: Utils::Time.extract_duration(@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: Utils::Time.extract_duration(@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: Utils::Time.extract_duration(@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: Utils::Time.extract_duration(@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: Utils::Time.extract_duration(@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: Utils::Time.extract_duration(@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: Utils::Time.extract_duration(@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
+
626
+ class AnalyticsIndexManager
627
+ alias inspect to_s
628
+
629
+ # @param [Couchbase::Backend] backend
630
+ def initialize(backend)
631
+ @backend = backend
632
+ end
633
+
634
+ # Creates a new dataverse
635
+ #
636
+ # @param [String] dataverse_name
637
+ # @param [Options::Analytics::CreateDataverse] options
638
+ #
639
+ # @return [void]
640
+ #
641
+ # @raise [ArgumentError]
642
+ # @raise [Error::DataverseExists]
643
+ def create_dataverse(dataverse_name, options = Options::Analytics::CreateDataverse.new)
644
+ @backend.analytics_dataverse_create(dataverse_name, options.to_backend)
645
+ end
646
+
647
+ # Drops a dataverse
648
+ #
649
+ # @param [String] dataverse_name name of the dataverse
650
+ # @param [Options::Analytics::DropDataverse] options
651
+ #
652
+ # @return [void]
653
+ #
654
+ # @raise [ArgumentError]
655
+ # @raise [Error::DataverseNotFound]
656
+ def drop_dataverse(dataverse_name, options = Options::Analytics::DropDataverse.new)
657
+ @backend.analytics_dataverse_drop(dataverse_name, options.to_backend)
658
+ end
659
+
660
+ # Creates a new dataset
661
+ #
662
+ # @param [String] dataset_name name of dataset
663
+ # @param [String] bucket_name name of the bucket
664
+ # @param [Options::Analytics::CreateDataset] options
665
+ #
666
+ # @return [void]
667
+ #
668
+ # @raise [ArgumentError]
669
+ # @raise [Error::DatasetExists]
670
+ # @raise [Error::LinkNotFound]
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)
673
+ end
674
+
675
+ # Drops a dataset
676
+ #
677
+ # @param [String] dataset_name name of the dataset
678
+ # @param [Options::Analytics::DropDataset] options
679
+ #
680
+ # @return [void]
681
+ #
682
+ # @raise [ArgumentError]
683
+ # @raise [Error::DatasetNotFound]
684
+ def drop_dataset(dataset_name, options = Options::Analytics::DropDataset.new)
685
+ @backend.analytics_dataset_drop(dataset_name, options.to_backend)
686
+ end
687
+
688
+ # Gets all datasets
689
+ #
690
+ # @param [Options::Analytics::GetAllDatasets] options
691
+ #
692
+ # @return [Array<AnalyticsDataset>]
693
+ def get_all_datasets(options = Options::Analytics::GetAllDatasets.new)
694
+ resp = @backend.analytics_dataset_get_all(options.to_backend)
695
+ resp.map do |entry|
696
+ AnalyticsDataset.new do |dataset|
697
+ dataset.name = entry[:name]
698
+ dataset.dataverse_name = entry[:dataverse_name]
699
+ dataset.link_name = entry[:link_name]
700
+ dataset.bucket_name = entry[:bucket_name]
701
+ end
702
+ end
703
+ end
704
+
705
+ # Creates a new index
706
+ #
707
+ # @param [String] index_name name of the index
708
+ # @param [String] dataset_name name of the dataset
709
+ # @param [Hash<String => String>] fields mapping of the field name to field type
710
+ # @param [Options::Analytics::CreateIndex] options
711
+ #
712
+ # @return [void]
713
+ #
714
+ # @raise [ArgumentError]
715
+ # @raise [Error::IndexExists]
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)
718
+ end
719
+
720
+ # Drops an index
721
+ #
722
+ # @param [String] index_name name of the index
723
+ # @param [String] dataset_name name of the dataset
724
+ # @param [Options::Analytics::DropIndex] options
725
+ #
726
+ # @return [void]
727
+ #
728
+ # @raise [ArgumentError]
729
+ # @raise [Error::IndexNotFound]
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)
732
+ end
733
+
734
+ # Gets all indexes
735
+ #
736
+ # @param [Options::Analytics::GetAllIndexes] options
737
+ #
738
+ # @return [Array<AnalyticsIndex>]
739
+ def get_all_indexes(options = Options::Analytics::GetAllIndexes.new)
740
+ resp = @backend.analytics_index_get_all(options.to_backend)
741
+ resp.map do |entry|
742
+ AnalyticsIndex.new do |dataset|
743
+ dataset.name = entry[:name]
744
+ dataset.dataverse_name = entry[:dataverse_name]
745
+ dataset.dataset_name = entry[:dataset_name]
746
+ dataset.is_primary = entry[:is_primary]
747
+ end
748
+ end
749
+ end
750
+
751
+ # Connects a link
752
+ #
753
+ # @param [Options::Analytics::ConnectLink] options
754
+ #
755
+ # @return [void]
756
+ #
757
+ # @raise [ArgumentError]
758
+ # @raise [Error::LinkNotFound]
759
+ def connect_link(options = Options::Analytics::ConnectLink.new)
760
+ @backend.analytics_link_connect(options.to_backend)
761
+ end
762
+
763
+ # Disconnects a link,
764
+ #
765
+ # @param [Options::Analytics::DisconnectLink] options
766
+ #
767
+ # @return [void]
768
+ #
769
+ # @raise [ArgumentError]
770
+ # @raise [Error::LinkNotFound]
771
+ def disconnect_link(options = Options::Analytics::DisconnectLink.new)
772
+ @backend.analytics_link_disconnect(options.to_backend)
773
+ end
774
+
775
+ # Gets the pending mutations for all datasets.
776
+ #
777
+ # @note If a link is disconnected then it will return no results. If all links are disconnected, then
778
+ # an empty object is returned.
779
+ #
780
+ # @param [Options::Analytics::GetPendingMutations] options
781
+ #
782
+ # @return [Hash<String => Integer>] dictionary, where keys are dataset coordinates encoded as +"dataverse.dataset"+
783
+ # and values are number of mutations for given dataset.
784
+ def get_pending_mutations(options = Options::Analytics::GetPendingMutations.new)
785
+ @backend.analytics_get_pending_mutations(options.to_backend)
786
+ end
787
+
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)
799
+ end
800
+
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)
812
+ end
813
+
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)
826
+ end
827
+
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
870
+ end
871
+ end
872
+
873
+ # @api private
874
+ # TODO: deprecate after 3.2
875
+ CreateDataverseOptions = ::Couchbase::Management::Options::Analytics::CreateDataverse
876
+
877
+ # @api private
878
+ # TODO: deprecate after 3.2
879
+ DropDataverseOptions = ::Couchbase::Management::Options::Analytics::DropDataverse
880
+
881
+ # @api private
882
+ # TODO: deprecate after 3.2
883
+ CreateDatasetOptions = ::Couchbase::Management::Options::Analytics::CreateDataset
884
+
885
+ # @api private
886
+ # TODO: deprecate after 3.2
887
+ DropDatasetOptions = ::Couchbase::Management::Options::Analytics::DropDataset
888
+
889
+ # @api private
890
+ # TODO: deprecate after 3.2
891
+ GetAllDatasetsOptions = ::Couchbase::Management::Options::Analytics::GetAllDatasets
892
+
893
+ # @api private
894
+ # TODO: deprecate after 3.2
895
+ CreateIndexOptions = ::Couchbase::Management::Options::Analytics::CreateIndex
896
+
897
+ # @api private
898
+ # TODO: deprecate after 3.2
899
+ DropIndexOptions = ::Couchbase::Management::Options::Analytics::DropIndex
900
+
901
+ # @api private
902
+ # TODO: deprecate after 3.2
903
+ GetAllIndexesOptions = ::Couchbase::Management::Options::Analytics::GetAllIndexes
904
+
905
+ # @api private
906
+ # TODO: deprecate after 3.2
907
+ ConnectLinkOptions = ::Couchbase::Management::Options::Analytics::ConnectLink
908
+
909
+ # @api private
910
+ # TODO: deprecate after 3.2
911
+ GetPendingMutationsOptions = ::Couchbase::Management::Options::Analytics::GetPendingMutations
912
+ end
913
+
914
+ class AnalyticsDataset
915
+ # @return [String]
916
+ attr_accessor :name
917
+
918
+ # @return [String]
919
+ attr_accessor :dataverse_name
920
+
921
+ # @return [String]
922
+ attr_accessor :link_name
923
+
924
+ # @return [String]
925
+ attr_accessor :bucket_name
926
+
927
+ # @yieldparam [AnalyticsDataset]
928
+ def initialize
929
+ yield self if block_given?
930
+ end
931
+ end
932
+
933
+ class AnalyticsIndex
934
+ # @return [String]
935
+ attr_accessor :name
936
+
937
+ # @return [String]
938
+ attr_accessor :dataset_name
939
+
940
+ # @return [String]
941
+ attr_accessor :dataverse_name
942
+
943
+ # @return [Boolean]
944
+ attr_accessor :is_primary
945
+ alias primary? is_primary
946
+
947
+ # @yieldparam [AnalyticsIndex]
948
+ def initialize
949
+ yield self if block_given?
950
+ end
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
1126
+ end
1127
+ end