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 and Instance objects are created, accessed, and managed by Google::Cloud::Bigtable::Project.
To create a Project instance, use new.
Instance Method Summary collapse
-
#clusters(token: nil) ⇒ Array<Google::Cloud::Bigtable::Cluster>
Lists all clusters in the project.
-
#copy_backup(dest_project_id:, dest_instance_id:, dest_cluster_id:, new_backup_id:, source_instance_id:, source_cluster_id:, source_backup_id:, expire_time:) ⇒ Google::Cloud::Bigtable::Backup::Job
Creates a copy of the backup at the desired location.
-
#create_instance(instance_id, display_name: nil, type: nil, labels: nil, clusters: nil) {|clusters| ... } ⇒ Google::Cloud::Bigtable::Instance::Job
Creates 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 the specified table and all of its data.
-
#instance(instance_id) ⇒ Google::Cloud::Bigtable::Instance?
Gets an existing Bigtable instance.
-
#instance_admin_client ⇒ Google::Cloud::Bigtable::Admin::V2::BigtableInstanceAdmin::Client
Retrieve a client for instance administration.
-
#instances(token: nil) ⇒ Array<Google::Cloud::Bigtable::Instance>
Retrieves the list of Bigtable instances for the project.
-
#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?
Returns a table representation.
-
#table_admin_client ⇒ Google::Cloud::Bigtable::Admin::V2::BigtableTableAdmin::Client
Retrieve a client for table administration.
-
#tables(instance_id) ⇒ Array<Google::Cloud::Bigtable::Table>
Lists all tables for the given instance.
-
#universe_domain ⇒ String
The universe domain the client is connected to.
Instance Method Details
#clusters(token: nil) ⇒ Array<Google::Cloud::Bigtable::Cluster>
Lists all clusters in the project.
295 296 297 298 299 |
# File 'lib/google/cloud/bigtable/project.rb', line 295 def clusters token: nil ensure_service! grpc = service.list_clusters "-", token: token Cluster::List.from_grpc grpc, service, instance_id: "-" end |
#copy_backup(dest_project_id:, dest_instance_id:, dest_cluster_id:, new_backup_id:, source_instance_id:, source_cluster_id:, source_backup_id:, expire_time:) ⇒ Google::Cloud::Bigtable::Backup::Job
Creates a copy of the backup at the desired location. Copy of the backup won't be created if the backup is already a copied one.
539 540 541 542 543 544 545 546 547 548 549 550 551 |
# File 'lib/google/cloud/bigtable/project.rb', line 539 def copy_backup dest_project_id:, dest_instance_id:, dest_cluster_id:, new_backup_id:, source_instance_id:, source_cluster_id:, source_backup_id:, expire_time: ensure_service! grpc = service.copy_backup project_id: dest_project_id, instance_id: dest_instance_id, cluster_id: dest_cluster_id, backup_id: new_backup_id, source_backup: service.backup_path(source_instance_id, source_cluster_id, source_backup_id), expire_time: expire_time Backup::Job.from_grpc grpc, service end |
#create_instance(instance_id, display_name: nil, type: nil, labels: nil, clusters: nil) {|clusters| ... } ⇒ Google::Cloud::Bigtable::Instance::Job
Creates a Bigtable instance.
261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 |
# File 'lib/google/cloud/bigtable/project.rb', line 261 def create_instance instance_id, display_name: nil, type: nil, labels: nil, clusters: nil labels = labels.to_h { |k, v| [String(k), String(v)] } if labels instance_attrs = { display_name: display_name, type: type, labels: labels }.compact instance = Google::Cloud::Bigtable::Admin::V2::Instance.new instance_attrs clusters ||= Instance::ClusterMap.new yield clusters if block_given? clusters.each_value do |cluster| cluster.location = service.location_path cluster.location unless cluster.location == "" 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.
459 460 461 462 463 464 465 466 467 468 469 470 |
# File 'lib/google/cloud/bigtable/project.rb', line 459 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 the specified table and all of its data.
487 488 489 490 |
# File 'lib/google/cloud/bigtable/project.rb', line 487 def delete_table instance_id, table_id service.delete_table instance_id, table_id true end |
#instance(instance_id) ⇒ Google::Cloud::Bigtable::Instance?
Gets an existing Bigtable instance.
161 162 163 164 165 166 167 |
# File 'lib/google/cloud/bigtable/project.rb', line 161 def instance instance_id ensure_service! grpc = service.get_instance instance_id Instance.from_grpc grpc, service rescue Google::Cloud::NotFoundError nil end |
#instance_admin_client ⇒ Google::Cloud::Bigtable::Admin::V2::BigtableInstanceAdmin::Client
Retrieve a client for instance administration. This client should be used for instance administration operations such as managing clusters, instances, and app profiles. See https://cloud.google.com/ruby/docs/reference/google-cloud-bigtable-admin-v2/latest/Google-Cloud-Bigtable-Admin-V2-BigtableInstanceAdmin-Client for documentation on this class.
73 74 75 |
# File 'lib/google/cloud/bigtable/project.rb', line 73 def instance_admin_client service.instances end |
#instances(token: nil) ⇒ Array<Google::Cloud::Bigtable::Instance>
Retrieves the list of Bigtable instances for the project.
138 139 140 141 142 |
# File 'lib/google/cloud/bigtable/project.rb', line 138 def instances token: nil ensure_service! grpc = service.list_instances token: token Instance::List.from_grpc grpc, service end |
#project_id ⇒ String
The identifier for the Cloud Bigtable project.
114 115 116 117 |
# File 'lib/google/cloud/bigtable/project.rb', line 114 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?
Returns a table representation. If perform_lookup is false (the default), a sparse representation will be
returned without performing an RPC and without verifying that the table resource exists.
377 378 379 380 381 382 383 384 385 386 387 388 389 |
# 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! view ||= :SCHEMA_VIEW if perform_lookup grpc = service.get_table instance_id, table_id, view: view Table.from_grpc grpc, service, view: view, app_profile_id: app_profile_id else Table.from_path service.table_path(instance_id, table_id), service, app_profile_id: app_profile_id end rescue Google::Cloud::NotFoundError nil end |
#table_admin_client ⇒ Google::Cloud::Bigtable::Admin::V2::BigtableTableAdmin::Client
Retrieve a client for table administration. This client should be used for table administration operations such as managing tables, backups, snapshots, and authorized views. See https://cloud.google.com/ruby/docs/reference/google-cloud-bigtable-admin-v2/latest/Google-Cloud-Bigtable-Admin-V2-BigtableTableAdmin-Client for documentation on this class.
86 87 88 |
# File 'lib/google/cloud/bigtable/project.rb', line 86 def table_admin_client service.tables end |
#tables(instance_id) ⇒ Array<Google::Cloud::Bigtable::Table>
Lists all tables for the given instance.
318 319 320 321 322 |
# File 'lib/google/cloud/bigtable/project.rb', line 318 def tables instance_id ensure_service! grpc = service.list_tables instance_id Table::List.from_grpc grpc, service end |
#universe_domain ⇒ String
The universe domain the client is connected to
94 95 96 97 |
# File 'lib/google/cloud/bigtable/project.rb', line 94 def universe_domain ensure_service! service.universe_domain end |