couchbase 3.0.0.alpha.1-universal-darwin-19 → 3.0.0.alpha.2-universal-darwin-19

Sign up to get free protection for your applications and to get access to all the features.
Files changed (176) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/tests-6.0.3.yml +49 -0
  3. data/.github/workflows/tests.yml +47 -0
  4. data/.gitmodules +3 -0
  5. data/.idea/dictionaries/gem_terms.xml +5 -0
  6. data/.idea/inspectionProfiles/Project_Default.xml +1 -0
  7. data/.idea/vcs.xml +1 -0
  8. data/Gemfile +1 -0
  9. data/README.md +55 -2
  10. data/Rakefile +18 -0
  11. data/bin/init-cluster +62 -0
  12. data/bin/setup +1 -0
  13. data/couchbase.gemspec +3 -2
  14. data/examples/crud.rb +1 -2
  15. data/examples/managing_buckets.rb +47 -0
  16. data/examples/managing_collections.rb +58 -0
  17. data/examples/managing_query_indexes.rb +63 -0
  18. data/examples/query.rb +3 -2
  19. data/examples/query_with_consistency.rb +76 -0
  20. data/examples/subdocument.rb +23 -1
  21. data/ext/.clang-format +1 -1
  22. data/ext/.idea/dictionaries/couchbase_terms.xml +2 -0
  23. data/ext/.idea/vcs.xml +1 -0
  24. data/ext/CMakeLists.txt +30 -12
  25. data/ext/build_version.hxx.in +26 -0
  26. data/ext/couchbase/bucket.hxx +69 -8
  27. data/ext/couchbase/cluster.hxx +70 -54
  28. data/ext/couchbase/collections_manifest.hxx +3 -3
  29. data/ext/couchbase/configuration.hxx +14 -0
  30. data/ext/couchbase/couchbase.cxx +2044 -383
  31. data/ext/couchbase/{operations/document_id.hxx → document_id.hxx} +5 -4
  32. data/ext/couchbase/io/http_message.hxx +5 -1
  33. data/ext/couchbase/io/http_parser.hxx +2 -1
  34. data/ext/couchbase/io/http_session.hxx +6 -3
  35. data/ext/couchbase/io/{binary_message.hxx → mcbp_message.hxx} +15 -12
  36. data/ext/couchbase/io/mcbp_parser.hxx +99 -0
  37. data/ext/couchbase/io/{key_value_session.hxx → mcbp_session.hxx} +200 -95
  38. data/ext/couchbase/io/session_manager.hxx +37 -22
  39. data/ext/couchbase/mutation_token.hxx +2 -1
  40. data/ext/couchbase/operations.hxx +38 -8
  41. data/ext/couchbase/operations/bucket_create.hxx +138 -0
  42. data/ext/couchbase/operations/bucket_drop.hxx +65 -0
  43. data/ext/couchbase/operations/bucket_flush.hxx +65 -0
  44. data/ext/couchbase/operations/bucket_get.hxx +69 -0
  45. data/ext/couchbase/operations/bucket_get_all.hxx +62 -0
  46. data/ext/couchbase/operations/bucket_settings.hxx +111 -0
  47. data/ext/couchbase/operations/bucket_update.hxx +115 -0
  48. data/ext/couchbase/operations/cluster_developer_preview_enable.hxx +60 -0
  49. data/ext/couchbase/operations/collection_create.hxx +86 -0
  50. data/ext/couchbase/operations/collection_drop.hxx +82 -0
  51. data/ext/couchbase/operations/command.hxx +10 -10
  52. data/ext/couchbase/operations/document_decrement.hxx +80 -0
  53. data/ext/couchbase/operations/document_exists.hxx +80 -0
  54. data/ext/couchbase/operations/{get.hxx → document_get.hxx} +4 -2
  55. data/ext/couchbase/operations/document_get_and_lock.hxx +64 -0
  56. data/ext/couchbase/operations/document_get_and_touch.hxx +64 -0
  57. data/ext/couchbase/operations/document_increment.hxx +80 -0
  58. data/ext/couchbase/operations/document_insert.hxx +74 -0
  59. data/ext/couchbase/operations/{lookup_in.hxx → document_lookup_in.hxx} +2 -2
  60. data/ext/couchbase/operations/{mutate_in.hxx → document_mutate_in.hxx} +11 -2
  61. data/ext/couchbase/operations/{query.hxx → document_query.hxx} +101 -6
  62. data/ext/couchbase/operations/document_remove.hxx +67 -0
  63. data/ext/couchbase/operations/document_replace.hxx +76 -0
  64. data/ext/couchbase/operations/{upsert.hxx → document_touch.hxx} +14 -14
  65. data/ext/couchbase/operations/{remove.hxx → document_unlock.hxx} +12 -10
  66. data/ext/couchbase/operations/document_upsert.hxx +74 -0
  67. data/ext/couchbase/operations/query_index_build_deferred.hxx +85 -0
  68. data/ext/couchbase/operations/query_index_create.hxx +134 -0
  69. data/ext/couchbase/operations/query_index_drop.hxx +108 -0
  70. data/ext/couchbase/operations/query_index_get_all.hxx +106 -0
  71. data/ext/couchbase/operations/scope_create.hxx +81 -0
  72. data/ext/couchbase/operations/scope_drop.hxx +79 -0
  73. data/ext/couchbase/operations/scope_get_all.hxx +72 -0
  74. data/ext/couchbase/protocol/client_opcode.hxx +35 -0
  75. data/ext/couchbase/protocol/client_request.hxx +56 -9
  76. data/ext/couchbase/protocol/client_response.hxx +52 -15
  77. data/ext/couchbase/protocol/cmd_cluster_map_change_notification.hxx +81 -0
  78. data/ext/couchbase/protocol/cmd_decrement.hxx +187 -0
  79. data/ext/couchbase/protocol/cmd_exists.hxx +171 -0
  80. data/ext/couchbase/protocol/cmd_get.hxx +31 -8
  81. data/ext/couchbase/protocol/cmd_get_and_lock.hxx +142 -0
  82. data/ext/couchbase/protocol/cmd_get_and_touch.hxx +142 -0
  83. data/ext/couchbase/protocol/cmd_get_cluster_config.hxx +16 -3
  84. data/ext/couchbase/protocol/cmd_get_collections_manifest.hxx +16 -3
  85. data/ext/couchbase/protocol/cmd_get_error_map.hxx +16 -3
  86. data/ext/couchbase/protocol/cmd_hello.hxx +24 -8
  87. data/ext/couchbase/protocol/cmd_increment.hxx +187 -0
  88. data/ext/couchbase/protocol/cmd_info.hxx +1 -0
  89. data/ext/couchbase/protocol/cmd_insert.hxx +172 -0
  90. data/ext/couchbase/protocol/cmd_lookup_in.hxx +28 -13
  91. data/ext/couchbase/protocol/cmd_mutate_in.hxx +65 -13
  92. data/ext/couchbase/protocol/cmd_remove.hxx +59 -4
  93. data/ext/couchbase/protocol/cmd_replace.hxx +172 -0
  94. data/ext/couchbase/protocol/cmd_sasl_auth.hxx +15 -3
  95. data/ext/couchbase/protocol/cmd_sasl_list_mechs.hxx +15 -3
  96. data/ext/couchbase/protocol/cmd_sasl_step.hxx +15 -3
  97. data/ext/couchbase/protocol/cmd_select_bucket.hxx +14 -2
  98. data/ext/couchbase/protocol/cmd_touch.hxx +102 -0
  99. data/ext/couchbase/protocol/cmd_unlock.hxx +95 -0
  100. data/ext/couchbase/protocol/cmd_upsert.hxx +50 -14
  101. data/ext/couchbase/protocol/durability_level.hxx +67 -0
  102. data/ext/couchbase/protocol/frame_info_id.hxx +187 -0
  103. data/ext/couchbase/protocol/hello_feature.hxx +137 -0
  104. data/ext/couchbase/protocol/server_opcode.hxx +57 -0
  105. data/ext/couchbase/protocol/server_request.hxx +122 -0
  106. data/ext/couchbase/protocol/unsigned_leb128.h +15 -15
  107. data/ext/couchbase/utils/byteswap.hxx +1 -2
  108. data/ext/couchbase/utils/url_codec.hxx +225 -0
  109. data/ext/couchbase/version.hxx +3 -1
  110. data/ext/extconf.rb +4 -1
  111. data/ext/test/main.cxx +37 -113
  112. data/ext/third_party/snappy/.appveyor.yml +36 -0
  113. data/ext/third_party/snappy/.gitignore +8 -0
  114. data/ext/third_party/snappy/.travis.yml +98 -0
  115. data/ext/third_party/snappy/AUTHORS +1 -0
  116. data/ext/third_party/snappy/CMakeLists.txt +345 -0
  117. data/ext/third_party/snappy/CONTRIBUTING.md +26 -0
  118. data/ext/third_party/snappy/COPYING +54 -0
  119. data/ext/third_party/snappy/NEWS +188 -0
  120. data/ext/third_party/snappy/README.md +148 -0
  121. data/ext/third_party/snappy/cmake/SnappyConfig.cmake.in +33 -0
  122. data/ext/third_party/snappy/cmake/config.h.in +59 -0
  123. data/ext/third_party/snappy/docs/README.md +72 -0
  124. data/ext/third_party/snappy/format_description.txt +110 -0
  125. data/ext/third_party/snappy/framing_format.txt +135 -0
  126. data/ext/third_party/snappy/snappy-c.cc +90 -0
  127. data/ext/third_party/snappy/snappy-c.h +138 -0
  128. data/ext/third_party/snappy/snappy-internal.h +315 -0
  129. data/ext/third_party/snappy/snappy-sinksource.cc +121 -0
  130. data/ext/third_party/snappy/snappy-sinksource.h +182 -0
  131. data/ext/third_party/snappy/snappy-stubs-internal.cc +42 -0
  132. data/ext/third_party/snappy/snappy-stubs-internal.h +493 -0
  133. data/ext/third_party/snappy/snappy-stubs-public.h.in +63 -0
  134. data/ext/third_party/snappy/snappy-test.cc +613 -0
  135. data/ext/third_party/snappy/snappy-test.h +526 -0
  136. data/ext/third_party/snappy/snappy.cc +1770 -0
  137. data/ext/third_party/snappy/snappy.h +209 -0
  138. data/ext/third_party/snappy/snappy_compress_fuzzer.cc +60 -0
  139. data/ext/third_party/snappy/snappy_uncompress_fuzzer.cc +58 -0
  140. data/ext/third_party/snappy/snappy_unittest.cc +1512 -0
  141. data/ext/third_party/snappy/testdata/alice29.txt +3609 -0
  142. data/ext/third_party/snappy/testdata/asyoulik.txt +4122 -0
  143. data/ext/third_party/snappy/testdata/baddata1.snappy +0 -0
  144. data/ext/third_party/snappy/testdata/baddata2.snappy +0 -0
  145. data/ext/third_party/snappy/testdata/baddata3.snappy +0 -0
  146. data/ext/third_party/snappy/testdata/fireworks.jpeg +0 -0
  147. data/ext/third_party/snappy/testdata/geo.protodata +0 -0
  148. data/ext/third_party/snappy/testdata/html +1 -0
  149. data/ext/third_party/snappy/testdata/html_x_4 +1 -0
  150. data/ext/third_party/snappy/testdata/kppkn.gtb +0 -0
  151. data/ext/third_party/snappy/testdata/lcet10.txt +7519 -0
  152. data/ext/third_party/snappy/testdata/paper-100k.pdf +600 -2
  153. data/ext/third_party/snappy/testdata/plrabn12.txt +10699 -0
  154. data/ext/third_party/snappy/testdata/urls.10K +10000 -0
  155. data/lib/couchbase/binary_collection.rb +33 -76
  156. data/lib/couchbase/binary_collection_options.rb +94 -0
  157. data/lib/couchbase/bucket.rb +9 -3
  158. data/lib/couchbase/cluster.rb +161 -23
  159. data/lib/couchbase/collection.rb +108 -191
  160. data/lib/couchbase/collection_options.rb +430 -0
  161. data/lib/couchbase/errors.rb +136 -134
  162. data/lib/couchbase/json_transcoder.rb +32 -0
  163. data/lib/couchbase/management/analytics_index_manager.rb +185 -9
  164. data/lib/couchbase/management/bucket_manager.rb +84 -33
  165. data/lib/couchbase/management/collection_manager.rb +166 -1
  166. data/lib/couchbase/management/query_index_manager.rb +261 -0
  167. data/lib/couchbase/management/search_index_manager.rb +291 -0
  168. data/lib/couchbase/management/user_manager.rb +12 -10
  169. data/lib/couchbase/management/view_index_manager.rb +151 -1
  170. data/lib/couchbase/mutation_state.rb +11 -1
  171. data/lib/couchbase/scope.rb +4 -4
  172. data/lib/couchbase/version.rb +1 -1
  173. metadata +113 -18
  174. data/.travis.yml +0 -7
  175. data/ext/couchbase/io/binary_parser.hxx +0 -64
  176. data/lib/couchbase/results.rb +0 -307
