Class: Couchbase::Protostellar::Management::BucketManager Private

Inherits:
Object
  • Object
show all
Defined in:
lib/couchbase/protostellar/management/bucket_manager.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ BucketManager

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of BucketManager.



27
28
29
30
# File 'lib/couchbase/protostellar/management/bucket_manager.rb', line 27

def initialize(client)
  @client = client
  @request_generator = RequestGenerator::Admin::Bucket.new
end

Instance Method Details

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

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



32
33
34
35
# File 'lib/couchbase/protostellar/management/bucket_manager.rb', line 32

def create_bucket(settings, options = Couchbase::Management::Options::Bucket::CreateBucket.new)
  req = @request_generator.create_bucket_request(settings, options)
  @client.send_request(req)
end

#drop_bucket(settings, options = Couchbase::Management::Options::Bucket::DropBucket.new) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



42
43
44
45
# File 'lib/couchbase/protostellar/management/bucket_manager.rb', line 42

def drop_bucket(settings, options = Couchbase::Management::Options::Bucket::DropBucket.new)
  req = @request_generator.delete_bucket_request(settings, options)
  @client.send_request(req)
end

#flush_bucket(_bucket_name, _options = Couchbase::Management::Options::Bucket::FlushBucket.new) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



61
62
63
# File 'lib/couchbase/protostellar/management/bucket_manager.rb', line 61

def flush_bucket(_bucket_name, _options = Couchbase::Management::Options::Bucket::FlushBucket.new)
  raise Couchbase::Error::FeatureNotAvailable, "The #{Protostellar::NAME} protocol does not support flush_bucket yet"
end

#get_all_buckets(options = Couchbase::Management::Options::Bucket::GetAllBuckets.new) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



47
48
49
50
51
# File 'lib/couchbase/protostellar/management/bucket_manager.rb', line 47

def get_all_buckets(options = Couchbase::Management::Options::Bucket::GetAllBuckets.new)
  req = @request_generator.list_buckets_request(options)
  resp = @client.send_request(req)
  ResponseConverter::Admin::Bucket.to_bucket_settings_array(resp)
end

#get_bucket(bucket_name, options = Couchbase::Management::Options::Bucket::GetBucket.new) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



53
54
55
56
57
58
59
# File 'lib/couchbase/protostellar/management/bucket_manager.rb', line 53

def get_bucket(bucket_name, options = Couchbase::Management::Options::Bucket::GetBucket.new)
  buckets = get_all_buckets(options)
  bucket = buckets.find { |b| b.name == bucket_name }
  raise Couchbase::Error::BucketNotFound, "Could not find bucket '#{bucket_name}'" if bucket.nil?

  bucket
end

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

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



37
38
39
40
# File 'lib/couchbase/protostellar/management/bucket_manager.rb', line 37

def update_bucket(settings, options = Couchbase::Management::Options::Bucket::UpdateBucket.new)
  req = @request_generator.update_bucket_request(settings, options)
  @client.send_request(req)
end