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,29 +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 Protobuf
18
- # A generic empty message that you can re-use to avoid defining duplicated
19
- # empty messages in your APIs. A typical example is to use it as the request
20
- # or the response type of an API method. For instance:
21
- #
22
- # service Foo {
23
- # rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty);
24
- # }
25
- #
26
- # The JSON representation for `Empty` is empty JSON object `{}`.
27
- class Empty; end
28
- end
29
- end
@@ -1,39 +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 Rpc
18
- # The `Status` type defines a logical error model that is suitable for
19
- # different programming environments, including REST APIs and RPC APIs. It is
20
- # used by [gRPC](https://github.com/grpc). Each `Status` message contains
21
- # three pieces of data: error code, error message, and error details.
22
- #
23
- # You can find out more about this error model and how to work with it in the
24
- # [API Design Guide](https://cloud.google.com/apis/design/errors).
25
- # @!attribute [rw] code
26
- # @return [Integer]
27
- # The status code, which should be an enum value of {Google::Rpc::Code}.
28
- # @!attribute [rw] message
29
- # @return [String]
30
- # A developer-facing error message, which should be in English. Any
31
- # user-facing error message should be localized and sent in the
32
- # {Google::Rpc::Status#details} field, or localized by the client.
33
- # @!attribute [rw] details
34
- # @return [Array<Google::Protobuf::Any>]
35
- # A list of messages that carry the error details. There is a common set of
36
- # message types for APIs to use.
37
- class Status; end
38
- end
39
- end
@@ -1,201 +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 Database
20
- module V1
21
- # A Cloud Spanner database.
22
- # @!attribute [rw] name
23
- # @return [String]
24
- # Required. The name of the database. Values are of the form
25
- # `projects/<project>/instances/<instance>/databases/<database>`,
26
- # where `<database>` is as specified in the `CREATE DATABASE`
27
- # statement. This name can be passed to other API methods to
28
- # identify the database.
29
- # @!attribute [rw] state
30
- # @return [Google::Spanner::Admin::Database::V1::Database::State]
31
- # Output only. The current database state.
32
- class Database
33
- # Indicates the current state of the database.
34
- module State
35
- # Not specified.
36
- STATE_UNSPECIFIED = 0
37
-
38
- # The database is still being created. Operations on the database may fail
39
- # with `FAILED_PRECONDITION` in this state.
40
- CREATING = 1
41
-
42
- # The database is fully created and ready for use.
43
- READY = 2
44
- end
45
- end
46
-
47
- # The request for
48
- # {Google::Spanner::Admin::Database::V1::DatabaseAdmin::ListDatabases ListDatabases}.
49
- # @!attribute [rw] parent
50
- # @return [String]
51
- # Required. The instance whose databases should be listed.
52
- # Values are of the form `projects/<project>/instances/<instance>`.
53
- # @!attribute [rw] page_size
54
- # @return [Integer]
55
- # Number of databases to be returned in the response. If 0 or less,
56
- # defaults to the server's maximum allowed page size.
57
- # @!attribute [rw] page_token
58
- # @return [String]
59
- # If non-empty, `page_token` should contain a
60
- # {Google::Spanner::Admin::Database::V1::ListDatabasesResponse#next_page_token next_page_token}
61
- # from a previous
62
- # {Google::Spanner::Admin::Database::V1::ListDatabasesResponse ListDatabasesResponse}.
63
- class ListDatabasesRequest; end
64
-
65
- # The response for
66
- # {Google::Spanner::Admin::Database::V1::DatabaseAdmin::ListDatabases ListDatabases}.
67
- # @!attribute [rw] databases
68
- # @return [Array<Google::Spanner::Admin::Database::V1::Database>]
69
- # Databases that matched the request.
70
- # @!attribute [rw] next_page_token
71
- # @return [String]
72
- # `next_page_token` can be sent in a subsequent
73
- # {Google::Spanner::Admin::Database::V1::DatabaseAdmin::ListDatabases ListDatabases}
74
- # call to fetch more of the matching databases.
75
- class ListDatabasesResponse; end
76
-
77
- # The request for
78
- # {Google::Spanner::Admin::Database::V1::DatabaseAdmin::CreateDatabase CreateDatabase}.
79
- # @!attribute [rw] parent
80
- # @return [String]
81
- # Required. The name of the instance that will serve the new database.
82
- # Values are of the form `projects/<project>/instances/<instance>`.
83
- # @!attribute [rw] create_statement
84
- # @return [String]
85
- # Required. A `CREATE DATABASE` statement, which specifies the ID of the
86
- # new database. The database ID must conform to the regular expression
87
- # `[a-z][a-z0-9_\-]*[a-z0-9]` and be between 2 and 30 characters in length.
88
- # If the database ID is a reserved word or if it contains a hyphen, the
89
- # database ID must be enclosed in backticks (`` ` ``).
90
- # @!attribute [rw] extra_statements
91
- # @return [Array<String>]
92
- # An optional list of DDL statements to run inside the newly created
93
- # database. Statements can create tables, indexes, etc. These
94
- # statements execute atomically with the creation of the database:
95
- # if there is an error in any statement, the database is not created.
96
- class CreateDatabaseRequest; end
97
-
98
- # Metadata type for the operation returned by
99
- # {Google::Spanner::Admin::Database::V1::DatabaseAdmin::CreateDatabase CreateDatabase}.
100
- # @!attribute [rw] database
101
- # @return [String]
102
- # The database being created.
103
- class CreateDatabaseMetadata; end
104
-
105
- # The request for
106
- # {Google::Spanner::Admin::Database::V1::DatabaseAdmin::GetDatabase GetDatabase}.
107
- # @!attribute [rw] name
108
- # @return [String]
109
- # Required. The name of the requested database. Values are of the form
110
- # `projects/<project>/instances/<instance>/databases/<database>`.
111
- class GetDatabaseRequest; end
112
-
113
- # Enqueues the given DDL statements to be applied, in order but not
114
- # necessarily all at once, to the database schema at some point (or
115
- # points) in the future. The server checks that the statements
116
- # are executable (syntactically valid, name tables that exist, etc.)
117
- # before enqueueing them, but they may still fail upon
118
- # later execution (e.g., if a statement from another batch of
119
- # statements is applied first and it conflicts in some way, or if
120
- # there is some data-related problem like a `NULL` value in a column to
121
- # which `NOT NULL` would be added). If a statement fails, all
122
- # subsequent statements in the batch are automatically cancelled.
123
- #
124
- # Each batch of statements is assigned a name which can be used with
125
- # the {Google::Longrunning::Operations Operations} API to monitor
126
- # progress. See the
127
- # {Google::Spanner::Admin::Database::V1::UpdateDatabaseDdlRequest#operation_id operation_id}
128
- # field for more details.
129
- # @!attribute [rw] database
130
- # @return [String]
131
- # Required. The database to update.
132
- # @!attribute [rw] statements
133
- # @return [Array<String>]
134
- # Required. DDL statements to be applied to the database.
135
- # @!attribute [rw] operation_id
136
- # @return [String]
137
- # If empty, the new update request is assigned an
138
- # automatically-generated operation ID. Otherwise, `operation_id`
139
- # is used to construct the name of the resulting
140
- # {Google::Longrunning::Operation Operation}.
141
- #
142
- # Specifying an explicit operation ID simplifies determining
143
- # whether the statements were executed in the event that the
144
- # {Google::Spanner::Admin::Database::V1::DatabaseAdmin::UpdateDatabaseDdl UpdateDatabaseDdl}
145
- # call is replayed, or the return value is otherwise lost: the
146
- # {Google::Spanner::Admin::Database::V1::UpdateDatabaseDdlRequest#database database}
147
- # and `operation_id` fields can be combined to form the
148
- # {Google::Longrunning::Operation#name name} of the resulting
149
- # {Google::Longrunning::Operation longrunning::Operation}:
150
- # `<database>/operations/<operation_id>`.
151
- #
152
- # `operation_id` should be unique within the database, and must be
153
- # a valid identifier: `[a-z][a-z0-9_]*`. Note that
154
- # automatically-generated operation IDs always begin with an
155
- # underscore. If the named operation already exists,
156
- # {Google::Spanner::Admin::Database::V1::DatabaseAdmin::UpdateDatabaseDdl UpdateDatabaseDdl}
157
- # returns `ALREADY_EXISTS`.
158
- class UpdateDatabaseDdlRequest; end
159
-
160
- # Metadata type for the operation returned by
161
- # {Google::Spanner::Admin::Database::V1::DatabaseAdmin::UpdateDatabaseDdl UpdateDatabaseDdl}.
162
- # @!attribute [rw] database
163
- # @return [String]
164
- # The database being modified.
165
- # @!attribute [rw] statements
166
- # @return [Array<String>]
167
- # For an update this list contains all the statements. For an
168
- # individual statement, this list contains only that statement.
169
- # @!attribute [rw] commit_timestamps
170
- # @return [Array<Google::Protobuf::Timestamp>]
171
- # Reports the commit timestamps of all statements that have
172
- # succeeded so far, where `commit_timestamps[i]` is the commit
173
- # timestamp for the statement `statements[i]`.
174
- class UpdateDatabaseDdlMetadata; end
175
-
176
- # The request for
177
- # {Google::Spanner::Admin::Database::V1::DatabaseAdmin::DropDatabase DropDatabase}.
178
- # @!attribute [rw] database
179
- # @return [String]
180
- # Required. The database to be dropped.
181
- class DropDatabaseRequest; end
182
-
183
- # The request for
184
- # {Google::Spanner::Admin::Database::V1::DatabaseAdmin::GetDatabaseDdl GetDatabaseDdl}.
185
- # @!attribute [rw] database
186
- # @return [String]
187
- # Required. The database whose schema we wish to get.
188
- class GetDatabaseDdlRequest; end
189
-
190
- # The response for
191
- # {Google::Spanner::Admin::Database::V1::DatabaseAdmin::GetDatabaseDdl GetDatabaseDdl}.
192
- # @!attribute [rw] statements
193
- # @return [Array<String>]
194
- # A list of formatted DDL statements defining the schema of the database
195
- # specified in the request.
196
- class GetDatabaseDdlResponse; end
197
- end
198
- end
199
- end
200
- end
201
- 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,164 +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
- require "google/gax"
17
- require "pathname"
18
-
19
- module Google
20
- module Cloud
21
- module Spanner
22
- module Admin
23
- # rubocop:disable LineLength
24
-
25
- ##
26
- # # Ruby Client for Cloud Spanner Instance Admin API ([Alpha](https://github.com/googleapis/google-cloud-ruby#versioning))
27
- #
28
- # [Cloud Spanner Instance Admin API][Product Documentation]:
29
- #
30
- # - [Product Documentation][]
31
- #
32
- # ## Quick Start
33
- # In order to use this library, you first need to go through the following
34
- # steps:
35
- #
36
- # 1. [Select or create a Cloud Platform project.](https://console.cloud.google.com/project)
37
- # 2. [Enable billing for your project.](https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project)
38
- # 3. [Enable the Cloud Spanner Instance Admin API.](https://console.cloud.google.com/apis/library/spanner.googleapis.com)
39
- # 4. [Setup Authentication.](https://googleapis.dev/ruby/google-cloud-spanner/latest/file.AUTHENTICATION.html)
40
- #
41
- # ### Installation
42
- # ```
43
- # $ gem install google-cloud-spanner
44
- # ```
45
- #
46
- # ### Next Steps
47
- # - Read the [Cloud Spanner Instance Admin API Product documentation][Product Documentation]
48
- # to learn more about the product and see How-to Guides.
49
- # - View this [repository's main README](https://github.com/googleapis/google-cloud-ruby/blob/master/README.md)
50
- # to see the full list of Cloud APIs that we cover.
51
- #
52
- # [Product Documentation]: https://cloud.google.com/spanner
53
- #
54
- # ## Enabling Logging
55
- #
56
- # To enable logging for this library, set the logger for the underlying [gRPC](https://github.com/grpc/grpc/tree/master/src/ruby) library.
57
- # The logger that you set may be a Ruby stdlib [`Logger`](https://ruby-doc.org/stdlib-2.5.0/libdoc/logger/rdoc/Logger.html) as shown below,
58
- # or a [`Google::Cloud::Logging::Logger`](https://googleapis.dev/ruby/google-cloud-logging/latest)
59
- # that will write logs to [Stackdriver Logging](https://cloud.google.com/logging/). See [grpc/logconfig.rb](https://github.com/grpc/grpc/blob/master/src/ruby/lib/grpc/logconfig.rb)
60
- # and the gRPC [spec_helper.rb](https://github.com/grpc/grpc/blob/master/src/ruby/spec/spec_helper.rb) for additional information.
61
- #
62
- # Configuring a Ruby stdlib logger:
63
- #
64
- # ```ruby
65
- # require "logger"
66
- #
67
- # module MyLogger
68
- # LOGGER = Logger.new $stderr, level: Logger::WARN
69
- # def logger
70
- # LOGGER
71
- # end
72
- # end
73
- #
74
- # # Define a gRPC module-level logger method before grpc/logconfig.rb loads.
75
- # module GRPC
76
- # extend MyLogger
77
- # end
78
- # ```
79
- #
80
- module Instance
81
- # rubocop:enable LineLength
82
-
83
- FILE_DIR = File.realdirpath(Pathname.new(__FILE__).join("..").join("instance"))
84
-
85
- AVAILABLE_VERSIONS = Dir["#{FILE_DIR}/*"]
86
- .select { |file| File.directory?(file) }
87
- .select { |dir| Google::Gax::VERSION_MATCHER.match(File.basename(dir)) }
88
- .select { |dir| File.exist?(dir + ".rb") }
89
- .map { |dir| File.basename(dir) }
90
-
91
- ##
92
- # Cloud Spanner Instance Admin API
93
- #
94
- # The Cloud Spanner Instance Admin API can be used to create, delete,
95
- # modify and list instances. Instances are dedicated Cloud Spanner serving
96
- # and storage resources to be used by Cloud Spanner databases.
97
- #
98
- # Each instance has a "configuration", which dictates where the
99
- # serving resources for the Cloud Spanner instance are located (e.g.,
100
- # US-central, Europe). Configurations are created by Google based on
101
- # resource availability.
102
- #
103
- # Cloud Spanner billing is based on the instances that exist and their
104
- # sizes. After an instance exists, there are no additional
105
- # per-database or per-operation charges for use of the instance
106
- # (though there may be additional network bandwidth charges).
107
- # Instances offer isolation: problems with databases in one instance
108
- # will not affect other instances. However, within an instance
109
- # databases can affect each other. For example, if one database in an
110
- # instance receives a lot of requests and consumes most of the
111
- # instance resources, fewer resources are available for other
112
- # databases in that instance, and their performance may suffer.
113
- #
114
- # @param version [Symbol, String]
115
- # The major version of the service to be used. By default :v1
116
- # is used.
117
- # @overload new(version:, credentials:, scopes:, client_config:, timeout:)
118
- # @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
119
- # Provides the means for authenticating requests made by the client. This parameter can
120
- # be many types.
121
- # A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
122
- # authenticating requests made by this client.
123
- # A `String` will be treated as the path to the keyfile to be used for the construction of
124
- # credentials for this client.
125
- # A `Hash` will be treated as the contents of a keyfile to be used for the construction of
126
- # credentials for this client.
127
- # A `GRPC::Core::Channel` will be used to make calls through.
128
- # A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
129
- # should already be composed with a `GRPC::Core::CallCredentials` object.
130
- # A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
131
- # metadata for requests, generally, to give OAuth credentials.
132
- # @param scopes [Array<String>]
133
- # The OAuth scopes for this service. This parameter is ignored if
134
- # an updater_proc is supplied.
135
- # @param client_config [Hash]
136
- # A Hash for call options for each method. See
137
- # Google::Gax#construct_settings for the structure of
138
- # this data. Falls back to the default config if not specified
139
- # or the specified config is missing data points.
140
- # @param timeout [Numeric]
141
- # The default timeout, in seconds, for calls made through this client.
142
- # @param metadata [Hash]
143
- # Default metadata to be sent with each request. This can be overridden on a per call basis.
144
- # @param exception_transformer [Proc]
145
- # An optional proc that intercepts any exceptions raised during an API call to inject
146
- # custom error handling.
147
- def self.new(*args, version: :v1, **kwargs)
148
- unless AVAILABLE_VERSIONS.include?(version.to_s.downcase)
149
- raise "The version: #{version} is not available. The available versions " \
150
- "are: [#{AVAILABLE_VERSIONS.join(", ")}]"
151
- end
152
-
153
- require "#{FILE_DIR}/#{version.to_s.downcase}"
154
- version_module = Google::Cloud::Spanner::Admin::Instance
155
- .constants
156
- .select {|sym| sym.to_s.downcase == version.to_s.downcase}
157
- .first
158
- Google::Cloud::Spanner::Admin::Instance.const_get(version_module).new(*args, **kwargs)
159
- end
160
- end
161
- end
162
- end
163
- end
164
- end