@@ -12,6 +12,8 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
+ require "couchbase/errors"
16
+
15
17
  module Couchbase
16
18
  module Management
17
19
  class SearchIndexManager
@@ -21,6 +23,295 @@ module Couchbase
21
23
  def initialize(backend)
22
24
  @backend = backend
23
25
  end
26
+
27
+ # Fetches an index from the server if it exists
28
+ #
29
+ # @param [String] index_name name of the index
30
+ # @param [GetIndexOptions] options
31
+ #
32
+ # @return [SearchIndex]
33
+ #
34
+ # @raise [ArgumentError]
35
+ # @raise [Error::IndexNotFound]
36
+ def get_index(index_name, options = GetIndexOptions.new)
37
+ # GET /api/index/{name}
38
+ end
39
+
40
+ # Fetches all indexes from the server
41
+ #
42
+ # @param [GetAllIndexesOptions] options
43
+ #
44
+ # @return [Array<SearchIndex>]
45
+ def get_all_indexes(options = GetAllIndexesOptions.new)
46
+ # GET /api/index
47
+ end
48
+
49
+ # Creates or updates the index
50
+ #
51
+ # @param [SearchIndex] index_definition the index definition
52
+ # @param [UpsertIndexOptions] options
53
+ #
54
+ # @raise [ArgumentError] if name, type or source_type is empty
55
+ def upsert_index(index_definition, options = UpsertIndexOptions.new)
56
+ # PUT /api/index/{index_name} "cache-control: no-cache"
57
+ end
58
+
59
+ # Drops the index
60
+ #
61
+ # @param [String] index_name name of the index
62
+ # @param [DropIndexOptions] options
63
+ #
64
+ # @raise [ArgumentError]
65
+ # @raise [Error::IndexNotFound]
66
+ def drop_index(index_name, options = DropIndexOptions.new)
67
+ # DELETE /api/index/{index_name}
68
+ end
69
+
70
+ # Retrieves the number of documents that have been indexed for an index
71
+ #
72
+ # @param [String] index_name name of the index
73
+ # @param [GetIndexedDocumentsOptions] options
74
+ #
75
+ # @return [Integer]
76
+ #
77
+ # @raise [ArgumentError]
78
+ # @raise [Error::IndexNotFound]
79
+ def get_indexed_documents_count(index_name, options = GetIndexedDocumentsCountOptions.new)
80
+ # GET /api/index/{index_name}/count
81
+ end
82
+
83
+ # Pauses updates and maintenance for the index
84
+ #
85
+ # @param [String] index_name name of the index
86
+ # @param [PauseIngestOptions] options
87
+ #
88
+ # @raise [ArgumentError]
89
+ # @raise [Error::IndexNotFound]
90
+ def pause_ingest(index_name, options = PauseIngestOptions.new)
91
+ # POST /api/index/{index_name}/ingestControl/pause
92
+ end
93
+
94
+ # Resumes updates and maintenance for an index
95
+ #
96
+ # @param [String] index_name name of the index
97
+ # @param [ResumeIngestOptions] options
98
+ #
99
+ # @raise [ArgumentError]
100
+ # @raise [Error::IndexNotFound]
101
+ def resume_ingest(index_name, options = ResumeIngestOptions.new)
102
+ # POST /api/index/{index_name}/ingestControl/resume
103
+ end
104
+
105
+ # Allows querying against the index
106
+ #
107
+ # @param [String] index_name name of the index
108
+ # @param [AllowQueryingOptions] options
109
+ #
110
+ # @raise [ArgumentError]
111
+ # @raise [Error::IndexNotFound]
112
+ def allow_querying(index_name, options = AllowQueryingOptions.new)
113
+ # POST /api/index/{index_name}/queryControl/allow
114
+ end
115
+
116
+ # Disallows querying against the index
117
+ #
118
+ # @param [String] index_name name of the index
119
+ # @param [DisallowQueryingOptions] options
120
+ #
121
+ # @raise [ArgumentError]
122
+ # @raise [Error::IndexNotFound]
123
+ def disallow_querying(index_name, options = DisallowQueryingOptions.new)
124
+ # POST /api/index/{index_name}/queryControl/disallow
125
+ end
126
+
127
+ # Freeze the assignment of index partitions to nodes
128
+ #
129
+ # @param [String] index_name name of the index
130
+ # @param [FreezePlanOptions] options
131
+ #
132
+ # @raise [ArgumentError]
133
+ # @raise [Error::IndexNotFound]
134
+ def freeze_plan(index_name, options = FreezePlanOptions.new)
135
+ # POST /api/index/{index_name}/planFreezeControl/freeze
136
+ end
137
+
138
+ # Unfreeze the assignment of index partitions to nodes
139
+ #
140
+ # @param [String] index_name name of the index
141
+ # @param [UnfreezePlanOptions] options
142
+ #
143
+ # @raise [ArgumentError]
144
+ # @raise [Error::IndexNotFound]
145
+ def unfreeze_plan(index_name, options = UnfreezePlanOptions.new)
146
+ # POST /api/index/{index_name}/planFreezeControl/unfreeze
147
+ end
148
+
149
+ # Allows to see how a document is analyzed against a specific index
150
+ #
151
+ # @param [String] index_name name of the index
152
+ # @param [Hash] document the document to be analyzed
153
+ #
154
+ # @return [Array<Hash>]
155
+ #
156
+ # @raise [ArgumentError]
157
+ # @raise [Error::IndexNotFound]
158
+ def analyze_document(index_name, document, options = AnalyzeDocumentOptions.new)
159
+ # POST /api/index/{index_name}/analyzeDoc
160
+ end
161
+
162
+ class GetIndexOptions
163
+ # @return [Integer] the time in milliseconds allowed for the operation to complete
164
+ attr_accessor :timeout
165
+
166
+ # @yieldparam [GetIndexOptions] self
167
+ def initialize
168
+ yield self if block_given?
169
+ end
170
+ end
171
+
172
+ class GetAllIndexesOptions
173
+ # @return [Integer] the time in milliseconds allowed for the operation to complete
174
+ attr_accessor :timeout
175
+
176
+ # @yieldparam [GetAllIndexesOptions] self
177
+ def initialize
178
+ yield self if block_given?
179
+ end
180
+ end
181
+
182
+ class UpsertIndexOptions
183
+ # @return [Integer] the time in milliseconds allowed for the operation to complete
184
+ attr_accessor :timeout
185
+
186
+ # @yieldparam [UpsertIndexOptions] self
187
+ def initialize
188
+ yield self if block_given?
189
+ end
190
+ end
191
+
192
+ class DropIndexOptions
193
+ # @return [Integer] the time in milliseconds allowed for the operation to complete
194
+ attr_accessor :timeout
195
+
196
+ # @yieldparam [DropIndexOptions] self
197
+ def initialize
198
+ yield self if block_given?
199
+ end
200
+ end
201
+
202
+ class GetIndexedDocumentsOptions
203
+ # @return [Integer] the time in milliseconds allowed for the operation to complete
204
+ attr_accessor :timeout
205
+
206
+ # @yieldparam [GetIndexedDocumentOptions] self
207
+ def initialize
208
+ yield self if block_given?
209
+ end
210
+ end
211
+
212
+ class PauseIngestOptions
213
+ # @return [Integer] the time in milliseconds allowed for the operation to complete
214
+ attr_accessor :timeout
215
+
216
+ # @yieldparam [PauseIngestOptions] self
217
+ def initialize
218
+ yield self if block_given?
219
+ end
220
+ end
221
+
222
+ class ResumeIngestOptions
223
+ # @return [Integer] the time in milliseconds allowed for the operation to complete
224
+ attr_accessor :timeout
225
+
226
+ # @yieldparam [ResumeIngestOptions] self
227
+ def initialize
228
+ yield self if block_given?
229
+ end
230
+ end
231
+
232
+ class AllowQueryingOptions
233
+ # @return [Integer] the time in milliseconds allowed for the operation to complete
234
+ attr_accessor :timeout
235
+
236
+ # @yieldparam [AllowQueryingOptions] self
237
+ def initialize
238
+ yield self if block_given?
239
+ end
240
+ end
241
+
242
+ class DisallowQueryingOptions
243
+ # @return [Integer] the time in milliseconds allowed for the operation to complete
244
+ attr_accessor :timeout
245
+
246
+ # @yieldparam [DisallowQueryingOptions] self
247
+ def initialize
248
+ yield self if block_given?
249
+ end
250
+ end
251
+
252
+ class FreezePlanOptions
253
+ # @return [Integer] the time in milliseconds allowed for the operation to complete
254
+ attr_accessor :timeout
255
+
256
+ # @yieldparam [FreezePlanOptions] self
257
+ def initialize
258
+ yield self if block_given?
259
+ end
260
+ end
261
+
262
+ class UnfreezePlanOptions
263
+ # @return [Integer] the time in milliseconds allowed for the operation to complete
264
+ attr_accessor :timeout
265
+
266
+ # @yieldparam [UnfreezePlanOptions] self
267
+ def initialize
268
+ yield self if block_given?
269
+ end
270
+ end
271
+
272
+ class AnalyzeDocumentOptions
273
+ # @return [Integer] the time in milliseconds allowed for the operation to complete
274
+ attr_accessor :timeout
275
+
276
+ # @yieldparam [AnalyzeDocumentOptions] self
277
+ def initialize
278
+ yield self if block_given?
279
+ end
280
+ end
281
+ end
282
+
283
+ class SearchIndex
284
+ # @return [String] name of the index
285
+ attr_accessor :name
286
+
287
+ # @return [String] type of the index
288
+ attr_accessor :type
289
+
290
+ # @return [String] UUID is required for update. It provides means of ensuring consistency.
291
+ attr_accessor :uuid
292
+
293
+ # @return [Hash] index properties such as store type and mappings
294
+ attr_accessor :params
295
+
296
+ # @return [String] name of the source of the data for the index (e.g. bucket name)
297
+ attr_accessor :source_name
298
+
299
+ # @return [String] type of the data source
300
+ attr_accessor :source_type
301
+
302
+ # @return [String] the UUID of the ata source, this can be used to more tightly tie the index to a source
303
+ attr_accessor :source_uuid
304
+
305
+ # @return [Hash] extra parameters for the source. These are usually things like advanced connection and tuning.
306
+ attr_accessor :source_params
307
+
308
+ # @return [Hash] plan properties such a number of replicas and number of partitions
309
+ attr_accessor :plan_params
310
+
311
+ # @yieldparam [SearchIndex] self
312
+ def initialize
313
+ yield self if block_given?
314
+ end
24
315
  end
