google-cloud-spanner 1.14.0 → 2.0.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 (102) hide show
  1. checksums.yaml +4 -4
  2. data/AUTHENTICATION.md +1 -1
  3. data/CHANGELOG.md +51 -0
  4. data/CONTRIBUTING.md +5 -5
  5. data/TROUBLESHOOTING.md +0 -6
  6. data/lib/google-cloud-spanner.rb +23 -13
  7. data/lib/google/cloud/spanner.rb +8 -9
  8. data/lib/google/cloud/spanner/admin/database/credentials.rb +2 -2
  9. data/lib/google/cloud/spanner/admin/instance/credentials.rb +2 -2
  10. data/lib/google/cloud/spanner/backup.rb +315 -0
  11. data/lib/google/cloud/spanner/backup/job.rb +274 -0
  12. data/lib/google/cloud/spanner/backup/job/list.rb +177 -0
  13. data/lib/google/cloud/spanner/backup/list.rb +169 -0
  14. data/lib/google/cloud/spanner/backup/restore/job.rb +246 -0
  15. data/lib/google/cloud/spanner/batch_client.rb +7 -5
  16. data/lib/google/cloud/spanner/batch_snapshot.rb +49 -16
  17. data/lib/google/cloud/spanner/batch_update.rb +1 -1
  18. data/lib/google/cloud/spanner/client.rb +65 -16
  19. data/lib/google/cloud/spanner/commit.rb +14 -14
  20. data/lib/google/cloud/spanner/convert.rb +7 -7
  21. data/lib/google/cloud/spanner/credentials.rb +2 -2
  22. data/lib/google/cloud/spanner/data.rb +2 -2
  23. data/lib/google/cloud/spanner/database.rb +275 -15
  24. data/lib/google/cloud/spanner/database/backup_info.rb +105 -0
  25. data/lib/google/cloud/spanner/database/job.rb +5 -2
  26. data/lib/google/cloud/spanner/database/job/list.rb +177 -0
  27. data/lib/google/cloud/spanner/database/list.rb +1 -1
  28. data/lib/google/cloud/spanner/database/restore_info.rb +63 -0
  29. data/lib/google/cloud/spanner/fields.rb +8 -8
  30. data/lib/google/cloud/spanner/instance.rb +401 -8
  31. data/lib/google/cloud/spanner/instance/config.rb +1 -1
  32. data/lib/google/cloud/spanner/instance/config/list.rb +1 -1
  33. data/lib/google/cloud/spanner/instance/job.rb +2 -2
  34. data/lib/google/cloud/spanner/instance/list.rb +1 -1
  35. data/lib/google/cloud/spanner/partition.rb +4 -4
  36. data/lib/google/cloud/spanner/policy.rb +2 -2
  37. data/lib/google/cloud/spanner/project.rb +31 -6
  38. data/lib/google/cloud/spanner/results.rb +4 -2
  39. data/lib/google/cloud/spanner/service.rb +231 -240
  40. data/lib/google/cloud/spanner/session.rb +46 -15
  41. data/lib/google/cloud/spanner/snapshot.rb +28 -5
  42. data/lib/google/cloud/spanner/transaction.rb +51 -7
  43. data/lib/google/cloud/spanner/version.rb +1 -1
  44. metadata +28 -104
  45. data/lib/google/cloud/spanner/admin/database.rb +0 -148
  46. data/lib/google/cloud/spanner/admin/database/v1.rb +0 -146
  47. data/lib/google/cloud/spanner/admin/database/v1/credentials.rb +0 -46
  48. data/lib/google/cloud/spanner/admin/database/v1/database_admin_client.rb +0 -791
  49. data/lib/google/cloud/spanner/admin/database/v1/database_admin_client_config.json +0 -71
  50. data/lib/google/cloud/spanner/admin/database/v1/doc/google/iam/v1/iam_policy.rb +0 -64
  51. data/lib/google/cloud/spanner/admin/database/v1/doc/google/iam/v1/options.rb +0 -33
  52. data/lib/google/cloud/spanner/admin/database/v1/doc/google/iam/v1/policy.rb +0 -151
  53. data/lib/google/cloud/spanner/admin/database/v1/doc/google/longrunning/operations.rb +0 -51
  54. data/lib/google/cloud/spanner/admin/database/v1/doc/google/protobuf/any.rb +0 -131
  55. data/lib/google/cloud/spanner/admin/database/v1/doc/google/protobuf/empty.rb +0 -29
  56. data/lib/google/cloud/spanner/admin/database/v1/doc/google/rpc/status.rb +0 -39
  57. data/lib/google/cloud/spanner/admin/database/v1/doc/google/spanner/admin/database/v1/spanner_database_admin.rb +0 -201
  58. data/lib/google/cloud/spanner/admin/database/v1/doc/google/type/expr.rb +0 -45
  59. data/lib/google/cloud/spanner/admin/instance.rb +0 -164
  60. data/lib/google/cloud/spanner/admin/instance/v1.rb +0 -162
  61. data/lib/google/cloud/spanner/admin/instance/v1/credentials.rb +0 -46
  62. data/lib/google/cloud/spanner/admin/instance/v1/doc/google/iam/v1/iam_policy.rb +0 -64
  63. data/lib/google/cloud/spanner/admin/instance/v1/doc/google/iam/v1/options.rb +0 -33
  64. data/lib/google/cloud/spanner/admin/instance/v1/doc/google/iam/v1/policy.rb +0 -151
  65. data/lib/google/cloud/spanner/admin/instance/v1/doc/google/longrunning/operations.rb +0 -51
  66. data/lib/google/cloud/spanner/admin/instance/v1/doc/google/protobuf/any.rb +0 -131
  67. data/lib/google/cloud/spanner/admin/instance/v1/doc/google/protobuf/empty.rb +0 -29
  68. data/lib/google/cloud/spanner/admin/instance/v1/doc/google/protobuf/field_mask.rb +0 -222
  69. data/lib/google/cloud/spanner/admin/instance/v1/doc/google/rpc/status.rb +0 -39
  70. data/lib/google/cloud/spanner/admin/instance/v1/doc/google/spanner/admin/instance/v1/spanner_instance_admin.rb +0 -341
  71. data/lib/google/cloud/spanner/admin/instance/v1/doc/google/type/expr.rb +0 -45
  72. data/lib/google/cloud/spanner/admin/instance/v1/instance_admin_client.rb +0 -972
  73. data/lib/google/cloud/spanner/admin/instance/v1/instance_admin_client_config.json +0 -76
  74. data/lib/google/cloud/spanner/v1.rb +0 -16
  75. data/lib/google/cloud/spanner/v1/credentials.rb +0 -42
  76. data/lib/google/cloud/spanner/v1/doc/google/protobuf/any.rb +0 -131
  77. data/lib/google/cloud/spanner/v1/doc/google/protobuf/duration.rb +0 -91
  78. data/lib/google/cloud/spanner/v1/doc/google/protobuf/empty.rb +0 -29
  79. data/lib/google/cloud/spanner/v1/doc/google/protobuf/struct.rb +0 -74
  80. data/lib/google/cloud/spanner/v1/doc/google/protobuf/timestamp.rb +0 -113
  81. data/lib/google/cloud/spanner/v1/doc/google/rpc/status.rb +0 -39
  82. data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/keys.rb +0 -150
  83. data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/mutation.rb +0 -88
  84. data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/query_plan.rb +0 -121
  85. data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/result_set.rb +0 -190
  86. data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/spanner.rb +0 -581
  87. data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/transaction.rb +0 -432
  88. data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/type.rb +0 -112
  89. data/lib/google/cloud/spanner/v1/spanner_client.rb +0 -1509
  90. data/lib/google/cloud/spanner/v1/spanner_client_config.json +0 -121
  91. data/lib/google/spanner/admin/database/v1/spanner_database_admin_pb.rb +0 -88
  92. data/lib/google/spanner/admin/database/v1/spanner_database_admin_services_pb.rb +0 -99
  93. data/lib/google/spanner/admin/instance/v1/spanner_instance_admin_pb.rb +0 -125
  94. data/lib/google/spanner/admin/instance/v1/spanner_instance_admin_services_pb.rb +0 -182
  95. data/lib/google/spanner/v1/keys_pb.rb +0 -34
  96. data/lib/google/spanner/v1/mutation_pb.rb +0 -39
  97. data/lib/google/spanner/v1/query_plan_pb.rb +0 -48
  98. data/lib/google/spanner/v1/result_set_pb.rb +0 -48
  99. data/lib/google/spanner/v1/spanner_pb.rb +0 -174
  100. data/lib/google/spanner/v1/spanner_services_pb.rb +0 -188
  101. data/lib/google/spanner/v1/transaction_pb.rb +0 -56
  102. data/lib/google/spanner/v1/type_pb.rb +0 -44
