Class: Google::Cloud::Bigtable::Project
- Inherits:
-
Object
- Object
- Google::Cloud::Bigtable::Project
- Defined in:
- lib/google/cloud/bigtable/project.rb
Overview
Project
Projects are top-level containers in Google Cloud Platform. They store information about billing and authorized users, and they contain Cloud Bigtable data. Each project has a friendly name and a unique ID.
Google::Cloud::Bigtable::Project is the main object for interacting with Cloud Bigtable.
Cluster, Instance objects are created, accessed, and managed by Google::Cloud::Bigtable::Project.
See new and Google::Cloud#bigtable.
Instance Method Summary collapse
-
#clusters(token: nil) ⇒ Array<Google::Cloud::Bigtable::Cluster>
List all clusters in project.
-
#create_instance(instance_id, display_name: nil, type: nil, labels: nil, clusters: nil) {|clusters| ... } ⇒ Google::Cloud::Bigtable::Instance::Job
Create a Bigtable instance.
-
#create_table(instance_id, table_id, column_families: nil, granularity: nil, initial_splits: nil) {|column_families| ... } ⇒ Google::Cloud::Bigtable::Table
Creates a new table in the specified instance.
-
#delete_table(instance_id, table_id) ⇒ Object
Permanently deletes a specified table and all of its data.
-
#instance(instance_id) ⇒ Google::Cloud::Bigtable::Instance?
Get existing Bigtable instance.
-
#instances(token: nil) ⇒ Array<Google::Cloud::Bigtable::Instance>
Retrieves the list of Bigtable instances for the project.
-
#modify_column_families(instance_id, table_id, modifications) ⇒ Google::Cloud::Bigtable::Table
Performs a series of column family modifications on the specified table.
-
#project_id ⇒ String
The identifier for the Cloud Bigtable project.
-
#table(instance_id, table_id, view: nil, perform_lookup: nil, app_profile_id: nil) ⇒ Google::Cloud::Bigtable::Table?
Get table information.
-
#tables(instance_id) ⇒ Array<Google::Cloud::Bigtable::Table>
List all tables for given instance.
Instance Method Details
#clusters(token: nil) ⇒ Array<Google::Cloud::Bigtable::Cluster>
List all clusters in project.
270 271 272 273 274 |
# File 'lib/google/cloud/bigtable/project.rb', line 270 def clusters token: nil ensure_service! grpc = service.list_clusters("-", token: token) Cluster::List.from_grpc(grpc, service, instance_id: "-") end |
#create_instance(instance_id, display_name: nil, type: nil, labels: nil, clusters: nil) {|clusters| ... } ⇒ Google::Cloud::Bigtable::Instance::Job
Create a Bigtable instance.
222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 |
# File 'lib/google/cloud/bigtable/project.rb', line 222 def create_instance \ instance_id, display_name: nil, type: nil, labels: nil, clusters: nil labels = Hash[labels.map { |k, v| [String(k), String(v)] }] if labels instance_attrs = { display_name: display_name, type: type, labels: labels }.delete_if { |_, v| v.nil? } instance = Google::Bigtable::Admin::V2::Instance.new(instance_attrs) clusters ||= Instance::ClusterMap.new yield clusters if block_given? clusters.each_value do |cluster| unless cluster.location == "".freeze cluster.location = service.location_path(cluster.location) end end grpc = service.create_instance( instance_id, instance, clusters.to_h ) Instance::Job.from_grpc(grpc, service) end |
#create_table(instance_id, table_id, column_families: nil, granularity: nil, initial_splits: nil) {|column_families| ... } ⇒ Google::Cloud::Bigtable::Table
Creates a new table in the specified instance. The table can be created with a full set of initial column families, specified in the request.
(See Instance::ColumnFamilyMap) GC Rules for column family see GcRule)
472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 |
# File 'lib/google/cloud/bigtable/project.rb', line 472 def create_table \ instance_id, table_id, column_families: nil, granularity: nil, initial_splits: nil, &block ensure_service! Table.create( service, instance_id, table_id, column_families: column_families, granularity: granularity, initial_splits: initial_splits, &block ) end |
#delete_table(instance_id, table_id) ⇒ Object
Permanently deletes a specified table and all of its data.
506 507 508 509 |
# File 'lib/google/cloud/bigtable/project.rb', line 506 def delete_table instance_id, table_id service.delete_table(instance_id, table_id) true end |
#instance(instance_id) ⇒ Google::Cloud::Bigtable::Instance?
Get existing Bigtable instance.
123 124 125 126 127 128 129 |
# File 'lib/google/cloud/bigtable/project.rb', line 123 def instance instance_id ensure_service! grpc = service.get_instance(instance_id) Instance.from_grpc(grpc, service) rescue Google::Cloud::NotFoundError nil end |
#instances(token: nil) ⇒ Array<Google::Cloud::Bigtable::Instance>
Retrieves the list of Bigtable instances for the project.
101 102 103 104 105 |
# File 'lib/google/cloud/bigtable/project.rb', line 101 def instances token: nil ensure_service! grpc = service.list_instances(token: token) Instance::List.from_grpc(grpc, service) end |
#modify_column_families(instance_id, table_id, modifications) ⇒ Google::Cloud::Bigtable::Table
Performs a series of column family modifications on the specified table. Either all or none of the modifications will occur before this method returns, but data requests received prior to that point may see a table where only some modifications have taken effect.
558 559 560 561 562 563 564 565 566 |
# File 'lib/google/cloud/bigtable/project.rb', line 558 def modify_column_families instance_id, table_id, modifications ensure_service! Table.modify_column_families( service, instance_id, table_id, modifications ) end |
#project_id ⇒ String
The identifier for the Cloud Bigtable project.
78 79 80 81 |
# File 'lib/google/cloud/bigtable/project.rb', line 78 def project_id ensure_service! service.project_id end |
#table(instance_id, table_id, view: nil, perform_lookup: nil, app_profile_id: nil) ⇒ Google::Cloud::Bigtable::Table?
Get table information.
377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 |
# File 'lib/google/cloud/bigtable/project.rb', line 377 def table \ instance_id, table_id, view: nil, perform_lookup: nil, app_profile_id: nil ensure_service! table = if perform_lookup grpc = service.get_table(instance_id, table_id, view: view) Table.from_grpc(grpc, service, view: view) else Table.from_path( service.table_path(instance_id, table_id), service ) end table.app_profile_id = app_profile_id table rescue Google::Cloud::NotFoundError nil end |
#tables(instance_id) ⇒ Array<Google::Cloud::Bigtable::Table>
List all tables for given instance.
292 293 294 295 296 |
# File 'lib/google/cloud/bigtable/project.rb', line 292 def tables instance_id ensure_service! grpc = service.list_tables(instance_id) Table::List.from_grpc(grpc, service) end |