25
316
  end
26
317
  end
@@ -12,6 +12,8 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
+ require "couchbase/errors"
16
+
15
17
  module Couchbase
16
18
  module Management
17
19
  class UserManager
@@ -29,8 +31,8 @@ module Couchbase
29
31
  #
30
32
  # @return [UserAndMetadata]
31
33
  #
32
- # @raise ArgumentError
33
- # @raise UserNotFound
34
+ # @raise [ArgumentError]
35
+ # @raise [Error::UserNotFound]
34
36
  def get_user(user_name, options = GetUserOptions.new)
35
37
  # GET /settings/rbac/users/#{options.domain}/#{user_name}
36
38
  end
@@ -47,7 +49,7 @@ module Couchbase
47
49
  # @param [User] user the new version of the user
48
50
  # @param [UpsertUserOptions] options
49
51
  #
50
- # @raise ArgumentError
52
+ # @raise [ArgumentError]
51
53
  def upsert_user(user, options = UpsertUserOptions.new)
52
54
  # PUT /settings/rbac/users/#{options.domain}/#{user_name}
53
55
  end
@@ -62,7 +64,7 @@ module Couchbase
62
64
 
63
65
  # Gets all roles supported by the server
64
66
  #
65
- # @param [GetRolesOptions]
67
+ # @param [GetRolesOptions] options
66
68
  #
