google-cloud-spanner 0.21.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +7 -0
  2. data/lib/google-cloud-spanner.rb +106 -0
  3. data/lib/google/cloud/spanner.rb +382 -0
  4. data/lib/google/cloud/spanner/admin/database/v1.rb +17 -0
  5. data/lib/google/cloud/spanner/admin/database/v1/database_admin_client.rb +703 -0
  6. data/lib/google/cloud/spanner/admin/database/v1/database_admin_client_config.json +73 -0
  7. data/lib/google/cloud/spanner/admin/database/v1/doc/google/iam/v1/policy.rb +139 -0
  8. data/lib/google/cloud/spanner/admin/database/v1/doc/google/protobuf/any.rb +114 -0
  9. data/lib/google/cloud/spanner/admin/database/v1/doc/google/rpc/status.rb +83 -0
  10. data/lib/google/cloud/spanner/admin/database/v1/doc/google/spanner/admin/database/v1/spanner_database_admin.rb +188 -0
  11. data/lib/google/cloud/spanner/admin/instance/v1.rb +17 -0
  12. data/lib/google/cloud/spanner/admin/instance/v1/doc/google/iam/v1/policy.rb +139 -0
  13. data/lib/google/cloud/spanner/admin/instance/v1/doc/google/protobuf/any.rb +114 -0
  14. data/lib/google/cloud/spanner/admin/instance/v1/doc/google/protobuf/field_mask.rb +223 -0
  15. data/lib/google/cloud/spanner/admin/instance/v1/doc/google/rpc/status.rb +83 -0
  16. data/lib/google/cloud/spanner/admin/instance/v1/doc/google/spanner/admin/instance/v1/spanner_instance_admin.rb +268 -0
  17. data/lib/google/cloud/spanner/admin/instance/v1/instance_admin_client.rb +868 -0
  18. data/lib/google/cloud/spanner/admin/instance/v1/instance_admin_client_config.json +78 -0
  19. data/lib/google/cloud/spanner/client.rb +1034 -0
  20. data/lib/google/cloud/spanner/commit.rb +351 -0
  21. data/lib/google/cloud/spanner/convert.rb +311 -0
  22. data/lib/google/cloud/spanner/credentials.rb +32 -0
  23. data/lib/google/cloud/spanner/data.rb +199 -0
  24. data/lib/google/cloud/spanner/database.rb +377 -0
  25. data/lib/google/cloud/spanner/database/job.rb +179 -0
  26. data/lib/google/cloud/spanner/database/list.rb +171 -0
  27. data/lib/google/cloud/spanner/errors.rb +73 -0
  28. data/lib/google/cloud/spanner/fields.rb +252 -0
  29. data/lib/google/cloud/spanner/instance.rb +472 -0
  30. data/lib/google/cloud/spanner/instance/config.rb +99 -0
  31. data/lib/google/cloud/spanner/instance/config/list.rb +171 -0
  32. data/lib/google/cloud/spanner/instance/job.rb +197 -0
  33. data/lib/google/cloud/spanner/instance/list.rb +167 -0
  34. data/lib/google/cloud/spanner/policy.rb +201 -0
  35. data/lib/google/cloud/spanner/pool.rb +279 -0
  36. data/lib/google/cloud/spanner/project.rb +480 -0
  37. data/lib/google/cloud/spanner/range.rb +99 -0
  38. data/lib/google/cloud/spanner/results.rb +280 -0
  39. data/lib/google/cloud/spanner/service.rb +458 -0
  40. data/lib/google/cloud/spanner/session.rb +565 -0
  41. data/lib/google/cloud/spanner/snapshot.rb +260 -0
  42. data/lib/google/cloud/spanner/transaction.rb +533 -0
  43. data/lib/google/cloud/spanner/v1.rb +17 -0
  44. data/lib/google/cloud/spanner/v1/doc/google/protobuf/duration.rb +77 -0
  45. data/lib/google/cloud/spanner/v1/doc/google/protobuf/struct.rb +73 -0
  46. data/lib/google/cloud/spanner/v1/doc/google/protobuf/timestamp.rb +81 -0
  47. data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/keys.rb +148 -0
  48. data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/mutation.rb +80 -0
  49. data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/query_plan.rb +120 -0
  50. data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/result_set.rb +175 -0
  51. data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/spanner.rb +206 -0
  52. data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/transaction.rb +351 -0
  53. data/lib/google/cloud/spanner/v1/spanner_client.rb +850 -0
  54. data/lib/google/cloud/spanner/v1/spanner_client_config.json +78 -0
  55. data/lib/google/cloud/spanner/version.rb +22 -0
  56. data/lib/google/spanner/admin/database/v1/spanner_database_admin_pb.rb +85 -0
  57. data/lib/google/spanner/admin/database/v1/spanner_database_admin_services_pb.rb +95 -0
  58. data/lib/google/spanner/admin/instance/v1/spanner_instance_admin_pb.rb +106 -0
  59. data/lib/google/spanner/admin/instance/v1/spanner_instance_admin_services_pb.rb +180 -0
  60. data/lib/google/spanner/v1/keys_pb.rb +33 -0
  61. data/lib/google/spanner/v1/mutation_pb.rb +38 -0
  62. data/lib/google/spanner/v1/query_plan_pb.rb +47 -0
  63. data/lib/google/spanner/v1/result_set_pb.rb +43 -0
  64. data/lib/google/spanner/v1/spanner_pb.rb +90 -0
  65. data/lib/google/spanner/v1/spanner_services_pb.rb +131 -0
  66. data/lib/google/spanner/v1/transaction_pb.rb +51 -0
  67. data/lib/google/spanner/v1/type_pb.rb +43 -0
  68. metadata +309 -0
