couchbase 3.9.0-aarch64-mingw-ucrt
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE.txt +202 -0
- data/README.md +154 -0
- data/ext/extconf.rb +0 -0
- data/lib/active_support/cache/couchbase_store.rb +407 -0
- data/lib/couchbase/3.4/libcouchbase.so +0 -0
- data/lib/couchbase/4.0/libcouchbase.so +0 -0
- data/lib/couchbase/analytics_options.rb +109 -0
- data/lib/couchbase/authenticator.rb +80 -0
- data/lib/couchbase/binary_collection.rb +145 -0
- data/lib/couchbase/binary_collection_options.rb +26 -0
- data/lib/couchbase/bucket.rb +173 -0
- data/lib/couchbase/cluster.rb +555 -0
- data/lib/couchbase/cluster_registry.rb +49 -0
- data/lib/couchbase/collection.rb +770 -0
- data/lib/couchbase/collection_options.rb +401 -0
- data/lib/couchbase/config_profiles.rb +57 -0
- data/lib/couchbase/configuration.rb +58 -0
- data/lib/couchbase/datastructures/couchbase_list.rb +192 -0
- data/lib/couchbase/datastructures/couchbase_map.rb +231 -0
- data/lib/couchbase/datastructures/couchbase_queue.rb +161 -0
- data/lib/couchbase/datastructures/couchbase_set.rb +145 -0
- data/lib/couchbase/datastructures.rb +26 -0
- data/lib/couchbase/deprecations.rb +61 -0
- data/lib/couchbase/diagnostics.rb +183 -0
- data/lib/couchbase/errors.rb +438 -0
- data/lib/couchbase/fork_hooks.rb +41 -0
- data/lib/couchbase/get_replica_strategy.rb +89 -0
- data/lib/couchbase/json_transcoder.rb +41 -0
- data/lib/couchbase/key_value_scan.rb +119 -0
- data/lib/couchbase/libcouchbase.rb +6 -0
- data/lib/couchbase/logger.rb +87 -0
- data/lib/couchbase/management/analytics_index_manager.rb +1160 -0
- data/lib/couchbase/management/bucket_manager.rb +479 -0
- data/lib/couchbase/management/collection_manager.rb +515 -0
- data/lib/couchbase/management/collection_query_index_manager.rb +247 -0
- data/lib/couchbase/management/query_index_manager.rb +671 -0
- data/lib/couchbase/management/scope_search_index_manager.rb +267 -0
- data/lib/couchbase/management/search_index_manager.rb +649 -0
- data/lib/couchbase/management/user_manager.rb +639 -0
- data/lib/couchbase/management/view_index_manager.rb +332 -0
- data/lib/couchbase/management.rb +31 -0
- data/lib/couchbase/metrics/logging_meter.rb +108 -0
- data/lib/couchbase/metrics/logging_value_recorder.rb +50 -0
- data/lib/couchbase/metrics/meter.rb +27 -0
- data/lib/couchbase/metrics/noop_meter.rb +30 -0
- data/lib/couchbase/metrics/noop_value_recorder.rb +27 -0
- data/lib/couchbase/metrics/value_recorder.rb +25 -0
- data/lib/couchbase/mutation_state.rb +65 -0
- data/lib/couchbase/options.rb +3097 -0
- data/lib/couchbase/protostellar/binary_collection.rb +55 -0
- data/lib/couchbase/protostellar/bucket.rb +59 -0
- data/lib/couchbase/protostellar/client.rb +97 -0
- data/lib/couchbase/protostellar/cluster.rb +182 -0
- data/lib/couchbase/protostellar/collection.rb +156 -0
- data/lib/couchbase/protostellar/connect_options.rb +63 -0
- data/lib/couchbase/protostellar/error_handling.rb +204 -0
- data/lib/couchbase/protostellar/generated/admin/analytics/v1/analytics_pb.rb +54 -0
- data/lib/couchbase/protostellar/generated/admin/analytics/v1/analytics_services_pb.rb +51 -0
- data/lib/couchbase/protostellar/generated/admin/bucket/v1/bucket_pb.rb +42 -0
- data/lib/couchbase/protostellar/generated/admin/bucket/v1/bucket_services_pb.rb +51 -0
- data/lib/couchbase/protostellar/generated/admin/collection/v1/collection_pb.rb +38 -0
- data/lib/couchbase/protostellar/generated/admin/collection/v1/collection_services_pb.rb +52 -0
- data/lib/couchbase/protostellar/generated/admin/query/v1/query_pb.rb +42 -0
- data/lib/couchbase/protostellar/generated/admin/query/v1/query_services_pb.rb +55 -0
- data/lib/couchbase/protostellar/generated/admin/search/v1/search_pb.rb +51 -0
- data/lib/couchbase/protostellar/generated/admin/search/v1/search_services_pb.rb +67 -0
- data/lib/couchbase/protostellar/generated/analytics/v1/analytics_pb.rb +31 -0
- data/lib/couchbase/protostellar/generated/analytics/v1/analytics_services_pb.rb +40 -0
- data/lib/couchbase/protostellar/generated/internal/hooks/v1/hooks_pb.rb +51 -0
- data/lib/couchbase/protostellar/generated/internal/hooks/v1/hooks_services_pb.rb +54 -0
- data/lib/couchbase/protostellar/generated/internal/xdcr/v1/xdcr_pb.rb +46 -0
- data/lib/couchbase/protostellar/generated/internal/xdcr/v1/xdcr_services_pb.rb +56 -0
- data/lib/couchbase/protostellar/generated/kv/v1/kv_pb.rb +74 -0
- data/lib/couchbase/protostellar/generated/kv/v1/kv_services_pb.rb +93 -0
- data/lib/couchbase/protostellar/generated/query/v1/query_pb.rb +35 -0
- data/lib/couchbase/protostellar/generated/query/v1/query_services_pb.rb +40 -0
- data/lib/couchbase/protostellar/generated/routing/v2/routing_pb.rb +26 -0
- data/lib/couchbase/protostellar/generated/routing/v2/routing_services_pb.rb +43 -0
- data/lib/couchbase/protostellar/generated/search/v1/search_pb.rb +78 -0
- data/lib/couchbase/protostellar/generated/search/v1/search_services_pb.rb +41 -0
- data/lib/couchbase/protostellar/generated/transactions/v1/transactions_pb.rb +36 -0
- data/lib/couchbase/protostellar/generated/transactions/v1/transactions_services_pb.rb +66 -0
- data/lib/couchbase/protostellar/generated/view/v1/view_pb.rb +30 -0
- data/lib/couchbase/protostellar/generated/view/v1/view_services_pb.rb +39 -0
- data/lib/couchbase/protostellar/generated.rb +9 -0
- data/lib/couchbase/protostellar/management/bucket_manager.rb +67 -0
- data/lib/couchbase/protostellar/management/collection_manager.rb +94 -0
- data/lib/couchbase/protostellar/management/collection_query_index_manager.rb +124 -0
- data/lib/couchbase/protostellar/management/query_index_manager.rb +112 -0
- data/lib/couchbase/protostellar/management.rb +24 -0
- data/lib/couchbase/protostellar/request.rb +79 -0
- data/lib/couchbase/protostellar/request_behaviour.rb +42 -0
- data/lib/couchbase/protostellar/request_generator/admin/bucket.rb +124 -0
- data/lib/couchbase/protostellar/request_generator/admin/collection.rb +96 -0
- data/lib/couchbase/protostellar/request_generator/admin/query.rb +132 -0
- data/lib/couchbase/protostellar/request_generator/admin.rb +24 -0
- data/lib/couchbase/protostellar/request_generator/kv.rb +488 -0
- data/lib/couchbase/protostellar/request_generator/query.rb +133 -0
- data/lib/couchbase/protostellar/request_generator/search.rb +403 -0
- data/lib/couchbase/protostellar/request_generator.rb +26 -0
- data/lib/couchbase/protostellar/response_converter/admin/bucket.rb +55 -0
- data/lib/couchbase/protostellar/response_converter/admin/collection.rb +42 -0
- data/lib/couchbase/protostellar/response_converter/admin/query.rb +59 -0
- data/lib/couchbase/protostellar/response_converter/admin.rb +24 -0
- data/lib/couchbase/protostellar/response_converter/kv.rb +151 -0
- data/lib/couchbase/protostellar/response_converter/query.rb +84 -0
- data/lib/couchbase/protostellar/response_converter/search.rb +136 -0
- data/lib/couchbase/protostellar/response_converter.rb +26 -0
- data/lib/couchbase/protostellar/retry/action.rb +38 -0
- data/lib/couchbase/protostellar/retry/orchestrator.rb +61 -0
- data/lib/couchbase/protostellar/retry/reason.rb +67 -0
- data/lib/couchbase/protostellar/retry/strategies/best_effort.rb +49 -0
- data/lib/couchbase/protostellar/retry/strategies/fail_fast.rb +33 -0
- data/lib/couchbase/protostellar/retry/strategies.rb +27 -0
- data/lib/couchbase/protostellar/retry.rb +28 -0
- data/lib/couchbase/protostellar/scope.rb +61 -0
- data/lib/couchbase/protostellar/timeout_defaults.rb +30 -0
- data/lib/couchbase/protostellar/timeouts.rb +83 -0
- data/lib/couchbase/protostellar.rb +29 -0
- data/lib/couchbase/query_options.rb +122 -0
- data/lib/couchbase/railtie.rb +47 -0
- data/lib/couchbase/raw_binary_transcoder.rb +39 -0
- data/lib/couchbase/raw_json_transcoder.rb +40 -0
- data/lib/couchbase/raw_string_transcoder.rb +42 -0
- data/lib/couchbase/scope.rb +272 -0
- data/lib/couchbase/search_options.rb +1744 -0
- data/lib/couchbase/subdoc.rb +293 -0
- data/lib/couchbase/tracing/noop_span.rb +29 -0
- data/lib/couchbase/tracing/noop_tracer.rb +29 -0
- data/lib/couchbase/tracing/request_span.rb +34 -0
- data/lib/couchbase/tracing/request_tracer.rb +28 -0
- data/lib/couchbase/tracing/threshold_logging_span.rb +112 -0
- data/lib/couchbase/tracing/threshold_logging_tracer.rb +231 -0
- data/lib/couchbase/transcoder_flags.rb +64 -0
- data/lib/couchbase/utils/generic_logger_adapter.rb +40 -0
- data/lib/couchbase/utils/hdr_histogram.rb +55 -0
- data/lib/couchbase/utils/observability.rb +263 -0
- data/lib/couchbase/utils/observability_constants.rb +200 -0
- data/lib/couchbase/utils/stdlib_logger_adapter.rb +65 -0
- data/lib/couchbase/utils/time.rb +71 -0
- data/lib/couchbase/utils.rb +23 -0
- data/lib/couchbase/version.rb +25 -0
- data/lib/couchbase/view_options.rb +67 -0
- data/lib/couchbase.rb +32 -0
- data/lib/rails/generators/couchbase/config/config_generator.rb +29 -0
- metadata +209 -0
|
@@ -0,0 +1,639 @@
|
|
|
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
|
+
require "time"
|
|
21
|
+
|
|
22
|
+
module Couchbase
|
|
23
|
+
module Management
|
|
24
|
+
module Options
|
|
25
|
+
module User
|
|
26
|
+
# Options for {UserManager#get_user}
|
|
27
|
+
class GetUser < ::Couchbase::Options::Base
|
|
28
|
+
# @return [:local, :external] Name of the user's domain. Defaults to +:local+
|
|
29
|
+
attr_accessor :domain
|
|
30
|
+
|
|
31
|
+
# Creates an instance of options for {UserManager#get_user}
|
|
32
|
+
# @param [:local, :external] domain the name of the user's domain. Defaults to +:local+
|
|
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 [Span, nil] parent_span if set holds the parent span, that should be used for this request
|
|
36
|
+
#
|
|
37
|
+
# @yieldparam [GetUser] self
|
|
38
|
+
def initialize(domain: :local,
|
|
39
|
+
timeout: nil,
|
|
40
|
+
retry_strategy: nil,
|
|
41
|
+
parent_span: nil)
|
|
42
|
+
super(timeout: timeout, retry_strategy: retry_strategy, parent_span: parent_span)
|
|
43
|
+
@domain = domain
|
|
44
|
+
yield self if block_given?
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# @api private
|
|
48
|
+
DEFAULT = GetUser.new.freeze
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# Options for {UserManager#get_all_users}
|
|
52
|
+
class GetAllUsers < ::Couchbase::Options::Base
|
|
53
|
+
# @return [:local, :external] Name of the user's domain. Defaults to +:local+
|
|
54
|
+
attr_accessor :domain
|
|
55
|
+
|
|
56
|
+
# Creates an instance of options for {UserManager#get_all_users}
|
|
57
|
+
# @param [:local, :external] the name of the user's domain. Defaults to +:local+
|
|
58
|
+
# @param [Integer, #in_milliseconds, nil] timeout the time in milliseconds allowed for the operation to complete
|
|
59
|
+
# @param [Symbol, nil] retry_strategy ignored by this operation
|
|
60
|
+
# @param [Span, nil] parent_span if set holds the parent span, that should be used for this request
|
|
61
|
+
#
|
|
62
|
+
# @yieldparam [GetAllUsers] self
|
|
63
|
+
def initialize(domain: :local,
|
|
64
|
+
timeout: nil,
|
|
65
|
+
retry_strategy: nil,
|
|
66
|
+
parent_span: nil)
|
|
67
|
+
super(timeout: timeout, retry_strategy: retry_strategy, parent_span: parent_span)
|
|
68
|
+
@domain = domain
|
|
69
|
+
yield self if block_given?
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
# Options for {UserManager#upsert_user}
|
|
74
|
+
class UpsertUser < ::Couchbase::Options::Base
|
|
75
|
+
# @return [:local, :external] Name of the user's domain. Defaults to +:local+
|
|
76
|
+
attr_accessor :domain
|
|
77
|
+
|
|
78
|
+
# Creates an instance of options for {UserManager#upsert_user}
|
|
79
|
+
# @param [:local, :external] domain the name of the user's domain. Defaults to +:local+
|
|
80
|
+
# @param [Integer, #in_milliseconds, nil] timeout the time in milliseconds allowed for the operation to complete
|
|
81
|
+
# @param [Symbol, nil] retry_strategy ignored by this operation
|
|
82
|
+
# @param [Span, nil] parent_span if set holds the parent span, that should be used for this request
|
|
83
|
+
#
|
|
84
|
+
# @yieldparam [UpsertUser] self
|
|
85
|
+
def initialize(domain: :local,
|
|
86
|
+
timeout: nil,
|
|
87
|
+
retry_strategy: nil,
|
|
88
|
+
parent_span: nil)
|
|
89
|
+
super(timeout: timeout, retry_strategy: retry_strategy, parent_span: parent_span)
|
|
90
|
+
@domain = domain
|
|
91
|
+
yield self if block_given?
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
# @api private
|
|
95
|
+
DEFAULT = UpsertUser.new.freeze
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
# Options for {UserManager#drop_user}
|
|
99
|
+
class DropUser < ::Couchbase::Options::Base
|
|
100
|
+
# @return [:local, :external] Name of the user's domain. Defaults to +:local+
|
|
101
|
+
attr_accessor :domain
|
|
102
|
+
|
|
103
|
+
# Creates an instance of options for {UserManager#drop_user}
|
|
104
|
+
# @param [:local, :external] domain the name of the user's domain. Defaults to +:local+
|
|
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 [Span, nil] parent_span if set holds the parent span, that should be used for this request
|
|
108
|
+
#
|
|
109
|
+
# @yieldparam [DropUser] self
|
|
110
|
+
def initialize(domain: :local,
|
|
111
|
+
timeout: nil,
|
|
112
|
+
retry_strategy: nil,
|
|
113
|
+
parent_span: nil)
|
|
114
|
+
super(timeout: timeout, retry_strategy: retry_strategy, parent_span: parent_span)
|
|
115
|
+
@domain = domain
|
|
116
|
+
yield self if block_given?
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
# @api private
|
|
120
|
+
DEFAULT = DropUser.new.freeze
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
# Options for {UserManager#change_password}
|
|
124
|
+
class ChangePassword < ::Couchbase::Options::Base
|
|
125
|
+
# Creates an instance of options for {UserManager#change_password}
|
|
126
|
+
# @param [Integer, #in_milliseconds, nil] timeout the time in milliseconds allowed for the operation to complete
|
|
127
|
+
# @param [Symbol, nil] retry_strategy ignored by this operation
|
|
128
|
+
# @param [Span, nil] parent_span if set holds the parent span, that should be used for this request
|
|
129
|
+
#
|
|
130
|
+
# @yieldparam [ChangePassword] self
|
|
131
|
+
def initialize(timeout: nil,
|
|
132
|
+
retry_strategy: nil,
|
|
133
|
+
parent_span: nil)
|
|
134
|
+
super
|
|
135
|
+
yield self if block_given?
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
# @api private
|
|
139
|
+
DEFAULT = ChangePassword.new.freeze
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
# Options for {UserManager#get_roles}
|
|
143
|
+
class GetRoles < ::Couchbase::Options::Base
|
|
144
|
+
# Creates an instance of options for {UserManager#get_roles}
|
|
145
|
+
# @param [Integer, #in_milliseconds, nil] timeout the time in milliseconds allowed for the operation to complete
|
|
146
|
+
# @param [Symbol, nil] retry_strategy ignored by this operation
|
|
147
|
+
# @param [Span, nil] parent_span if set holds the parent span, that should be used for this request
|
|
148
|
+
#
|
|
149
|
+
# @yieldparam [GetRoles] self
|
|
150
|
+
def initialize(timeout: nil,
|
|
151
|
+
retry_strategy: nil,
|
|
152
|
+
parent_span: nil)
|
|
153
|
+
super
|
|
154
|
+
yield self if block_given?
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
# @api private
|
|
158
|
+
DEFAULT = GetRoles.new.freeze
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
# Options for {UserManager#get_group}
|
|
162
|
+
class GetGroup < ::Couchbase::Options::Base
|
|
163
|
+
# Creates an instance of options for {UserManager#get_group}
|
|
164
|
+
# @param [Integer, #in_milliseconds, nil] timeout the time in milliseconds allowed for the operation to complete
|
|
165
|
+
# @param [Symbol, nil] retry_strategy ignored by this operation
|
|
166
|
+
# @param [Span, nil] parent_span if set holds the parent span, that should be used for this request
|
|
167
|
+
#
|
|
168
|
+
# @yieldparam [GetGroup] self
|
|
169
|
+
def initialize(timeout: nil,
|
|
170
|
+
retry_strategy: nil,
|
|
171
|
+
parent_span: nil)
|
|
172
|
+
super
|
|
173
|
+
yield self if block_given?
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
# @api private
|
|
177
|
+
DEFAULT = GetGroup.new.freeze
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
# Options for {UserManager#get_all_groups}
|
|
181
|
+
class GetAllGroups < ::Couchbase::Options::Base
|
|
182
|
+
# Creates an instance of options for {UserManager#get_all_groups}
|
|
183
|
+
# @param [Integer, #in_milliseconds, nil] timeout the time in milliseconds allowed for the operation to complete
|
|
184
|
+
# @param [Symbol, nil] retry_strategy ignored by this operation
|
|
185
|
+
# @param [Span, nil] parent_span if set holds the parent span, that should be used for this request
|
|
186
|
+
#
|
|
187
|
+
# @yieldparam [GetAllGroups] self
|
|
188
|
+
def initialize(timeout: nil,
|
|
189
|
+
retry_strategy: nil,
|
|
190
|
+
parent_span: nil)
|
|
191
|
+
super
|
|
192
|
+
yield self if block_given?
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
# @api private
|
|
196
|
+
DEFAULT = GetAllGroups.new.freeze
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
# Options for {UserManager#upsert_group}
|
|
200
|
+
class UpsertGroup < ::Couchbase::Options::Base
|
|
201
|
+
# Creates an instance of options for {UserManager#upsert_group}
|
|
202
|
+
# @param [Integer, #in_milliseconds, nil] timeout the time in milliseconds allowed for the operation to complete
|
|
203
|
+
# @param [Symbol, nil] retry_strategy ignored by this operation
|
|
204
|
+
# @param [Span, nil] parent_span if set holds the parent span, that should be used for this request
|
|
205
|
+
#
|
|
206
|
+
# @yieldparam [UpsertGroup] self
|
|
207
|
+
def initialize(timeout: nil,
|
|
208
|
+
retry_strategy: nil,
|
|
209
|
+
parent_span: nil)
|
|
210
|
+
super
|
|
211
|
+
yield self if block_given?
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
# @api private
|
|
215
|
+
DEFAULT = UpsertGroup.new.freeze
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
# Options for {UserManager#drop_group}
|
|
219
|
+
class DropGroup < ::Couchbase::Options::Base
|
|
220
|
+
# Creates an instance of options for {UserManager#drop_group}
|
|
221
|
+
# @param [Integer, #in_milliseconds, nil] timeout the time in milliseconds allowed for the operation to complete
|
|
222
|
+
# @param [Symbol, nil] retry_strategy ignored by this operation
|
|
223
|
+
# @param [Span, nil] parent_span if set holds the parent span, that should be used for this request
|
|
224
|
+
#
|
|
225
|
+
# @yieldparam [DropGroup] self
|
|
226
|
+
def initialize(timeout: nil,
|
|
227
|
+
retry_strategy: nil,
|
|
228
|
+
parent_span: nil)
|
|
229
|
+
super
|
|
230
|
+
yield self if block_given?
|
|
231
|
+
end
|
|
232
|
+
|
|
233
|
+
# @api private
|
|
234
|
+
DEFAULT = DropGroup.new.freeze
|
|
235
|
+
end
|
|
236
|
+
end
|
|
237
|
+
end
|
|
238
|
+
|
|
239
|
+
class UserManager
|
|
240
|
+
alias inspect to_s
|
|
241
|
+
|
|
242
|
+
# @param [Couchbase::Backend] backend
|
|
243
|
+
# @param [Couchbase::Observability::Wrapper] observability wrapper
|
|
244
|
+
#
|
|
245
|
+
# @api private
|
|
246
|
+
def initialize(backend, observability)
|
|
247
|
+
@backend = backend
|
|
248
|
+
@observability = observability
|
|
249
|
+
end
|
|
250
|
+
|
|
251
|
+
# Get a user
|
|
252
|
+
#
|
|
253
|
+
# @param [String] username ID of the user
|
|
254
|
+
# @param [Options::User::GetUser] options
|
|
255
|
+
#
|
|
256
|
+
# @return [UserAndMetadata]
|
|
257
|
+
#
|
|
258
|
+
# @raise [ArgumentError]
|
|
259
|
+
# @raise [Error::UserNotFound]
|
|
260
|
+
def get_user(username, options = Options::User::GetUser::DEFAULT)
|
|
261
|
+
@observability.record_operation(Observability::OP_UM_GET_USER, options.parent_span, self, :management) do |obs_handler|
|
|
262
|
+
resp = @backend.user_get(options.domain, username, options.timeout, obs_handler)
|
|
263
|
+
extract_user(resp)
|
|
264
|
+
end
|
|
265
|
+
end
|
|
266
|
+
|
|
267
|
+
# Gets all users
|
|
268
|
+
#
|
|
269
|
+
# @param [Options::User::GetAllUsers] options
|
|
270
|
+
#
|
|
271
|
+
# @return [Array<UserAndMetadata>]
|
|
272
|
+
def get_all_users(options = Options::User::GetAllUsers::DEFAULT)
|
|
273
|
+
@observability.record_operation(Observability::OP_UM_GET_ALL_USERS, options.parent_span, self, :management) do |obs_handler|
|
|
274
|
+
resp = @backend.user_get_all(options.domain, options.timeout, obs_handler)
|
|
275
|
+
resp.map { |entry| extract_user(entry) }
|
|
276
|
+
end
|
|
277
|
+
end
|
|
278
|
+
|
|
279
|
+
# Creates or updates a user
|
|
280
|
+
#
|
|
281
|
+
# @param [User] user the new version of the user
|
|
282
|
+
# @param [Options::User::UpsertUser] options
|
|
283
|
+
#
|
|
284
|
+
# @raise [ArgumentError]
|
|
285
|
+
def upsert_user(user, options = Options::User::UpsertUser::DEFAULT)
|
|
286
|
+
@observability.record_operation(Observability::OP_UM_UPSERT_USER, options.parent_span, self, :management) do |obs_handler|
|
|
287
|
+
@backend.user_upsert(
|
|
288
|
+
options.domain,
|
|
289
|
+
{
|
|
290
|
+
username: user.username,
|
|
291
|
+
display_name: user.display_name,
|
|
292
|
+
groups: user.groups,
|
|
293
|
+
password: user.password,
|
|
294
|
+
roles: user.roles.map do |role|
|
|
295
|
+
{
|
|
296
|
+
name: role.name,
|
|
297
|
+
bucket: role.bucket,
|
|
298
|
+
scope: role.scope,
|
|
299
|
+
collection: role.collection,
|
|
300
|
+
}
|
|
301
|
+
end,
|
|
302
|
+
},
|
|
303
|
+
options.timeout,
|
|
304
|
+
obs_handler,
|
|
305
|
+
)
|
|
306
|
+
end
|
|
307
|
+
end
|
|
308
|
+
|
|
309
|
+
# Removes a user
|
|
310
|
+
#
|
|
311
|
+
# @param [String] username ID of the user
|
|
312
|
+
# @param [Options::User::DropUser] options
|
|
313
|
+
def drop_user(username, options = Options::User::DropUser::DEFAULT)
|
|
314
|
+
@observability.record_operation(Observability::OP_UM_DROP_USER, options.parent_span, self, :management) do |obs_handler|
|
|
315
|
+
@backend.user_drop(options.domain, username, options.timeout, obs_handler)
|
|
316
|
+
end
|
|
317
|
+
end
|
|
318
|
+
|
|
319
|
+
# Gets all roles supported by the server
|
|
320
|
+
#
|
|
321
|
+
# @param [Options::User::GetRoles] options
|
|
322
|
+
#
|
|
323
|
+
# @return [Array<RoleAndDescription>]
|
|
324
|
+
def get_roles(options = Options::User::GetRoles::DEFAULT)
|
|
325
|
+
@observability.record_operation(Observability::OP_UM_GET_ROLES, options.parent_span, self, :management) do |obs_handler|
|
|
326
|
+
resp = @backend.role_get_all(options.timeout, obs_handler)
|
|
327
|
+
resp.map do |r|
|
|
328
|
+
RoleAndDescription.new do |role|
|
|
329
|
+
role.name = r[:name]
|
|
330
|
+
role.display_name = r[:display_name]
|
|
331
|
+
role.description = r[:description]
|
|
332
|
+
role.bucket = r[:bucket]
|
|
333
|
+
role.scope = r[:scope]
|
|
334
|
+
role.collection = r[:collection]
|
|
335
|
+
end
|
|
336
|
+
end
|
|
337
|
+
end
|
|
338
|
+
end
|
|
339
|
+
|
|
340
|
+
# Changes the password of the currently authenticated user
|
|
341
|
+
#
|
|
342
|
+
# @param [Options::User::ChangePassword] options
|
|
343
|
+
#
|
|
344
|
+
# @raise [ArgumentError]
|
|
345
|
+
def change_password(new_password, options = Options::User::ChangePassword::DEFAULT)
|
|
346
|
+
@observability.record_operation(Observability::OP_UM_CHANGE_PASSWORD, options.parent_span, self, :management) do |obs_handler|
|
|
347
|
+
@backend.change_password(new_password, options.timeout, obs_handler)
|
|
348
|
+
end
|
|
349
|
+
end
|
|
350
|
+
|
|
351
|
+
# Gets a group
|
|
352
|
+
#
|
|
353
|
+
# @param [String] group_name name of the group to get
|
|
354
|
+
# @param [Options::User::GetGroup] options
|
|
355
|
+
#
|
|
356
|
+
# @return [Group]
|
|
357
|
+
#
|
|
358
|
+
# @raise [ArgumentError]
|
|
359
|
+
# @raise [Error::GroupNotFound]
|
|
360
|
+
def get_group(group_name, options = Options::User::GetGroup::DEFAULT)
|
|
361
|
+
@observability.record_operation(Observability::OP_UM_GET_GROUP, options.parent_span, self, :management) do |obs_handler|
|
|
362
|
+
resp = @backend.group_get(group_name, options.timeout, obs_handler)
|
|
363
|
+
extract_group(resp)
|
|
364
|
+
end
|
|
365
|
+
end
|
|
366
|
+
|
|
367
|
+
# Gets all groups
|
|
368
|
+
#
|
|
369
|
+
# @param [Options::User::GetAllGroups] options
|
|
370
|
+
#
|
|
371
|
+
# @return [Array<Group>]
|
|
372
|
+
def get_all_groups(options = Options::User::GetAllGroups::DEFAULT)
|
|
373
|
+
@observability.record_operation(Observability::OP_UM_GET_ALL_GROUPS, options.parent_span, self, :management) do |obs_handler|
|
|
374
|
+
resp = @backend.group_get_all(options.timeout, obs_handler)
|
|
375
|
+
resp.map { |entry| extract_group(entry) }
|
|
376
|
+
end
|
|
377
|
+
end
|
|
378
|
+
|
|
379
|
+
# Creates or updates a group
|
|
380
|
+
#
|
|
381
|
+
# @param [Group] group the new version of the group
|
|
382
|
+
# @param [Options::User::UpsertGroup] options
|
|
383
|
+
#
|
|
384
|
+
# @raise [ArgumentError]
|
|
385
|
+
# @raise [Error::GroupNotFound]
|
|
386
|
+
def upsert_group(group, options = Options::User::UpsertGroup::DEFAULT)
|
|
387
|
+
@observability.record_operation(Observability::OP_UM_UPSERT_GROUP, options.parent_span, self, :management) do |obs_handler|
|
|
388
|
+
@backend.group_upsert({
|
|
389
|
+
name: group.name,
|
|
390
|
+
description: group.description,
|
|
391
|
+
ldap_group_reference: group.ldap_group_reference,
|
|
392
|
+
roles: group.roles.map do |role|
|
|
393
|
+
{
|
|
394
|
+
name: role.name,
|
|
395
|
+
bucket: role.bucket,
|
|
396
|
+
scope: role.scope,
|
|
397
|
+
collection: role.collection,
|
|
398
|
+
}
|
|
399
|
+
end,
|
|
400
|
+
}, options.timeout, obs_handler)
|
|
401
|
+
end
|
|
402
|
+
end
|
|
403
|
+
|
|
404
|
+
# Removes a group
|
|
405
|
+
#
|
|
406
|
+
# @param [String] group_name name of the group
|
|
407
|
+
# @param [Options::User::DropGroup] options
|
|
408
|
+
#
|
|
409
|
+
# @raise [Error::GroupNotFound]
|
|
410
|
+
def drop_group(group_name, options = Options::User::DropGroup::DEFAULT)
|
|
411
|
+
@observability.record_operation(Observability::OP_UM_DROP_GROUP, options.parent_span, self, :management) do |obs_handler|
|
|
412
|
+
@backend.group_drop(group_name, options.timeout, obs_handler)
|
|
413
|
+
end
|
|
414
|
+
end
|
|
415
|
+
|
|
416
|
+
# @api private
|
|
417
|
+
# @deprecated Use {Couchbase::Management::Options::User::GetUser} instead
|
|
418
|
+
GetUserOptions = ::Couchbase::Management::Options::User::GetUser
|
|
419
|
+
|
|
420
|
+
# @api private
|
|
421
|
+
# @deprecated Use {Couchbase::Management::Options::User::GetAllUsers} instead
|
|
422
|
+
GetAllUsersOptions = ::Couchbase::Management::Options::User::GetAllUsers
|
|
423
|
+
|
|
424
|
+
# @api private
|
|
425
|
+
# @deprecated Use {Couchbase::Management::Options::User::UpsertUser} instead
|
|
426
|
+
UpsertUserOptions = ::Couchbase::Management::Options::User::UpsertUser
|
|
427
|
+
|
|
428
|
+
# @api private
|
|
429
|
+
# @deprecated Use {Couchbase::Management::Options::User::DropUser} instead
|
|
430
|
+
DropUserOptions = ::Couchbase::Management::Options::User::DropUser
|
|
431
|
+
|
|
432
|
+
# @api private
|
|
433
|
+
# @deprecated Use {Couchbase::Management::Options::User::ChangePassword} instead
|
|
434
|
+
ChangePasswordOptions = ::Couchbase::Management::Options::User::ChangePassword
|
|
435
|
+
|
|
436
|
+
# @api private
|
|
437
|
+
# @deprecated Use {Couchbase::Management::Options::User::GetRoles} instead
|
|
438
|
+
GetRolesOptions = ::Couchbase::Management::Options::User::GetRoles
|
|
439
|
+
|
|
440
|
+
# @api private
|
|
441
|
+
# @deprecated Use {Couchbase::Management::Options::User::GetGroup} instead
|
|
442
|
+
GetGroupOptions = ::Couchbase::Management::Options::User::GetGroup
|
|
443
|
+
|
|
444
|
+
# @api private
|
|
445
|
+
# @deprecated Use {Couchbase::Management::Options::User::GetAllGroups} instead
|
|
446
|
+
GetAllGroupsOptions = ::Couchbase::Management::Options::User::GetAllGroups
|
|
447
|
+
|
|
448
|
+
# @api private
|
|
449
|
+
# @deprecated Use {Couchbase::Management::Options::User::UpsertGroup} instead
|
|
450
|
+
UpsertGroupOptions = ::Couchbase::Management::Options::User::UpsertGroup
|
|
451
|
+
|
|
452
|
+
# @api private
|
|
453
|
+
# @deprecated Use {Couchbase::Management::Options::User::DropGroup} instead
|
|
454
|
+
DropGroupOptions = ::Couchbase::Management::Options::User::DropGroup
|
|
455
|
+
|
|
456
|
+
private
|
|
457
|
+
|
|
458
|
+
def extract_group(resp)
|
|
459
|
+
Group.new do |group|
|
|
460
|
+
group.name = resp[:name]
|
|
461
|
+
group.description = resp[:description]
|
|
462
|
+
group.ldap_group_reference = resp[:ldap_group_reference]
|
|
463
|
+
if resp[:roles]
|
|
464
|
+
group.roles = resp[:roles].map do |r|
|
|
465
|
+
Role.new do |role|
|
|
466
|
+
role.name = r[:name]
|
|
467
|
+
role.bucket = r[:bucket]
|
|
468
|
+
role.scope = r[:scope]
|
|
469
|
+
role.collection = r[:collection]
|
|
470
|
+
end
|
|
471
|
+
end
|
|
472
|
+
end
|
|
473
|
+
end
|
|
474
|
+
end
|
|
475
|
+
|
|
476
|
+
def extract_user(resp)
|
|
477
|
+
UserAndMetadata.new do |user|
|
|
478
|
+
user.domain = resp[:domain]
|
|
479
|
+
user.username = resp[:username]
|
|
480
|
+
user.display_name = resp[:display_name]
|
|
481
|
+
user.groups = resp[:groups]
|
|
482
|
+
user.external_groups = resp[:external_groups]
|
|
483
|
+
user.password_changed = Time.parse(resp[:password_changed]) if resp[:password_changed]
|
|
484
|
+
if resp[:roles]
|
|
485
|
+
user.roles = resp[:roles].map do |r|
|
|
486
|
+
Role.new do |role|
|
|
487
|
+
role.name = r[:name]
|
|
488
|
+
role.bucket = r[:bucket]
|
|
489
|
+
role.scope = r[:scope]
|
|
490
|
+
role.collection = r[:collection]
|
|
491
|
+
end
|
|
492
|
+
end
|
|
493
|
+
end
|
|
494
|
+
if resp[:effective_roles]
|
|
495
|
+
user.effective_roles = resp[:effective_roles].map do |r|
|
|
496
|
+
RoleAndOrigins.new do |role|
|
|
497
|
+
role.name = r[:name]
|
|
498
|
+
role.bucket = r[:bucket]
|
|
499
|
+
role.scope = r[:scope]
|
|
500
|
+
role.collection = r[:collection]
|
|
501
|
+
if r[:origins]
|
|
502
|
+
role.origins = r[:origins].map do |o|
|
|
503
|
+
Origin.new do |origin|
|
|
504
|
+
origin.type = o[:type]
|
|
505
|
+
origin.name = o[:name]
|
|
506
|
+
end
|
|
507
|
+
end
|
|
508
|
+
end
|
|
509
|
+
end
|
|
510
|
+
end
|
|
511
|
+
end
|
|
512
|
+
end
|
|
513
|
+
end
|
|
514
|
+
end
|
|
515
|
+
|
|
516
|
+
class Role
|
|
517
|
+
# @return [String]
|
|
518
|
+
attr_accessor :name
|
|
519
|
+
|
|
520
|
+
# @return [String]
|
|
521
|
+
attr_accessor :bucket
|
|
522
|
+
|
|
523
|
+
# @return [String]
|
|
524
|
+
attr_accessor :scope
|
|
525
|
+
|
|
526
|
+
# @return [String]
|
|
527
|
+
attr_accessor :collection
|
|
528
|
+
|
|
529
|
+
# @yieldparam [Role] self
|
|
530
|
+
def initialize
|
|
531
|
+
yield self if block_given?
|
|
532
|
+
end
|
|
533
|
+
end
|
|
534
|
+
|
|
535
|
+
class RoleAndDescription < Role
|
|
536
|
+
# @return [String]
|
|
537
|
+
attr_accessor :display_name
|
|
538
|
+
|
|
539
|
+
# @return [String]
|
|
540
|
+
attr_accessor :description
|
|
541
|
+
|
|
542
|
+
# @yieldparam [RoleAndDescription] self
|
|
543
|
+
def initialize
|
|
544
|
+
super
|
|
545
|
+
yield self if block_given?
|
|
546
|
+
end
|
|
547
|
+
end
|
|
548
|
+
|
|
549
|
+
class Origin
|
|
550
|
+
# @return [String]
|
|
551
|
+
attr_writer :type
|
|
552
|
+
|
|
553
|
+
# @return [String]
|
|
554
|
+
attr_writer :name
|
|
555
|
+
|
|
556
|
+
# @yieldparam [Origin] self
|
|
557
|
+
def initialize
|
|
558
|
+
yield self if block_given?
|
|
559
|
+
end
|
|
560
|
+
end
|
|
561
|
+
|
|
562
|
+
class RoleAndOrigins < Role
|
|
563
|
+
# @return [Array<Origin>]
|
|
564
|
+
attr_writer :origins
|
|
565
|
+
|
|
566
|
+
# @yieldparam [RoleAndOrigins] self
|
|
567
|
+
def initialize
|
|
568
|
+
super
|
|
569
|
+
@origins = []
|
|
570
|
+
yield self if block_given?
|
|
571
|
+
end
|
|
572
|
+
end
|
|
573
|
+
|
|
574
|
+
class User
|
|
575
|
+
# @return [String]
|
|
576
|
+
attr_accessor :username
|
|
577
|
+
|
|
578
|
+
# @return [String]
|
|
579
|
+
attr_accessor :display_name
|
|
580
|
+
|
|
581
|
+
# @return [Array<String>]
|
|
582
|
+
attr_accessor :groups
|
|
583
|
+
|
|
584
|
+
# @return [Array<Role>]
|
|
585
|
+
attr_accessor :roles
|
|
586
|
+
|
|
587
|
+
# @return [String]
|
|
588
|
+
attr_accessor :password
|
|
589
|
+
|
|
590
|
+
# @yieldparam [User] self
|
|
591
|
+
def initialize
|
|
592
|
+
@groups = []
|
|
593
|
+
@roles = []
|
|
594
|
+
yield self if block_given?
|
|
595
|
+
end
|
|
596
|
+
end
|
|
597
|
+
|
|
598
|
+
class UserAndMetadata < User
|
|
599
|
+
# @return [:local, :external]
|
|
600
|
+
attr_accessor :domain
|
|
601
|
+
|
|
602
|
+
# @return [Array<RoleAndOrigins>]
|
|
603
|
+
attr_accessor :effective_roles
|
|
604
|
+
|
|
605
|
+
# @return [Time]
|
|
606
|
+
attr_accessor :password_changed
|
|
607
|
+
|
|
608
|
+
# @return [Array<String>]
|
|
609
|
+
attr_accessor :external_groups
|
|
610
|
+
|
|
611
|
+
# @yieldparam [UserAndMetadata] self
|
|
612
|
+
def initialize
|
|
613
|
+
super
|
|
614
|
+
@effective_roles = []
|
|
615
|
+
yield self if block_given?
|
|
616
|
+
end
|
|
617
|
+
end
|
|
618
|
+
|
|
619
|
+
class Group
|
|
620
|
+
# @return [String]
|
|
621
|
+
attr_accessor :name
|
|
622
|
+
|
|
623
|
+
# @return [String]
|
|
624
|
+
attr_accessor :description
|
|
625
|
+
|
|
626
|
+
# @return [Array<Role>]
|
|
627
|
+
attr_accessor :roles
|
|
628
|
+
|
|
629
|
+
# @return [String]
|
|
630
|
+
attr_accessor :ldap_group_reference
|
|
631
|
+
|
|
632
|
+
# @yieldparam [Group] self
|
|
633
|
+
def initialize
|
|
634
|
+
@roles = []
|
|
635
|
+
yield self if block_given?
|
|
636
|
+
end
|
|
637
|
+
end
|
|
638
|
+
end
|
|
639
|
+
end
|