Class: Couchbase::Protostellar::RequestGenerator::Admin::Query Private

Inherits:
Object
  • Object
show all
Defined in:
lib/couchbase/protostellar/request_generator/admin/query.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(bucket_name: nil, scope_name: nil, collection_name: nil) ⇒ Query

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



25
26
27
28
29
# File 'lib/couchbase/protostellar/request_generator/admin/query.rb', line 25

def initialize(bucket_name: nil, scope_name: nil, collection_name: nil)
  @bucket_name = bucket_name
  @scope_name = scope_name
  @collection_name = collection_name
end

Instance Method Details

#build_deferred_indexes_request(options, bucket_name = nil) ⇒ 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.



97
98
99
100
101
102
103
104
105
# File 'lib/couchbase/protostellar/request_generator/admin/query.rb', line 97

def build_deferred_indexes_request(options, bucket_name = nil)
  proto_req = Generated::Admin::Query::V1::BuildDeferredIndexesRequest.new(
    **location(
      bucket_name: bucket_name, scope_name: options.scope_name, collection_name: options.collection_name
    )
  )

  create_request(proto_req, :build_deferred_indexes, options)
end

#create_index_request(index_name, fields, options, bucket_name = nil) ⇒ 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.



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/couchbase/protostellar/request_generator/admin/query.rb', line 58

def create_index_request(index_name, fields, options, bucket_name = nil)
  proto_opts = {
    deferred: options.deferred,
  }
  proto_opts[:num_replicas] = options.num_replicas unless options.num_replicas.nil?

  proto_req = Generated::Admin::Query::V1::CreateIndexRequest.new(
    **location(
      bucket_name: bucket_name, scope_name: options.scope_name, collection_name: options.collection_name
    ),
    name: index_name,
    fields: fields,
    **proto_opts
  )

  create_request(proto_req, :create_index, options)
end

#create_primary_index_request(options, bucket_name = nil) ⇒ 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.



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/couchbase/protostellar/request_generator/admin/query.rb', line 41

def create_primary_index_request(options, bucket_name = nil)
  proto_opts = {
    deferred: options.deferred,
  }
  proto_opts[:name] = options.index_name unless options.index_name.nil?
  proto_opts[:num_replicas] = options.num_replicas unless options.num_replicas.nil?

  proto_req = Generated::Admin::Query::V1::CreatePrimaryIndexRequest.new(
    **location(
      bucket_name: bucket_name, scope_name: options.scope_name, collection_name: options.collection_name
    ),
    **proto_opts
  )

  create_request(proto_req, :create_primary_index, options)
end

#drop_index_request(index_name, options, bucket_name = nil) ⇒ 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.



86
87
88
89
90
91
92
93
94
95
# File 'lib/couchbase/protostellar/request_generator/admin/query.rb', line 86

def drop_index_request(index_name, options, bucket_name = nil)
  proto_req = Generated::Admin::Query::V1::DropIndexRequest.new(
    **location(
      bucket_name: bucket_name, scope_name: options.scope_name, collection_name: options.collection_name
    ),
    name: index_name
  )

  create_request(proto_req, :drop_index, options)
end

#drop_primary_index_request(options, bucket_name = nil) ⇒ 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.



76
77
78
79
80
81
82
83
84
# File 'lib/couchbase/protostellar/request_generator/admin/query.rb', line 76

def drop_primary_index_request(options, bucket_name = nil)
  proto_req = Generated::Admin::Query::V1::DropPrimaryIndexRequest.new(
    **location(
      bucket_name: bucket_name, scope_name: options.scope_name, collection_name: options.collection_name
    )
  )

  create_request(proto_req, :drop_primary_index, options)
end

#get_all_indexes_request(options, bucket_name = nil) ⇒ 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.



31
32
33
34
35
36
37
38
39
# File 'lib/couchbase/protostellar/request_generator/admin/query.rb', line 31

def get_all_indexes_request(options, bucket_name = nil)
  proto_req = Generated::Admin::Query::V1::GetAllIndexesRequest.new(
    **location(
      bucket_name: bucket_name, scope_name: options.scope_name, collection_name: options.collection_name
    )
  )

  create_request(proto_req, :get_all_indexes, options, idempotent: true)
end