google-cloud-bigtable 0.1.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.
Files changed (88) hide show
  1. checksums.yaml +7 -0
  2. data/.yardopts +10 -0
  3. data/LICENSE +201 -0
  4. data/README.md +65 -0
  5. data/lib/google/bigtable/admin/v2/bigtable_instance_admin_pb.rb +139 -0
  6. data/lib/google/bigtable/admin/v2/bigtable_instance_admin_services_pb.rb +85 -0
  7. data/lib/google/bigtable/admin/v2/bigtable_table_admin_pb.rb +137 -0
  8. data/lib/google/bigtable/admin/v2/bigtable_table_admin_services_pb.rb +117 -0
  9. data/lib/google/bigtable/admin/v2/common_pb.rb +24 -0
  10. data/lib/google/bigtable/admin/v2/instance_pb.rb +72 -0
  11. data/lib/google/bigtable/admin/v2/table_pb.rb +88 -0
  12. data/lib/google/bigtable/v2/bigtable_pb.rb +109 -0
  13. data/lib/google/bigtable/v2/bigtable_services_pb.rb +67 -0
  14. data/lib/google/bigtable/v2/data_pb.rb +155 -0
  15. data/lib/google/cloud/bigtable/admin/credentials.rb +26 -0
  16. data/lib/google/cloud/bigtable/admin/v2/bigtable_instance_admin_client.rb +1417 -0
  17. data/lib/google/cloud/bigtable/admin/v2/bigtable_instance_admin_client_config.json +123 -0
  18. data/lib/google/cloud/bigtable/admin/v2/bigtable_table_admin_client.rb +1079 -0
  19. data/lib/google/cloud/bigtable/admin/v2/bigtable_table_admin_client_config.json +109 -0
  20. data/lib/google/cloud/bigtable/admin/v2/credentials.rb +50 -0
  21. data/lib/google/cloud/bigtable/admin/v2/doc/google/bigtable/admin/v2/bigtable_instance_admin.rb +279 -0
  22. data/lib/google/cloud/bigtable/admin/v2/doc/google/bigtable/admin/v2/bigtable_table_admin.rb +353 -0
  23. data/lib/google/cloud/bigtable/admin/v2/doc/google/bigtable/admin/v2/instance.rb +194 -0
  24. data/lib/google/cloud/bigtable/admin/v2/doc/google/bigtable/admin/v2/table.rb +209 -0
  25. data/lib/google/cloud/bigtable/admin/v2/doc/google/iam/v1/iam_policy.rb +62 -0
  26. data/lib/google/cloud/bigtable/admin/v2/doc/google/iam/v1/policy.rb +127 -0
  27. data/lib/google/cloud/bigtable/admin/v2/doc/google/longrunning/operations.rb +92 -0
  28. data/lib/google/cloud/bigtable/admin/v2/doc/google/protobuf/any.rb +124 -0
  29. data/lib/google/cloud/bigtable/admin/v2/doc/google/protobuf/duration.rb +90 -0
  30. data/lib/google/cloud/bigtable/admin/v2/doc/google/protobuf/empty.rb +28 -0
  31. data/lib/google/cloud/bigtable/admin/v2/doc/google/protobuf/field_mask.rb +223 -0
  32. data/lib/google/cloud/bigtable/admin/v2/doc/google/protobuf/timestamp.rb +106 -0
  33. data/lib/google/cloud/bigtable/admin/v2/doc/google/rpc/status.rb +83 -0
  34. data/lib/google/cloud/bigtable/admin/v2.rb +200 -0
  35. data/lib/google/cloud/bigtable/admin.rb +196 -0
  36. data/lib/google/cloud/bigtable/app_profile/job.rb +102 -0
  37. data/lib/google/cloud/bigtable/app_profile/list.rb +159 -0
  38. data/lib/google/cloud/bigtable/app_profile.rb +373 -0
  39. data/lib/google/cloud/bigtable/chunk_processor.rb +253 -0
  40. data/lib/google/cloud/bigtable/cluster/job.rb +92 -0
  41. data/lib/google/cloud/bigtable/cluster/list.rb +169 -0
  42. data/lib/google/cloud/bigtable/cluster.rb +264 -0
  43. data/lib/google/cloud/bigtable/column_family.rb +280 -0
  44. data/lib/google/cloud/bigtable/column_range.rb +186 -0
  45. data/lib/google/cloud/bigtable/convert.rb +75 -0
  46. data/lib/google/cloud/bigtable/credentials.rb +24 -0
  47. data/lib/google/cloud/bigtable/errors.rb +35 -0
  48. data/lib/google/cloud/bigtable/gc_rule.rb +215 -0
  49. data/lib/google/cloud/bigtable/instance/cluster_map.rb +70 -0
  50. data/lib/google/cloud/bigtable/instance/job.rb +97 -0
  51. data/lib/google/cloud/bigtable/instance/list.rb +159 -0
  52. data/lib/google/cloud/bigtable/instance.rb +921 -0
  53. data/lib/google/cloud/bigtable/longrunning_job.rb +105 -0
  54. data/lib/google/cloud/bigtable/mutation_entry.rb +244 -0
  55. data/lib/google/cloud/bigtable/mutation_operations.rb +338 -0
  56. data/lib/google/cloud/bigtable/policy.rb +163 -0
  57. data/lib/google/cloud/bigtable/project.rb +580 -0
  58. data/lib/google/cloud/bigtable/read_modify_write_rule.rb +129 -0
  59. data/lib/google/cloud/bigtable/read_operations.rb +345 -0
  60. data/lib/google/cloud/bigtable/row.rb +125 -0
  61. data/lib/google/cloud/bigtable/row_filter/chain_filter.rb +539 -0
  62. data/lib/google/cloud/bigtable/row_filter/condition_filter.rb +108 -0
  63. data/lib/google/cloud/bigtable/row_filter/interleave_filter.rb +570 -0
  64. data/lib/google/cloud/bigtable/row_filter/simple_filter.rb +273 -0
  65. data/lib/google/cloud/bigtable/row_filter.rb +593 -0
  66. data/lib/google/cloud/bigtable/row_range.rb +174 -0
  67. data/lib/google/cloud/bigtable/rows_mutator.rb +120 -0
  68. data/lib/google/cloud/bigtable/rows_reader.rb +196 -0
  69. data/lib/google/cloud/bigtable/sample_row_key.rb +82 -0
  70. data/lib/google/cloud/bigtable/service.rb +817 -0
  71. data/lib/google/cloud/bigtable/table/cluster_state.rb +93 -0
  72. data/lib/google/cloud/bigtable/table/column_family_map.rb +68 -0
  73. data/lib/google/cloud/bigtable/table/list.rb +147 -0
  74. data/lib/google/cloud/bigtable/table.rb +676 -0
  75. data/lib/google/cloud/bigtable/v2/bigtable_client.rb +579 -0
  76. data/lib/google/cloud/bigtable/v2/bigtable_client_config.json +65 -0
  77. data/lib/google/cloud/bigtable/v2/credentials.rb +45 -0
  78. data/lib/google/cloud/bigtable/v2/doc/google/bigtable/v2/bigtable.rb +286 -0
  79. data/lib/google/cloud/bigtable/v2/doc/google/bigtable/v2/data.rb +492 -0
  80. data/lib/google/cloud/bigtable/v2/doc/google/protobuf/any.rb +124 -0
  81. data/lib/google/cloud/bigtable/v2/doc/google/protobuf/wrappers.rb +89 -0
  82. data/lib/google/cloud/bigtable/v2/doc/google/rpc/status.rb +83 -0
  83. data/lib/google/cloud/bigtable/v2.rb +132 -0
  84. data/lib/google/cloud/bigtable/value_range.rb +175 -0
  85. data/lib/google/cloud/bigtable/version.rb +22 -0
  86. data/lib/google/cloud/bigtable.rb +223 -0
  87. data/lib/google-cloud-bigtable.rb +167 -0
  88. metadata +283 -0