67
69
  # @return [Array<RoleAndDescription>]
68
70
  def get_roles(options = GetRolesOptions.new)
@@ -75,8 +77,8 @@ module Couchbase
75
77
  #
76
78
  # @return [Group]
77
79
  #
78
- # @raise GroupNotFound
79
- # @raise ArgumentError
80
+ # @raise [ArgumentError]
81
+ # @raise [Error::GroupNotFound]
80
82
  def get_group(group_name, options = GetGroupOptions.new)
81
83
  # GET /settings/rbac/groups/#{group_name}
82
84
  end
@@ -95,8 +97,8 @@ module Couchbase
95
97
  # @param [Group] group the new version of the group
96
98
  # @param [UpsertGroupOptions] options
97
99
  #
98
- # @raise GroupNotFound
99
- # @raise ArgumentError
100
+ # @raise [ArgumentError]
101
+ # @raise [Error::GroupNotFound]
100
102
  def upsert_group(group, options = UpsertGroupOptions.new)
101
103
  # PUT /settings/rbac/groups/#{group.name}
102
104
  end
@@ -106,7 +108,7 @@ module Couchbase
106
108
  # @param [String] group_name name of the group
107
109
  # @param [DropGroupOptions] options
108
110
  #
109
- # @raise GroupNotFound
111
+ # @raise [Error::GroupNotFound]
110
112
  def drop_group(group_name, options = DropGroupOptions.new) end