@@ -1,341 +0,0 @@
1
- # Copyright 2020 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 Spanner
18
- module Admin
19
- module Instance
20
- module V1
21
- # @!attribute [rw] location
22
- # @return [String]
23
- # The location of the serving resources, e.g. "us-central1".
24
- # @!attribute [rw] type
25
- # @return [Google::Spanner::Admin::Instance::V1::ReplicaInfo::ReplicaType]
26
- # The type of replica.
27
- # @!attribute [rw] default_leader_location
28
- # @return [true, false]
29
- # If true, this location is designated as the default leader location where
30
- # leader replicas are placed. See the [region types
31
- # documentation](https://cloud.google.com/spanner/docs/instances#region_types)
32
- # for more details.
33
- class ReplicaInfo
34
- # Indicates the type of replica. See the [replica types
35
- # documentation](https://cloud.google.com/spanner/docs/replication#replica_types)
36
- # for more details.
37
- module ReplicaType
38
- # Not specified.
39
- TYPE_UNSPECIFIED = 0
40
-
41
- # Read-write replicas support both reads and writes. These replicas:
42
- #
43
- # * Maintain a full copy of your data.
44
- # * Serve reads.
45
- # * Can vote whether to commit a write.
46
- # * Participate in leadership election.
47
- # * Are eligible to become a leader.
48
- READ_WRITE = 1
49
-
50
- # Read-only replicas only support reads (not writes). Read-only replicas:
51
- #
52
- # * Maintain a full copy of your data.
53
- # * Serve reads.
54
- # * Do not participate in voting to commit writes.
55
- # * Are not eligible to become a leader.
56
- READ_ONLY = 2
57
-
58
- # Witness replicas don't support reads but do participate in voting to
59
- # commit writes. Witness replicas:
60
- #
61
- # * Do not maintain a full copy of data.
62
- # * Do not serve reads.
63
- # * Vote whether to commit writes.
64
- # * Participate in leader election but are not eligible to become leader.
65
- WITNESS = 3
66
- end
67
- end
68
-
69
- # A possible configuration for a Cloud Spanner instance. Configurations
70
- # define the geographic placement of nodes and their replication.
71
- # @!attribute [rw] name
72
- # @return [String]
73
- # A unique identifier for the instance configuration. Values
74
- # are of the form
75
- # `projects/<project>/instanceConfigs/[a-z][-a-z0-9]*`
76
- # @!attribute [rw] display_name
77
- # @return [String]
78
- # The name of this instance configuration as it appears in UIs.
79
- # @!attribute [rw] replicas
80
- # @return [Array<Google::Spanner::Admin::Instance::V1::ReplicaInfo>]
81
- # The geographic placement of nodes in this instance configuration and their
82
- # replication properties.
83
- class InstanceConfig; end
84
-
85
- # An isolated set of Cloud Spanner resources on which databases can be hosted.
86
- # @!attribute [rw] name
87
- # @return [String]
88
- # Required. A unique identifier for the instance, which cannot be changed
89
- # after the instance is created. Values are of the form
90
- # `projects/<project>/instances/[a-z][-a-z0-9]*[a-z0-9]`. The final
91
- # segment of the name must be between 2 and 64 characters in length.
92
- # @!attribute [rw] config
93
- # @return [String]
94
- # Required. The name of the instance's configuration. Values are of the form
95
- # `projects/<project>/instanceConfigs/<configuration>`. See
96
- # also {Google::Spanner::Admin::Instance::V1::InstanceConfig InstanceConfig} and
97
- # {Google::Spanner::Admin::Instance::V1::InstanceAdmin::ListInstanceConfigs ListInstanceConfigs}.
98
- # @!attribute [rw] display_name
99
- # @return [String]
100
- # Required. The descriptive name for this instance as it appears in UIs.
101
- # Must be unique per project and between 4 and 30 characters in length.
102
- # @!attribute [rw] node_count
103
- # @return [Integer]
104
- # Required. The number of nodes allocated to this instance. This may be zero
105
- # in API responses for instances that are not yet in state `READY`.
106
- #
107
- # See [the
108
- # documentation](https://cloud.google.com/spanner/docs/instances#node_count)
109
- # for more information about nodes.
110
- # @!attribute [rw] state
111
- # @return [Google::Spanner::Admin::Instance::V1::Instance::State]
112
- # Output only. The current instance state. For
113
- # {Google::Spanner::Admin::Instance::V1::InstanceAdmin::CreateInstance CreateInstance}, the state must be
114
- # either omitted or set to `CREATING`. For
115
- # {Google::Spanner::Admin::Instance::V1::InstanceAdmin::UpdateInstance UpdateInstance}, the state must be
116
- # either omitted or set to `READY`.
117
- # @!attribute [rw] labels
118
- # @return [Hash{String => String}]
119
- # Cloud Labels are a flexible and lightweight mechanism for organizing cloud
120
- # resources into groups that reflect a customer's organizational needs and
121
- # deployment strategies. Cloud Labels can be used to filter collections of
122
- # resources. They can be used to control how resource metrics are aggregated.
123
- # And they can be used as arguments to policy management rules (e.g. route,
124
- # firewall, load balancing, etc.).
125
- #
126
- # * Label keys must be between 1 and 63 characters long and must conform to
127
- # the following regular expression: `[a-z](https://cloud.google.com[-a-z0-9]*[a-z0-9])?`.
128
- # * Label values must be between 0 and 63 characters long and must conform
129
- # to the regular expression `([a-z](https://cloud.google.com[-a-z0-9]*[a-z0-9])?)?`.
130
- # * No more than 64 labels can be associated with a given resource.
131
- #
132
- # See https://goo.gl/xmQnxf for more information on and examples of labels.
133
- #
134
- # If you plan to use labels in your own code, please note that additional
135
- # characters may be allowed in the future. And so you are advised to use an
136
- # internal label representation, such as JSON, which doesn't rely upon
137
- # specific characters being disallowed. For example, representing labels
138
- # as the string: name + "_" + value would prove problematic if we were to
139
- # allow "_" in a future release.
140
- # @!attribute [rw] endpoint_uris
141
- # @return [Array<String>]
142
- # Output only. The endpoint URIs based on the instance config.
143
- # For example, instances located in a specific cloud region (or multi region)
144
- # such as nam3, would have a nam3 specific endpoint URI.
145
- # This URI is to be used implictly by SDK clients, with fallback to default
146
- # URI. These endpoints are intended to optimize the network routing between
147
- # the client and the instance's serving resources.
148
- # If multiple endpoints are present, client may establish connections using
149
- # any of the given URIs.
150
- class Instance
151
- # Indicates the current state of the instance.
152
- module State
153
- # Not specified.
154
- STATE_UNSPECIFIED = 0
155
-
156
- # The instance is still being created. Resources may not be
157
- # available yet, and operations such as database creation may not
158
- # work.
159
- CREATING = 1
160
-
161
- # The instance is fully created and ready to do work such as
162
- # creating databases.
163
- READY = 2
164
- end
165
- end
166
-
167
- # The request for {Google::Spanner::Admin::Instance::V1::InstanceAdmin::ListInstanceConfigs ListInstanceConfigs}.
168
- # @!attribute [rw] parent
169
- # @return [String]
170
- # Required. The name of the project for which a list of supported instance
171
- # configurations is requested. Values are of the form
172
- # `projects/<project>`.
173
- # @!attribute [rw] page_size
174
- # @return [Integer]
175
- # Number of instance configurations to be returned in the response. If 0 or
176
- # less, defaults to the server's maximum allowed page size.
177
- # @!attribute [rw] page_token
178
- # @return [String]
179
- # If non-empty, `page_token` should contain a
180
- # {Google::Spanner::Admin::Instance::V1::ListInstanceConfigsResponse#next_page_token next_page_token}
181
- # from a previous {Google::Spanner::Admin::Instance::V1::ListInstanceConfigsResponse ListInstanceConfigsResponse}.
182
- class ListInstanceConfigsRequest; end
183
-
184
- # The response for {Google::Spanner::Admin::Instance::V1::InstanceAdmin::ListInstanceConfigs ListInstanceConfigs}.
185
- # @!attribute [rw] instance_configs
186
- # @return [Array<Google::Spanner::Admin::Instance::V1::InstanceConfig>]
187
- # The list of requested instance configurations.
188
- # @!attribute [rw] next_page_token
189
- # @return [String]
190
- # `next_page_token` can be sent in a subsequent
191
- # {Google::Spanner::Admin::Instance::V1::InstanceAdmin::ListInstanceConfigs ListInstanceConfigs} call to
192
- # fetch more of the matching instance configurations.
193
- class ListInstanceConfigsResponse; end
194
-
195
- # The request for
196
- # {Google::Spanner::Admin::Instance::V1::InstanceAdmin::GetInstanceConfig GetInstanceConfigRequest}.
197
- # @!attribute [rw] name
198
- # @return [String]
199
- # Required. The name of the requested instance configuration. Values are of
200
- # the form `projects/<project>/instanceConfigs/<config>`.
201
- class GetInstanceConfigRequest; end
202
-
203
- # The request for {Google::Spanner::Admin::Instance::V1::InstanceAdmin::GetInstance GetInstance}.
204
- # @!attribute [rw] name
205
- # @return [String]
206
- # Required. The name of the requested instance. Values are of the form
207
- # `projects/<project>/instances/<instance>`.
208
- # @!attribute [rw] field_mask
209
- # @return [Google::Protobuf::FieldMask]
210
- # If field_mask is present, specifies the subset of [][google.spanner.admin.instance.v1.Instance] fields that
211
- # should be returned.
212
- # If absent, all [][google.spanner.admin.instance.v1.Instance] fields are returned.
213
- class GetInstanceRequest; end
214
-
215
- # The request for {Google::Spanner::Admin::Instance::V1::InstanceAdmin::CreateInstance CreateInstance}.
216
- # @!attribute [rw] parent
217
- # @return [String]
218
- # Required. The name of the project in which to create the instance. Values
219
- # are of the form `projects/<project>`.
220
- # @!attribute [rw] instance_id
221
- # @return [String]
222
- # Required. The ID of the instance to create. Valid identifiers are of the
223
- # form `[a-z][-a-z0-9]*[a-z0-9]` and must be between 2 and 64 characters in
224
- # length.
225
- # @!attribute [rw] instance
226
- # @return [Google::Spanner::Admin::Instance::V1::Instance]
227
- # Required. The instance to create. The name may be omitted, but if
228
- # specified must be `<parent>/instances/<instance_id>`.
229
- class CreateInstanceRequest; end
230
-
231
- # The request for {Google::Spanner::Admin::Instance::V1::InstanceAdmin::ListInstances ListInstances}.
232
- # @!attribute [rw] parent
233
- # @return [String]
234
- # Required. The name of the project for which a list of instances is
235
- # requested. Values are of the form `projects/<project>`.
236
- # @!attribute [rw] page_size
237
- # @return [Integer]
238
- # Number of instances to be returned in the response. If 0 or less, defaults
239
- # to the server's maximum allowed page size.
240
- # @!attribute [rw] page_token
241
- # @return [String]
242
- # If non-empty, `page_token` should contain a
243
- # {Google::Spanner::Admin::Instance::V1::ListInstancesResponse#next_page_token next_page_token} from a
244
- # previous {Google::Spanner::Admin::Instance::V1::ListInstancesResponse ListInstancesResponse}.
245
- # @!attribute [rw] filter
246
- # @return [String]
247
- # An expression for filtering the results of the request. Filter rules are
248
- # case insensitive. The fields eligible for filtering are:
249
- #
250
- # * `name`
251
- # * `display_name`
252
- # * `labels.key` where key is the name of a label
253
- #
254
- # Some examples of using filters are:
255
- #
256
- # * `name:*` --> The instance has a name.
257
- # * `name:Howl` --> The instance's name contains the string "howl".
258
- # * `name:HOWL` --> Equivalent to above.
259
- # * `NAME:howl` --> Equivalent to above.
260
- # * `labels.env:*` --> The instance has the label "env".
261
- # * `labels.env:dev` --> The instance has the label "env" and the value of
262
- # the label contains the string "dev".
263
- # * `name:howl labels.env:dev` --> The instance's name contains "howl" and
264
- # it has the label "env" with its value
265
- # containing "dev".
266
- class ListInstancesRequest; end
267
-
268
- # The response for {Google::Spanner::Admin::Instance::V1::InstanceAdmin::ListInstances ListInstances}.
269
- # @!attribute [rw] instances
270
- # @return [Array<Google::Spanner::Admin::Instance::V1::Instance>]
271
- # The list of requested instances.
272
- # @!attribute [rw] next_page_token
273
- # @return [String]
274
- # `next_page_token` can be sent in a subsequent
275
- # {Google::Spanner::Admin::Instance::V1::InstanceAdmin::ListInstances ListInstances} call to fetch more
276
- # of the matching instances.
277
- class ListInstancesResponse; end
278
-
279
- # The request for {Google::Spanner::Admin::Instance::V1::InstanceAdmin::UpdateInstance UpdateInstance}.
280
- # @!attribute [rw] instance
281
- # @return [Google::Spanner::Admin::Instance::V1::Instance]
282
- # Required. The instance to update, which must always include the instance
283
- # name. Otherwise, only fields mentioned in [][google.spanner.admin.instance.v1.UpdateInstanceRequest.field_mask] need be included.
284
- # @!attribute [rw] field_mask
285
- # @return [Google::Protobuf::FieldMask]
286
- # Required. A mask specifying which fields in [][google.spanner.admin.instance.v1.UpdateInstanceRequest.instance] should be updated.
287
- # The field mask must always be specified; this prevents any future fields in
288
- # [][google.spanner.admin.instance.v1.Instance] from being erased accidentally by clients that do not know
289
- # about them.
290
- class UpdateInstanceRequest; end
291
-
292
- # The request for {Google::Spanner::Admin::Instance::V1::InstanceAdmin::DeleteInstance DeleteInstance}.
293
- # @!attribute [rw] name
294
- # @return [String]
295
- # Required. The name of the instance to be deleted. Values are of the form
296
- # `projects/<project>/instances/<instance>`
297
- class DeleteInstanceRequest; end
298
-
299
- # Metadata type for the operation returned by
300
- # {Google::Spanner::Admin::Instance::V1::InstanceAdmin::CreateInstance CreateInstance}.
301
- # @!attribute [rw] instance
302
- # @return [Google::Spanner::Admin::Instance::V1::Instance]
303
- # The instance being created.
304
- # @!attribute [rw] start_time
305
- # @return [Google::Protobuf::Timestamp]
306
- # The time at which the
307
- # {Google::Spanner::Admin::Instance::V1::InstanceAdmin::CreateInstance CreateInstance} request was
308
- # received.
309
- # @!attribute [rw] cancel_time
310
- # @return [Google::Protobuf::Timestamp]
311
- # The time at which this operation was cancelled. If set, this operation is
312
- # in the process of undoing itself (which is guaranteed to succeed) and
313
- # cannot be cancelled again.
314
- # @!attribute [rw] end_time
315
- # @return [Google::Protobuf::Timestamp]
316
- # The time at which this operation failed or was completed successfully.
317
- class CreateInstanceMetadata; end
318
-
319
- # Metadata type for the operation returned by
320
- # {Google::Spanner::Admin::Instance::V1::InstanceAdmin::UpdateInstance UpdateInstance}.
321
- # @!attribute [rw] instance
322
- # @return [Google::Spanner::Admin::Instance::V1::Instance]
323
- # The desired end state of the update.
324
- # @!attribute [rw] start_time
325
- # @return [Google::Protobuf::Timestamp]
326
- # The time at which {Google::Spanner::Admin::Instance::V1::InstanceAdmin::UpdateInstance UpdateInstance}
327
- # request was received.
328
- # @!attribute [rw] cancel_time
329
- # @return [Google::Protobuf::Timestamp]
330
- # The time at which this operation was cancelled. If set, this operation is
331
- # in the process of undoing itself (which is guaranteed to succeed) and
332
- # cannot be cancelled again.
333
- # @!attribute [rw] end_time
334
- # @return [Google::Protobuf::Timestamp]
335
- # The time at which this operation failed or was completed successfully.
336
- class UpdateInstanceMetadata; end
337
- end
338
- end
339
- end
340
- end
341
- end
@@ -1,45 +0,0 @@
1
- # Copyright 2020 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 Type
18
- # Represents an expression text. Example:
19
- #
20
- # title: "User account presence"
21
- # description: "Determines whether the request has a user account"
22
- # expression: "size(request.user) > 0"
23
- # @!attribute [rw] expression
24
- # @return [String]
25
- # Textual representation of an expression in
26
- # Common Expression Language syntax.
27
- #
28
- # The application context of the containing message determines which
29
- # well-known feature set of CEL is supported.
30
- # @!attribute [rw] title
31
- # @return [String]
32
- # An optional title for the expression, i.e. a short string describing
33
- # its purpose. This can be used e.g. in UIs which allow to enter the
34
- # expression.
35
- # @!attribute [rw] description
36
- # @return [String]
37
- # An optional description of the expression. This is a longer text which
38
- # describes the expression, e.g. when hovered over it in a UI.
39
- # @!attribute [rw] location
40
- # @return [String]
41
- # An optional string indicating the location of the expression for error
42
- # reporting, e.g. a file name and a position in the file.
43
- class Expr; end
44
- end
45
- end
@@ -1,972 +0,0 @@
1
- # Copyright 2020 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
- # EDITING INSTRUCTIONS
16
- # This file was generated from the file
17
- # https://github.com/googleapis/googleapis/blob/master/google/spanner/admin/instance/v1/spanner_instance_admin.proto,
18
- # and updates to that file get reflected here through a refresh process.
19
- # For the short term, the refresh process will only be runnable by Google
20
- # engineers.
21
-
22
-
23
- require "json"
24
- require "pathname"
25
-
26
- require "google/gax"
27
- require "google/gax/operation"
28
- require "google/longrunning/operations_client"
29
-
30
- require "google/spanner/admin/instance/v1/spanner_instance_admin_pb"
31
- require "google/cloud/spanner/admin/instance/v1/credentials"
32
- require "google/cloud/spanner/version"
33
-
34
- module Google
35
- module Cloud
36
- module Spanner
37
- module Admin
38
- module Instance
39
- module V1
40
- # Cloud Spanner Instance Admin API
41
- #
42
- # The Cloud Spanner Instance Admin API can be used to create, delete,
43
- # modify and list instances. Instances are dedicated Cloud Spanner serving
44
- # and storage resources to be used by Cloud Spanner databases.
45
- #
46
- # Each instance has a "configuration", which dictates where the
47
- # serving resources for the Cloud Spanner instance are located (e.g.,
48
- # US-central, Europe). Configurations are created by Google based on
49
- # resource availability.
50
- #
51
- # Cloud Spanner billing is based on the instances that exist and their
52
- # sizes. After an instance exists, there are no additional
53
- # per-database or per-operation charges for use of the instance
54
- # (though there may be additional network bandwidth charges).
55
- # Instances offer isolation: problems with databases in one instance
56
- # will not affect other instances. However, within an instance
57
- # databases can affect each other. For example, if one database in an
58
- # instance receives a lot of requests and consumes most of the
59
- # instance resources, fewer resources are available for other
60
- # databases in that instance, and their performance may suffer.
61
- #
62
- # @!attribute [r] instance_admin_stub
63
- # @return [Google::Spanner::Admin::Instance::V1::InstanceAdmin::Stub]
64
- class InstanceAdminClient
65
- # @private
66
- attr_reader :instance_admin_stub
67
-
68
- # The default address of the service.
69
- SERVICE_ADDRESS = "spanner.googleapis.com".freeze
70
-
71
- # The default port of the service.
72
- DEFAULT_SERVICE_PORT = 443
73
-
74
- # The default set of gRPC interceptors.
75
- GRPC_INTERCEPTORS = []
76
-
77
- DEFAULT_TIMEOUT = 30
78
-
79
- PAGE_DESCRIPTORS = {
80
- "list_instance_configs" => Google::Gax::PageDescriptor.new(
81
- "page_token",
82
- "next_page_token",
83
- "instance_configs"),
84
- "list_instances" => Google::Gax::PageDescriptor.new(
85
- "page_token",
86
- "next_page_token",
87
- "instances")
88
- }.freeze
89
-
90
- private_constant :PAGE_DESCRIPTORS
91
-
92
- # The scopes needed to make gRPC calls to all of the methods defined in
93
- # this service.
94
- ALL_SCOPES = [
95
- "https://www.googleapis.com/auth/cloud-platform",
96
- "https://www.googleapis.com/auth/spanner.admin"
97
- ].freeze
98
-
99
- # @private
100
- class OperationsClient < Google::Longrunning::OperationsClient
101
- self::SERVICE_ADDRESS = InstanceAdminClient::SERVICE_ADDRESS
102
- self::GRPC_INTERCEPTORS = InstanceAdminClient::GRPC_INTERCEPTORS
103
- end
104
-
105
- INSTANCE_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
106
- "projects/{project}/instances/{instance}"
107
- )
108
-
109
- private_constant :INSTANCE_PATH_TEMPLATE
110
-
111
- INSTANCE_CONFIG_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
112
- "projects/{project}/instanceConfigs/{instance_config}"
113
- )
114
-
115
- private_constant :INSTANCE_CONFIG_PATH_TEMPLATE
116
-
117
- PROJECT_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
118
- "projects/{project}"
119
- )
120
-
121
- private_constant :PROJECT_PATH_TEMPLATE
122
-
123
- # Returns a fully-qualified instance resource name string.
124
- # @param project [String]
125
- # @param instance [String]
126
- # @return [String]
127
- def self.instance_path project, instance
128
- INSTANCE_PATH_TEMPLATE.render(
129
- :"project" => project,
130
- :"instance" => instance
131
- )
132
- end
133
-
134
- # Returns a fully-qualified instance_config resource name string.
135
- # @param project [String]
136
- # @param instance_config [String]
137
- # @return [String]
138
- def self.instance_config_path project, instance_config
139
- INSTANCE_CONFIG_PATH_TEMPLATE.render(
140
- :"project" => project,
141
- :"instance_config" => instance_config
142
- )
143
- end
144
-
145
- # Returns a fully-qualified project resource name string.
146
- # @param project [String]
147
- # @return [String]
148
- def self.project_path project
149
- PROJECT_PATH_TEMPLATE.render(
150
- :"project" => project
151
- )
152
- end
153
-
154
- # @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
155
- # Provides the means for authenticating requests made by the client. This parameter can
156
- # be many types.
157
- # A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
158
- # authenticating requests made by this client.
159
- # A `String` will be treated as the path to the keyfile to be used for the construction of
160
- # credentials for this client.
161
- # A `Hash` will be treated as the contents of a keyfile to be used for the construction of
162
- # credentials for this client.
163
- # A `GRPC::Core::Channel` will be used to make calls through.
164
- # A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
165
- # should already be composed with a `GRPC::Core::CallCredentials` object.
166
- # A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
167
- # metadata for requests, generally, to give OAuth credentials.
168
- # @param scopes [Array<String>]
169
- # The OAuth scopes for this service. This parameter is ignored if
170
- # an updater_proc is supplied.
171
- # @param client_config [Hash]
172
- # A Hash for call options for each method. See
173
- # Google::Gax#construct_settings for the structure of
174
- # this data. Falls back to the default config if not specified
175
- # or the specified config is missing data points.
176
- # @param timeout [Numeric]
177
- # The default timeout, in seconds, for calls made through this client.
178
- # @param metadata [Hash]
179
- # Default metadata to be sent with each request. This can be overridden on a per call basis.
180
- # @param service_address [String]
181
- # Override for the service hostname, or `nil` to leave as the default.
182
- # @param service_port [Integer]
183
- # Override for the service port, or `nil` to leave as the default.
184
- # @param exception_transformer [Proc]
185
- # An optional proc that intercepts any exceptions raised during an API call to inject
186
- # custom error handling.
187
- def initialize \
188
- credentials: nil,
189
- scopes: ALL_SCOPES,
190
- client_config: {},
191
- timeout: DEFAULT_TIMEOUT,
192
- metadata: nil,
193
- service_address: nil,
194
- service_port: nil,
195
- exception_transformer: nil,
196
- lib_name: nil,
197
- lib_version: ""
198
- # These require statements are intentionally placed here to initialize
199
- # the gRPC module only when it's required.
200
- # See https://github.com/googleapis/toolkit/issues/446
201
- require "google/gax/grpc"
202
- require "google/spanner/admin/instance/v1/spanner_instance_admin_services_pb"
203
-
204
- credentials ||= Google::Cloud::Spanner::Admin::Instance::V1::Credentials.default
205
-
206
- @operations_client = OperationsClient.new(
207
- credentials: credentials,
208
- scopes: scopes,
209
- client_config: client_config,
210
- timeout: timeout,
211
- service_address: service_address,
212
- service_port: service_port,
213
- lib_name: lib_name,
214
- lib_version: lib_version,
215
- metadata: metadata,
216
- )
217
-
218
- if credentials.is_a?(String) || credentials.is_a?(Hash)
219
- updater_proc = Google::Cloud::Spanner::Admin::Instance::V1::Credentials.new(credentials).updater_proc
220
- end
221
- if credentials.is_a?(GRPC::Core::Channel)
222
- channel = credentials
223
- end
224
- if credentials.is_a?(GRPC::Core::ChannelCredentials)
225
- chan_creds = credentials
226
- end
227
- if credentials.is_a?(Proc)
228
- updater_proc = credentials
229
- end
230
- if credentials.is_a?(Google::Auth::Credentials)
231
- updater_proc = credentials.updater_proc
232
- end
233
-
234
- package_version = Google::Cloud::Spanner::VERSION
235
-
236
- google_api_client = "gl-ruby/#{RUBY_VERSION}"
237
- google_api_client << " #{lib_name}/#{lib_version}" if lib_name
238
- google_api_client << " gapic/#{package_version} gax/#{Google::Gax::VERSION}"
239
- google_api_client << " grpc/#{GRPC::VERSION}"
240
- google_api_client.freeze
241
-
242
- headers = { :"x-goog-api-client" => google_api_client }
243
- headers.merge!(metadata) unless metadata.nil?
244
- client_config_file = Pathname.new(__dir__).join(
245
- "instance_admin_client_config.json"
246
- )
247
- defaults = client_config_file.open do |f|
248
- Google::Gax.construct_settings(
249
- "google.spanner.admin.instance.v1.InstanceAdmin",
250
- JSON.parse(f.read),
251
- client_config,
252
- Google::Gax::Grpc::STATUS_CODE_NAMES,
253
- timeout,
254
- page_descriptors: PAGE_DESCRIPTORS,
255
- errors: Google::Gax::Grpc::API_ERRORS,
256
- metadata: headers
257
- )
258
- end
259
-
260
- # Allow overriding the service path/port in subclasses.
261
- service_path = service_address || self.class::SERVICE_ADDRESS
262
- port = service_port || self.class::DEFAULT_SERVICE_PORT
263
- interceptors = self.class::GRPC_INTERCEPTORS
264
- @instance_admin_stub = Google::Gax::Grpc.create_stub(
265
- service_path,
266
- port,
267
- chan_creds: chan_creds,
268
- channel: channel,
269
- updater_proc: updater_proc,
270
- scopes: scopes,
271
- interceptors: interceptors,
272
- &Google::Spanner::Admin::Instance::V1::InstanceAdmin::Stub.method(:new)
273
- )
274
-
275
- @list_instance_configs = Google::Gax.create_api_call(
276
- @instance_admin_stub.method(:list_instance_configs),
277
- defaults["list_instance_configs"],
278
- exception_transformer: exception_transformer,
279
- params_extractor: proc do |request|
280
- {'parent' => request.parent}
281
- end
282
- )
283
- @get_instance_config = Google::Gax.create_api_call(
284
- @instance_admin_stub.method(:get_instance_config),
285
- defaults["get_instance_config"],
286
- exception_transformer: exception_transformer,
287
- params_extractor: proc do |request|
288
- {'name' => request.name}
289
- end
290
- )
291
- @list_instances = Google::Gax.create_api_call(
292
- @instance_admin_stub.method(:list_instances),
293
- defaults["list_instances"],
294
- exception_transformer: exception_transformer,
295
- params_extractor: proc do |request|
296
- {'parent' => request.parent}
297
- end
298
- )
299
- @get_instance = Google::Gax.create_api_call(
300
- @instance_admin_stub.method(:get_instance),
301
- defaults["get_instance"],
302
- exception_transformer: exception_transformer,
303
- params_extractor: proc do |request|
304
- {'name' => request.name}
305
- end
306
- )
307
- @create_instance = Google::Gax.create_api_call(
308
- @instance_admin_stub.method(:create_instance),
309
- defaults["create_instance"],
310
- exception_transformer: exception_transformer,
311
- params_extractor: proc do |request|
312
- {'parent' => request.parent}
313
- end
314
- )
315
- @update_instance = Google::Gax.create_api_call(
316
- @instance_admin_stub.method(:update_instance),
317
- defaults["update_instance"],
318
- exception_transformer: exception_transformer,
319
- params_extractor: proc do |request|
320
- {'instance.name' => request.instance.name}
321
- end
322
- )
323
- @delete_instance = Google::Gax.create_api_call(
324
- @instance_admin_stub.method(:delete_instance),
325
- defaults["delete_instance"],
326
- exception_transformer: exception_transformer,
327
- params_extractor: proc do |request|
328
- {'name' => request.name}
329
- end
330
- )
331
- @set_iam_policy = Google::Gax.create_api_call(
332
- @instance_admin_stub.method(:set_iam_policy),
333
- defaults["set_iam_policy"],
334
- exception_transformer: exception_transformer,
335
- params_extractor: proc do |request|
336
- {'resource' => request.resource}
337
- end
338
- )
339
- @get_iam_policy = Google::Gax.create_api_call(
340
- @instance_admin_stub.method(:get_iam_policy),
341
- defaults["get_iam_policy"],
342
- exception_transformer: exception_transformer,
343
- params_extractor: proc do |request|
344
- {'resource' => request.resource}
345
- end
346
- )
347
- @test_iam_permissions = Google::Gax.create_api_call(
348
- @instance_admin_stub.method(:test_iam_permissions),
349
- defaults["test_iam_permissions"],
350
- exception_transformer: exception_transformer,
351
- params_extractor: proc do |request|
352
- {'resource' => request.resource}
353
- end
354
- )
355
- end
356
-
357
- # Service calls
358
-
359
- # Lists the supported instance configurations for a given project.
360
- #
361
- # @param parent [String]
362
- # Required. The name of the project for which a list of supported instance
363
- # configurations is requested. Values are of the form
364
- # `projects/<project>`.
365
- # @param page_size [Integer]
366
- # The maximum number of resources contained in the underlying API
367
- # response. If page streaming is performed per-resource, this
368
- # parameter does not affect the return value. If page streaming is
369
- # performed per-page, this determines the maximum number of
370
- # resources in a page.
371
- # @param options [Google::Gax::CallOptions]
372
- # Overrides the default settings for this call, e.g, timeout,
373
- # retries, etc.
374
- # @yield [result, operation] Access the result along with the RPC operation
375
- # @yieldparam result [Google::Gax::PagedEnumerable<Google::Spanner::Admin::Instance::V1::InstanceConfig>]
376
- # @yieldparam operation [GRPC::ActiveCall::Operation]
377
- # @return [Google::Gax::PagedEnumerable<Google::Spanner::Admin::Instance::V1::InstanceConfig>]
378
- # An enumerable of Google::Spanner::Admin::Instance::V1::InstanceConfig instances.
379
- # See Google::Gax::PagedEnumerable documentation for other
380
- # operations such as per-page iteration or access to the response
381
- # object.
382
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
383
- # @example
384
- # require "google/cloud/spanner/admin/instance"
385
- #
386
- # instance_admin_client = Google::Cloud::Spanner::Admin::Instance.new(version: :v1)
387
- # formatted_parent = Google::Cloud::Spanner::Admin::Instance::V1::InstanceAdminClient.project_path("[PROJECT]")
388
- #
389
- # # Iterate over all results.
390
- # instance_admin_client.list_instance_configs(formatted_parent).each do |element|
391
- # # Process element.
392
- # end
393
- #
394
- # # Or iterate over results one page at a time.
395
- # instance_admin_client.list_instance_configs(formatted_parent).each_page do |page|
396
- # # Process each page at a time.
397
- # page.each do |element|
398
- # # Process element.
399
- # end
400
- # end
401
-
402
- def list_instance_configs \
403
- parent,
404
- page_size: nil,
405
- options: nil,
406
- &block
407
- req = {
408
- parent: parent,
409
- page_size: page_size
410
- }.delete_if { |_, v| v.nil? }
411
- req = Google::Gax::to_proto(req, Google::Spanner::Admin::Instance::V1::ListInstanceConfigsRequest)
412
- @list_instance_configs.call(req, options, &block)
413
- end
414
-
415
- # Gets information about a particular instance configuration.
416
- #
417
- # @param name [String]
418
- # Required. The name of the requested instance configuration. Values are of
419
- # the form `projects/<project>/instanceConfigs/<config>`.
420
- # @param options [Google::Gax::CallOptions]
421
- # Overrides the default settings for this call, e.g, timeout,
422
- # retries, etc.
423
- # @yield [result, operation] Access the result along with the RPC operation
424
- # @yieldparam result [Google::Spanner::Admin::Instance::V1::InstanceConfig]
425
- # @yieldparam operation [GRPC::ActiveCall::Operation]
426
- # @return [Google::Spanner::Admin::Instance::V1::InstanceConfig]
427
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
428
- # @example
429
- # require "google/cloud/spanner/admin/instance"
430
- #
431
- # instance_admin_client = Google::Cloud::Spanner::Admin::Instance.new(version: :v1)
432
- # formatted_name = Google::Cloud::Spanner::Admin::Instance::V1::InstanceAdminClient.instance_config_path("[PROJECT]", "[INSTANCE_CONFIG]")
433
- # response = instance_admin_client.get_instance_config(formatted_name)
434
-
435
- def get_instance_config \
436
- name,
437
- options: nil,
438
- &block
439
- req = {
440
- name: name
441
- }.delete_if { |_, v| v.nil? }
442
- req = Google::Gax::to_proto(req, Google::Spanner::Admin::Instance::V1::GetInstanceConfigRequest)
443
- @get_instance_config.call(req, options, &block)
444
- end
445
-
446
- # Lists all instances in the given project.
447
- #
448
- # @param parent [String]
449
- # Required. The name of the project for which a list of instances is
450
- # requested. Values are of the form `projects/<project>`.
451
- # @param page_size [Integer]
452
- # The maximum number of resources contained in the underlying API
453
- # response. If page streaming is performed per-resource, this
454
- # parameter does not affect the return value. If page streaming is
455
- # performed per-page, this determines the maximum number of
456
- # resources in a page.
457
- # @param filter [String]
458
- # An expression for filtering the results of the request. Filter rules are
459
- # case insensitive. The fields eligible for filtering are:
460
- #
461
- # * `name`
462
- # * `display_name`
463
- # * `labels.key` where key is the name of a label
464
- #
465
- # Some examples of using filters are:
466
- #
467
- # * `name:*` --> The instance has a name.
468
- # * `name:Howl` --> The instance's name contains the string "howl".
469
- # * `name:HOWL` --> Equivalent to above.
470
- # * `NAME:howl` --> Equivalent to above.
471
- # * `labels.env:*` --> The instance has the label "env".
472
- # * `labels.env:dev` --> The instance has the label "env" and the value of
473
- # the label contains the string "dev".
474
- # * `name:howl labels.env:dev` --> The instance's name contains "howl" and
475
- # it has the label "env" with its value
476
- # containing "dev".
477
- # @param options [Google::Gax::CallOptions]
478
- # Overrides the default settings for this call, e.g, timeout,
479
- # retries, etc.
480
- # @yield [result, operation] Access the result along with the RPC operation
481
- # @yieldparam result [Google::Gax::PagedEnumerable<Google::Spanner::Admin::Instance::V1::Instance>]
482
- # @yieldparam operation [GRPC::ActiveCall::Operation]
483
- # @return [Google::Gax::PagedEnumerable<Google::Spanner::Admin::Instance::V1::Instance>]
484
- # An enumerable of Google::Spanner::Admin::Instance::V1::Instance instances.
485
- # See Google::Gax::PagedEnumerable documentation for other
486
- # operations such as per-page iteration or access to the response
487
- # object.
488
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
489
- # @example
490
- # require "google/cloud/spanner/admin/instance"
491
- #
492
- # instance_admin_client = Google::Cloud::Spanner::Admin::Instance.new(version: :v1)
493
- # formatted_parent = Google::Cloud::Spanner::Admin::Instance::V1::InstanceAdminClient.project_path("[PROJECT]")
494
- #
495
- # # Iterate over all results.
496
- # instance_admin_client.list_instances(formatted_parent).each do |element|
497
- # # Process element.
498
- # end
499
- #
500
- # # Or iterate over results one page at a time.
501
- # instance_admin_client.list_instances(formatted_parent).each_page do |page|
502
- # # Process each page at a time.
503
- # page.each do |element|
504
- # # Process element.
505
- # end
506
- # end
507
-
508
- def list_instances \
509
- parent,
510
- page_size: nil,
511
- filter: nil,
512
- options: nil,
513
- &block
514
- req = {
515
- parent: parent,
516
- page_size: page_size,
517
- filter: filter
518
- }.delete_if { |_, v| v.nil? }
519
- req = Google::Gax::to_proto(req, Google::Spanner::Admin::Instance::V1::ListInstancesRequest)
520
- @list_instances.call(req, options, &block)
521
- end
522
-
523
- # Gets information about a particular instance.
524
- #
525
- # @param name [String]
526
- # Required. The name of the requested instance. Values are of the form
527
- # `projects/<project>/instances/<instance>`.
528
- # @param field_mask [Google::Protobuf::FieldMask | Hash]
529
- # If field_mask is present, specifies the subset of [][google.spanner.admin.instance.v1.Instance] fields that
530
- # should be returned.
531
- # If absent, all [][google.spanner.admin.instance.v1.Instance] fields are returned.
532
- # A hash of the same form as `Google::Protobuf::FieldMask`
533
- # can also be provided.
534
- # @param options [Google::Gax::CallOptions]
535
- # Overrides the default settings for this call, e.g, timeout,
536
- # retries, etc.
537
- # @yield [result, operation] Access the result along with the RPC operation
538
- # @yieldparam result [Google::Spanner::Admin::Instance::V1::Instance]
539
- # @yieldparam operation [GRPC::ActiveCall::Operation]
540
- # @return [Google::Spanner::Admin::Instance::V1::Instance]
541
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
542
- # @example
543
- # require "google/cloud/spanner/admin/instance"
544
- #
545
- # instance_admin_client = Google::Cloud::Spanner::Admin::Instance.new(version: :v1)
546
- # formatted_name = Google::Cloud::Spanner::Admin::Instance::V1::InstanceAdminClient.instance_path("[PROJECT]", "[INSTANCE]")
547
- # response = instance_admin_client.get_instance(formatted_name)
548
-
549
- def get_instance \
550
- name,
551
- field_mask: nil,
552
- options: nil,
553
- &block
554
- req = {
555
- name: name,
556
- field_mask: field_mask
557
- }.delete_if { |_, v| v.nil? }
558
- req = Google::Gax::to_proto(req, Google::Spanner::Admin::Instance::V1::GetInstanceRequest)
559
- @get_instance.call(req, options, &block)
560
- end
561
-
562
- # Creates an instance and begins preparing it to begin serving. The
563
- # returned {Google::Longrunning::Operation long-running operation}
564
- # can be used to track the progress of preparing the new
565
- # instance. The instance name is assigned by the caller. If the
566
- # named instance already exists, `CreateInstance` returns
567
- # `ALREADY_EXISTS`.
568
- #
569
- # Immediately upon completion of this request:
570
- #
571
- # * The instance is readable via the API, with all requested attributes
572
- # but no allocated resources. Its state is `CREATING`.
573
- #
574
- # Until completion of the returned operation:
575
- #
576
- # * Cancelling the operation renders the instance immediately unreadable
577
- # via the API.
578
- # * The instance can be deleted.
579
- # * All other attempts to modify the instance are rejected.
580
- #
581
- # Upon completion of the returned operation:
582
- #
583
- # * Billing for all successfully-allocated resources begins (some types
584
- # may have lower than the requested levels).
585
- # * Databases can be created in the instance.
586
- # * The instance's allocated resource levels are readable via the API.
587
- # * The instance's state becomes `READY`.
588
- #
589
- # The returned {Google::Longrunning::Operation long-running operation} will
590
- # have a name of the format `<instance_name>/operations/<operation_id>` and
591
- # can be used to track creation of the instance. The
592
- # {Google::Longrunning::Operation#metadata metadata} field type is
593
- # {Google::Spanner::Admin::Instance::V1::CreateInstanceMetadata CreateInstanceMetadata}.
594
- # The {Google::Longrunning::Operation#response response} field type is
595
- # {Google::Spanner::Admin::Instance::V1::Instance Instance}, if successful.
596
- #
597
- # @param parent [String]
598
- # Required. The name of the project in which to create the instance. Values
599
- # are of the form `projects/<project>`.
600
- # @param instance_id [String]
601
- # Required. The ID of the instance to create. Valid identifiers are of the
602
- # form `[a-z][-a-z0-9]*[a-z0-9]` and must be between 2 and 64 characters in
603
- # length.
604
- # @param instance [Google::Spanner::Admin::Instance::V1::Instance | Hash]
605
- # Required. The instance to create. The name may be omitted, but if
606
- # specified must be `<parent>/instances/<instance_id>`.
607
- # A hash of the same form as `Google::Spanner::Admin::Instance::V1::Instance`
608
- # can also be provided.
609
- # @param options [Google::Gax::CallOptions]
610
- # Overrides the default settings for this call, e.g, timeout,
611
- # retries, etc.
612
- # @return [Google::Gax::Operation]
613
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
614
- # @example
615
- # require "google/cloud/spanner/admin/instance"
616
- #
617
- # instance_admin_client = Google::Cloud::Spanner::Admin::Instance.new(version: :v1)
618
- # formatted_parent = Google::Cloud::Spanner::Admin::Instance::V1::InstanceAdminClient.project_path("[PROJECT]")
619
- #
620
- # # TODO: Initialize `instance_id`:
621
- # instance_id = ''
622
- #
623
- # # TODO: Initialize `instance`:
624
- # instance = {}
625
- #
626
- # # Register a callback during the method call.
627
- # operation = instance_admin_client.create_instance(formatted_parent, instance_id, instance) do |op|
628
- # raise op.results.message if op.error?
629
- # op_results = op.results
630
- # # Process the results.
631
- #
632
- # metadata = op.metadata
633
- # # Process the metadata.
634
- # end
635
- #
636
- # # Or use the return value to register a callback.
637
- # operation.on_done do |op|
638
- # raise op.results.message if op.error?
639
- # op_results = op.results
640
- # # Process the results.
641
- #
642
- # metadata = op.metadata
643
- # # Process the metadata.
644
- # end
645
- #
646
- # # Manually reload the operation.
647
- # operation.reload!
648
- #
649
- # # Or block until the operation completes, triggering callbacks on
650
- # # completion.
651
- # operation.wait_until_done!
652
-
653
- def create_instance \
654
- parent,
655
- instance_id,
656
- instance,
657
- options: nil
658
- req = {
659
- parent: parent,
660
- instance_id: instance_id,
661
- instance: instance
662
- }.delete_if { |_, v| v.nil? }
663
- req = Google::Gax::to_proto(req, Google::Spanner::Admin::Instance::V1::CreateInstanceRequest)
664
- operation = Google::Gax::Operation.new(
665
- @create_instance.call(req, options),
666
- @operations_client,
667
- Google::Spanner::Admin::Instance::V1::Instance,
668
- Google::Spanner::Admin::Instance::V1::CreateInstanceMetadata,
669
- call_options: options
670
- )
671
- operation.on_done { |operation| yield(operation) } if block_given?
672
- operation
673
- end
674
-
675
- # Updates an instance, and begins allocating or releasing resources
676
- # as requested. The returned [long-running
677
- # operation][google.longrunning.Operation] can be used to track the
678
- # progress of updating the instance. If the named instance does not
679
- # exist, returns `NOT_FOUND`.
680
- #
681
- # Immediately upon completion of this request:
682
- #
683
- # * For resource types for which a decrease in the instance's allocation
684
- # has been requested, billing is based on the newly-requested level.
685
- #
686
- # Until completion of the returned operation:
687
- #
688
- # * Cancelling the operation sets its metadata's
689
- # {Google::Spanner::Admin::Instance::V1::UpdateInstanceMetadata#cancel_time cancel_time}, and begins
690
- # restoring resources to their pre-request values. The operation
691
- # is guaranteed to succeed at undoing all resource changes,
692
- # after which point it terminates with a `CANCELLED` status.
693
- # * All other attempts to modify the instance are rejected.
694
- # * Reading the instance via the API continues to give the pre-request
695
- # resource levels.
696
- #
697
- # Upon completion of the returned operation:
698
- #
699
- # * Billing begins for all successfully-allocated resources (some types
700
- # may have lower than the requested levels).
701
- # * All newly-reserved resources are available for serving the instance's
702
- # tables.
703
- # * The instance's new resource levels are readable via the API.
704
- #
705
- # The returned {Google::Longrunning::Operation long-running operation} will
706
- # have a name of the format `<instance_name>/operations/<operation_id>` and
707
- # can be used to track the instance modification. The
708
- # {Google::Longrunning::Operation#metadata metadata} field type is
709
- # {Google::Spanner::Admin::Instance::V1::UpdateInstanceMetadata UpdateInstanceMetadata}.
710
- # The {Google::Longrunning::Operation#response response} field type is
711
- # {Google::Spanner::Admin::Instance::V1::Instance Instance}, if successful.
712
- #
713
- # Authorization requires `spanner.instances.update` permission on
714
- # resource {Google::Spanner::Admin::Instance::V1::Instance#name name}.
715
- #
716
- # @param instance [Google::Spanner::Admin::Instance::V1::Instance | Hash]
717
- # Required. The instance to update, which must always include the instance
718
- # name. Otherwise, only fields mentioned in [][google.spanner.admin.instance.v1.UpdateInstanceRequest.field_mask] need be included.
719
- # A hash of the same form as `Google::Spanner::Admin::Instance::V1::Instance`
720
- # can also be provided.
721
- # @param field_mask [Google::Protobuf::FieldMask | Hash]
722
- # Required. A mask specifying which fields in [][google.spanner.admin.instance.v1.UpdateInstanceRequest.instance] should be updated.
723
- # The field mask must always be specified; this prevents any future fields in
724
- # [][google.spanner.admin.instance.v1.Instance] from being erased accidentally by clients that do not know
725
- # about them.
726
- # A hash of the same form as `Google::Protobuf::FieldMask`
727
- # can also be provided.
728
- # @param options [Google::Gax::CallOptions]
729
- # Overrides the default settings for this call, e.g, timeout,
730
- # retries, etc.
731
- # @return [Google::Gax::Operation]
732
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
733
- # @example
734
- # require "google/cloud/spanner/admin/instance"
735
- #
736
- # instance_admin_client = Google::Cloud::Spanner::Admin::Instance.new(version: :v1)
737
- #
738
- # # TODO: Initialize `instance`:
739
- # instance = {}
740
- #
741
- # # TODO: Initialize `field_mask`:
742
- # field_mask = {}
743
- #
744
- # # Register a callback during the method call.
745
- # operation = instance_admin_client.update_instance(instance, field_mask) do |op|
746
- # raise op.results.message if op.error?
747
- # op_results = op.results
748
- # # Process the results.
749
- #
750
- # metadata = op.metadata
751
- # # Process the metadata.
752
- # end
753
- #
754
- # # Or use the return value to register a callback.
755
- # operation.on_done do |op|
756
- # raise op.results.message if op.error?
757
- # op_results = op.results
758
- # # Process the results.
759
- #
760
- # metadata = op.metadata
761
- # # Process the metadata.
762
- # end
763
- #
764
- # # Manually reload the operation.
765
- # operation.reload!
766
- #
767
- # # Or block until the operation completes, triggering callbacks on
768
- # # completion.
769
- # operation.wait_until_done!
770
-
771
- def update_instance \
772
- instance,
773
- field_mask,
774
- options: nil
775
- req = {
776
- instance: instance,
777
- field_mask: field_mask
778
- }.delete_if { |_, v| v.nil? }
779
- req = Google::Gax::to_proto(req, Google::Spanner::Admin::Instance::V1::UpdateInstanceRequest)
780
- operation = Google::Gax::Operation.new(
781
- @update_instance.call(req, options),
782
- @operations_client,
783
- Google::Spanner::Admin::Instance::V1::Instance,
784
- Google::Spanner::Admin::Instance::V1::UpdateInstanceMetadata,
785
- call_options: options
786
- )
787
- operation.on_done { |operation| yield(operation) } if block_given?
788
- operation
789
- end
790
-
791
- # Deletes an instance.
792
- #
793
- # Immediately upon completion of the request:
794
- #
795
- # * Billing ceases for all of the instance's reserved resources.
796
- #
797
- # Soon afterward:
798
- #
799
- # * The instance and *all of its databases* immediately and
800
- # irrevocably disappear from the API. All data in the databases
801
- # is permanently deleted.
802
- #
803
- # @param name [String]
804
- # Required. The name of the instance to be deleted. Values are of the form
805
- # `projects/<project>/instances/<instance>`
806
- # @param options [Google::Gax::CallOptions]
807
- # Overrides the default settings for this call, e.g, timeout,
808
- # retries, etc.
809
- # @yield [result, operation] Access the result along with the RPC operation
810
- # @yieldparam result []
811
- # @yieldparam operation [GRPC::ActiveCall::Operation]
812
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
813
- # @example
814
- # require "google/cloud/spanner/admin/instance"
815
- #
816
- # instance_admin_client = Google::Cloud::Spanner::Admin::Instance.new(version: :v1)
817
- # formatted_name = Google::Cloud::Spanner::Admin::Instance::V1::InstanceAdminClient.instance_path("[PROJECT]", "[INSTANCE]")
818
- # instance_admin_client.delete_instance(formatted_name)
819
-
820
- def delete_instance \
821
- name,
822
- options: nil,
823
- &block
824
- req = {
825
- name: name
826
- }.delete_if { |_, v| v.nil? }
827
- req = Google::Gax::to_proto(req, Google::Spanner::Admin::Instance::V1::DeleteInstanceRequest)
828
- @delete_instance.call(req, options, &block)
829
- nil
830
- end
831
-
832
- # Sets the access control policy on an instance resource. Replaces any
833
- # existing policy.
834
- #
835
- # Authorization requires `spanner.instances.setIamPolicy` on
836
- # {Google::Iam::V1::SetIamPolicyRequest#resource resource}.
837
- #
838
- # @param resource [String]
839
- # REQUIRED: The resource for which the policy is being specified.
840
- # See the operation documentation for the appropriate value for this field.
841
- # @param policy [Google::Iam::V1::Policy | Hash]
842
- # REQUIRED: The complete policy to be applied to the `resource`. The size of
843
- # the policy is limited to a few 10s of KB. An empty policy is a
844
- # valid policy but certain Cloud Platform services (such as Projects)
845
- # might reject them.
846
- # A hash of the same form as `Google::Iam::V1::Policy`
847
- # can also be provided.
848
- # @param options [Google::Gax::CallOptions]
849
- # Overrides the default settings for this call, e.g, timeout,
850
- # retries, etc.
851
- # @yield [result, operation] Access the result along with the RPC operation
852
- # @yieldparam result [Google::Iam::V1::Policy]
853
- # @yieldparam operation [GRPC::ActiveCall::Operation]
854
- # @return [Google::Iam::V1::Policy]
855
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
856
- # @example
857
- # require "google/cloud/spanner/admin/instance"
858
- #
859
- # instance_admin_client = Google::Cloud::Spanner::Admin::Instance.new(version: :v1)
860
- # formatted_resource = Google::Cloud::Spanner::Admin::Instance::V1::InstanceAdminClient.instance_path("[PROJECT]", "[INSTANCE]")
861
- #
862
- # # TODO: Initialize `policy`:
863
- # policy = {}
864
- # response = instance_admin_client.set_iam_policy(formatted_resource, policy)
865
-
866
- def set_iam_policy \
867
- resource,
868
- policy,
869
- options: nil,
870
- &block
871
- req = {
872
- resource: resource,
873
- policy: policy
874
- }.delete_if { |_, v| v.nil? }
875
- req = Google::Gax::to_proto(req, Google::Iam::V1::SetIamPolicyRequest)
876
- @set_iam_policy.call(req, options, &block)
877
- end
878
-
879
- # Gets the access control policy for an instance resource. Returns an empty
880
- # policy if an instance exists but does not have a policy set.
881
- #
882
- # Authorization requires `spanner.instances.getIamPolicy` on
883
- # {Google::Iam::V1::GetIamPolicyRequest#resource resource}.
884
- #
885
- # @param resource [String]
886
- # REQUIRED: The resource for which the policy is being requested.
887
- # See the operation documentation for the appropriate value for this field.
888
- # @param options_ [Google::Iam::V1::GetPolicyOptions | Hash]
889
- # OPTIONAL: A `GetPolicyOptions` object for specifying options to
890
- # `GetIamPolicy`. This field is only used by Cloud IAM.
891
- # A hash of the same form as `Google::Iam::V1::GetPolicyOptions`
892
- # can also be provided.
893
- # @param options [Google::Gax::CallOptions]
894
- # Overrides the default settings for this call, e.g, timeout,
895
- # retries, etc.
896
- # @yield [result, operation] Access the result along with the RPC operation
897
- # @yieldparam result [Google::Iam::V1::Policy]
898
- # @yieldparam operation [GRPC::ActiveCall::Operation]
899
- # @return [Google::Iam::V1::Policy]
900
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
901
- # @example
902
- # require "google/cloud/spanner/admin/instance"
903
- #
904
- # instance_admin_client = Google::Cloud::Spanner::Admin::Instance.new(version: :v1)
905
- # formatted_resource = Google::Cloud::Spanner::Admin::Instance::V1::InstanceAdminClient.instance_path("[PROJECT]", "[INSTANCE]")
906
- # response = instance_admin_client.get_iam_policy(formatted_resource)
907
-
908
- def get_iam_policy \
909
- resource,
910
- options_: nil,
911
- options: nil,
912
- &block
913
- req = {
914
- resource: resource,
915
- options: options_
916
- }.delete_if { |_, v| v.nil? }
917
- req = Google::Gax::to_proto(req, Google::Iam::V1::GetIamPolicyRequest)
918
- @get_iam_policy.call(req, options, &block)
919
- end
920
-
921
- # Returns permissions that the caller has on the specified instance resource.
922
- #
923
- # Attempting this RPC on a non-existent Cloud Spanner instance resource will
924
- # result in a NOT_FOUND error if the user has `spanner.instances.list`
925
- # permission on the containing Google Cloud Project. Otherwise returns an
926
- # empty set of permissions.
927
- #
928
- # @param resource [String]
929
- # REQUIRED: The resource for which the policy detail is being requested.
930
- # See the operation documentation for the appropriate value for this field.
931
- # @param permissions [Array<String>]
932
- # The set of permissions to check for the `resource`. Permissions with
933
- # wildcards (such as '*' or 'storage.*') are not allowed. For more
934
- # information see
935
- # [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions).
936
- # @param options [Google::Gax::CallOptions]
937
- # Overrides the default settings for this call, e.g, timeout,
938
- # retries, etc.
939
- # @yield [result, operation] Access the result along with the RPC operation
940
- # @yieldparam result [Google::Iam::V1::TestIamPermissionsResponse]
941
- # @yieldparam operation [GRPC::ActiveCall::Operation]
942
- # @return [Google::Iam::V1::TestIamPermissionsResponse]
943
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
944
- # @example
945
- # require "google/cloud/spanner/admin/instance"
946
- #
947
- # instance_admin_client = Google::Cloud::Spanner::Admin::Instance.new(version: :v1)
948
- # formatted_resource = Google::Cloud::Spanner::Admin::Instance::V1::InstanceAdminClient.instance_path("[PROJECT]", "[INSTANCE]")
949
- #
950
- # # TODO: Initialize `permissions`:
951
- # permissions = []
952
- # response = instance_admin_client.test_iam_permissions(formatted_resource, permissions)
953
-
954
- def test_iam_permissions \
955
- resource,
956
- permissions,
957
- options: nil,
958
- &block
959
- req = {
960
- resource: resource,
961
- permissions: permissions
962
- }.delete_if { |_, v| v.nil? }
963
- req = Google::Gax::to_proto(req, Google::Iam::V1::TestIamPermissionsRequest)
964
- @test_iam_permissions.call(req, options, &block)
965
- end
966
- end
967
- end
968
- end
969
- end
970
- end
971
- end
972
- end