google-cloud-bigtable 2.11.1 → 2.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 181c696f1d64a700deb5f67d1016a4418fb204b3830da7ee07eac490b7215214
4
- data.tar.gz: 550c9917f375b880c02862916f15b22a7d5ebf82ee75c097d96160dc847a6b3d
3
+ metadata.gz: d532accadd2ab9206259a83bc75b52a460d8e15e2253c81ee9f7124fdefbfa83
4
+ data.tar.gz: d1bee0fb74cf2522095176d827323731d347e6a60575f3b2beb1f664879aa616
5
5
  SHA512:
6
- metadata.gz: f0b52d13a6236bbf5ec702dd3e5f157113ae8a9926cf7450c5c5823d268066d12e3380fc6b79016d9e7e7298a6db540c2b8571032805c926fc3bafaec795d94c
7
- data.tar.gz: 9edb14a3040f7fff3ea9fb4b07efcdbd4dadc41bb687f2d9efc8a3c167b7a2e46d96fbff2293e0cd20ce2066149c8195bb3f588d9634ac5583e57a6be73a6e24
6
+ metadata.gz: 3c7164cb81c2f57bbfadb426cc1038fe1fe817cb102e6305e468c41034e0f081e4e13183c6490b49c93203b8390b4415e8288e84a3c2a330beb2a0f4b80b0fae
7
+ data.tar.gz: e8c61bb38bc9a0297cbf2954323239bd4ebd95a4578627b1a1707683b7e40b35e50bfd3e5f2dd8d90389330cad1562e88cd0de946006a71500db0060d4d00143
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Release History
2
2
 