111
113
 
112
114
  class GetUserOptions
@@ -318,4 +320,4 @@ module Couchbase
318
320
  end
319
321
  end
320
322
  end
321
- end
323
+ end
@@ -12,8 +12,25 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
+ require "couchbase/errors"
16
+
15
17
  module Couchbase
16
18
  module Management
19
+ # The View Index Manager interface contains the means for managing design documents used for views.
20
+ #
21
+ # A design document belongs to either the "development" or "production" namespace. A development document has a name
22
+ # that starts with "dev_". This is an implementation detail we've chosen to hide from consumers of this API.
23
+ # Document names presented to the user (returned from the "get" and "get all" methods, for example) always have the
24
+ # "dev_" prefix stripped.
25
+ #
26
+ # Whenever the user passes a design document name to any method of this API, the user may refer to the document
27
+ # using the "dev_" prefix regardless of whether the user is referring to a development document or production
28
+ # document. The "dev_" prefix is always stripped from user input, and the actual document name passed to the server
29
+ # is determined by the "namespace" argument.
30
+ #
31
+ # All methods (except publish) have a required "namespace" argument indicating whether the operation targets a
32
+ # development document or a production document. The type of this argument is [Symbol] with allowed values
33
+ # +:production+ and +:development+.
17
34
  class ViewIndexManager
