UNPKG

13.2 kBTypeScriptView Raw
1import { CppManagementClusterBucketSettings } from './binding';
2import { Cluster } from './cluster';
3import { DurabilityLevel } from './generaltypes';
4import { NodeCallback } from './utilities';
5/**
6 * Represents the various conflict resolution modes which can be used for
7 * XDCR synchronization against a bucket.
8 *
9 * @category Management
10 */
11export declare enum ConflictResolutionType {
12 /**
13 * Indicates that timestamps should be used for conflict resolution. The most
14 * recently modified document (according to each server, ie: time synchronization
15 * is important) is the one selected to win.
16 */
17 Timestamp = "lww",
18 /**
19 * Indicates that the seqno of the document should be used for conflict resolution.
20 */
21 SequenceNumber = "seqno",
22 /**
23 * Indicates that custom conflict resolution should be used.
24 *
25 * @experimental This mode is only available in Couchbase Server 7.1 with the
26 * "developer-preview" mode enabled.
27 */
28 Custom = "custom"
29}
30/**
31 * Represents the type of a bucket.
32 *
33 * @category Management
34 */
35export declare enum BucketType {
36 /**
37 * Indicates the bucket should be a Couchbase bucket.
38 */
39 Couchbase = "membase",
40 /**
41 * Indicates the bucket should be a Memcached bucket.
42 */
43 Memcached = "memcached",
44 /**
45 * Indicates the bucket should be a Ephemeral bucket.
46 */
47 Ephemeral = "ephemeral"
48}
49/**
50 * Represents the storage backend to use for a bucket.
51 *
52 * @category Management
53 */
54export declare enum StorageBackend {
55 /**
56 * Indicates the bucket should use the Couchstore storage engine.
57 */
58 Couchstore = "couchstore",
59 /**
60 * Indicates the bucket should use the Magma storage engine.
61 */
62 Magma = "magma"
63}
64/**
65 * Represents the eviction policy that should be used for a bucket.
66 *
67 * @category Management
68 */
69export declare enum EvictionPolicy {
70 /**
71 * Indicates that both the document meta-data and value should be evicted.
72 */
73 FullEviction = "fullEviction",
74 /**
75 * Indicates that only the value of a document should be evicted.
76 */
77 ValueOnly = "valueOnly",
78 /**
79 * Indicates that the least recently used documents are evicted.
80 */
81 NotRecentlyUsed = "nruEviction",
82 /**
83 * Indicates that nothing should be evicted.
84 */
85 NoEviction = "noEviction"
86}
87/**
88 * Specifies the compression mode that should be used for a bucket.
89 *
90 * @category Management
91 */
92export declare enum CompressionMode {
93 /**
94 * Indicates that compression should not be used on the server.
95 */
96 Off = "off",
97 /**
98 * Indicates that compression should be used passively. That is that if the
99 * client sends data which is encrypted, it is stored on the server in its
100 * compressed form, but the server does not actively compress documents.
101 */
102 Passive = "passive",
103 /**
104 * Indicates that compression should be performed actively. Even if the
105 * client does not transmit the document in a compressed form.
106 */
107 Active = "active"
108}
109/**
110 * Specifies a number of options which can be used when updating a buckets
111 * settings.
112 *
113 * @category Management
114 */
115export interface IBucketSettings {
116 /**
117 * The name of the bucket.
118 */
119 name: string;
120 /**
121 * Whether the flush operation (truncating all data in the bucket) should
122 * be enabled.
123 */
124 flushEnabled?: boolean;
125 /**
126 * The amount of RAM which should be allocated to this bucket, expressed in
127 * megabytes.
128 */
129 ramQuotaMB: number;
130 /**
131 * The number of replicas that should exist for this bucket.
132 */
133 numReplicas?: number;
134 /**
135 * Whether the indexes on this bucket should be replicated.
136 */
137 replicaIndexes?: boolean;
138 /**
139 * Specifies the type of bucket that should be used.
140 */
141 bucketType?: BucketType | string;
142 /**
143 * Specifies the storage backend to use for the bucket.
144 */
145 storageBackend?: StorageBackend | string;
146 /**
147 * Specifies the ejection method that should be used.
148 */
149 evictionPolicy?: EvictionPolicy | string;
150 /**
151 * Specifies the maximum expiry time that any document should be permitted
152 * to have. Any documents stored with an expiry configured higher than this
153 * will be forced to this number.
154 */
155 maxExpiry?: number;
156 /**
157 * Specifies the compression mode that should be used.
158 */
159 compressionMode?: CompressionMode | string;
160 /**
161 * Specifies the minimum durability level that should be used for any write
162 * operations which are performed against this bucket.
163 */
164 minimumDurabilityLevel?: DurabilityLevel | string;
165 /**
166 * Specifies the default history retention on all collections in this bucket.
167 * Only available on Magma Buckets.
168 *
169 * @see {@link StorageBackend.Magma}.
170 */
171 historyRetentionCollectionDefault?: boolean;
172 /**
173 * Specifies the maximum history retention in bytes on all collections in this bucket.
174 */
175 historyRetentionBytes?: number;
176 /**
177 * Specifies the maximum duration in seconds to be covered by the change history that is written
178 * to disk for all collections in this bucket.
179 */
180 historyRetentionDuration?: number;
181 /**
182 * Same as {@link IBucketSettings.maxExpiry}.
183 *
184 * @deprecated Use {@link IBucketSettings.maxExpiry} instead.
185 */
186 maxTTL?: number;
187 /**
188 * Same as {@link IBucketSettings.minimumDurabilityLevel}, but represented as
189 * the raw server-side configuration string.
190 *
191 * @deprecated Use {@link IBucketSettings.minimumDurabilityLevel} instead.
192 */
193 durabilityMinLevel?: string;
194 /**
195 * Same as {@link IBucketSettings.evictionPolicy}, but represented as
196 * the raw server-side configuration string.
197 *
198 * @deprecated Use {@link IBucketSettings.evictionPolicy} instead.
199 */
200 ejectionMethod?: EvictionPolicy | string;
201}
202/**
203 * Represents the configured options for a bucket.
204 *
205 * @category Management
206 */
207export declare class BucketSettings implements IBucketSettings {
208 /**
209 * The name of the bucket.
210 */
211 name: string;
212 /**
213 * Whether the flush operation (truncating all data in the bucket) should
214 * be enabled.
215 */
216 flushEnabled?: boolean;
217 /**
218 * The amount of RAM which should be allocated to this bucket, expressed in
219 * megabytes.
220 */
221 ramQuotaMB: number;
222 /**
223 * The number of replicas that should exist for this bucket.
224 */
225 numReplicas?: number;
226 /**
227 * Whether the indexes on this bucket should be replicated.
228 */
229 replicaIndexes?: boolean;
230 /**
231 * Specifies the type of bucket that should be used.
232 */
233 bucketType?: BucketType;
234 /**
235 * Specifies the storage backend to use for the bucket.
236 */
237 storageBackend?: StorageBackend | string;
238 /**
239 * Specifies the ejection method that should be used.
240 */
241 evictionPolicy?: EvictionPolicy;
242 /**
243 * Specifies the maximum expiry time that any document should be permitted
244 * to have. Any documents stored with an expiry configured higher than this
245 * will be forced to this number.
246 */
247 maxExpiry?: number;
248 /**
249 * Specifies the compression mode that should be used.
250 */
251 compressionMode?: CompressionMode;
252 /**
253 * Specifies the minimum durability level that should be used for any write
254 * operations which are performed against this bucket.
255 */
256 minimumDurabilityLevel?: DurabilityLevel;
257 /**
258 * Specifies the default history retention on all collections in this bucket.
259 * Only available on Magma Buckets.
260 *
261 * @see {@link StorageBackend.Magma}.
262 */
263 historyRetentionCollectionDefault?: boolean;
264 /**
265 * Specifies the maximum history retention in bytes on all collections in this bucket.
266 */
267 historyRetentionBytes?: number;
268 /**
269 * Specifies the maximum duration in seconds to be covered by the change history that is written
270 * to disk for all collections in this bucket.
271 */
272 historyRetentionDuration?: number;
273 /**
274 * @internal
275 */
276 constructor(data: BucketSettings);
277 /**
278 * Same as {@link IBucketSettings.maxExpiry}.
279 *
280 * @deprecated Use {@link IBucketSettings.maxExpiry} instead.
281 */
282 get maxTTL(): number;
283 set maxTTL(val: number);
284 /**
285 * Same as {@link IBucketSettings.evictionPolicy}.
286 *
287 * @deprecated Use {@link IBucketSettings.evictionPolicy} instead.
288 */
289 get ejectionMethod(): EvictionPolicy | string;
290 set ejectionMethod(val: EvictionPolicy | string);
291 /**
292 * Same as {@link IBucketSettings.minimumDurabilityLevel}, but represented as
293 * the raw server-side configuration string.
294 *
295 * @deprecated Use {@link IBucketSettings.minimumDurabilityLevel} instead.
296 */
297 get durabilityMinLevel(): string;
298 /**
299 * @internal
300 */
301 static _toCppData(data: IBucketSettings): any;
302 /**
303 * @internal
304 */
305 static _fromCppData(data: CppManagementClusterBucketSettings): BucketSettings;
306}
307/**
308 * Specifies a number of settings which can be set when creating a bucket.
309 *
310 * @category Management
311 */
312export interface ICreateBucketSettings extends IBucketSettings {
313 /**
314 * Specifies the conflict resolution mode to use for XDCR of this bucket.
315 */
316 conflictResolutionType?: ConflictResolutionType | string;
317}
318/**
319 * @category Management
320 */
321export interface CreateBucketOptions {
322 /**
323 * The timeout for this operation, represented in milliseconds.
324 */
325 timeout?: number;
326}
327/**
328 * @category Management
329 */
330export interface UpdateBucketOptions {
331 /**
332 * The timeout for this operation, represented in milliseconds.
333 */
334 timeout?: number;
335}
336/**
337 * @category Management
338 */
339export interface DropBucketOptions {
340 /**
341 * The timeout for this operation, represented in milliseconds.
342 */
343 timeout?: number;
344}
345/**
346 * @category Management
347 */
348export interface GetBucketOptions {
349 /**
350 * The timeout for this operation, represented in milliseconds.
351 */
352 timeout?: number;
353}
354/**
355 * @category Management
356 */
357export interface GetAllBucketsOptions {
358 /**
359 * The timeout for this operation, represented in milliseconds.
360 */
361 timeout?: number;
362}
363/**
364 * @category Management
365 */
366export interface FlushBucketOptions {
367 /**
368 * The timeout for this operation, represented in milliseconds.
369 */
370 timeout?: number;
371}
372/**
373 * BucketManager provides an interface for adding/removing/updating
374 * buckets within the cluster.
375 *
376 * @category Management
377 */
378export declare class BucketManager {
379 private _cluster;
380 /**
381 * @internal
382 */
383 constructor(cluster: Cluster);
384 /**
385 * Creates a new bucket.
386 *
387 * @param settings The settings to use for the new bucket.
388 * @param options Optional parameters for this operation.
389 * @param callback A node-style callback to be invoked after execution.
390 */
391 createBucket(settings: ICreateBucketSettings, options?: CreateBucketOptions, callback?: NodeCallback<void>): Promise<void>;
392 /**
393 * Updates the settings for an existing bucket.
394 *
395 * @param settings The new settings to use for the bucket.
396 * @param options Optional parameters for this operation.
397 * @param callback A node-style callback to be invoked after execution.
398 */
399 updateBucket(settings: BucketSettings, options?: UpdateBucketOptions, callback?: NodeCallback<void>): Promise<void>;
400 /**
401 * Drops an existing bucket.
402 *
403 * @param bucketName The name of the bucket to drop.
404 * @param options Optional parameters for this operation.
405 * @param callback A node-style callback to be invoked after execution.
406 */
407 dropBucket(bucketName: string, options?: DropBucketOptions, callback?: NodeCallback<void>): Promise<void>;
408 /**
409 * Fetches the settings in use for a specified bucket.
410 *
411 * @param bucketName The name of the bucket to fetch settings for.
412 * @param options Optional parameters for this operation.
413 * @param callback A node-style callback to be invoked after execution.
414 */
415 getBucket(bucketName: string, options?: GetBucketOptions, callback?: NodeCallback<BucketSettings>): Promise<BucketSettings>;
416 /**
417 * Returns a list of existing buckets in the cluster.
418 *
419 * @param options Optional parameters for this operation.
420 * @param callback A node-style callback to be invoked after execution.
421 */
422 getAllBuckets(options?: GetAllBucketsOptions, callback?: NodeCallback<BucketSettings[]>): Promise<BucketSettings[]>;
423 /**
424 * Flushes the bucket, deleting all the existing data that is stored in it.
425 *
426 * @param bucketName The name of the bucket to flush.
427 * @param options Optional parameters for this operation.
428 * @param callback A node-style callback to be invoked after execution.
429 */
430 flushBucket(bucketName: string, options?: FlushBucketOptions, callback?: NodeCallback<void>): Promise<void>;
431}