3
+ ### 2.12.0 (2025-02-25)
4
+
5
+ #### Features
6
+
7
+ * Provide easier access to the admin clients ([#28917](https://github.com/googleapis/google-cloud-ruby/issues/28917))
8
+ * Support for setting the universe domain ([#29173](https://github.com/googleapis/google-cloud-ruby/issues/29173))
9
+
3
10
  ### 2.11.1 (2024-12-12)
4
11
 
5
12
  #### Bug Fixes
data/OVERVIEW.md CHANGED
@@ -25,22 +25,34 @@ allocation of resources that are used by Cloud Bigtable. When you create an
25
25
  instance, you must specify at least one cluster. Clusters describe where your
26
26
  data is stored and how many nodes are used for your data.
27
27
 
28
- Use {Google::Cloud::Bigtable::Project#create_instance Project#create_instance}
29
- to create an instance. The following example creates a production instance with
30
- one cluster and three nodes:
28
+ To create an instance, use the instance admin client, which you can get from
29
+ {Google::Cloud::Bigtable::Project#instance_admin_client Project#instance_admin_client}.
30
+ The following example creates a production instance with one cluster and three
31
+ nodes:
31
32
 
32
33
  ```ruby
33
34
  require "google/cloud/bigtable"
34
35
 
35
36
  bigtable = Google::Cloud::Bigtable.new
37
+ instance_client = bigtable.instance_admin_client
36
38
 
37
- job = bigtable.create_instance(
38
- "my-instance",
39
+ instance_attrs = {
39
40
  display_name: "Instance for user data",
40
41
  labels: { "env" => "dev"}
41
- ) do |clusters|
42
- clusters.add("test-cluster", "us-east1-b", nodes: 3, storage_type: :SSD)
43
- end
42
+ }
43
+ clusters = {
44
+ "test-cluster" => {
45
+ location: "us-east1-b",
46
+ nodes: 3,
47
+ storage_type: :SSD
48
+ }
49
+ }
50
+ job = instance_client.create_instance(
51
+ parent: "projects/my-project",
52
+ instance_id: "my-instance",
53
+ instance: instance_attrs,
54
+ clusters: clusters
55
+ )
44
56
 
45
57
  job.done? #=> false
46
58
 
@@ -51,7 +63,7 @@ job.done? #=> true
51
63
  if job.error?
52
64
  status = job.error
53
65
  else
54
- instance = job.instance
66
+ instance = job.response.instance
55
67
  end
56
68
  ```
57
69
 
@@ -61,19 +73,28 @@ monitoring or throughput guarantees; replication is not available; and the SLA
61
73
  does not apply. When creating a development instance, you do not specify `nodes`
62
74
  for your clusters:
63
75
 
64
- ```ruby
76
+ ```ruby
65
77
  require "google/cloud/bigtable"
66
78
 
67
79
  bigtable = Google::Cloud::Bigtable.new
80
+ instance_client = bigtable.instance_admin_client
68
81
 
69
- job = bigtable.create_instance(
70
- "my-instance",
82
+ instance_attrs = {
71
83
  display_name: "Instance for user data",
72
84
  type: :DEVELOPMENT,
73
85
  labels: { "env" => "dev"}
74
- ) do |clusters|
75
- clusters.add("test-cluster", "us-east1-b") # nodes not allowed
76
- end
86
+ }
87
+ clusters = {
88
+ "test-cluster" => {
89
+ location: "us-east1-b", # nodes not allowed
90
+ }
91
+ }
92
+ job = instance_client.create_instance(
93
+ parent: "projects/my-project",
94
+ instance_id: "my-instance",
95
+ instance: instance_attrs,
96
+ clusters: clusters
97
+ )
77
98
 
78
99
  job.done? #=> false
79
100
 
@@ -84,9 +105,9 @@ job.done? #=> true
84
105
  if job.error?
85
106
  status = job.error
86
107
  else
87
- instance = job.instance
108
+ instance = job.response.instance
88
109
  end
89
- ```
110
+ ```
90
111
 
91
112
  You can upgrade a development instance to a production instance at any time.
92
113
 
@@ -105,20 +126,25 @@ different timestamps, providing a record of how the stored data has been altered
105
126
  over time. Cloud Bigtable tables are sparse; if a cell does not contain any
106
127
  data, it does not take up any space.
107
128
 
108
- Use {Google::Cloud::Bigtable::Project#create_table Project#create_table} or
109
- {Google::Cloud::Bigtable::Instance#create_table Instance#create_table} to
110
- create a table:
129
+ To create an instance, use the table admin client, which you can get from
130
+ {Google::Cloud::Bigtable::Project#table_admin_client Project#table_admin_client},
131
+ as illustrated in the following example:
111
132
 
112
133
  ```ruby
113
134
  require "google/cloud/bigtable"
114
135
 
115
136
  bigtable = Google::Cloud::Bigtable.new
137
+ table_client = bigtable.table_admin_client
138
+
139
+ instance_name = table_client.instance_path project: "my-project", instance: "my-instance"
140
+ table = table_client.create_table parent: instance_name,
141
+ table_id: "my-table",
142
+ table: {}
116
143
 
117
- table = bigtable.create_table("my-instance", "my-table")
118
144
  puts table.name
119
145
  ```
120
146
 
121
- When you create a table, you may specify the column families to use in the
147
+ When you create a table, you can specify the column families to use in the
122
148
  table, as well as a list of row keys that will be used to initially split the
123
149
  table into several tablets (tablets are similar to HBase regions):
124
150
 
@@ -126,45 +152,75 @@ table into several tablets (tablets are similar to HBase regions):
126
152
  require "google/cloud/bigtable"
127
153
 
128
154
  bigtable = Google::Cloud::Bigtable.new
129
-
130
- initial_splits = ["user-00001", "user-100000", "others"]
131
- table = bigtable.create_table("my-instance", "my-table", initial_splits: initial_splits) do |cfm|
132
- cfm.add('cf1', gc_rule: Google::Cloud::Bigtable::GcRule.max_versions(5))
133
- cfm.add('cf2', gc_rule: Google::Cloud::Bigtable::GcRule.max_age(600))
134
-
135
- gc_rule = Google::Cloud::Bigtable::GcRule.union(
136
- Google::Cloud::Bigtable::GcRule.max_age(1800),
137
- Google::Cloud::Bigtable::GcRule.max_versions(3)
138
- )
139
- cfm.add('cf3', gc_rule: gc_rule)
140
- end
155
+ table_client = bigtable.table_admin_client
156
+
157
+ instance_name = table_client.instance_path project: "my-project", instance: "my-instance"
158
+ initial_splits = [
159
+ {key: "user-00001"},
160
+ {key: "user-100000"},
161
+ {key: "others"}
162
+ ]
163
+ column_families = {
164
+ "cf1" => {
165
+ gc_rule: Google::Cloud::Bigtable::Admin::V2::GcRule.max_num_versions(5)
166
+ },
167
+ "cf2" => {
168
+ gc_rule: Google::Cloud::Bigtable::Admin::V2::GcRule.max_age(600)
169
+ },
170
+ "cf3" => {
171
+ gc_rule: Google::Cloud::Bigtable::Admin::V2::GcRule.union(
172
+ Google::Cloud::Bigtable::Admin::V2::GcRule.max_age(1800),
173
+ Google::Cloud::Bigtable::Admin::V2::GcRule.max_num_versions(3)
174
+ )
175
+ }
176
+ }
177
+ table = table_client.create_table parent: instance_name,
178
+ table_id: "my-table",
179
+ table: {column_families: column_families},
180
+ initial_splits: initial_splits
141
181
 
142
182
  puts table
143
183
  ```
144
184
 
145
- You may also add, update, and delete column families later by passing a block to
146
- {Google::Cloud::Bigtable::Table#column_families Table#column_families}:
185
+ You can also add, update, and delete column families later:
147
186
 
148
187
  ```ruby
149
188
  require "google/cloud/bigtable"
150
189
 
151
190
  bigtable = Google::Cloud::Bigtable.new
152
-
153
- table = bigtable.table("my-instance", "my-table", perform_lookup: true)
154
-
155
- table.column_families do |cfm|
156
- cfm.add "cf4", gc_rule: Google::Cloud::Bigtable::GcRule.max_age(600)
157
- cfm.add "cf5", gc_rule: Google::Cloud::Bigtable::GcRule.max_versions(5)
158
-
159
- rule_1 = Google::Cloud::Bigtable::GcRule.max_versions(3)
160
- rule_2 = Google::Cloud::Bigtable::GcRule.max_age(600)
161
- rule_union = Google::Cloud::Bigtable::GcRule.union(rule_1, rule_2)
162
- cfm.update "cf2", gc_rule: rule_union
163
-
164
- cfm.delete "cf3"
165
- end
166
-
167
- puts table.column_families["cf3"] #=> nil
191
+ table_client = bigtable.table_admin_client
192
+
193
+ table_name = table_client.table_path project: "my-project",
194
+ instance: "my-instance",
195
+ table: "my-table"
196
+ modifications = [
197
+ {
198
+ id: "cf4",
199
+ create: {
200
+ gc_rule: Google::Cloud::Bigtable::Admin::V2::GcRule.max_age(600)
201
+ }
202
+ },
203
+ {
204
+ id: "cf5",
205
+ create: {
206
+ gc_rule: Google::Cloud::Bigtable::Admin::V2::GcRule.max_num_versions(5)
207
+ }
208
+ },
209
+ {
210
+ id: "cf2",
211
+ update: {
212
+ gc_rule: Google::Cloud::Bigtable::Admin::V2::GcRule.union(
213
+ Google::Cloud::Bigtable::Admin::V2::GcRule.max_age(600),
214
+ Google::Cloud::Bigtable::Admin::V2::GcRule.max_num_versions(3)
215
+ )
216
+ }
217
+ },
218
+ {
219
+ id: "cf3",
220
+ drop: true
221
+ }
222
+ ]
223
+ table_client.modify_column_families name: table_name, modifications: modifications
168
224
  ```
169
225
 
170
226
  ## Writing data
@@ -61,6 +61,41 @@ module Google
61
61
  @service = service
62
62
  end
63
63
 
64
+ ##
65
+ # Retrieve a client for instance administration. This client should be
66
+ # used for instance administration operations such as managing
67
+ # clusters, instances, and app profiles. See
68
+ # https://cloud.google.com/ruby/docs/reference/google-cloud-bigtable-admin-v2/latest/Google-Cloud-Bigtable-Admin-V2-BigtableInstanceAdmin-Client
69
+ # for documentation on this class.
70
+ #
71
+ # @return [Google::Cloud::Bigtable::Admin::V2::BigtableInstanceAdmin::Client]
72
+ #
73
+ def instance_admin_client
74
+ service.instances
75
+ end
76
+
77
+ ##
78
+ # Retrieve a client for table administration. This client should be
79
+ # used for table administration operations such as managing tables,
80
+ # backups, snapshots, and authorized views. See
81
+ # https://cloud.google.com/ruby/docs/reference/google-cloud-bigtable-admin-v2/latest/Google-Cloud-Bigtable-Admin-V2-BigtableTableAdmin-Client
82
+ # for documentation on this class.
83
+ #
84
+ # @return [Google::Cloud::Bigtable::Admin::V2::BigtableTableAdmin::Client]
85
+ #
86
+ def table_admin_client
87
+ service.tables
88
+ end
89
+
90
+ # The universe domain the client is connected to
91
+ #
92
+ # @return [String]
93
+ #
94
+ def universe_domain
95
+ ensure_service!
96
+ service.universe_domain
97
+ end
98
+
64
99
  ##
65
100
  # The identifier for the Cloud Bigtable project.
66
101
  #
@@ -33,6 +33,11 @@ module Google
33
33
  # @private
34
34
  attr_accessor :project_id, :credentials, :host, :host_admin, :timeout
35
35
 
36
+ # @private
37
+ def universe_domain
38
+ tables.universe_domain
39
+ end
40
+
36
41
  # @private
37
42
  # Creates a new Service instance.
38
43
  #
@@ -53,7 +58,7 @@ module Google
53
58
  # The default timeout, in seconds, for calls made through this client.
54
59
  #
55
60
  def initialize project_id, credentials, host: nil, host_admin: nil, timeout: nil,
56
- channel_selection: nil, channel_count: nil
61
+ channel_selection: nil, channel_count: nil, universe_domain: nil
57
62
  @project_id = project_id
58
63
  @credentials = credentials
59
64
  @host = host
@@ -61,6 +66,7 @@ module Google
61
66
  @timeout = timeout
62
67
  @channel_selection = channel_selection
63
68
  @channel_count = channel_count
69
+ @universe_domain_override = universe_domain
64
70
  @bigtable_clients = ::Gapic::LruHash.new 10
65
71
  @mutex = Mutex.new
66
72
  end
@@ -68,6 +74,7 @@ module Google
68
74
  def instances
69
75
  return mocked_instances if mocked_instances
70
76
  @instances ||= Admin::V2::BigtableInstanceAdmin::Client.new do |config|
77
+ config.universe_domain = @universe_domain_override if @universe_domain_override
71
78
  config.credentials = credentials if credentials
72
79
  config.timeout = timeout if timeout
73
80
  config.endpoint = host_admin if host_admin
@@ -81,6 +88,7 @@ module Google
81
88
  def tables
82
89
  return mocked_tables if mocked_tables
83
90
  @tables ||= Admin::V2::BigtableTableAdmin::Client.new do |config|
91
+ config.universe_domain = @universe_domain_override if @universe_domain_override
84
92
  config.credentials = credentials if credentials
85
93
  config.timeout = timeout if timeout
86
94
  config.endpoint = host_admin if host_admin
@@ -895,6 +903,7 @@ module Google
895
903
  def create_bigtable_client table_path, app_profile_id
896
904
  V2::Bigtable::Client.new do |config|
897
905
  config.credentials = credentials if credentials
906
+ config.universe_domain = @universe_domain_override if @universe_domain_override
898
907
  config.timeout = timeout if timeout
899
908
  config.endpoint = host if host
900
909
  config.lib_name = "gccl"
@@ -16,7 +16,7 @@
16
16
  module Google
17
17
  module Cloud
18
18
  module Bigtable
19
- VERSION = "2.11.1".freeze
19
+ VERSION = "2.12.0".freeze
20
20
  end
21
21
  end
22
22
  end
@@ -27,6 +27,9 @@ module Google
27
27
  # See {file:OVERVIEW.md Bigtable Overview}.
28
28
  #
29
29
  module Bigtable
30
+ # rubocop:disable Metrics/CyclomaticComplexity
31
+ # rubocop:disable Metrics/AbcSize
32
+
30
33
  ##
31
34
  # Service for managing Cloud Bigtable instances and tables and for reading from and
32
35
  # writing to Bigtable tables.
@@ -49,11 +52,12 @@ module Google
49
52
  # should already be composed with a `GRPC::Core::CallCredentials` object.
50
53
  # `Proc` will be used as an updater_proc for the gRPC channel. The proc transforms the
51
54
  # metadata for requests, generally, to give OAuth credentials.
52
- # @param [String] endpoint Override of the endpoint host name. Optional.
55
+ # @param universe_domain [String] Override of the universe domain. Optional.
56
+ # @param endpoint [String] Override of the endpoint host name. Optional.
53
57
  # If the param is nil, uses the default endpoint.
54
- # @param [String] endpoint_admin Override of the admin service endpoint host name. Optional.
58
+ # @param endpoint_admin [String] Override of the admin service endpoint host name. Optional.
55
59
  # If the param is nil, uses the default admin endpoint.
56
- # @param [String] emulator_host Bigtable emulator host. Optional.
60
+ # @param emulator_host [String] Bigtable emulator host. Optional.
57
61
  # If the parameter is nil, uses the value of the `emulator_host` config.
58
62
  # @param scope [Array<String>]
59
63
  # The OAuth 2.0 scopes controlling the set of resources and operations
@@ -74,10 +78,9 @@ module Google
74
78
  #
75
79
  # client = Google::Cloud::Bigtable.new
76
80
  #
77
- # rubocop:disable Metrics/CyclomaticComplexity
78
- # rubocop:disable Metrics/AbcSize
79
81
  def self.new project_id: nil,
80
82
  credentials: nil,
83
+ universe_domain: nil,
81
84
  emulator_host: nil,
82
85
  scope: nil,
83
86
  endpoint: nil,
@@ -86,6 +89,7 @@ module Google
86
89
  channel_selection: nil,
87
90
  channel_count: nil
88
91
  project_id ||= default_project_id
92
+ universe_domain ||= configure.universe_domain
89
93
  scope ||= configure.scope
90
94
  timeout ||= configure.timeout
91
95
  emulator_host ||= configure.emulator_host
@@ -100,8 +104,11 @@ module Google
100
104
  project_id = resolve_project_id project_id, credentials
101
105
  raise ArgumentError, "project_id is missing" if project_id.empty?
102
106
 
103
- service = Bigtable::Service.new project_id, credentials, host: endpoint,
104
- host_admin: endpoint_admin, timeout: timeout,
107
+ service = Bigtable::Service.new project_id, credentials,
108
+ universe_domain: universe_domain,
109
+ host: endpoint,
110
+ host_admin: endpoint_admin,
111
+ timeout: timeout,
105
112
  channel_selection: channel_selection,
106
113
  channel_count: channel_count
107
114
  Bigtable::Project.new service
@@ -109,7 +116,6 @@ module Google
109
116
  # rubocop:enable Metrics/CyclomaticComplexity
110
117
  # rubocop:enable Metrics/AbcSize
111
118
 
112
-
113
119
  ##
114
120
  # Configure the Google Cloud Bigtable library.
115
121
  #
@@ -171,8 +171,9 @@ Google::Cloud.configure.add_config! :bigtable do |config|
171
171
  config.add_field! :quota_project, nil, match: String
172
172
  config.add_field! :timeout, nil, match: Integer
173
173
  config.add_field! :emulator_host, default_emulator, match: String, allow_nil: true
174
- config.add_field! :endpoint, "bigtable.googleapis.com", match: String
175
- config.add_field! :endpoint_admin, "bigtableadmin.googleapis.com", match: String
174
+ config.add_field! :endpoint, nil, match: String
175
+ config.add_field! :endpoint_admin, nil, match: String
176
176
  config.add_field! :channel_selection, :least_loaded, match: Symbol
177
177
  config.add_field! :channel_count, 1, match: Integer
178
+ config.add_field! :universe_domain, nil, match: String, allow_nil: true
178
179
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google-cloud-bigtable
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.11.1
4
+ version: 2.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Google LLC
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-12-12 00:00:00.000000000 Z
10
+ date: 2025-02-25 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: concurrent-ruby
@@ -28,42 +27,30 @@ dependencies:
28
27
  name: google-cloud-bigtable-admin-v2
29
28
  requirement: !ruby/object:Gem::Requirement
30
29
  requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0.0'
34
- - - "<"
30
+ - - "~>"
35
31
  - !ruby/object:Gem::Version
36
- version: 2.a
32
+ version: '1.7'
37
33
  type: :runtime
38
34
  prerelease: false
39
35
  version_requirements: !ruby/object:Gem::Requirement
40
36
  requirements:
41
- - - ">="
42
- - !ruby/object:Gem::Version
43
- version: '0.0'
44
- - - "<"
37
+ - - "~>"
45
38
  - !ruby/object:Gem::Version
46
- version: 2.a
39
+ version: '1.7'
47
40
  - !ruby/object:Gem::Dependency
48
41
  name: google-cloud-bigtable-v2
49
42
  requirement: !ruby/object:Gem::Requirement
50
43
  requirements:
51
- - - ">="
52
- - !ruby/object:Gem::Version
53
- version: '0.14'
54
- - - "<"
44
+ - - "~>"
55
45
  - !ruby/object:Gem::Version
56
- version: 2.a
46
+ version: '1.5'
57
47
  type: :runtime
58
48
  prerelease: false
59
49
  version_requirements: !ruby/object:Gem::Requirement
60
50
  requirements:
61
- - - ">="
62
- - !ruby/object:Gem::Version
63
- version: '0.14'
64
- - - "<"
51
+ - - "~>"
65
52
  - !ruby/object:Gem::Version
66
- version: 2.a
53
+ version: '1.5'
67
54
  - !ruby/object:Gem::Dependency
68
55
  name: google-cloud-core
69
56
  requirement: !ruby/object:Gem::Requirement
@@ -148,7 +135,6 @@ homepage: https://github.com/googleapis/google-cloud-ruby/tree/master/google-clo
148
135
  licenses:
149
136
  - Apache-2.0
150
137
  metadata: {}
151
- post_install_message:
152
138
  rdoc_options: []
153
139
  require_paths:
154
140
  - lib
@@ -156,15 +142,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
156
142
  requirements:
157
143
  - - ">="
158
144
  - !ruby/object:Gem::Version
159
- version: '2.7'
145
+ version: '3.0'
160
146
  required_rubygems_version: !ruby/object:Gem::Requirement
161
147
  requirements:
162
148
  - - ">="
163
149
  - !ruby/object:Gem::Version
164
150
  version: '0'
165
151
  requirements: []
166
- rubygems_version: 3.5.23
167
- signing_key:
152
+ rubygems_version: 3.6.5
168
153
  specification_version: 4
169
154
  summary: API Client library for Cloud Bigtable API
170
155
  test_files: []