Class: Couchbase::Management::BucketManager

Inherits:
Object
  • Object
show all
Defined in:
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)
[View source]

23
24
25
# File 'lib/couchbase/management/bucket_manager.rb', line 23

def initialize(backend)
  @backend = backend
end

Instance Method Details

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

Creates new bucket

Parameters:

Returns:

  • void

Raises:

[View source]

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

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,
          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:

[View source]

88
89
90
# File 'lib/couchbase/management/bucket_manager.rb', line 88

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:

[View source]

122
123
124
# File 'lib/couchbase/management/bucket_manager.rb', line 122

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:

[View source]

110
111
112
113
# File 'lib/couchbase/management/bucket_manager.rb', line 110

def get_all_buckets(options = GetAllBucketsOptions.new)
  res = @backend.bucket_get_all(options.timeout)
  res.map(&method(:extract_bucket_settings))
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:

[View source]

101
102
103
104
# File 'lib/couchbase/management/bucket_manager.rb', line 101

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:

[View source]

63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/couchbase/management/bucket_manager.rb', line 63

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,
      }, options.timeout
  )
end