Class: Couchbase::Protostellar::Management::CollectionManager Private

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

Overview

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.

API:

  • private

Instance Method Summary collapse

Constructor Details

#initialize(client:, bucket_name:) ⇒ CollectionManager

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 CollectionManager.

API:

  • private



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

def initialize(client:, bucket_name:)
  @client = client
  @bucket_name = bucket_name
  @request_generator = RequestGenerator::Admin::Collection.new(bucket_name: @bucket_name)
end

Instance Method Details

#create_collection(*args) ⇒ 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.

API:

  • private



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/couchbase/protostellar/management/collection_manager.rb', line 48

def create_collection(*args)
  req =
    if args[0].is_a?(Couchbase::Management::CollectionSpec)
      collection = args[0]
      options = args[1] || Couchbase::Management::Options::Collection::CreateCollection::DEFAULT
      settings = Couchbase::Management::CreateCollectionSettings.new(max_expiry: collection.max_expiry, history: collection.history)

      warn "Calling create_collection with a CollectionSpec object has been deprecated, supply scope name, " \
           "collection name and optionally a CreateCollectionSettings instance"

      @request_generator.create_collection_request(collection.scope_name, collection.name, settings, options)
    else
      scope_name = args[0]
      collection_name = args[1]
      settings = args[2] || Couchbase::Management::CreateCollectionSettings::DEFAULT
      options = args[3] || Couchbase::Management::Options::Collection::CreateCollection::DEFAULT
      @request_generator.create_collection_request(scope_name, collection_name, settings, options)
    end
  @client.send_request(req)
end

#create_scope(scope_name, options = Couchbase::Management::Options::Collection::CreateScope.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.

API:

  • private



38
39
40
41
# File 'lib/couchbase/protostellar/management/collection_manager.rb', line 38

def create_scope(scope_name, options = Couchbase::Management::Options::Collection::CreateScope.new)
  req = @request_generator.create_scope_request(scope_name, options)
  @client.send_request(req)
end

#drop_collection(*args) ⇒ 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.

API:

  • private



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/couchbase/protostellar/management/collection_manager.rb', line 69

def drop_collection(*args)
  req =
    if args[0].is_a?(Couchbase::Management::CollectionSpec)
      collection = args[0]
      options = args[1] || Couchbase::Management::Options::Collection::CreateCollection::DEFAULT

      warn "Calling drop_collection with a CollectionSpec object has been deprecated, supply scope name and collection name"

      @request_generator.delete_collection_request(collection.scope_name, collection.name, options)
    else
      scope_name = args[0]
      collection_name = args[1]
      options = args[2] || Couchbase::Management::Options::Collection::CreateCollection::DEFAULT
      @request_generator.delete_collection_request(scope_name, collection_name, options)
    end
  @client.send_request(req)
end

#drop_scope(scope_name, options = Couchbase::Management::Options::Collection::DropScope.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.

API:

  • private



43
44
45
46
# File 'lib/couchbase/protostellar/management/collection_manager.rb', line 43

def drop_scope(scope_name, options = Couchbase::Management::Options::Collection::DropScope.new)
  req = @request_generator.delete_scope_request(scope_name, options)
  @client.send_request(req)
end

#get_all_scopes(options = Couchbase::Management::Options::Collection::GetAllScopes.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.

API:

  • private



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

def get_all_scopes(options = Couchbase::Management::Options::Collection::GetAllScopes.new)
  req = @request_generator.list_collections_request(options)
  resp = @client.send_request(req)
  ResponseConverter::Admin::Collection.to_scope_spec_array(resp)
end

#update_collection(_scope_name, _collection_name, _settings = UpdateCollectionSettings::DEFAULT, _options = Couchbase::Management::Options::Collection::UpdateCollection::DEFAULT) ⇒ 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.

Raises:

API:

  • private



87
88
89
90
# File 'lib/couchbase/protostellar/management/collection_manager.rb', line 87

def update_collection(_scope_name, _collection_name, _settings = UpdateCollectionSettings::DEFAULT,
                      _options = Couchbase::Management::Options::Collection::UpdateCollection::DEFAULT)
  raise Couchbase::Error::FeatureNotAvailable, "The #{Protostellar::NAME} protocol does not support update_collection"
end