google-cloud-bigtable 1.3.0 → 2.3.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 (87) hide show
  1. checksums.yaml +4 -4
  2. data/AUTHENTICATION.md +1 -1
  3. data/CHANGELOG.md +54 -0
  4. data/CONTRIBUTING.md +1 -1
  5. data/OVERVIEW.md +4 -4
  6. data/lib/google-cloud-bigtable.rb +30 -27
  7. data/lib/google/cloud/bigtable.rb +18 -26
  8. data/lib/google/cloud/bigtable/app_profile.rb +3 -3
  9. data/lib/google/cloud/bigtable/app_profile/list.rb +4 -2
  10. data/lib/google/cloud/bigtable/backup.rb +123 -2
  11. data/lib/google/cloud/bigtable/backup/list.rb +2 -2
  12. data/lib/google/cloud/bigtable/chunk_processor.rb +1 -1
  13. data/lib/google/cloud/bigtable/cluster.rb +2 -2
  14. data/lib/google/cloud/bigtable/cluster/list.rb +1 -1
  15. data/lib/google/cloud/bigtable/column_family.rb +2 -2
  16. data/lib/google/cloud/bigtable/column_family_map.rb +10 -10
  17. data/lib/google/cloud/bigtable/column_range.rb +2 -2
  18. data/lib/google/cloud/bigtable/convert.rb +12 -0
  19. data/lib/google/cloud/bigtable/credentials.rb +36 -2
  20. data/lib/google/cloud/bigtable/gc_rule.rb +7 -7
  21. data/lib/google/cloud/bigtable/instance.rb +8 -8
  22. data/lib/google/cloud/bigtable/instance/cluster_map.rb +1 -1
  23. data/lib/google/cloud/bigtable/instance/list.rb +1 -1
  24. data/lib/google/cloud/bigtable/longrunning_job.rb +2 -2
  25. data/lib/google/cloud/bigtable/mutation_entry.rb +22 -18
  26. data/lib/google/cloud/bigtable/mutation_operations.rb +6 -6
  27. data/lib/google/cloud/bigtable/project.rb +1 -1
  28. data/lib/google/cloud/bigtable/read_modify_write_rule.rb +2 -2
  29. data/lib/google/cloud/bigtable/read_operations.rb +2 -2
  30. data/lib/google/cloud/bigtable/routing_policy.rb +2 -2
  31. data/lib/google/cloud/bigtable/row_filter/chain_filter.rb +3 -3
  32. data/lib/google/cloud/bigtable/row_filter/condition_filter.rb +3 -3
  33. data/lib/google/cloud/bigtable/row_filter/interleave_filter.rb +3 -3
  34. data/lib/google/cloud/bigtable/row_filter/simple_filter.rb +9 -4
  35. data/lib/google/cloud/bigtable/row_range.rb +2 -2
  36. data/lib/google/cloud/bigtable/rows_mutator.rb +3 -3
  37. data/lib/google/cloud/bigtable/rows_reader.rb +10 -10
  38. data/lib/google/cloud/bigtable/sample_row_key.rb +2 -2
  39. data/lib/google/cloud/bigtable/service.rb +239 -281
  40. data/lib/google/cloud/bigtable/table.rb +5 -4
  41. data/lib/google/cloud/bigtable/table/cluster_state.rb +2 -2
  42. data/lib/google/cloud/bigtable/table/list.rb +1 -1
  43. data/lib/google/cloud/bigtable/value_range.rb +26 -8
  44. data/lib/google/cloud/bigtable/version.rb +1 -1
  45. metadata +12 -94
  46. data/lib/google/bigtable/admin/v2/bigtable_instance_admin_pb.rb +0 -145
  47. data/lib/google/bigtable/admin/v2/bigtable_instance_admin_services_pb.rb +0 -90
  48. data/lib/google/bigtable/admin/v2/bigtable_table_admin_pb.rb +0 -208
  49. data/lib/google/bigtable/admin/v2/bigtable_table_admin_services_pb.rb +0 -154
  50. data/lib/google/bigtable/admin/v2/common_pb.rb +0 -30
  51. data/lib/google/bigtable/admin/v2/instance_pb.rb +0 -74
  52. data/lib/google/bigtable/admin/v2/table_pb.rb +0 -127
  53. data/lib/google/bigtable/v2/bigtable_pb.rb +0 -113
  54. data/lib/google/bigtable/v2/bigtable_services_pb.rb +0 -68
  55. data/lib/google/bigtable/v2/data_pb.rb +0 -156
  56. data/lib/google/cloud/bigtable/admin.rb +0 -202
  57. data/lib/google/cloud/bigtable/admin/credentials.rb +0 -27
  58. data/lib/google/cloud/bigtable/admin/v2.rb +0 -223
  59. data/lib/google/cloud/bigtable/admin/v2/bigtable_instance_admin_client.rb +0 -1451
  60. data/lib/google/cloud/bigtable/admin/v2/bigtable_instance_admin_client_config.json +0 -139
  61. data/lib/google/cloud/bigtable/admin/v2/bigtable_table_admin_client.rb +0 -1734
  62. data/lib/google/cloud/bigtable/admin/v2/bigtable_table_admin_client_config.json +0 -163
  63. data/lib/google/cloud/bigtable/admin/v2/credentials.rb +0 -51
  64. data/lib/google/cloud/bigtable/admin/v2/doc/google/bigtable/admin/v2/bigtable_instance_admin.rb +0 -297
  65. data/lib/google/cloud/bigtable/admin/v2/doc/google/bigtable/admin/v2/bigtable_table_admin.rb +0 -587
  66. data/lib/google/cloud/bigtable/admin/v2/doc/google/bigtable/admin/v2/instance.rb +0 -193
  67. data/lib/google/cloud/bigtable/admin/v2/doc/google/bigtable/admin/v2/table.rb +0 -303
  68. data/lib/google/cloud/bigtable/admin/v2/doc/google/iam/v1/iam_policy.rb +0 -64
  69. data/lib/google/cloud/bigtable/admin/v2/doc/google/iam/v1/options.rb +0 -33
  70. data/lib/google/cloud/bigtable/admin/v2/doc/google/iam/v1/policy.rb +0 -151
  71. data/lib/google/cloud/bigtable/admin/v2/doc/google/longrunning/operations.rb +0 -51
  72. data/lib/google/cloud/bigtable/admin/v2/doc/google/protobuf/any.rb +0 -131
  73. data/lib/google/cloud/bigtable/admin/v2/doc/google/protobuf/duration.rb +0 -91
  74. data/lib/google/cloud/bigtable/admin/v2/doc/google/protobuf/empty.rb +0 -29
  75. data/lib/google/cloud/bigtable/admin/v2/doc/google/protobuf/field_mask.rb +0 -222
  76. data/lib/google/cloud/bigtable/admin/v2/doc/google/protobuf/timestamp.rb +0 -113
  77. data/lib/google/cloud/bigtable/admin/v2/doc/google/rpc/status.rb +0 -39
  78. data/lib/google/cloud/bigtable/admin/v2/doc/google/type/expr.rb +0 -45
  79. data/lib/google/cloud/bigtable/v2.rb +0 -146
  80. data/lib/google/cloud/bigtable/v2/bigtable_client.rb +0 -591
  81. data/lib/google/cloud/bigtable/v2/bigtable_client_config.json +0 -83
  82. data/lib/google/cloud/bigtable/v2/credentials.rb +0 -46
  83. data/lib/google/cloud/bigtable/v2/doc/google/bigtable/v2/bigtable.rb +0 -290
  84. data/lib/google/cloud/bigtable/v2/doc/google/bigtable/v2/data.rb +0 -493
  85. data/lib/google/cloud/bigtable/v2/doc/google/protobuf/any.rb +0 -131
  86. data/lib/google/cloud/bigtable/v2/doc/google/protobuf/wrappers.rb +0 -34
  87. data/lib/google/cloud/bigtable/v2/doc/google/rpc/status.rb +0 -39
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 109fb6841cdecd45ebfadc3c2bafd019010847bbe9592ad9f2d9d44e56000d06
4
- data.tar.gz: 41b10cd762bc1c11ef42754af3fb6dc3e9bc5d97bd75e84c74752228596bb245
3
+ metadata.gz: ceb71908240117b3c3e98f009a6be24f4ae9ca510523414b91720aab576f925a
4
+ data.tar.gz: 15c5a7c7617184eac62271c0ba4b2de71b4f9d643c25751dcef0de98dde7d67c
5
5
  SHA512:
6
- metadata.gz: 63fda26d33b5b2185086377ecf4ca64d99d20e19013b97b7a34a11164baefbc2e09e444e4304a22a4ac5da49013bb09803e0d81b55bcd3ac8f94f712e320043d
7
- data.tar.gz: ec6d0a4356a0fb357264bd72654cfb21581c9787e5594e016e81d286345ef25ad6b8b8eb450dd26de061e5ca0ee32bf337fb43beb0847197d039b4007f74b5f0
6
+ metadata.gz: 00155edefe171f720de9af636a6a8be2844f889c1750af57a851de83c567e6fc746ce1dbf2f05515d73f0424acade2566874d096f867af1b8c1f5b99e132e81c
7
+ data.tar.gz: e8a2f9731e9d43897c213ace6810f3a4dcc86a9f5d71eefcf802143c34ca6a151b23e2649081779932c03244e4f3c1ca182f214f122e82b76cbc3a0404d3e54f
data/AUTHENTICATION.md CHANGED
@@ -76,7 +76,7 @@ The environment variables that google-cloud-bigtable checks for project ID are:
76
76
  1. `BIGTABLE_PROJECT`
77
77
  2. `GOOGLE_CLOUD_PROJECT`
78
78
 
79
- The environment variables that google-cloud-bigtable checks for credentials are configured on {Google::Cloud::Bigtable::V2::Credentials}:
79
+ The environment variables that google-cloud-bigtable checks for credentials are configured on {Google::Cloud::Bigtable::Credentials}:
80
80
 