@@ -0,0 +1,75 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2018 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+
18
+ require "time"
19
+ require "date"
20
+
21
+ module Google
22
+ module Cloud
23
+ module Bigtable
24
+ # @private
25
+ # Helper module for converting Bigtable values.
26
+ module Convert
27
+ module_function
28
+
29
+ # Convert number to protobuf duration.
30
+ #
31
+ # @param number [Float] Seconds with nano seconds
32
+ # @return [Google::Protobuf::Duration, nil]
33
+ def number_to_duration number
34
+ return unless number
35
+
36
+ Google::Protobuf::Duration.new(
37
+ seconds: number.to_i,
38
+ nanos: (number.remainder(1) * 1000000000).round
39
+ )
40
+ end
41
+
42
+ # Convert protobuf durations to float.
43
+ #
44
+ # @param duration [Google::Protobuf::Duration, nil]
45
+ # @return [Float, Integer, nil] Seconds with nano seconds
46
+ def duration_to_number duration
47
+ return unless duration
48
+ return duration.seconds if duration.nanos.zero?
49
+
50
+ duration.seconds + (duration.nanos / 1000000000.0)
51
+ end
52
+
53
+ # Convert protobuf timestamp to Time object.
54
+ #
55
+ # @param timestamp [Google::Protobuf::Timestamp]
56
+ # @return [Time, nil]
57
+ def timestamp_to_time timestamp
58
+ return unless timestamp
59
+
60
+ Time.at(timestamp.seconds, timestamp.nanos / 1000.0)
61
+ end
62
+
63
+ # Convert time to timestamp protobuf object.
64
+ #
65
+ # @param time [Time]
66
+ # @return [Google::Protobuf::Timestamp, nil]
67
+ def time_to_timestamp time
68
+ return unless time
69
+
70
+ Google::Protobuf::Timestamp.new(seconds: time.to_i, nanos: time.nsec)
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,24 @@
1
+ # Copyright 2018 Google LLC
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # https://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ require "google/cloud/bigtable/v2/credentials"
16
+
17
+ module Google
18
+ module Cloud
19
+ module Bigtable
20
+ class Credentials < Google::Cloud::Bigtable::V2::Credentials
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,35 @@
1
+ # Copyright 2018 Google LLC
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # https://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+
16
+ module Google
17
+ module Cloud
18
+ module Bigtable
19
+ # Invalid read row state error
20
+ class InvalidRowStateError < Google::Cloud::Error
21
+ # Invalid row chunk data
22
+ attr_reader :data
23
+
24
+ def initialize message, data = nil
25
+ super(message)
26
+ @data = data if data
27
+ end
28
+ end
29
+
30
+ # Row filter error.
31
+ class RowFilterError < Google::Cloud::Error
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,215 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2018 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+
18
+ module Google
19
+ module Cloud
20
+ module Bigtable
21
+ # # GcRule
22
+ #
23
+ # Rule for determining which cells to delete during garbage collection.
24
+ # Garbage collection executes opportunistically in the background, and
25
+ # so it's possible for reads to return a cell even if it matches the active
26
+ # GC expression for its family.
27
+ #
28
+ # NOTE: GC Rule can hold only one type at a time.
29
+ # GC Rule types:
30
+ # * `max_num_versions` - Delete all cells in a column except the most recent N
31
+ # * `max_age` - Delete cells in a column older than the given age.
32
+ # * `union` - Delete cells that would be deleted by every nested rule.
33
+ # It can have mutiple chainable GC Rules.
34
+ # * `intersection` - Delete cells that would be deleted by any nested rule.
35
+ # It can have mutiple chainable GC Rules.
36
+ #
37
+ # @example Create GC rule instance with max version.
38
+ #
39
+ # gc_rule = Google::Cloud::Bigtable::GcRule.max_versions(3)
40
+ #
41
+ # # Change max verions
42
+ # gc_rule.max_versions = 5
43
+ #
44
+ # @example Create GC rule instance with max age.
45
+ #
46
+ # gc_rule = Google::Cloud::Bigtable::GcRule.max_age(3)
47
+ #
48
+ # # Change max age
49
+ # gc_rule.max_age = 600 # 10 minutes
50
+ #
51
+ # @example Create GC rule instance with union.
52
+ #
53
+ # max_age_gc_rule = Google::Cloud::Bigtable::GcRule.max_age(180)
54
+ # union_gc_rule = Google::Cloud::Bigtable::GcRule.union(max_age_gc_rule)
55
+ #
56
+ # # Change union GC rule
57
+ # gc_rule.union = Google::Cloud::Bigtable::GcRule.max_age(600)
58
+ #
59
+ # @example Create GC rule instance with intersection.
60
+ #
61
+ # max_versions_gc_rule = Google::Cloud::Bigtable::GcRule.max_versions(3)
62
+ # gc_rule = Google::Cloud::Bigtable::GcRule.intersection(max_versions_gc_rule)
63
+ #
64
+ # # Change intersection GC rule
65
+ # gc_rule.intersection = Google::Cloud::Bigtable::GcRule.max_age(600)
66
+ #
67
+ class GcRule
68
+ # @private
69
+ # Creates a new GC Rule instance.
70
+ #
71
+ # @param grpc [Google::Bigtable::Admin::V2::GcRule | nil]
72
+ #
73
+ def initialize grpc = nil
74
+ @grpc = grpc || Google::Bigtable::Admin::V2::GcRule.new
75
+ end
76
+
77
+ # Delete all cells in a column except the most recent N.
78
+ #
79
+ # @param versions [Integer]
80
+ #
81
+ def max_versions= versions
82
+ @grpc.max_num_versions = versions
83
+ end
84
+
85
+ # Get max versions.
86
+ #
87
+ # @return [Integer, nil]
88
+ #
89
+ def max_versions
90
+ @grpc.max_num_versions
91
+ end
92
+
93
+ # Delete cells in a column older than the given age.
94
+ # Values must be at least one millisecond, and will be truncated to
95
+ # microsecond granularity.
96
+ #
97
+ # @param age [Integer] age in seconds
98
+ #
99
+ def max_age= age
100
+ @grpc.max_age = Convert.number_to_duration(age)
101
+ end
102
+
103
+ # Max age in seconds, if max age is set.
104
+ #
105
+ # @return [Integer, nil] Max age in seconds.
106
+ #
107
+ def max_age
108
+ @grpc.max_age.seconds if @grpc.max_age
109
+ end
110
+
111
+ # Delete cells that would be deleted by every nested rule.
112
+ #
113
+ # @param rules [Array<Google::Cloud::Bigtable::GcRule>]
114
+ # List of GcRule with nested rules.
115
+ #
116
+ def intersection= rules
117
+ @grpc.intersection = \
118
+ Google::Bigtable::Admin::V2::GcRule::Intersection.new(
119
+ rules: rules.map(&:to_grpc)
120
+ )
121
+ end
122
+
123
+ # Get intersection GC rules
124
+ #
125
+ # @return [Google::Bigtable::Admin::V2::GcRule::Intersection, nil]
126
+ #
127
+ def intersection
128
+ @grpc.intersection
129
+ end
130
+
131
+ # Delete cells that would be deleted by any nested rule.
132
+ #
133
+ # @param rules [Array<Google::Cloud::Bigtable::GcRule>]
134
+ # List of GcRule with nested rules.
135
+ #
136
+ def union= rules
137
+ @grpc.union = Google::Bigtable::Admin::V2::GcRule::Union.new(
138
+ rules: rules.map(&:to_grpc)
139
+ )
140
+ end
141
+
142
+ # Get union GC rules
143
+ #
144
+ # @return [Google::Bigtable::Admin::V2::GcRule::Union, nil]
145
+ #
146
+ def union
147
+ @grpc.union
148
+ end
149
+
150
+ # Create GcRule instance with max number of versions.
151
+ #
152
+ # @param versions [Integer] Max number of versions
153
+ # @return [Google::Bigtable::Admin::V2::GcRule]
154
+ #
155
+ def self.max_versions versions
156
+ new.tap do |gc_rule|
157
+ gc_rule.max_versions = versions
158
+ end
159
+ end
160
+
161
+ # Create GcRule instance with max age.
162
+ #
163
+ # @param age [Integer] Max age in seconds.
164
+ # @return [Google::Bigtable::Admin::V2::GcRule]
165
+ #
166
+ def self.max_age age
167
+ new.tap do |gc_rule|
168
+ gc_rule.max_age = age
169
+ end
170
+ end
171
+
172
+ # Create union GcRule instance.
173
+ #
174
+ # @param rules [Google::Cloud::Bigtable::GcRule, Array<Google::Cloud::Bigtable::GcRule>]
175
+ # List of GcRule with nested rules.
176
+ # @return [Google::Bigtable::Admin::V2::GcRule]
177
+ #
178
+ def self.union *rules
179
+ new.tap do |gc_rule|
180
+ gc_rule.union = rules
181
+ end
182
+ end
183
+
184
+ # Create intersection GCRule instance.
185
+ #
186
+ # @param rules [Google::Cloud::Bigtable::GcRule, Array<Google::Cloud::Bigtable::GcRule>]
187
+ # List of GcRule with nested rules.
188
+ # @return [Google::Bigtable::Admin::V2::GcRule]
189
+ #
190
+ def self.intersection *rules
191
+ new.tap do |gc_rule|
192
+ gc_rule.intersection = rules
193
+ end
194
+ end
195
+
196
+ # @private
197
+ # Get gRPC instance of GC Rule
198
+ # @return [Google::Bigtable::Admin::V2::GcRule]
199
+ def to_grpc
200
+ @grpc
201
+ end
202
+
203
+ # @private
204
+ #
205
+ # Creates a new GcRule instance from a
206
+ # Google::Bigtable::Admin::V2::GcRule.
207
+ # @param grpc [Google::Bigtable::Admin::V2::GcRule]
208
+ # @return [Google::Cloud::Bigtable::GcRule]
209
+ def self.from_grpc grpc
210
+ new(grpc)
211
+ end
212
+ end
213
+ end
214
+ end
215
+ end
@@ -0,0 +1,70 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2018 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+
18
+ module Google
19
+ module Cloud
20
+ module Bigtable
21
+ class Instance
22
+ # Instance::ClusterMap is a Hash with cluster name and gRPC object.
23
+ # It is used to create instance.
24
+ # @example Create
25
+ #
26
+ # clusters = Google::Cloud::Bigtable::Instance::ClusterMap.new
27
+ #
28
+ # clusters.add("cluster-1", 3, location: "us-east1-b", storage_type: :SSD)
29
+ #
30
+ # # Or
31
+ # cluster.add("cluster-2", 1)
32
+ #
33
+ class ClusterMap < DelegateClass(::Hash)
34
+ # @private
35
+ #
36
+ # Create a new Instance::ClusterMap with an hash of Cluster name and
37
+ # cluster grpc instances.
38
+ def initialize value = {}
39
+ super(value)
40
+ end
41
+
42
+ # Add cluster to map
43
+ #
44
+ # @param name [String] Cluster name
45
+ # @param location [String]
46
+ # The location where this cluster's nodes and storage reside. For best
47
+ # performance, clients should be located as close as possible to this
48
+ # cluster. Currently only zones are supported.
49
+ # @param nodes [Integer] No of nodes
50
+ # @param storage_type [Symbol]
51
+ # Valid values are:
52
+ # * `:SSD`(Flash (SSD) storage should be used),
53
+ # *`:HDD`(Magnetic drive (HDD) storage should be used)
54
+ #
55
+ # If not set then default will set to `:STORAGE_TYPE_UNSPECIFIED`
56
+
57
+ def add name, location, nodes: nil, storage_type: nil
58
+ attrs = {
59
+ serve_nodes: nodes,
60
+ location: location,
61
+ default_storage_type: storage_type
62
+ }.delete_if { |_, v| v.nil? }
63
+
64
+ self[name] = Google::Bigtable::Admin::V2::Cluster.new(attrs)
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,97 @@
1
+ # Copyright 2018 Google LLC
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # https://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+
16
+ module Google
17
+ module Cloud
18
+ module Bigtable
19
+ class Instance
20
+ # # Job
21
+ #
22
+ # A resource representing the long-running, asynchronous processing of
23
+ # an instance create or update operation. The job can be refreshed to
24
+ # retrieve the instance object once the operation has been completed.
25
+ #
26
+ # See {Project#create_instance} and {Instance#update}.
27
+ #
28
+ # @see https://cloud.google.com/bigtable/docs/reference/admin/rpc/google.longrunning#google.longrunning.Operation
29
+ # Long-running Operation
30
+ #
31
+ # @example
32
+ # require "google/cloud/bigtable"
33
+ #
34
+ # bigtable = Google::Cloud::Bigtable.new
35
+ #
36
+ # job = bigtable.create_instance(
37
+ # "my-instance",
38
+ # display_name: "Instance for user data",
39
+ # type: :DEVELOPMENT,
40
+ # labels: { "env" => "dev"}
41
+ # ) do |clusters|
42
+ # clusters.add("test-cluster", "us-east1-b", nodes: 1)
43
+ # end
44
+ #
45
+ # # Check and reload.
46
+ # job.done? #=> false
47
+ # job.reload! # API call
48
+ # job.done? #=> true
49
+ #
50
+ # # OR - Wailt until complete
51
+ # job.wait_until_done!
52
+ # job.done? #=> true
53
+ #
54
+ # if job.error?
55
+ # status = job.error
56
+ # else
57
+ # instance = job.instance
58
+ # end
59
+ #
60
+ #
61
+ class Job < LongrunningJob
62
+ # Get the instance object from operation results.
63
+ #
64
+ # @return [Google::Cloud::Bigtable::Instance, nil] The Instance instance, or
65
+ # `nil` if the operation is not complete.
66
+ #
67
+ # @example
68
+ # require "google/cloud/bigtable"
69
+ #
70
+ # bigtable = Google::Cloud::Bigtable.new
71
+ #
72
+ # job = bigtable.create_instance(
73
+ # "my-instance",
74
+ # "Instance for user data",
75
+ # type: :DEVELOPMENT,
76
+ # labels: { "env" => "dev"}
77
+ # ) do |clusters|
78
+ # clusters.add("test-cluster", "us-east1-b", nodes: 1)
79
+ # end
80
+ #
81
+ # job.done? #=> false
82
+ # job.reload!
83
+ # job.done? #=> true
84
+ #
85
+ # # OR
86
+ # job.wait_until_done!
87
+ #
88
+ # instance = job.instance
89
+ #
90
+ def instance
91
+ Instance.from_grpc(results, service) if results
92
+ end
93
+ end
94
+ end
95
+ end
96
+ end
97
+ end