Class: Couchbase::Management::BucketManager

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

Defined Under Namespace

Classes: CreateBucketOptions, DropBucketOptions, FlushBucketOptions, GetAllBucketsOptions, GetBucketOptions, UpdateBucketOptions

Instance Method Summary collapse

Constructor Details

#initialize(backend) ⇒ BucketManager

Returns a new instance of BucketManager.

Parameters:

  • backend (Couchbase::Backend)


25
26
27
# File 'lib/couchbase/management/bucket_manager.rb', line 25

def initialize(backend)
  @backend = backend
end

Instance Method Details

#create_bucket(settings, options = CreateBucketOptions.new) ⇒ Object

Creates new bucket

Parameters:

Returns:

  • void

Raises:



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/couchbase/management/bucket_manager.rb', line 38

def create_bucket(settings, options = CreateBucketOptions.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,
      ejection_policy: settings.ejection_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,
    }, options.timeout
  )
end

#drop_bucket(bucket_name, options = DropBucketOptions.new) ⇒ Object

Removes a bucket

Parameters:

  • bucket_name (String)

    name of the bucket

  • options (DropBucketOptions) (defaults to: DropBucketOptions.new)

Returns:

  • void

Raises:



92
93
94
# File 'lib/couchbase/management/bucket_manager.rb', line 92

def drop_bucket(bucket_name, options = DropBucketOptions.new)
  @backend.bucket_drop(bucket_name, options.timeout)
end

#flush_bucket(bucket_name, options = FlushBucketOptions.new) ⇒ Object

Returns void.

Parameters:

  • bucket_name (String)

    name of the bucket

Returns:

  • void

Raises:



126
127
128
# File 'lib/couchbase/management/bucket_manager.rb', line 126

def flush_bucket(bucket_name, options = FlushBucketOptions.new)
  @backend.bucket_flush(bucket_name, options.timeout)
end

#get_all_buckets(options = GetAllBucketsOptions.new) ⇒ Array<BucketSettings>

Get settings for all buckets

Parameters:

Returns:



114
115
116
117
# File 'lib/couchbase/management/bucket_manager.rb', line 114

def get_all_buckets(options = GetAllBucketsOptions.new)
  res = @backend.bucket_get_all(options.timeout)
  res.map { |entry| extract_bucket_settings(entry) }
end

#get_bucket(bucket_name, options = GetBucketOptions.new) ⇒ BucketSettings

Fetch settings of the bucket

Parameters:

  • bucket_name (String)

    name of the bucket

  • options (GetBucketOptions) (defaults to: GetBucketOptions.new)

Returns:

Raises:



105
106
107
108
# File 'lib/couchbase/management/bucket_manager.rb', line 105

def get_bucket(bucket_name, options = GetBucketOptions.new)
  res = @backend.bucket_get(bucket_name, options.timeout)
  extract_bucket_settings(res)
end

#update_bucket(settings, options = UpdateBucketOptions.new) ⇒ Object

Updates the bucket settings

Parameters:

Returns:

  • void

Raises:



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/couchbase/management/bucket_manager.rb', line 66

def update_bucket(settings, options = UpdateBucketOptions.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,
      ejection_policy: settings.ejection_policy,
      max_expiry: settings.max_expiry,
      compression_mode: settings.compression_mode,
      minimum_durability_level: settings.minimum_durability_level,
    }, options.timeout
  )
end