18
35
  alias_method :inspect, :to_s
19
36
 
@@ -23,6 +40,139 @@ module Couchbase
23
40
  @backend = backend
24
41
  @bucket_name = bucket_name
25
42
  end
43
+
44
+ # Fetches a design document from the server
45
+ #
46
+ # @param [String] name the name of the design document
47
+ # @param [:production, :development] namespace the namespace
48
+ # @param [GetDesignDocumentOptions] options
49
+ #
50
+ # @return [DesignDocument]
51
+ #
52
+ # @raise [Error::DesignDocumentNotFound]
53
+ def get_design_document(name, namespace, options = GetDesignDocumentOptions.new)
54
+ # GET /{bucket_name}/_design/{namespace}_{name}
55
+ end
56
+
57
+ # Fetches all design documents from the server
58
+ #
59
+ # @param [:production, :development] namespace the namespace
60
+ # @param [GetAllDesignDocumentsOptions] options
61
+ #
62
+ # @return [Array<DesignDocument>]
63
+ def get_all_design_documents(namespace, options = GetAllDesignDocumentsOptions.new)
64
+ # GET /pools/default/buckets/{bucket_name}/ddocs
65
+ end
66
+
67
+ # Updates or inserts the design document
68
+ #
69
+ # @param [DesignDocument] document
70
+ # @param [:production, :development] namespace the namespace
71
+ # @param [UpsertDesignDocumentOptions] options
72
+ def upsert_design_document(document, namespace, options = UpsertDesignDocumentOptions.new)
73
+ # PUT /{bucket_name}/_design/{namespace}_{name}
74
+ end
75
+
76
+ # Removes the design document
77
+ #
78
+ # @param [String] name design document name
79
+ # @param [:production, :development] namespace the namespace
80
+ # @param [DropDesignDocumentOptions] options
81
+ #
82
+ # @raise [Error::DesignDocumentNotFound]
83
+ def drop_design_document(name, namespace, options = DropDesignDocumentOptions.new)
84
+ # DELETE /{bucket_name}/_design/{namespace}_{name}
85
+ end
86
+
87
+ # Publishes the design document.
88
+ #
89
+ # This method is equivalent to getting a document from the development namespace and upserting
90
+ # it to the production namespace.
91
+ #
92
+ # @param [String] name design document name
93
+ # @param [PublishDesignDocumentOptions] options
94
+ #
95
+ # @raise [ArgumentError]
96
+ # @raise [Error::DesignDocumentNotFound]
97
+ def publish_design_document(name, options = PublishDesignDocumentOptions.new)
98
+ end
99
+
100
+ class GetDesignDocumentOptions
101
+ # @return [Integer] the time in milliseconds allowed for the operation to complete
102
+ attr_accessor :timeout
103
+
104
+ # @yieldparam [GetDesignDocumentOptions] self
105
+ def initialize
106
+ yield self if block_given?
107
+ end
108
+ end
109
+
110
+ class GetAllDesignDocumentsOptions
111
+ # @return [Integer] the time in milliseconds allowed for the operation to complete
112
+ attr_accessor :timeout
113
+
114
+ # @yieldparam [GetAllDesignDocumentsOptions] self
115
+ def initialize
116
+ yield self if block_given?
117
+ end
118
+ end
119
+
120
+ class UpsertDesignDocumentOptions
121
+ # @return [Integer] the time in milliseconds allowed for the operation to complete
122
+ attr_accessor :timeout
123
+
124
+ # @yieldparam [UpsertDesignDocumentOptions] self
125
+ def initialize
126
+ yield self if block_given?
127
+ end
128
+ end
129
+
130
+ class DropDesignDocumentOptions
131
+ # @return [Integer] the time in milliseconds allowed for the operation to complete
132
+ attr_accessor :timeout
133
+
134
+ # @yieldparam [DropDesignDocumentOptions] self
135
+ def initialize
136
+ yield self if block_given?
137
+ end
138
+ end
139
+
140
+ class PublishDesignDocumentOptions
141
+ # @return [Integer] the time in milliseconds allowed for the operation to complete
142
+ attr_accessor :timeout
143
+
144
+ # @yieldparam [PublishDesignDocumentOptions] self
145
+ def initialize
146
+ yield self if block_given?
147
+ end
148
+ end
149
+
150
+ end
151
+
152
+ class View
153
+ # @return [String] map function in javascript
154
+ attr_accessor :map
155
+
156
+ # @return [String] reduce function in javascript
157
+ attr_accessor :reduce
158
+
159
+ # @yieldparam [View] self
160
+ def initialize
161
+ yield self if block_given?
162
+ end
163
+ end
164
+
165
+ class DesignDocument
166
+ # @return [String] name
167
+ attr_accessor :name
168
+
169
+ # @return [Hash<String, View>]
170
+ attr_accessor :views
171
+
172
+ # @yieldparam [DesignDocument] self
173
+ def initialize
174
+ yield self if block_given?
175
+ end
26
176
  end
27
177
  end
28
- end
178
+ end