@@ -0,0 +1,83 @@
1
+ # Copyright 2017, Google Inc. All rights reserved.
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
+ # http://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
+ module Google
16
+ module Rpc
17
+ # The +Status+ type defines a logical error model that is suitable for different
18
+ # programming environments, including REST APIs and RPC APIs. It is used by
19
+ # {gRPC}[https://github.com/grpc]. The error model is designed to be:
20
+ #
21
+ # - Simple to use and understand for most users
22
+ # - Flexible enough to meet unexpected needs
23
+ #
24
+ # = Overview
25
+ #
26
+ # The +Status+ message contains three pieces of data: error code, error message,
27
+ # and error details. The error code should be an enum value of
28
+ # Google::Rpc::Code, but it may accept additional error codes if needed. The
29
+ # error message should be a developer-facing English message that helps
30
+ # developers *understand* and *resolve* the error. If a localized user-facing
31
+ # error message is needed, put the localized message in the error details or
32
+ # localize it in the client. The optional error details may contain arbitrary
33
+ # information about the error. There is a predefined set of error detail types
34
+ # in the package +google.rpc+ which can be used for common error conditions.
35
+ #
36
+ # = Language mapping
37
+ #
38
+ # The +Status+ message is the logical representation of the error model, but it
39
+ # is not necessarily the actual wire format. When the +Status+ message is
40
+ # exposed in different client libraries and different wire protocols, it can be
41
+ # mapped differently. For example, it will likely be mapped to some exceptions
42
+ # in Java, but more likely mapped to some error codes in C.
43
+ #
44
+ # = Other uses
45
+ #
46
+ # The error model and the +Status+ message can be used in a variety of
47
+ # environments, either with or without APIs, to provide a
48
+ # consistent developer experience across different environments.
49
+ #
50
+ # Example uses of this error model include:
51
+ #
52
+ # - Partial errors. If a service needs to return partial errors to the client,
53
+ # it may embed the +Status+ in the normal response to indicate the partial
54
+ # errors.
55
+ #
56
+ # - Workflow errors. A typical workflow has multiple steps. Each step may
57
+ # have a +Status+ message for error reporting purpose.
58
+ #
59
+ # - Batch operations. If a client uses batch request and batch response, the
60
+ # +Status+ message should be used directly inside batch response, one for
61
+ # each error sub-response.
62
+ #
63
+ # - Asynchronous operations. If an API call embeds asynchronous operation
64
+ # results in its response, the status of those operations should be
65
+ # represented directly using the +Status+ message.
66
+ #
67
+ # - Logging. If some API errors are stored in logs, the message +Status+ could
68
+ # be used directly after any stripping needed for security/privacy reasons.
69
+ # @!attribute [rw] code
70
+ # @return [Integer]
71
+ # The status code, which should be an enum value of Google::Rpc::Code.
72
+ # @!attribute [rw] message
73
+ # @return [String]
74
+ # A developer-facing error message, which should be in English. Any
75
+ # user-facing error message should be localized and sent in the
76
+ # Google::Rpc::Status#details field, or localized by the client.
77
+ # @!attribute [rw] details
78
+ # @return [Array<Google::Protobuf::Any>]
79
+ # A list of messages that carry the error details. There will be a
80
+ # common set of message types for APIs to use.
81
+ class Status; end
82
+ end
83
+ end
@@ -0,0 +1,268 @@
1
+ # Copyright 2017, Google Inc. All rights reserved.
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
+ # http://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
+ module Google
16
+ module Spanner
17
+ module Admin
18
+ module Instance
19
+ module V1
20
+ # A possible configuration for a Cloud Spanner instance. Configurations
21
+ # define the geographic placement of nodes and their replication.
22
+ # @!attribute [rw] name
23
+ # @return [String]
24
+ # A unique identifier for the instance configuration. Values
25
+ # are of the form
26
+ # +projects/<project>/instanceConfigs/[a-z][-a-z0-9]*+
27
+ # @!attribute [rw] display_name
28
+ # @return [String]
29
+ # The name of this instance configuration as it appears in UIs.
30
+ class InstanceConfig; end
31
+
32
+ # An isolated set of Cloud Spanner resources on which databases can be hosted.
33
+ # @!attribute [rw] name
34
+ # @return [String]
35
+ # Required. A unique identifier for the instance, which cannot be changed
36
+ # after the instance is created. Values are of the form
37
+ # +projects/<project>/instances/[a-z][-a-z0-9]*[a-z0-9]+. The final
38
+ # segment of the name must be between 6 and 30 characters in length.
39
+ # @!attribute [rw] config
40
+ # @return [String]
41
+ # Required. The name of the instance's configuration. Values are of the form
42
+ # +projects/<project>/instanceConfigs/<configuration>+. See
43
+ # also InstanceConfig and
44
+ # ListInstanceConfigs.
45
+ # @!attribute [rw] display_name
46
+ # @return [String]
47
+ # Required. The descriptive name for this instance as it appears in UIs.
48
+ # Must be unique per project and between 4 and 30 characters in length.
49
+ # @!attribute [rw] node_count
50
+ # @return [Integer]
51
+ # Required. The number of nodes allocated to this instance.
52
+ # @!attribute [rw] state
53
+ # @return [Google::Spanner::Admin::Instance::V1::Instance::State]
54
+ # Output only. The current instance state. For
55
+ # CreateInstance, the state must be
56
+ # either omitted or set to +CREATING+. For
57
+ # UpdateInstance, the state must be
58
+ # either omitted or set to +READY+.
59
+ # @!attribute [rw] labels
60
+ # @return [Hash{String => String}]
61
+ # Cloud Labels are a flexible and lightweight mechanism for organizing cloud
62
+ # resources into groups that reflect a customer's organizational needs and
63
+ # deployment strategies. Cloud Labels can be used to filter collections of
64
+ # resources. They can be used to control how resource metrics are aggregated.
65
+ # And they can be used as arguments to policy management rules (e.g. route,
66
+ # firewall, load balancing, etc.).
67
+ #
68
+ # * Label keys must be between 1 and 63 characters long and must conform to
69
+ # the following regular expression: +{a-z}[https://cloud.google.com[-a-z0-9]*[a-z0-9]]?+.
70
+ # * Label values must be between 0 and 63 characters long and must conform
71
+ # to the regular expression +({a-z}[https://cloud.google.com[-a-z0-9]*[a-z0-9]]?)?+.
72
+ # * No more than 64 labels can be associated with a given resource.
73
+ #
74
+ # See https://goo.gl/xmQnxf for more information on and examples of labels.
75
+ #
76
+ # If you plan to use labels in your own code, please note that additional
77
+ # characters may be allowed in the future. And so you are advised to use an
78
+ # internal label representation, such as JSON, which doesn't rely upon
79
+ # specific characters being disallowed. For example, representing labels
80
+ # as the string: name + "_" + value would prove problematic if we were to
81
+ # allow "_" in a future release.
82
+ class Instance
83
+ # Indicates the current state of the instance.
84
+ module State
85
+ # Not specified.
86
+ STATE_UNSPECIFIED = 0
87
+
88
+ # The instance is still being created. Resources may not be
89
+ # available yet, and operations such as database creation may not
90
+ # work.
91
+ CREATING = 1
92
+
93
+ # The instance is fully created and ready to do work such as
94
+ # creating databases.
95
+ READY = 2
96
+ end
97
+ end
98
+
99
+ # The request for ListInstanceConfigs.
100
+ # @!attribute [rw] parent
101
+ # @return [String]
102
+ # Required. The name of the project for which a list of supported instance
103
+ # configurations is requested. Values are of the form
104
+ # +projects/<project>+.
105
+ # @!attribute [rw] page_size
106
+ # @return [Integer]
107
+ # Number of instance configurations to be returned in the response. If 0 or
108
+ # less, defaults to the server's maximum allowed page size.
109
+ # @!attribute [rw] page_token
110
+ # @return [String]
111
+ # If non-empty, +page_token+ should contain a
112
+ # Next_page_token
113
+ # from a previous ListInstanceConfigsResponse.
114
+ class ListInstanceConfigsRequest; end
115
+
116
+ # The response for ListInstanceConfigs.
117
+ # @!attribute [rw] instance_configs
118
+ # @return [Array<Google::Spanner::Admin::Instance::V1::InstanceConfig>]
119
+ # The list of requested instance configurations.
120
+ # @!attribute [rw] next_page_token
121
+ # @return [String]
122
+ # +next_page_token+ can be sent in a subsequent
123
+ # ListInstanceConfigs call to
124
+ # fetch more of the matching instance configurations.
125
+ class ListInstanceConfigsResponse; end
126
+
127
+ # The request for
128
+ # GetInstanceConfigRequest.
129
+ # @!attribute [rw] name
130
+ # @return [String]
131
+ # Required. The name of the requested instance configuration. Values are of
132
+ # the form +projects/<project>/instanceConfigs/<config>+.
133
+ class GetInstanceConfigRequest; end
134
+
135
+ # The request for GetInstance.
136
+ # @!attribute [rw] name
137
+ # @return [String]
138
+ # Required. The name of the requested instance. Values are of the form
139
+ # +projects/<project>/instances/<instance>+.
140
+ class GetInstanceRequest; end
141
+
142
+ # The request for CreateInstance.
143
+ # @!attribute [rw] parent
144
+ # @return [String]
145
+ # Required. The name of the project in which to create the instance. Values
146
+ # are of the form +projects/<project>+.
147
+ # @!attribute [rw] instance_id
148
+ # @return [String]
149
+ # Required. The ID of the instance to create. Valid identifiers are of the
150
+ # form +[a-z][-a-z0-9]*[a-z0-9]+ and must be between 6 and 30 characters in
151
+ # length.
152
+ # @!attribute [rw] instance
153
+ # @return [Google::Spanner::Admin::Instance::V1::Instance]
154
+ # Required. The instance to create. The name may be omitted, but if
155
+ # specified must be +<parent>/instances/<instance_id>+.
156
+ class CreateInstanceRequest; end
157
+
158
+ # The request for ListInstances.
159
+ # @!attribute [rw] parent
160
+ # @return [String]
161
+ # Required. The name of the project for which a list of instances is
162
+ # requested. Values are of the form +projects/<project>+.
163
+ # @!attribute [rw] page_size
164
+ # @return [Integer]
165
+ # Number of instances to be returned in the response. If 0 or less, defaults
166
+ # to the server's maximum allowed page size.
167
+ # @!attribute [rw] page_token
168
+ # @return [String]
169
+ # If non-empty, +page_token+ should contain a
170
+ # Next_page_token from a
171
+ # previous ListInstancesResponse.
172
+ # @!attribute [rw] filter
173
+ # @return [String]
174
+ # An expression for filtering the results of the request. Filter rules are
175
+ # case insensitive. The fields eligible for filtering are:
176
+ #
177
+ # * name
178
+ # * display_name
179
+ # * labels.key where key is the name of a label
180
+ #
181
+ # Some examples of using filters are:
182
+ #
183
+ # * name:* --> The instance has a name.
184
+ # * name:Howl --> The instance's name contains the string "howl".
185
+ # * name:HOWL --> Equivalent to above.
186
+ # * NAME:howl --> Equivalent to above.
187
+ # * labels.env:* --> The instance has the label "env".
188
+ # * labels.env:dev --> The instance has the label "env" and the value of
189
+ # the label contains the string "dev".
190
+ # * name:howl labels.env:dev --> The instance's name contains "howl" and
191
+ # it has the label "env" with its value
192
+ # containing "dev".
193
+ class ListInstancesRequest; end
194
+
195
+ # The response for ListInstances.
196
+ # @!attribute [rw] instances
197
+ # @return [Array<Google::Spanner::Admin::Instance::V1::Instance>]
198
+ # The list of requested instances.
199
+ # @!attribute [rw] next_page_token
200
+ # @return [String]
201
+ # +next_page_token+ can be sent in a subsequent
202
+ # ListInstances call to fetch more
203
+ # of the matching instances.
204
+ class ListInstancesResponse; end
205
+
206
+ # The request for UpdateInstance.
207
+ # @!attribute [rw] instance
208
+ # @return [Google::Spanner::Admin::Instance::V1::Instance]
209
+ # Required. The instance to update, which must always include the instance
210
+ # name. Otherwise, only fields mentioned in [][google.spanner.admin.instance.v1.UpdateInstanceRequest.field_mask] need be included.
211
+ # @!attribute [rw] field_mask
212
+ # @return [Google::Protobuf::FieldMask]
213
+ # Required. A mask specifying which fields in [][google.spanner.admin.instance.v1.UpdateInstanceRequest.instance] should be updated.
214
+ # The field mask must always be specified; this prevents any future fields in
215
+ # [][google.spanner.admin.instance.v1.Instance] from being erased accidentally by clients that do not know
216
+ # about them.
217
+ class UpdateInstanceRequest; end
218
+
219
+ # The request for DeleteInstance.
220
+ # @!attribute [rw] name
221
+ # @return [String]
222
+ # Required. The name of the instance to be deleted. Values are of the form
223
+ # +projects/<project>/instances/<instance>+
224
+ class DeleteInstanceRequest; end
225
+
226
+ # Metadata type for the operation returned by
227
+ # CreateInstance.
228
+ # @!attribute [rw] instance
229
+ # @return [Google::Spanner::Admin::Instance::V1::Instance]
230
+ # The instance being created.
231
+ # @!attribute [rw] start_time
232
+ # @return [Google::Protobuf::Timestamp]
233
+ # The time at which the
234
+ # CreateInstance request was
235
+ # received.
236
+ # @!attribute [rw] cancel_time
237
+ # @return [Google::Protobuf::Timestamp]
238
+ # The time at which this operation was cancelled. If set, this operation is
239
+ # in the process of undoing itself (which is guaranteed to succeed) and
240
+ # cannot be cancelled again.
241
+ # @!attribute [rw] end_time
242
+ # @return [Google::Protobuf::Timestamp]
243
+ # The time at which this operation failed or was completed successfully.
244
+ class CreateInstanceMetadata; end
245
+
246
+ # Metadata type for the operation returned by
247
+ # UpdateInstance.
248
+ # @!attribute [rw] instance
249
+ # @return [Google::Spanner::Admin::Instance::V1::Instance]
250
+ # The desired end state of the update.
251
+ # @!attribute [rw] start_time
252
+ # @return [Google::Protobuf::Timestamp]
253
+ # The time at which UpdateInstance
254
+ # request was received.
255
+ # @!attribute [rw] cancel_time
256
+ # @return [Google::Protobuf::Timestamp]
257
+ # The time at which this operation was cancelled. If set, this operation is
258
+ # in the process of undoing itself (which is guaranteed to succeed) and
259
+ # cannot be cancelled again.
260
+ # @!attribute [rw] end_time
261
+ # @return [Google::Protobuf::Timestamp]
262
+ # The time at which this operation failed or was completed successfully.
263
+ class UpdateInstanceMetadata; end
264
+ end
265
+ end
266
+ end
267
+ end
268
+ end
@@ -0,0 +1,868 @@
1
+ # Copyright 2017, Google Inc. All rights reserved.
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
+ # http://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
+ # The only allowed edits are to method and file documentation. A 3-way
23
+ # merge preserves those additions if the generated source changes.
24
+
25
+ require "json"
26
+ require "pathname"
27
+
28
+ require "google/gax"
29
+ require "google/gax/operation"
30
+ require "google/longrunning/operations_client"
31
+
32
+ require "google/spanner/admin/instance/v1/spanner_instance_admin_pb"
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
+ attr_reader :instance_admin_stub
66
+
67
+ # The default address of the service.
68
+ SERVICE_ADDRESS = "spanner.googleapis.com".freeze
69
+
70
+ # The default port of the service.
71
+ DEFAULT_SERVICE_PORT = 443
72
+
73
+ DEFAULT_TIMEOUT = 30
74
+
75
+ PAGE_DESCRIPTORS = {
76
+ "list_instance_configs" => Google::Gax::PageDescriptor.new(
77
+ "page_token",
78
+ "next_page_token",
79
+ "instance_configs"),
80
+ "list_instances" => Google::Gax::PageDescriptor.new(
81
+ "page_token",
82
+ "next_page_token",
83
+ "instances")
84
+ }.freeze
85
+
86
+ private_constant :PAGE_DESCRIPTORS
87
+
88
+ # The scopes needed to make gRPC calls to all of the methods defined in
89
+ # this service.
90
+ ALL_SCOPES = [
91
+ "https://www.googleapis.com/auth/cloud-platform",
92
+ "https://www.googleapis.com/auth/spanner.admin"
93
+ ].freeze
94
+
95
+ PROJECT_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
96
+ "projects/{project}"
97
+ )
98
+
99
+ private_constant :PROJECT_PATH_TEMPLATE
100
+
101
+ INSTANCE_CONFIG_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
102
+ "projects/{project}/instanceConfigs/{instance_config}"
103
+ )
104
+
105
+ private_constant :INSTANCE_CONFIG_PATH_TEMPLATE
106
+
107
+ INSTANCE_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
108
+ "projects/{project}/instances/{instance}"
109
+ )
110
+
111
+ private_constant :INSTANCE_PATH_TEMPLATE
112
+
113
+ # Returns a fully-qualified project resource name string.
114
+ # @param project [String]
115
+ # @return [String]
116
+ def self.project_path project
117
+ PROJECT_PATH_TEMPLATE.render(
118
+ :"project" => project
119
+ )
120
+ end
121
+
122
+ # Returns a fully-qualified instance_config resource name string.
123
+ # @param project [String]
124
+ # @param instance_config [String]
125
+ # @return [String]
126
+ def self.instance_config_path project, instance_config
127
+ INSTANCE_CONFIG_PATH_TEMPLATE.render(
128
+ :"project" => project,
129
+ :"instance_config" => instance_config
130
+ )
131
+ end
132
+
133
+ # Returns a fully-qualified instance resource name string.
134
+ # @param project [String]
135
+ # @param instance [String]
136
+ # @return [String]
137
+ def self.instance_path project, instance
138
+ INSTANCE_PATH_TEMPLATE.render(
139
+ :"project" => project,
140
+ :"instance" => instance
141
+ )
142
+ end
143
+
144
+ # Parses the project from a project resource.
145
+ # @param project_name [String]
146
+ # @return [String]
147
+ def self.match_project_from_project_name project_name
148
+ PROJECT_PATH_TEMPLATE.match(project_name)["project"]
149
+ end
150
+
151
+ # Parses the project from a instance_config resource.
152
+ # @param instance_config_name [String]
153
+ # @return [String]
154
+ def self.match_project_from_instance_config_name instance_config_name
155
+ INSTANCE_CONFIG_PATH_TEMPLATE.match(instance_config_name)["project"]
156
+ end
157
+
158
+ # Parses the instance_config from a instance_config resource.
159
+ # @param instance_config_name [String]
160
+ # @return [String]
161
+ def self.match_instance_config_from_instance_config_name instance_config_name
162
+ INSTANCE_CONFIG_PATH_TEMPLATE.match(instance_config_name)["instance_config"]
163
+ end
164
+
165
+ # Parses the project from a instance resource.
166
+ # @param instance_name [String]
167
+ # @return [String]
168
+ def self.match_project_from_instance_name instance_name
169
+ INSTANCE_PATH_TEMPLATE.match(instance_name)["project"]
170
+ end
171
+
172
+ # Parses the instance from a instance resource.
173
+ # @param instance_name [String]
174
+ # @return [String]
175
+ def self.match_instance_from_instance_name instance_name
176
+ INSTANCE_PATH_TEMPLATE.match(instance_name)["instance"]
177
+ end
178
+
179
+ # @param service_path [String]
180
+ # The domain name of the API remote host.
181
+ # @param port [Integer]
182
+ # The port on which to connect to the remote host.
183
+ # @param channel [Channel]
184
+ # A Channel object through which to make calls.
185
+ # @param chan_creds [Grpc::ChannelCredentials]
186
+ # A ChannelCredentials for the setting up the RPC client.
187
+ # @param client_config[Hash]
188
+ # A Hash for call options for each method. See
189
+ # Google::Gax#construct_settings for the structure of
190
+ # this data. Falls back to the default config if not specified
191
+ # or the specified config is missing data points.
192
+ # @param timeout [Numeric]
193
+ # The default timeout, in seconds, for calls made through this client.
194
+ def initialize \
195
+ service_path: SERVICE_ADDRESS,
196
+ port: DEFAULT_SERVICE_PORT,
197
+ channel: nil,
198
+ chan_creds: nil,
199
+ scopes: ALL_SCOPES,
200
+ client_config: {},
201
+ timeout: DEFAULT_TIMEOUT,
202
+ app_name: nil,
203
+ app_version: nil,
204
+ lib_name: nil,
205
+ lib_version: ""
206
+ # These require statements are intentionally placed here to initialize
207
+ # the gRPC module only when it's required.
208
+ # See https://github.com/googleapis/toolkit/issues/446
209
+ require "google/gax/grpc"
210
+ require "google/spanner/admin/instance/v1/spanner_instance_admin_services_pb"
211
+
212
+ @operations_client = Google::Longrunning::OperationsClient.new(
213
+ service_path: service_path,
214
+ port: port,
215
+ channel: channel,
216
+ chan_creds: chan_creds,
217
+ scopes: scopes,
218
+ client_config: client_config,
219
+ timeout: timeout,
220
+ app_name: app_name,
221
+ app_version: app_version,
222
+ lib_name: lib_name,
223
+ lib_version: lib_version,
224
+ )
225
+
226
+ if app_name || app_version
227
+ warn "`app_name` and `app_version` are no longer being used in the request headers."
228
+ end
229
+
230
+ google_api_client = "gl-ruby/#{RUBY_VERSION}"
231
+ google_api_client << " #{lib_name}/#{lib_version}" if lib_name
232
+ google_api_client << " gapic/0.6.8 gax/#{Google::Gax::VERSION}"
233
+ google_api_client << " grpc/#{GRPC::VERSION}"
234
+ google_api_client.freeze
235
+
236
+ headers = { :"x-goog-api-client" => google_api_client }
237
+ client_config_file = Pathname.new(__dir__).join(
238
+ "instance_admin_client_config.json"
239
+ )
240
+ defaults = client_config_file.open do |f|
241
+ Google::Gax.construct_settings(
242
+ "google.spanner.admin.instance.v1.InstanceAdmin",
243
+ JSON.parse(f.read),
244
+ client_config,
245
+ Google::Gax::Grpc::STATUS_CODE_NAMES,
246
+ timeout,
247
+ page_descriptors: PAGE_DESCRIPTORS,
248
+ errors: Google::Gax::Grpc::API_ERRORS,
249
+ kwargs: headers
250
+ )
251
+ end
252
+ @instance_admin_stub = Google::Gax::Grpc.create_stub(
253
+ service_path,
254
+ port,
255
+ chan_creds: chan_creds,
256
+ channel: channel,
257
+ scopes: scopes,
258
+ &Google::Spanner::Admin::Instance::V1::InstanceAdmin::Stub.method(:new)
259
+ )
260
+
261
+ @list_instance_configs = Google::Gax.create_api_call(
262
+ @instance_admin_stub.method(:list_instance_configs),
263
+ defaults["list_instance_configs"]
264
+ )
265
+ @get_instance_config = Google::Gax.create_api_call(
266
+ @instance_admin_stub.method(:get_instance_config),
267
+ defaults["get_instance_config"]
268
+ )
269
+ @list_instances = Google::Gax.create_api_call(
270
+ @instance_admin_stub.method(:list_instances),
271
+ defaults["list_instances"]
272
+ )
273
+ @get_instance = Google::Gax.create_api_call(
274
+ @instance_admin_stub.method(:get_instance),
275
+ defaults["get_instance"]
276
+ )
277
+ @create_instance = Google::Gax.create_api_call(
278
+ @instance_admin_stub.method(:create_instance),
279
+ defaults["create_instance"]
280
+ )
281
+ @update_instance = Google::Gax.create_api_call(
282
+ @instance_admin_stub.method(:update_instance),
283
+ defaults["update_instance"]
284
+ )
285
+ @delete_instance = Google::Gax.create_api_call(
286
+ @instance_admin_stub.method(:delete_instance),
287
+ defaults["delete_instance"]
288
+ )
289
+ @set_iam_policy = Google::Gax.create_api_call(
290
+ @instance_admin_stub.method(:set_iam_policy),
291
+ defaults["set_iam_policy"]
292
+ )
293
+ @get_iam_policy = Google::Gax.create_api_call(
294
+ @instance_admin_stub.method(:get_iam_policy),
295
+ defaults["get_iam_policy"]
296
+ )
297
+ @test_iam_permissions = Google::Gax.create_api_call(
298
+ @instance_admin_stub.method(:test_iam_permissions),
299
+ defaults["test_iam_permissions"]
300
+ )
301
+ end
302
+
303
+ # Service calls
304
+
305
+ # Lists the supported instance configurations for a given project.
306
+ #
307
+ # @param parent [String]
308
+ # Required. The name of the project for which a list of supported instance
309
+ # configurations is requested. Values are of the form
310
+ # +projects/<project>+.
311
+ # @param page_size [Integer]
312
+ # The maximum number of resources contained in the underlying API
313
+ # response. If page streaming is performed per-resource, this
314
+ # parameter does not affect the return value. If page streaming is
315
+ # performed per-page, this determines the maximum number of
316
+ # resources in a page.
317
+ # @param options [Google::Gax::CallOptions]
318
+ # Overrides the default settings for this call, e.g, timeout,
319
+ # retries, etc.
320
+ # @return [Google::Gax::PagedEnumerable<Google::Spanner::Admin::Instance::V1::InstanceConfig>]
321
+ # An enumerable of Google::Spanner::Admin::Instance::V1::InstanceConfig instances.
322
+ # See Google::Gax::PagedEnumerable documentation for other
323
+ # operations such as per-page iteration or access to the response
324
+ # object.
325
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
326
+ # @example
327
+ # require "google/cloud/spanner/admin/instance/v1/instance_admin_client"
328
+ #
329
+ # InstanceAdminClient = Google::Cloud::Spanner::Admin::Instance::V1::InstanceAdminClient
330
+ #
331
+ # instance_admin_client = InstanceAdminClient.new
332
+ # formatted_parent = InstanceAdminClient.project_path("[PROJECT]")
333
+ #
334
+ # # Iterate over all results.
335
+ # instance_admin_client.list_instance_configs(formatted_parent).each do |element|
336
+ # # Process element.
337
+ # end
338
+ #
339
+ # # Or iterate over results one page at a time.
340
+ # instance_admin_client.list_instance_configs(formatted_parent).each_page do |page|
341
+ # # Process each page at a time.
342
+ # page.each do |element|
343
+ # # Process element.
344
+ # end
345
+ # end
346
+
347
+ def list_instance_configs \
348
+ parent,
349
+ page_size: nil,
350
+ options: nil
351
+ req = Google::Spanner::Admin::Instance::V1::ListInstanceConfigsRequest.new({
352
+ parent: parent,
353
+ page_size: page_size
354
+ }.delete_if { |_, v| v.nil? })
355
+ @list_instance_configs.call(req, options)
356
+ end
357
+
358
+ # Gets information about a particular instance configuration.
359
+ #
360
+ # @param name [String]
361
+ # Required. The name of the requested instance configuration. Values are of
362
+ # the form +projects/<project>/instanceConfigs/<config>+.
363
+ # @param options [Google::Gax::CallOptions]
364
+ # Overrides the default settings for this call, e.g, timeout,
365
+ # retries, etc.
366
+ # @return [Google::Spanner::Admin::Instance::V1::InstanceConfig]
367
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
368
+ # @example
369
+ # require "google/cloud/spanner/admin/instance/v1/instance_admin_client"
370
+ #
371
+ # InstanceAdminClient = Google::Cloud::Spanner::Admin::Instance::V1::InstanceAdminClient
372
+ #
373
+ # instance_admin_client = InstanceAdminClient.new
374
+ # formatted_name = InstanceAdminClient.instance_config_path("[PROJECT]", "[INSTANCE_CONFIG]")
375
+ # response = instance_admin_client.get_instance_config(formatted_name)
376
+
377
+ def get_instance_config \
378
+ name,
379
+ options: nil
380
+ req = Google::Spanner::Admin::Instance::V1::GetInstanceConfigRequest.new({
381
+ name: name
382
+ }.delete_if { |_, v| v.nil? })
383
+ @get_instance_config.call(req, options)
384
+ end
385
+
386
+ # Lists all instances in the given project.
387
+ #
388
+ # @param parent [String]
389
+ # Required. The name of the project for which a list of instances is
390
+ # requested. Values are of the form +projects/<project>+.
391
+ # @param page_size [Integer]
392
+ # The maximum number of resources contained in the underlying API
393
+ # response. If page streaming is performed per-resource, this
394
+ # parameter does not affect the return value. If page streaming is
395
+ # performed per-page, this determines the maximum number of
396
+ # resources in a page.
397
+ # @param filter [String]
398
+ # An expression for filtering the results of the request. Filter rules are
399
+ # case insensitive. The fields eligible for filtering are:
400
+ #
401
+ # * name
402
+ # * display_name
403
+ # * labels.key where key is the name of a label
404
+ #
405
+ # Some examples of using filters are:
406
+ #
407
+ # * name:* --> The instance has a name.
408
+ # * name:Howl --> The instance's name contains the string "howl".
409
+ # * name:HOWL --> Equivalent to above.
410
+ # * NAME:howl --> Equivalent to above.
411
+ # * labels.env:* --> The instance has the label "env".
412
+ # * labels.env:dev --> The instance has the label "env" and the value of
413
+ # the label contains the string "dev".
414
+ # * name:howl labels.env:dev --> The instance's name contains "howl" and
415
+ # it has the label "env" with its value
416
+ # containing "dev".
417
+ # @param options [Google::Gax::CallOptions]
418
+ # Overrides the default settings for this call, e.g, timeout,
419
+ # retries, etc.
420
+ # @return [Google::Gax::PagedEnumerable<Google::Spanner::Admin::Instance::V1::Instance>]
421
+ # An enumerable of Google::Spanner::Admin::Instance::V1::Instance instances.
422
+ # See Google::Gax::PagedEnumerable documentation for other
423
+ # operations such as per-page iteration or access to the response
424
+ # object.
425
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
426
+ # @example
427
+ # require "google/cloud/spanner/admin/instance/v1/instance_admin_client"
428
+ #
429
+ # InstanceAdminClient = Google::Cloud::Spanner::Admin::Instance::V1::InstanceAdminClient
430
+ #
431
+ # instance_admin_client = InstanceAdminClient.new
432
+ # formatted_parent = InstanceAdminClient.project_path("[PROJECT]")
433
+ #
434
+ # # Iterate over all results.
435
+ # instance_admin_client.list_instances(formatted_parent).each do |element|
436
+ # # Process element.
437
+ # end
438
+ #
439
+ # # Or iterate over results one page at a time.
440
+ # instance_admin_client.list_instances(formatted_parent).each_page do |page|
441
+ # # Process each page at a time.
442
+ # page.each do |element|
443
+ # # Process element.
444
+ # end
445
+ # end
446
+
447
+ def list_instances \
448
+ parent,
449
+ page_size: nil,
450
+ filter: nil,
451
+ options: nil
452
+ req = Google::Spanner::Admin::Instance::V1::ListInstancesRequest.new({
453
+ parent: parent,
454
+ page_size: page_size,
455
+ filter: filter
456
+ }.delete_if { |_, v| v.nil? })
457
+ @list_instances.call(req, options)
458
+ end
459
+
460
+ # Gets information about a particular instance.
461
+ #
462
+ # @param name [String]
463
+ # Required. The name of the requested instance. Values are of the form
464
+ # +projects/<project>/instances/<instance>+.
465
+ # @param options [Google::Gax::CallOptions]
466
+ # Overrides the default settings for this call, e.g, timeout,
467
+ # retries, etc.
468
+ # @return [Google::Spanner::Admin::Instance::V1::Instance]
469
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
470
+ # @example
471
+ # require "google/cloud/spanner/admin/instance/v1/instance_admin_client"
472
+ #
473
+ # InstanceAdminClient = Google::Cloud::Spanner::Admin::Instance::V1::InstanceAdminClient
474
+ #
475
+ # instance_admin_client = InstanceAdminClient.new
476
+ # formatted_name = InstanceAdminClient.instance_path("[PROJECT]", "[INSTANCE]")
477
+ # response = instance_admin_client.get_instance(formatted_name)
478
+
479
+ def get_instance \
480
+ name,
481
+ options: nil
482
+ req = Google::Spanner::Admin::Instance::V1::GetInstanceRequest.new({
483
+ name: name
484
+ }.delete_if { |_, v| v.nil? })
485
+ @get_instance.call(req, options)
486
+ end
487
+
488
+ # Creates an instance and begins preparing it to begin serving. The
489
+ # returned Long-running operation
490
+ # can be used to track the progress of preparing the new
491
+ # instance. The instance name is assigned by the caller. If the
492
+ # named instance already exists, +CreateInstance+ returns
493
+ # +ALREADY_EXISTS+.
494
+ #
495
+ # Immediately upon completion of this request:
496
+ #
497
+ # * The instance is readable via the API, with all requested attributes
498
+ # but no allocated resources. Its state is +CREATING+.
499
+ #
500
+ # Until completion of the returned operation:
501
+ #
502
+ # * Cancelling the operation renders the instance immediately unreadable
503
+ # via the API.
504
+ # * The instance can be deleted.
505
+ # * All other attempts to modify the instance are rejected.
506
+ #
507
+ # Upon completion of the returned operation:
508
+ #
509
+ # * Billing for all successfully-allocated resources begins (some types
510
+ # may have lower than the requested levels).
511
+ # * Databases can be created in the instance.
512
+ # * The instance's allocated resource levels are readable via the API.
513
+ # * The instance's state becomes +READY+.
514
+ #
515
+ # The returned Long-running operation will
516
+ # have a name of the format +<instance_name>/operations/<operation_id>+ and
517
+ # can be used to track creation of the instance. The
518
+ # Metadata field type is
519
+ # CreateInstanceMetadata.
520
+ # The Response field type is
521
+ # Instance, if successful.
522
+ #
523
+ # @param parent [String]
524
+ # Required. The name of the project in which to create the instance. Values
525
+ # are of the form +projects/<project>+.
526
+ # @param instance_id [String]
527
+ # Required. The ID of the instance to create. Valid identifiers are of the
528
+ # form +[a-z][-a-z0-9]*[a-z0-9]+ and must be between 6 and 30 characters in
529
+ # length.
530
+ # @param instance [Google::Spanner::Admin::Instance::V1::Instance]
531
+ # Required. The instance to create. The name may be omitted, but if
532
+ # specified must be +<parent>/instances/<instance_id>+.
533
+ # @param options [Google::Gax::CallOptions]
534
+ # Overrides the default settings for this call, e.g, timeout,
535
+ # retries, etc.
536
+ # @return [Google::Gax::Operation]
537
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
538
+ # @example
539
+ # require "google/cloud/spanner/admin/instance/v1/instance_admin_client"
540
+ #
541
+ # Instance = Google::Spanner::Admin::Instance::V1::Instance
542
+ # InstanceAdminClient = Google::Cloud::Spanner::Admin::Instance::V1::InstanceAdminClient
543
+ #
544
+ # instance_admin_client = InstanceAdminClient.new
545
+ # formatted_parent = InstanceAdminClient.project_path("[PROJECT]")
546
+ # instance_id = ''
547
+ # instance = Instance.new
548
+ #
549
+ # # Register a callback during the method call.
550
+ # operation = instance_admin_client.create_instance(formatted_parent, instance_id, instance) do |op|
551
+ # raise op.results.message if op.error?
552
+ # op_results = op.results
553
+ # # Process the results.
554
+ #
555
+ # metadata = op.metadata
556
+ # # Process the metadata.
557
+ # end
558
+ #
559
+ # # Or use the return value to register a callback.
560
+ # operation.on_done do |op|
561
+ # raise op.results.message if op.error?
562
+ # op_results = op.results
563
+ # # Process the results.
564
+ #
565
+ # metadata = op.metadata
566
+ # # Process the metadata.
567
+ # end
568
+ #
569
+ # # Manually reload the operation.
570
+ # operation.reload!
571
+ #
572
+ # # Or block until the operation completes, triggering callbacks on
573
+ # # completion.
574
+ # operation.wait_until_done!
575
+
576
+ def create_instance \
577
+ parent,
578
+ instance_id,
579
+ instance,
580
+ options: nil
581
+ req = Google::Spanner::Admin::Instance::V1::CreateInstanceRequest.new({
582
+ parent: parent,
583
+ instance_id: instance_id,
584
+ instance: instance
585
+ }.delete_if { |_, v| v.nil? })
586
+ operation = Google::Gax::Operation.new(
587
+ @create_instance.call(req, options),
588
+ @operations_client,
589
+ Google::Spanner::Admin::Instance::V1::Instance,
590
+ Google::Spanner::Admin::Instance::V1::CreateInstanceMetadata,
591
+ call_options: options
592
+ )
593
+ operation.on_done { |operation| yield(operation) } if block_given?
594
+ operation
595
+ end
596
+
597
+ # Updates an instance, and begins allocating or releasing resources
598
+ # as requested. The returned Long-running
599
+ # operation can be used to track the
600
+ # progress of updating the instance. If the named instance does not
601
+ # exist, returns +NOT_FOUND+.
602
+ #
603
+ # Immediately upon completion of this request:
604
+ #
605
+ # * For resource types for which a decrease in the instance's allocation
606
+ # has been requested, billing is based on the newly-requested level.
607
+ #
608
+ # Until completion of the returned operation:
609
+ #
610
+ # * Cancelling the operation sets its metadata's
611
+ # Cancel_time, and begins
612
+ # restoring resources to their pre-request values. The operation
613
+ # is guaranteed to succeed at undoing all resource changes,
614
+ # after which point it terminates with a +CANCELLED+ status.
615
+ # * All other attempts to modify the instance are rejected.
616
+ # * Reading the instance via the API continues to give the pre-request
617
+ # resource levels.
618
+ #
619
+ # Upon completion of the returned operation:
620
+ #
621
+ # * Billing begins for all successfully-allocated resources (some types
622
+ # may have lower than the requested levels).
623
+ # * All newly-reserved resources are available for serving the instance's
624
+ # tables.
625
+ # * The instance's new resource levels are readable via the API.
626
+ #
627
+ # The returned Long-running operation will
628
+ # have a name of the format +<instance_name>/operations/<operation_id>+ and
629
+ # can be used to track the instance modification. The
630
+ # Metadata field type is
631
+ # UpdateInstanceMetadata.
632
+ # The Response field type is
633
+ # Instance, if successful.
634
+ #
635
+ # Authorization requires +spanner.instances.update+ permission on
636
+ # resource Name.
637
+ #
638
+ # @param instance [Google::Spanner::Admin::Instance::V1::Instance]
639
+ # Required. The instance to update, which must always include the instance
640
+ # name. Otherwise, only fields mentioned in [][google.spanner.admin.instance.v1.UpdateInstanceRequest.field_mask] need be included.
641
+ # @param field_mask [Google::Protobuf::FieldMask]
642
+ # Required. A mask specifying which fields in [][google.spanner.admin.instance.v1.UpdateInstanceRequest.instance] should be updated.
643
+ # The field mask must always be specified; this prevents any future fields in
644
+ # [][google.spanner.admin.instance.v1.Instance] from being erased accidentally by clients that do not know
645
+ # about them.
646
+ # @param options [Google::Gax::CallOptions]
647
+ # Overrides the default settings for this call, e.g, timeout,
648
+ # retries, etc.
649
+ # @return [Google::Gax::Operation]
650
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
651
+ # @example
652
+ # require "google/cloud/spanner/admin/instance/v1/instance_admin_client"
653
+ #
654
+ # FieldMask = Google::Protobuf::FieldMask
655
+ # Instance = Google::Spanner::Admin::Instance::V1::Instance
656
+ # InstanceAdminClient = Google::Cloud::Spanner::Admin::Instance::V1::InstanceAdminClient
657
+ #
658
+ # instance_admin_client = InstanceAdminClient.new
659
+ # instance = Instance.new
660
+ # field_mask = FieldMask.new
661
+ #
662
+ # # Register a callback during the method call.
663
+ # operation = instance_admin_client.update_instance(instance, field_mask) do |op|
664
+ # raise op.results.message if op.error?
665
+ # op_results = op.results
666
+ # # Process the results.
667
+ #
668
+ # metadata = op.metadata
669
+ # # Process the metadata.
670
+ # end
671
+ #
672
+ # # Or use the return value to register a callback.
673
+ # operation.on_done do |op|
674
+ # raise op.results.message if op.error?
675
+ # op_results = op.results
676
+ # # Process the results.
677
+ #
678
+ # metadata = op.metadata
679
+ # # Process the metadata.
680
+ # end
681
+ #
682
+ # # Manually reload the operation.
683
+ # operation.reload!
684
+ #
685
+ # # Or block until the operation completes, triggering callbacks on
686
+ # # completion.
687
+ # operation.wait_until_done!
688
+
689
+ def update_instance \
690
+ instance,
691
+ field_mask,
692
+ options: nil
693
+ req = Google::Spanner::Admin::Instance::V1::UpdateInstanceRequest.new({
694
+ instance: instance,
695
+ field_mask: field_mask
696
+ }.delete_if { |_, v| v.nil? })
697
+ operation = Google::Gax::Operation.new(
698
+ @update_instance.call(req, options),
699
+ @operations_client,
700
+ Google::Spanner::Admin::Instance::V1::Instance,
701
+ Google::Spanner::Admin::Instance::V1::UpdateInstanceMetadata,
702
+ call_options: options
703
+ )
704
+ operation.on_done { |operation| yield(operation) } if block_given?
705
+ operation
706
+ end
707
+
708
+ # Deletes an instance.
709
+ #
710
+ # Immediately upon completion of the request:
711
+ #
712
+ # * Billing ceases for all of the instance's reserved resources.
713
+ #
714
+ # Soon afterward:
715
+ #
716
+ # * The instance and *all of its databases* immediately and
717
+ # irrevocably disappear from the API. All data in the databases
718
+ # is permanently deleted.
719
+ #
720
+ # @param name [String]
721
+ # Required. The name of the instance to be deleted. Values are of the form
722
+ # +projects/<project>/instances/<instance>+
723
+ # @param options [Google::Gax::CallOptions]
724
+ # Overrides the default settings for this call, e.g, timeout,
725
+ # retries, etc.
726
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
727
+ # @example
728
+ # require "google/cloud/spanner/admin/instance/v1/instance_admin_client"
729
+ #
730
+ # InstanceAdminClient = Google::Cloud::Spanner::Admin::Instance::V1::InstanceAdminClient
731
+ #
732
+ # instance_admin_client = InstanceAdminClient.new
733
+ # formatted_name = InstanceAdminClient.instance_path("[PROJECT]", "[INSTANCE]")
734
+ # instance_admin_client.delete_instance(formatted_name)
735
+
736
+ def delete_instance \
737
+ name,
738
+ options: nil
739
+ req = Google::Spanner::Admin::Instance::V1::DeleteInstanceRequest.new({
740
+ name: name
741
+ }.delete_if { |_, v| v.nil? })
742
+ @delete_instance.call(req, options)
743
+ nil
744
+ end
745
+
746
+ # Sets the access control policy on an instance resource. Replaces any
747
+ # existing policy.
748
+ #
749
+ # Authorization requires +spanner.instances.setIamPolicy+ on
750
+ # Resource.
751
+ #
752
+ # @param resource [String]
753
+ # REQUIRED: The resource for which the policy is being specified.
754
+ # +resource+ is usually specified as a path. For example, a Project
755
+ # resource is specified as +projects/{project}+.
756
+ # @param policy [Google::Iam::V1::Policy]
757
+ # REQUIRED: The complete policy to be applied to the +resource+. The size of
758
+ # the policy is limited to a few 10s of KB. An empty policy is a
759
+ # valid policy but certain Cloud Platform services (such as Projects)
760
+ # might reject them.
761
+ # @param options [Google::Gax::CallOptions]
762
+ # Overrides the default settings for this call, e.g, timeout,
763
+ # retries, etc.
764
+ # @return [Google::Iam::V1::Policy]
765
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
766
+ # @example
767
+ # require "google/cloud/spanner/admin/instance/v1/instance_admin_client"
768
+ #
769
+ # InstanceAdminClient = Google::Cloud::Spanner::Admin::Instance::V1::InstanceAdminClient
770
+ # Policy = Google::Iam::V1::Policy
771
+ #
772
+ # instance_admin_client = InstanceAdminClient.new
773
+ # formatted_resource = InstanceAdminClient.instance_path("[PROJECT]", "[INSTANCE]")
774
+ # policy = Policy.new
775
+ # response = instance_admin_client.set_iam_policy(formatted_resource, policy)
776
+
777
+ def set_iam_policy \
778
+ resource,
779
+ policy,
780
+ options: nil
781
+ req = Google::Iam::V1::SetIamPolicyRequest.new({
782
+ resource: resource,
783
+ policy: policy
784
+ }.delete_if { |_, v| v.nil? })
785
+ @set_iam_policy.call(req, options)
786
+ end
787
+
788
+ # Gets the access control policy for an instance resource. Returns an empty
789
+ # policy if an instance exists but does not have a policy set.
790
+ #
791
+ # Authorization requires +spanner.instances.getIamPolicy+ on
792
+ # Resource.
793
+ #
794
+ # @param resource [String]
795
+ # REQUIRED: The resource for which the policy is being requested.
796
+ # +resource+ is usually specified as a path. For example, a Project
797
+ # resource is specified as +projects/{project}+.
798
+ # @param options [Google::Gax::CallOptions]
799
+ # Overrides the default settings for this call, e.g, timeout,
800
+ # retries, etc.
801
+ # @return [Google::Iam::V1::Policy]
802
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
803
+ # @example
804
+ # require "google/cloud/spanner/admin/instance/v1/instance_admin_client"
805
+ #
806
+ # InstanceAdminClient = Google::Cloud::Spanner::Admin::Instance::V1::InstanceAdminClient
807
+ #
808
+ # instance_admin_client = InstanceAdminClient.new
809
+ # formatted_resource = InstanceAdminClient.instance_path("[PROJECT]", "[INSTANCE]")
810
+ # response = instance_admin_client.get_iam_policy(formatted_resource)
811
+
812
+ def get_iam_policy \
813
+ resource,
814
+ options: nil
815
+ req = Google::Iam::V1::GetIamPolicyRequest.new({
816
+ resource: resource
817
+ }.delete_if { |_, v| v.nil? })
818
+ @get_iam_policy.call(req, options)
819
+ end
820
+
821
+ # Returns permissions that the caller has on the specified instance resource.
822
+ #
823
+ # Attempting this RPC on a non-existent Cloud Spanner instance resource will
824
+ # result in a NOT_FOUND error if the user has +spanner.instances.list+
825
+ # permission on the containing Google Cloud Project. Otherwise returns an
826
+ # empty set of permissions.
827
+ #
828
+ # @param resource [String]
829
+ # REQUIRED: The resource for which the policy detail is being requested.
830
+ # +resource+ is usually specified as a path. For example, a Project
831
+ # resource is specified as +projects/{project}+.
832
+ # @param permissions [Array<String>]
833
+ # The set of permissions to check for the +resource+. Permissions with
834
+ # wildcards (such as '*' or 'storage.*') are not allowed. For more
835
+ # information see
836
+ # {IAM Overview}[https://cloud.google.com/iam/docs/overview#permissions].
837
+ # @param options [Google::Gax::CallOptions]
838
+ # Overrides the default settings for this call, e.g, timeout,
839
+ # retries, etc.
840
+ # @return [Google::Iam::V1::TestIamPermissionsResponse]
841
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
842
+ # @example
843
+ # require "google/cloud/spanner/admin/instance/v1/instance_admin_client"
844
+ #
845
+ # InstanceAdminClient = Google::Cloud::Spanner::Admin::Instance::V1::InstanceAdminClient
846
+ #
847
+ # instance_admin_client = InstanceAdminClient.new
848
+ # formatted_resource = InstanceAdminClient.instance_path("[PROJECT]", "[INSTANCE]")
849
+ # permissions = []
850
+ # response = instance_admin_client.test_iam_permissions(formatted_resource, permissions)
851
+
852
+ def test_iam_permissions \
853
+ resource,
854
+ permissions,
855
+ options: nil
856
+ req = Google::Iam::V1::TestIamPermissionsRequest.new({
857
+ resource: resource,
858
+ permissions: permissions
859
+ }.delete_if { |_, v| v.nil? })
860
+ @test_iam_permissions.call(req, options)
861
+ end
862
+ end
863
+ end
864
+ end
865
+ end
866
+ end
867
+ end
868
+ end