81
81
  1. `BIGTABLE_CREDENTIALS` - Path to JSON file, or JSON contents
82
82
  2. `BIGTABLE_KEYFILE` - Path to JSON file, or JSON contents
data/CHANGELOG.md CHANGED
@@ -1,5 +1,59 @@
1
1
  # Release History
2
2
 
3
+ ### 2.3.0 / 2021-02-04
4
+
5
+ #### Features
6
+
7
+ * Add integer support to RowFilter#value and ValueRange
8
+ * Encode Integer arguments as 64-bit signed big-endian integer data
9
+
10
+ ### 2.2.1 / 2021-01-13
11
+
12
+ #### Documentation
13
+
14
+ * Use consistent column family and field names in samples
15
+
16
+ ### 2.2.0 / 2020-11-11
17
+
18
+ #### Features
19
+
20
+ * Add Backup-level IAM Policy support
21
+ * Add Backup#policy
22
+ * Add Backup#update_policy
23
+ * Add Backup#test_iam_permissions
24
+
25
+ ### 2.1.0 / 2020-09-17
26
+
27
+ #### Features
28
+
29
+ * quota_project can be set via library configuration ([#7630](https://www.github.com/googleapis/google-cloud-ruby/issues/7630))
30
+
31
+ ### 2.0.0 / 2020-08-06
32
+
33
+ This is a major update that removes the "low-level" client interface code, and
34
+ instead adds the new `google-cloud-bigtable-v2` and
35
+ `google-cloud-bigtable-admin-v2` gems as dependencies. The new dependencies
36
+ are rewritten low-level clients, produced by a next-generation client code
37
+ generator, with improved performance and stability.
38
+
39
+ This change should have no effect on the high-level interface that most users
40
+ will use. The one exception is that the (mostly undocumented) `client_config`
41
+ argument, for adjusting low-level parameters such as RPC retry settings on
42
+ client objects, has been removed. If you need to adjust these parameters, use
43
+ the configuration interface in `google-cloud-bigtable-v2` and
44
+ `google-cloud-bigtable-admin-v2`.
45
+
46
+ Substantial changes have been made in the low-level interfaces, however. If you
47
+ are using the low-level classes under the `Google::Cloud::Bigtable::V2` or
48
+ `Google::Cloud::Bigtable::Admin::V2` modules, please review the docs for the
49
+ new `google-cloud-bigtable-v2` and `google-cloud-bigtable-admin-v2` gems.
50
+ In particular:
51
+
52
+ * Some classes have been renamed, notably the client classes themselves.
53
+ * The client constructor takes a configuration block instead of configuration
54
+ keyword arguments.
55
+ * All RPC method arguments are now keyword arguments.
56
+
3
57
  ### 1.3.0 / 2020-07-21
4
58
 
5
59
  #### Features
data/CONTRIBUTING.md CHANGED
@@ -45,7 +45,7 @@ there is a small amount of setup:
45
45
 
46
46
  ```sh
47
47
  $ cd google-cloud-bigtable/
48
- $ bundle exec rake bundleupdate
48
+ $ bundle install
49
49
  ```
50
50
 
51
51
  ## Console
data/OVERVIEW.md CHANGED
@@ -194,8 +194,8 @@ table = bigtable.table("my-instance", "my-table")
194
194
 
195
195
  entry = table.new_mutation_entry("user-1")
196
196
  entry.set_cell(
197
- "cf-1",
198
- "field-1",
197
+ "cf1",
198
+ "field1",
199
199
  "XYZ",
200
200
  timestamp: (Time.now.to_f * 1000000).round(-3) # microseconds
201
201
  ).delete_cells("cf2", "field02")
@@ -245,8 +245,8 @@ table = bigtable.table("my-instance", "my-table")
245
245
  predicate_filter = Google::Cloud::Bigtable::RowFilter.key("user-10")
246
246
  on_match_mutations = Google::Cloud::Bigtable::MutationEntry.new
247
247
  on_match_mutations.set_cell(
248
- "cf-1",
249
- "field-1",
248
+ "cf1",
249
+ "field1",
250
250
  "XYZ",
251
251
  timestamp: (Time.now.to_f * 1000000).round(-3) # microseconds
252
252
  ).delete_cells("cf2", "field02")
@@ -55,11 +55,6 @@ module Google
55
55
  # should already be composed with a `GRPC::Core::CallCredentials` object.
56
56
  # `Proc` will be used as an updater_proc for the gRPC channel. The proc transforms the
57
57
  # metadata for requests, generally, to give OAuth credentials.
58
- # @param client_config [Hash]
59
- # A hash for call options for each method.
60
- # See Google::Gax#construct_settings for the structure of
61
- # this data. Falls back to the default config if not specified
62
- # or the specified config is missing data points.
63
58
  # @return [Google::Cloud::Bigtable::Project]
64
59
  #
65
60
  # @example
@@ -69,13 +64,12 @@ module Google
69
64
  #
70
65
  # bigtable = gcloud.bigtable
71
66
  #
72
- def bigtable scope: nil, timeout: nil, credentials: nil, client_config: nil
67
+ def bigtable scope: nil, timeout: nil, credentials: nil
73
68
  Google::Cloud.bigtable(
74
- project_id: @project,
75
- credentials: (credentials || @keyfile),
76
- scope: scope,
77
- timeout: (timeout || @timeout),
78
- client_config: client_config
69
+ project_id: @project,
70
+ credentials: (credentials || @keyfile),
71
+ scope: scope,
72
+ timeout: (timeout || @timeout)
79
73
  )
80
74
  end
81
75
 
@@ -110,11 +104,6 @@ module Google
110
104
  # updater_proc is supplied.
111
105
  # @param timeout [Integer]
112
106
  # The default timeout, in seconds, for calls made through this client.
113
- # @param client_config [Hash]
114
- # A hash for call options for each method.
115
- # See Google::Gax#construct_settings for the structure of
116
- # this data. Falls back to the default config if not specified
117
- # or the specified config is missing data points. Optional.
118
107
  # @return [Google::Cloud::Bigtable::Project]
119
108
  #
120
109
  # @example
@@ -122,14 +111,13 @@ module Google
122
111
  #
123
112
  # bigtable = Google::Cloud.bigtable
124
113
  #
125
- def self.bigtable project_id: nil, credentials: nil, scope: nil, timeout: nil, client_config: nil
114
+ def self.bigtable project_id: nil, credentials: nil, scope: nil, timeout: nil
126
115
  require "google/cloud/bigtable"
127
116
  Google::Cloud::Bigtable.new(
128
- project_id: project_id,
129
- credentials: credentials,
130
- scope: scope,
131
- timeout: timeout,
132
- client_config: client_config
117
+ project_id: project_id,
118
+ credentials: credentials,
119
+ scope: scope,
120
+ timeout: timeout
133
121
  )
134
122
  end
135
123
  end
@@ -149,6 +137,21 @@ Google::Cloud.configure.add_config! :bigtable do |config|
149
137
  default_emulator = Google::Cloud::Config.deferred do
150
138
  ENV["BIGTABLE_EMULATOR_HOST"]
151
139
  end
140
+ default_scopes = [
141
+ "https://www.googleapis.com/auth/bigtable.admin",
142
+ "https://www.googleapis.com/auth/bigtable.admin.cluster",
143
+ "https://www.googleapis.com/auth/bigtable.admin.instance",
144
+ "https://www.googleapis.com/auth/bigtable.admin.table",
145
+ "https://www.googleapis.com/auth/bigtable.data",
146
+ "https://www.googleapis.com/auth/bigtable.data.readonly",
147
+ "https://www.googleapis.com/auth/cloud-bigtable.admin",
148
+ "https://www.googleapis.com/auth/cloud-bigtable.admin.cluster",
149
+ "https://www.googleapis.com/auth/cloud-bigtable.admin.table",
150
+ "https://www.googleapis.com/auth/cloud-bigtable.data",
151
+ "https://www.googleapis.com/auth/cloud-bigtable.data.readonly",
152
+ "https://www.googleapis.com/auth/cloud-platform",
153
+ "https://www.googleapis.com/auth/cloud-platform.read-only"
154
+ ]
152
155
 
153
156
  config.add_field! :project_id, default_project, match: String, allow_nil: true
154
157
  config.add_alias! :project, :project_id
@@ -162,10 +165,10 @@ Google::Cloud.configure.add_config! :bigtable do |config|
162
165
  Proc
163
166
  ],
164
167
  allow_nil: true
165
- config.add_field! :scope, nil, match: [String, Array]
168
+ config.add_field! :scope, default_scopes, match: [String, Array]
169
+ config.add_field! :quota_project, nil, match: String
166
170
  config.add_field! :timeout, nil, match: Integer
167
- config.add_field! :client_config, nil, match: Hash
168
- config.add_field! :emulator_host, default_emulator,
169
- match: String, allow_nil: true
170
- config.add_field! :endpoint, nil, match: String
171
+ config.add_field! :emulator_host, default_emulator, match: String, allow_nil: true
172
+ config.add_field! :endpoint, "bigtable.googleapis.com", match: String
173
+ config.add_field! :endpoint_admin, "bigtableadmin.googleapis.com", match: String
171
174
  end
@@ -51,6 +51,8 @@ module Google
51
51
  # metadata for requests, generally, to give OAuth credentials.
52
52
  # @param [String] endpoint Override of the endpoint host name. Optional.
53
53
  # If the param is nil, uses the default endpoint.
54
+ # @param [String] endpoint_admin Override of the admin service endpoint host name. Optional.
55
+ # If the param is nil, uses the default admin endpoint.
54
56
  # @param [String] emulator_host Bigtable emulator host. Optional.
55
57
  # If the parameter is nil, uses the value of the `emulator_host` config.
56
58
  # @param scope [Array<String>]
@@ -59,11 +61,6 @@ module Google
59
61
  # APIs](https://developers.google.com/identity/protocols/OAuth2).
60
62
  # The OAuth scopes for this service. This parameter is ignored if an
61
63
  # updater_proc is supplied.
62
- # @param client_config [Hash]
63
- # A hash for call options for each method.
64
- # See Google::Gax#construct_settings for the structure of
65
- # this data. Falls back to the default config if not specified
66
- # or the specified config is missing data points.
67
64
  # @param timeout [Integer]
68
65
  # The default timeout, in seconds, for calls made through this client. Optional.
69
66
  # @return [Google::Cloud::Bigtable::Project]
@@ -73,28 +70,28 @@ module Google
73
70
  #
74
71
  # client = Google::Cloud::Bigtable.new
75
72
  #
76
- def self.new project_id: nil, credentials: nil, emulator_host: nil, scope: nil, client_config: nil, endpoint: nil,
73
+ def self.new project_id: nil,
74
+ credentials: nil,
75
+ emulator_host: nil,
76
+ scope: nil,
77
+ endpoint: nil,
78
+ endpoint_admin: nil,
77
79
  timeout: nil
78
80
  project_id ||= default_project_id
79
81
  scope ||= configure.scope
80
82
  timeout ||= configure.timeout
81
- client_config ||= configure.client_config
82
83
  emulator_host ||= configure.emulator_host
83
84
  endpoint ||= configure.endpoint
85
+ endpoint_admin ||= configure.endpoint_admin
84
86
 
85
- if emulator_host
86
- return new_with_emulator project_id, emulator_host, timeout,
87
- client_config
88
- end
87
+ return new_with_emulator project_id, emulator_host, timeout if emulator_host
89
88
 
90
89
  credentials = resolve_credentials credentials, scope
91
90
  project_id = resolve_project_id project_id, credentials
92
91
  raise ArgumentError, "project_id is missing" if project_id.empty?
93
92
 
94
- service = Bigtable::Service.new(
95
- project_id, credentials,
96
- host: endpoint, timeout: timeout, client_config: client_config
97
- )
93
+ service = Bigtable::Service.new \
94
+ project_id, credentials, host: endpoint, host_admin: endpoint_admin, timeout: timeout
98
95
  Bigtable::Project.new service
99
96
  end
100
97
 
@@ -113,10 +110,10 @@ module Google
113
110
  # * `scope` - (String, Array<String>) The OAuth 2.0 scopes controlling
114
111
  # the set of resources and operations that the connection can access.
115
112
  # * `timeout` - (Integer) Default timeout to use in requests.
116
- # * `client_config` - (Hash) A hash of values to override the default
117
- # behavior of the API client.
118
113
  # * `endpoint` - (String) Override of the endpoint host name, or `nil`
119
114
  # to use the default endpoint.
115
+ # * `endpoint_admin` - (String) Override of the admin service endpoint
116
+ # host name, or `nil` to use the default admin endpoint.
120
117
  #
121
118
  # @return [Google::Cloud::Config] The configuration object the
122
119
  # Google::Cloud::Bigtable library uses.
@@ -130,18 +127,13 @@ module Google
130
127
  # @private
131
128
  # New client given an emulator host.
132
129
  #
133
- def self.new_with_emulator project_id, emulator_host, timeout,
134
- client_config
130
+ def self.new_with_emulator project_id, emulator_host, timeout
135
131
  project_id = project_id.to_s # Always cast to a string
136
132
  raise ArgumentError, "project_id is missing" if project_id.empty?
137
133
 
138
- Bigtable::Project.new(
139
- Bigtable::Service.new(
140
- project_id, :this_channel_is_insecure,
141
- host: emulator_host, timeout: timeout,
142
- client_config: client_config
143
- )
144
- )
134
+ service = Bigtable::Service.new \
135
+ project_id, :this_channel_is_insecure, host: emulator_host, host_admin: emulator_host, timeout: timeout
136
+ Bigtable::Project.new service
145
137
  end
146
138
 
147
139
  # @private
@@ -193,7 +193,7 @@ module Google
193
193
  #
194
194
  def routing_policy= policy
195
195
  routing_policy_grpc = policy.to_grpc
196
- if routing_policy_grpc.is_a? Google::Bigtable::Admin::V2::AppProfile::SingleClusterRouting
196
+ if routing_policy_grpc.is_a? Google::Cloud::Bigtable::Admin::V2::AppProfile::SingleClusterRouting
197
197
  @grpc.single_cluster_routing = routing_policy_grpc
198
198
  @changed_fields["routing_policy"] = "single_cluster_routing"
199
199
  else
@@ -417,8 +417,8 @@ module Google
417
417
  # @private
418
418
  #
419
419
  # Creates a new Instance instance from a
420
- # Google::Bigtable::Admin::V2::Table.
421
- # @param grpc [Google::Bigtable::Admin::V2::Table]
420
+ # Google::Cloud::Bigtable::Admin::V2::Table.
421
+ # @param grpc [Google::Cloud::Bigtable::Admin::V2::Table]
422
422
  # @param service [Google::Cloud::Bigtable::Service]
423
423
  # @return [Google::Cloud::Bigtable::Table]
424
424
  def self.from_grpc grpc, service
@@ -135,8 +135,10 @@ module Google
135
135
  end
136
136
 
137
137
  # @private
138
- # New Snapshot::List from a Google::Gax::PagedEnumerable<Google::Bigtable::Admin::V2::AppProfile> object.
139
- # @param grpc [Google::Gax::PagedEnumerable<Google::Bigtable::Admin::V2::AppProfile> ]
138
+ # New Snapshot::List from a Gapic::PagedEnumerable<Google::Cloud::Bigtable::Admin::V2::AppProfile>
139
+ # object.
140
+ #
141
+ # @param grpc [Gapic::PagedEnumerable<Google::Cloud::Bigtable::Admin::V2::AppProfile> ]
140
142
  # @param service [Google::Cloud::Bigtable::Service]
141
143
  # @return [Array<Google::Cloud::Bigtable::AppProfile>]
142
144
  def self.from_grpc grpc, service
@@ -18,6 +18,7 @@
18
18
  require "google/cloud/bigtable/backup/job"
19
19
  require "google/cloud/bigtable/backup/list"
20
20
  require "google/cloud/bigtable/convert"
21
+ require "google/cloud/bigtable/policy"
21
22
  require "google/cloud/bigtable/table/restore_job"
22
23
 
23
24
 
@@ -206,6 +207,126 @@ module Google
206
207
  state == :READY
207
208
  end
208
209
 
210
+ ##
211
+ # Gets the [Cloud IAM](https://cloud.google.com/iam/) access control
212
+ # policy for the backup.
213
+ #
214
+ # @see https://cloud.google.com/bigtable/docs/access-control
215
+ #
216
+ # @yield [policy] A block for updating the policy. The latest policy
217
+ # will be read from the Bigtable service and passed to the block. After
218
+ # the block completes, the modified policy will be written to the
219
+ # service.
220
+ # @yieldparam [Policy] policy the current Cloud IAM Policy for this
221
+ # backup.
222
+ #
223
+ # @return [Policy] The current Cloud IAM Policy for the backup.
224
+ #
225
+ # @example
226
+ # require "google/cloud/bigtable"
227
+ #
228
+ # bigtable = Google::Cloud::Bigtable.new
229
+ # instance = bigtable.instance("my-instance")
230
+ # cluster = instance.cluster("my-cluster")
231
+ #
232
+ # backup = cluster.backup("my-backup")
233
+ #
234
+ # policy = backup.policy
235
+ #
236
+ # @example Update the policy by passing a block.
237
+ # require "google/cloud/bigtable"
238
+ #
239
+ # bigtable = Google::Cloud::Bigtable.new
240
+ # instance = bigtable.instance("my-instance")
241
+ # cluster = instance.cluster("my-cluster")
242
+ #
243
+ # backup = cluster.backup("my-backup")
244
+ #
245
+ # backup.policy do |p|
246
+ # p.add("roles/owner", "user:owner@example.com")
247
+ # end # 2 API calls
248
+ #
249
+ def policy
250
+ ensure_service!
251
+ grpc = service.get_backup_policy instance_id, cluster_id, backup_id
252
+ policy = Policy.from_grpc grpc
253
+ return policy unless block_given?
254
+ yield policy
255
+ update_policy policy
256
+ end
257
+
258
+ ##
259
+ # Updates the [Cloud IAM](https://cloud.google.com/iam/) access control
260
+ # policy for the backup. The policy should be read from {#policy}.
261
+ # See {Google::Cloud::Bigtable::Policy} for an explanation of the policy
262
+ # `etag` property and how to modify policies.
263
+ #
264
+ # You can also update the policy by passing a block to {#policy}, which
265
+ # will call this method internally after the block completes.
266
+ #
267
+ # @param new_policy [Policy] a new or modified Cloud IAM Policy for this
268
+ # backup
269
+ #
270
+ # @return [Policy] The policy returned by the API update operation.
271
+ #
272
+ # @example
273
+ # require "google/cloud/bigtable"
274
+ #
275
+ # bigtable = Google::Cloud::Bigtable.new
276
+ # instance = bigtable.instance("my-instance")
277
+ # cluster = instance.cluster("my-cluster")
278
+ #
279
+ # backup = cluster.backup("my-backup")
280
+ #
281
+ # policy = backup.policy
282
+ # policy.add("roles/owner", "user:owner@example.com")
283
+ # updated_policy = backup.update_policy(policy)
284
+ #
285
+ # puts updated_policy.roles
286
+ #
287
+ def update_policy new_policy
288
+ ensure_service!
289
+ grpc = service.set_backup_policy instance_id, cluster_id, backup_id, new_policy.to_grpc
290
+ Policy.from_grpc grpc
291
+ end
292
+ alias policy= update_policy
293
+
294
+ ##
295
+ # Tests the specified permissions against the [Cloud
296
+ # IAM](https://cloud.google.com/iam/) access control policy.
297
+ #
298
+ # @see https://cloud.google.com/iam/docs/managing-policies Managing Policies
299
+ # @see https://cloud.google.com/bigtable/docs/access-control Access Control
300
+ #
301
+ # @param permissions [String, Array<String>] permissions The set of permissions to
302
+ # check access for. Permissions with wildcards (such as `*` or `bigtable.*`) are
303
+ # not allowed.
304
+ # See [Access Control](https://cloud.google.com/bigtable/docs/access-control).
305
+ #
306
+ # @return [Array<String>] The permissions that are configured for the policy.
307
+ #
308
+ # @example
309
+ # require "google/cloud/bigtable"
310
+ #
311
+ # bigtable = Google::Cloud::Bigtable.new
312
+ # instance = bigtable.instance("my-instance")
313
+ # cluster = instance.cluster("my-cluster")
314
+ #
315
+ # backup = cluster.backup("my-backup")
316
+ #
317
+ # permissions = backup.test_iam_permissions(
318
+ # "bigtable.backups.delete",
319
+ # "bigtable.backups.get"
320
+ # )
321
+ # permissions.include? "bigtable.backups.delete" #=> false
322
+ # permissions.include? "bigtable.backups.get" #=> true
323
+ #
324
+ def test_iam_permissions *permissions
325
+ ensure_service!
326
+ grpc = service.test_backup_permissions instance_id, cluster_id, backup_id, permissions.flatten
327
+ grpc.permissions.to_a
328
+ end
329
+
209
330
  ##
210
331
  # Creates a new table by restoring from a completed backup.
211
332
  #
@@ -301,9 +422,9 @@ module Google
301
422
 
302
423
  # @private
303
424
  #
304
- # Creates a new Backup instance from a Google::Bigtable::Admin::V2::Backup.
425
+ # Creates a new Backup instance from a Google::Cloud::Bigtable::Admin::V2::Backup.
305
426
  #
306
- # @param grpc [Google::Bigtable::Admin::V2::Backup]
427
+ # @param grpc [Google::Cloud::Bigtable::Admin::V2::Backup]
307
428
  # @param service [Google::Cloud::Bigtable::Service]
308
429
  # @return [Google::Cloud::Bigtable::Backup]
309
430
  def self.from_grpc grpc, service