Class: Couchbase::Management::BucketManager

Inherits:
Object
  • Object
show all
Defined in:
lib/couchbase/management/bucket_manager.rb,
/code/couchbase-ruby-client/lib/couchbase/management/bucket_manager.rb

Instance Method Summary collapse

Constructor Details

#initialize(backend) ⇒ BucketManager

Returns a new instance of BucketManager.

Parameters:

  • backend (Couchbase::Backend)


193
194
195
# File 'lib/couchbase/management/bucket_manager.rb', line 193

def initialize(backend)
  @backend = backend
end

Instance Method Details

#create_bucket(settings, options = Options::Bucket::CreateBucket.new) ⇒ Object

Creates new bucket

Parameters:

Returns:

  • void

Raises:



206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
# File 'lib/couchbase/management/bucket_manager.rb', line 206

def create_bucket(settings, options = Options::Bucket::CreateBucket.new)
  @backend.bucket_create(
    {

      name: settings.name,
      flush_enabled: settings.flush_enabled,
      ram_quota_mb: settings.ram_quota_mb,
      num_replicas: settings.num_replicas,
      replica_indexes: settings.replica_indexes,
      bucket_type: settings.bucket_type,
      eviction_policy: settings.eviction_policy,
      max_expiry: settings.max_expiry,
      compression_mode: settings.compression_mode,
      minimum_durability_level: settings.minimum_durability_level,
      conflict_resolution_type: settings.conflict_resolution_type,
      storage_backend: settings.storage_backend,
      history_retention_collection_default: settings.history_retention_collection_default,
      history_retention_duration: settings.history_retention_duration,
      history_retention_bytes: settings.history_retention_bytes,
    }, options.to_backend
  )
end

#drop_bucket(bucket_name, options = Options::Bucket::DropBucket.new) ⇒ Object

Removes a bucket

Parameters:

Returns:

  • void

Raises:



268
269
270
# File 'lib/couchbase/management/bucket_manager.rb', line 268

def drop_bucket(bucket_name, options = Options::Bucket::DropBucket.new)
  @backend.bucket_drop(bucket_name, options.to_backend)
end

#flush_bucket(bucket_name, options = Options::Bucket::FlushBucket.new) ⇒ Object

Returns void.

Parameters:

Returns:

  • void

Raises:



302
303
304
# File 'lib/couchbase/management/bucket_manager.rb', line 302

def flush_bucket(bucket_name, options = Options::Bucket::FlushBucket.new)
  @backend.bucket_flush(bucket_name, options.to_backend)
end

#get_all_buckets(options = Options::Bucket::GetAllBuckets.new) ⇒ Array<BucketSettings>

Get settings for all buckets

Parameters:

Returns:



289
290
291
292
# File 'lib/couchbase/management/bucket_manager.rb', line 289

def get_all_buckets(options = Options::Bucket::GetAllBuckets.new)
  @backend.bucket_get_all(options.to_backend)
          .map { |entry| extract_bucket_settings(entry) }
end

#get_bucket(bucket_name, options = Options::Bucket::GetBucket.new) ⇒ BucketSettings

Fetch settings of the bucket

Parameters:

Returns:

Raises:



281
282
283
# File 'lib/couchbase/management/bucket_manager.rb', line 281

def get_bucket(bucket_name, options = Options::Bucket::GetBucket.new)
  extract_bucket_settings(@backend.bucket_get(bucket_name, options.to_backend))
end

#update_bucket(settings, options = Options::Bucket::UpdateBucket.new) ⇒ Object

Updates the bucket settings

Parameters:

Returns:

  • void

Raises:



238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
# File 'lib/couchbase/management/bucket_manager.rb', line 238

def update_bucket(settings, options = Options::Bucket::UpdateBucket.new)
  @backend.bucket_update(
    {
      name: settings.name,
      flush_enabled: settings.flush_enabled,
      ram_quota_mb: settings.ram_quota_mb,
      num_replicas: settings.num_replicas,
      replica_indexes: settings.replica_indexes,
      bucket_type: settings.bucket_type,
      eviction_policy: settings.eviction_policy,
      max_expiry: settings.max_expiry,
      compression_mode: settings.compression_mode,
      minimum_durability_level: settings.minimum_durability_level,
      storage_backend: settings.storage_backend,
      history_retention_collection_default: settings.history_retention_collection_default,
      history_retention_bytes: settings.history_retention_bytes,
      history_retention_duration: settings.history_retention_duration,
    }, options.to_backend
  )
end