google-cloud-spanner 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/google-cloud-spanner.rb +13 -10
- data/lib/google/cloud/spanner.rb +21 -18
- data/lib/google/cloud/spanner/admin/database.rb +111 -0
- data/lib/google/cloud/spanner/admin/database/credentials.rb +35 -0
- data/lib/google/cloud/spanner/admin/database/v1.rb +100 -3
- data/lib/google/cloud/spanner/admin/database/v1/database_admin_client.rb +129 -138
- data/lib/google/cloud/spanner/admin/database/v1/doc/google/iam/v1/policy.rb +8 -8
- data/lib/google/cloud/spanner/admin/database/v1/doc/google/protobuf/any.rb +12 -2
- data/lib/google/cloud/spanner/admin/database/v1/doc/google/rpc/status.rb +22 -22
- data/lib/google/cloud/spanner/admin/database/v1/doc/google/spanner/admin/database/v1/spanner_database_admin.rb +33 -20
- data/lib/google/cloud/spanner/admin/database/v1/doc/overview.rb +57 -0
- data/lib/google/cloud/spanner/admin/instance.rb +127 -0
- data/lib/google/cloud/spanner/admin/instance/credentials.rb +35 -0
- data/lib/google/cloud/spanner/admin/instance/v1.rb +116 -3
- data/lib/google/cloud/spanner/admin/instance/v1/doc/google/iam/v1/policy.rb +8 -8
- data/lib/google/cloud/spanner/admin/instance/v1/doc/google/protobuf/any.rb +12 -2
- data/lib/google/cloud/spanner/admin/instance/v1/doc/google/rpc/status.rb +22 -22
- data/lib/google/cloud/spanner/admin/instance/v1/doc/google/spanner/admin/instance/v1/spanner_instance_admin.rb +58 -43
- data/lib/google/cloud/spanner/admin/instance/v1/doc/overview.rb +57 -0
- data/lib/google/cloud/spanner/admin/instance/v1/instance_admin_client.rb +180 -189
- data/lib/google/cloud/spanner/client.rb +3 -3
- data/lib/google/cloud/spanner/credentials.rb +33 -7
- data/lib/google/cloud/spanner/database.rb +3 -6
- data/lib/google/cloud/spanner/instance.rb +2 -4
- data/lib/google/cloud/spanner/instance/config.rb +2 -4
- data/lib/google/cloud/spanner/project.rb +6 -6
- data/lib/google/cloud/spanner/service.rb +5 -26
- data/lib/google/cloud/spanner/session.rb +4 -4
- data/lib/google/cloud/spanner/v1/doc/google/protobuf/duration.rb +14 -1
- data/lib/google/cloud/spanner/v1/doc/google/protobuf/timestamp.rb +26 -1
- data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/keys.rb +3 -3
- data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/mutation.rb +12 -12
- data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/query_plan.rb +9 -9
- data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/result_set.rb +33 -33
- data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/spanner.rb +99 -28
- data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/transaction.rb +41 -31
- data/lib/google/cloud/spanner/v1/doc/overview.rb +54 -0
- data/lib/google/cloud/spanner/v1/spanner_client.rb +277 -195
- data/lib/google/cloud/spanner/v1/spanner_client_config.json +5 -0
- data/lib/google/cloud/spanner/version.rb +1 -1
- data/lib/google/spanner/v1/spanner_pb.rb +16 -1
- data/lib/google/spanner/v1/spanner_services_pb.rb +2 -0
- metadata +16 -23
@@ -45,7 +45,7 @@ module Google
|
|
45
45
|
# }
|
46
46
|
#
|
47
47
|
# For a description of IAM and its features, see the
|
48
|
-
#
|
48
|
+
# [IAM developer's guide](https://cloud.google.com/iam).
|
49
49
|
# @!attribute [rw] version
|
50
50
|
# @return [Integer]
|
51
51
|
# Version of the +Policy+. The default version is 0.
|
@@ -80,23 +80,23 @@ module Google
|
|
80
80
|
# +members+ can have the following values:
|
81
81
|
#
|
82
82
|
# * +allUsers+: A special identifier that represents anyone who is
|
83
|
-
#
|
83
|
+
# on the internet; with or without a Google account.
|
84
84
|
#
|
85
85
|
# * +allAuthenticatedUsers+: A special identifier that represents anyone
|
86
|
-
#
|
86
|
+
# who is authenticated with a Google account or a service account.
|
87
87
|
#
|
88
88
|
# * +user:{emailid}+: An email address that represents a specific Google
|
89
|
-
#
|
89
|
+
# account. For example, +alice@gmail.com+ or +joe@example.com+.
|
90
90
|
#
|
91
91
|
#
|
92
92
|
# * +serviceAccount:{emailid}+: An email address that represents a service
|
93
|
-
#
|
93
|
+
# account. For example, +my-other-app@appspot.gserviceaccount.com+.
|
94
94
|
#
|
95
95
|
# * +group:{emailid}+: An email address that represents a Google group.
|
96
|
-
#
|
96
|
+
# For example, +admins@example.com+.
|
97
97
|
#
|
98
98
|
# * +domain:{domain}+: A Google Apps domain name that represents all the
|
99
|
-
#
|
99
|
+
# users of that domain. For example, +google.com+ or +example.com+.
|
100
100
|
class Binding; end
|
101
101
|
|
102
102
|
# The difference delta between two policies.
|
@@ -136,4 +136,4 @@ module Google
|
|
136
136
|
end
|
137
137
|
end
|
138
138
|
end
|
139
|
-
end
|
139
|
+
end
|
@@ -49,6 +49,16 @@ module Google
|
|
49
49
|
# any.Unpack(foo)
|
50
50
|
# ...
|
51
51
|
#
|
52
|
+
# Example 4: Pack and unpack a message in Go
|
53
|
+
#
|
54
|
+
# foo := &pb.Foo{...}
|
55
|
+
# any, err := ptypes.MarshalAny(foo)
|
56
|
+
# ...
|
57
|
+
# foo := &pb.Foo{}
|
58
|
+
# if err := ptypes.UnmarshalAny(any, foo); err != nil {
|
59
|
+
# ...
|
60
|
+
# }
|
61
|
+
#
|
52
62
|
# The pack methods provided by protobuf library will by default use
|
53
63
|
# 'type.googleapis.com/full.type.name' as the type URL and the unpack
|
54
64
|
# methods only use the fully qualified type name after the last '/'
|
@@ -77,7 +87,7 @@ module Google
|
|
77
87
|
# If the embedded message type is well-known and has a custom JSON
|
78
88
|
# representation, that representation will be embedded adding a field
|
79
89
|
# +value+ which holds the custom JSON in addition to the +@type+
|
80
|
-
# field. Example (for message Google::Protobuf::Duration):
|
90
|
+
# field. Example (for message {Google::Protobuf::Duration}):
|
81
91
|
#
|
82
92
|
# {
|
83
93
|
# "@type": "type.googleapis.com/google.protobuf.Duration",
|
@@ -96,7 +106,7 @@ module Google
|
|
96
106
|
# qualified name of the type (as in +path/google.protobuf.Duration+).
|
97
107
|
# The name should be in a canonical form (e.g., leading "." is
|
98
108
|
# not accepted).
|
99
|
-
# * An HTTP GET on the URL must yield a Google::Protobuf::Type
|
109
|
+
# * An HTTP GET on the URL must yield a {Google::Protobuf::Type}
|
100
110
|
# value in binary format, or produce an error.
|
101
111
|
# * Applications are allowed to cache lookup results based on the
|
102
112
|
# URL, or have them precompiled into a binary to avoid any
|
@@ -16,22 +16,22 @@ module Google
|
|
16
16
|
module Rpc
|
17
17
|
# The +Status+ type defines a logical error model that is suitable for different
|
18
18
|
# programming environments, including REST APIs and RPC APIs. It is used by
|
19
|
-
#
|
19
|
+
# [gRPC](https://github.com/grpc). The error model is designed to be:
|
20
20
|
#
|
21
|
-
#
|
22
|
-
#
|
21
|
+
# * Simple to use and understand for most users
|
22
|
+
# * Flexible enough to meet unexpected needs
|
23
23
|
#
|
24
24
|
# = Overview
|
25
25
|
#
|
26
26
|
# The +Status+ message contains three pieces of data: error code, error message,
|
27
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
|
28
|
+
# {Google::Rpc::Code}, but it may accept additional error codes if needed. The
|
29
29
|
# error message should be a developer-facing English message that helps
|
30
30
|
# developers *understand* and *resolve* the error. If a localized user-facing
|
31
31
|
# error message is needed, put the localized message in the error details or
|
32
32
|
# localize it in the client. The optional error details may contain arbitrary
|
33
33
|
# information about the error. There is a predefined set of error detail types
|
34
|
-
# in the package +google.rpc+
|
34
|
+
# in the package +google.rpc+ that can be used for common error conditions.
|
35
35
|
#
|
36
36
|
# = Language mapping
|
37
37
|
#
|
@@ -49,35 +49,35 @@ module Google
|
|
49
49
|
#
|
50
50
|
# Example uses of this error model include:
|
51
51
|
#
|
52
|
-
#
|
53
|
-
#
|
54
|
-
#
|
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
55
|
#
|
56
|
-
#
|
57
|
-
#
|
56
|
+
# * Workflow errors. A typical workflow has multiple steps. Each step may
|
57
|
+
# have a +Status+ message for error reporting.
|
58
58
|
#
|
59
|
-
#
|
60
|
-
#
|
61
|
-
#
|
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
62
|
#
|
63
|
-
#
|
64
|
-
#
|
65
|
-
#
|
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
66
|
#
|
67
|
-
#
|
68
|
-
#
|
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
69
|
# @!attribute [rw] code
|
70
70
|
# @return [Integer]
|
71
|
-
# The status code, which should be an enum value of Google::Rpc::Code.
|
71
|
+
# The status code, which should be an enum value of {Google::Rpc::Code}.
|
72
72
|
# @!attribute [rw] message
|
73
73
|
# @return [String]
|
74
74
|
# A developer-facing error message, which should be in English. Any
|
75
75
|
# user-facing error message should be localized and sent in the
|
76
|
-
# Google::Rpc::Status#details field, or localized by the client.
|
76
|
+
# {Google::Rpc::Status#details} field, or localized by the client.
|
77
77
|
# @!attribute [rw] details
|
78
78
|
# @return [Array<Google::Protobuf::Any>]
|
79
|
-
# A list of messages that carry the error details. There
|
80
|
-
#
|
79
|
+
# A list of messages that carry the error details. There is a common set of
|
80
|
+
# message types for APIs to use.
|
81
81
|
class Status; end
|
82
82
|
end
|
83
83
|
end
|
@@ -16,6 +16,17 @@ module Google
|
|
16
16
|
module Spanner
|
17
17
|
module Admin
|
18
18
|
module Database
|
19
|
+
##
|
20
|
+
# # Cloud Spanner Database Admin API Contents
|
21
|
+
#
|
22
|
+
# | Class | Description |
|
23
|
+
# | ----- | ----------- |
|
24
|
+
# | [DatabaseAdminClient][] | |
|
25
|
+
# | [Data Types][] | Data types for Google::Cloud::Spanner::Admin::Database::V1 |
|
26
|
+
#
|
27
|
+
# [DatabaseAdminClient]: https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud-spanner-admin-database/latest/google/spanner/admin/database/v1/databaseadminclient
|
28
|
+
# [Data Types]: https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud-spanner-admin-database/latest/google/spanner/admin/database/v1/datatypes
|
29
|
+
#
|
19
30
|
module V1
|
20
31
|
# A Cloud Spanner database.
|
21
32
|
# @!attribute [rw] name
|
@@ -43,7 +54,7 @@ module Google
|
|
43
54
|
end
|
44
55
|
end
|
45
56
|
|
46
|
-
# The request for ListDatabases.
|
57
|
+
# The request for {Google::Spanner::Admin::Database::V1::DatabaseAdmin::ListDatabases ListDatabases}.
|
47
58
|
# @!attribute [rw] parent
|
48
59
|
# @return [String]
|
49
60
|
# Required. The instance whose databases should be listed.
|
@@ -55,22 +66,22 @@ module Google
|
|
55
66
|
# @!attribute [rw] page_token
|
56
67
|
# @return [String]
|
57
68
|
# If non-empty, +page_token+ should contain a
|
58
|
-
#
|
59
|
-
# previous ListDatabasesResponse.
|
69
|
+
# {Google::Spanner::Admin::Database::V1::ListDatabasesResponse#next_page_token next_page_token} from a
|
70
|
+
# previous {Google::Spanner::Admin::Database::V1::ListDatabasesResponse ListDatabasesResponse}.
|
60
71
|
class ListDatabasesRequest; end
|
61
72
|
|
62
|
-
# The response for ListDatabases.
|
73
|
+
# The response for {Google::Spanner::Admin::Database::V1::DatabaseAdmin::ListDatabases ListDatabases}.
|
63
74
|
# @!attribute [rw] databases
|
64
75
|
# @return [Array<Google::Spanner::Admin::Database::V1::Database>]
|
65
76
|
# Databases that matched the request.
|
66
77
|
# @!attribute [rw] next_page_token
|
67
78
|
# @return [String]
|
68
79
|
# +next_page_token+ can be sent in a subsequent
|
69
|
-
# ListDatabases call to fetch more
|
80
|
+
# {Google::Spanner::Admin::Database::V1::DatabaseAdmin::ListDatabases ListDatabases} call to fetch more
|
70
81
|
# of the matching databases.
|
71
82
|
class ListDatabasesResponse; end
|
72
83
|
|
73
|
-
# The request for CreateDatabase.
|
84
|
+
# The request for {Google::Spanner::Admin::Database::V1::DatabaseAdmin::CreateDatabase CreateDatabase}.
|
74
85
|
# @!attribute [rw] parent
|
75
86
|
# @return [String]
|
76
87
|
# Required. The name of the instance that will serve the new database.
|
@@ -80,6 +91,8 @@ module Google
|
|
80
91
|
# Required. A +CREATE DATABASE+ statement, which specifies the ID of the
|
81
92
|
# new database. The database ID must conform to the regular expression
|
82
93
|
# +[a-z][a-z0-9_\-]*[a-z0-9]+ and be between 2 and 30 characters in length.
|
94
|
+
# If the database ID is a reserved word or if it contains a hyphen, the
|
95
|
+
# database ID must be enclosed in backticks (+ + +).
|
83
96
|
# @!attribute [rw] extra_statements
|
84
97
|
# @return [Array<String>]
|
85
98
|
# An optional list of DDL statements to run inside the newly created
|
@@ -89,13 +102,13 @@ module Google
|
|
89
102
|
class CreateDatabaseRequest; end
|
90
103
|
|
91
104
|
# Metadata type for the operation returned by
|
92
|
-
# CreateDatabase.
|
105
|
+
# {Google::Spanner::Admin::Database::V1::DatabaseAdmin::CreateDatabase CreateDatabase}.
|
93
106
|
# @!attribute [rw] database
|
94
107
|
# @return [String]
|
95
108
|
# The database being created.
|
96
109
|
class CreateDatabaseMetadata; end
|
97
110
|
|
98
|
-
# The request for GetDatabase.
|
111
|
+
# The request for {Google::Spanner::Admin::Database::V1::DatabaseAdmin::GetDatabase GetDatabase}.
|
99
112
|
# @!attribute [rw] name
|
100
113
|
# @return [String]
|
101
114
|
# Required. The name of the requested database. Values are of the form
|
@@ -114,9 +127,9 @@ module Google
|
|
114
127
|
# subsequent statements in the batch are automatically cancelled.
|
115
128
|
#
|
116
129
|
# Each batch of statements is assigned a name which can be used with
|
117
|
-
# the Operations API to monitor
|
130
|
+
# the {Google::Longrunning::Operations Operations} API to monitor
|
118
131
|
# progress. See the
|
119
|
-
#
|
132
|
+
# {Google::Spanner::Admin::Database::V1::UpdateDatabaseDdlRequest#operation_id operation_id} field for more
|
120
133
|
# details.
|
121
134
|
# @!attribute [rw] database
|
122
135
|
# @return [String]
|
@@ -129,26 +142,26 @@ module Google
|
|
129
142
|
# If empty, the new update request is assigned an
|
130
143
|
# automatically-generated operation ID. Otherwise, +operation_id+
|
131
144
|
# is used to construct the name of the resulting
|
132
|
-
# Operation.
|
145
|
+
# {Google::Longrunning::Operation Operation}.
|
133
146
|
#
|
134
147
|
# Specifying an explicit operation ID simplifies determining
|
135
148
|
# whether the statements were executed in the event that the
|
136
|
-
# UpdateDatabaseDdl call is replayed,
|
137
|
-
# or the return value is otherwise lost: the Database and
|
149
|
+
# {Google::Spanner::Admin::Database::V1::DatabaseAdmin::UpdateDatabaseDdl UpdateDatabaseDdl} call is replayed,
|
150
|
+
# or the return value is otherwise lost: the {Google::Spanner::Admin::Database::V1::UpdateDatabaseDdlRequest#database database} and
|
138
151
|
# +operation_id+ fields can be combined to form the
|
139
|
-
#
|
140
|
-
# Longrunning::Operation: +<database>/operations/<operation_id>+.
|
152
|
+
# {Google::Longrunning::Operation#name name} of the resulting
|
153
|
+
# {Google::Longrunning::Operation longrunning::Operation}: +<database>/operations/<operation_id>+.
|
141
154
|
#
|
142
155
|
# +operation_id+ should be unique within the database, and must be
|
143
156
|
# a valid identifier: +[a-z][a-z0-9_]*+. Note that
|
144
157
|
# automatically-generated operation IDs always begin with an
|
145
158
|
# underscore. If the named operation already exists,
|
146
|
-
# UpdateDatabaseDdl returns
|
159
|
+
# {Google::Spanner::Admin::Database::V1::DatabaseAdmin::UpdateDatabaseDdl UpdateDatabaseDdl} returns
|
147
160
|
# +ALREADY_EXISTS+.
|
148
161
|
class UpdateDatabaseDdlRequest; end
|
149
162
|
|
150
163
|
# Metadata type for the operation returned by
|
151
|
-
# UpdateDatabaseDdl.
|
164
|
+
# {Google::Spanner::Admin::Database::V1::DatabaseAdmin::UpdateDatabaseDdl UpdateDatabaseDdl}.
|
152
165
|
# @!attribute [rw] database
|
153
166
|
# @return [String]
|
154
167
|
# The database being modified.
|
@@ -163,19 +176,19 @@ module Google
|
|
163
176
|
# timestamp for the statement +statements[i]+.
|
164
177
|
class UpdateDatabaseDdlMetadata; end
|
165
178
|
|
166
|
-
# The request for DropDatabase.
|
179
|
+
# The request for {Google::Spanner::Admin::Database::V1::DatabaseAdmin::DropDatabase DropDatabase}.
|
167
180
|
# @!attribute [rw] database
|
168
181
|
# @return [String]
|
169
182
|
# Required. The database to be dropped.
|
170
183
|
class DropDatabaseRequest; end
|
171
184
|
|
172
|
-
# The request for GetDatabaseDdl.
|
185
|
+
# The request for {Google::Spanner::Admin::Database::V1::DatabaseAdmin::GetDatabaseDdl GetDatabaseDdl}.
|
173
186
|
# @!attribute [rw] database
|
174
187
|
# @return [String]
|
175
188
|
# Required. The database whose schema we wish to get.
|
176
189
|
class GetDatabaseDdlRequest; end
|
177
190
|
|
178
|
-
# The response for GetDatabaseDdl.
|
191
|
+
# The response for {Google::Spanner::Admin::Database::V1::DatabaseAdmin::GetDatabaseDdl GetDatabaseDdl}.
|
179
192
|
# @!attribute [rw] statements
|
180
193
|
# @return [Array<String>]
|
181
194
|
# A list of formatted DDL statements defining the schema of the database
|
@@ -0,0 +1,57 @@
|
|
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 Cloud
|
17
|
+
module Spanner
|
18
|
+
module Admin
|
19
|
+
# rubocop:disable LineLength
|
20
|
+
|
21
|
+
##
|
22
|
+
# # Ruby Client for Cloud Spanner Database Admin API ([Alpha](https://github.com/GoogleCloudPlatform/google-cloud-ruby#versioning))
|
23
|
+
#
|
24
|
+
# [Cloud Spanner Database Admin API][Product Documentation]:
|
25
|
+
#
|
26
|
+
# - [Product Documentation][]
|
27
|
+
#
|
28
|
+
# ## Quick Start
|
29
|
+
# In order to use this library, you first need to go through the following
|
30
|
+
# steps:
|
31
|
+
#
|
32
|
+
# 1. [Select or create a Cloud Platform project.](https://console.cloud.google.com/project)
|
33
|
+
# 2. [Enable the Cloud Spanner Database Admin API.](https://console.cloud.google.com/apis/api/spanner-admin-database)
|
34
|
+
# 3. [Setup Authentication.](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud/master/guides/authentication)
|
35
|
+
#
|
36
|
+
# ### Installation
|
37
|
+
# ```
|
38
|
+
# $ gem install google-cloud-spanner-admin-database
|
39
|
+
# ```
|
40
|
+
#
|
41
|
+
# ### Next Steps
|
42
|
+
# - Read the [Cloud Spanner Database Admin API Product documentation][Product Documentation]
|
43
|
+
# to learn more about the product and see How-to Guides.
|
44
|
+
# - View this [repository's main README](https://github.com/GoogleCloudPlatform/google-cloud-ruby/blob/master/README.md)
|
45
|
+
# to see the full list of Cloud APIs that we cover.
|
46
|
+
#
|
47
|
+
# [Product Documentation]: https://cloud.google.com/spanner-admin-database
|
48
|
+
#
|
49
|
+
#
|
50
|
+
module Database
|
51
|
+
module V1
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,127 @@
|
|
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
|
+
require "google/gax"
|
16
|
+
require "pathname"
|
17
|
+
|
18
|
+
module Google
|
19
|
+
module Cloud
|
20
|
+
module Spanner
|
21
|
+
module Admin
|
22
|
+
# rubocop:disable LineLength
|
23
|
+
|
24
|
+
##
|
25
|
+
# # Ruby Client for Cloud Spanner Instance Admin API ([Alpha](https://github.com/GoogleCloudPlatform/google-cloud-ruby#versioning))
|
26
|
+
#
|
27
|
+
# [Cloud Spanner Instance Admin API][Product Documentation]:
|
28
|
+
#
|
29
|
+
# - [Product Documentation][]
|
30
|
+
#
|
31
|
+
# ## Quick Start
|
32
|
+
# In order to use this library, you first need to go through the following
|
33
|
+
# steps:
|
34
|
+
#
|
35
|
+
# 1. [Select or create a Cloud Platform project.](https://console.cloud.google.com/project)
|
36
|
+
# 2. [Enable the Cloud Spanner Instance Admin API.](https://console.cloud.google.com/apis/api/spanner-admin-instance)
|
37
|
+
# 3. [Setup Authentication.](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud/master/guides/authentication)
|
38
|
+
#
|
39
|
+
# ### Next Steps
|
40
|
+
# - Read the [Cloud Spanner Instance Admin API Product documentation][Product Documentation]
|
41
|
+
# to learn more about the product and see How-to Guides.
|
42
|
+
# - View this [repository's main README](https://github.com/GoogleCloudPlatform/google-cloud-ruby/blob/master/README.md)
|
43
|
+
# to see the full list of Cloud APIs that we cover.
|
44
|
+
#
|
45
|
+
# [Product Documentation]: https://cloud.google.com/spanner-admin-instance
|
46
|
+
#
|
47
|
+
#
|
48
|
+
module Instance
|
49
|
+
# rubocop:enable LineLength
|
50
|
+
|
51
|
+
FILE_DIR = File.realdirpath(Pathname.new(__FILE__).join("..").join("instance"))
|
52
|
+
|
53
|
+
AVAILABLE_VERSIONS = Dir["#{FILE_DIR}/*"]
|
54
|
+
.select { |file| File.directory?(file) }
|
55
|
+
.select { |dir| Google::Gax::VERSION_MATCHER.match(File.basename(dir)) }
|
56
|
+
.select { |dir| File.exist?(dir + ".rb") }
|
57
|
+
.map { |dir| File.basename(dir) }
|
58
|
+
|
59
|
+
##
|
60
|
+
# Cloud Spanner Instance Admin API
|
61
|
+
#
|
62
|
+
# The Cloud Spanner Instance Admin API can be used to create, delete,
|
63
|
+
# modify and list instances. Instances are dedicated Cloud Spanner serving
|
64
|
+
# and storage resources to be used by Cloud Spanner databases.
|
65
|
+
#
|
66
|
+
# Each instance has a "configuration", which dictates where the
|
67
|
+
# serving resources for the Cloud Spanner instance are located (e.g.,
|
68
|
+
# US-central, Europe). Configurations are created by Google based on
|
69
|
+
# resource availability.
|
70
|
+
#
|
71
|
+
# Cloud Spanner billing is based on the instances that exist and their
|
72
|
+
# sizes. After an instance exists, there are no additional
|
73
|
+
# per-database or per-operation charges for use of the instance
|
74
|
+
# (though there may be additional network bandwidth charges).
|
75
|
+
# Instances offer isolation: problems with databases in one instance
|
76
|
+
# will not affect other instances. However, within an instance
|
77
|
+
# databases can affect each other. For example, if one database in an
|
78
|
+
# instance receives a lot of requests and consumes most of the
|
79
|
+
# instance resources, fewer resources are available for other
|
80
|
+
# databases in that instance, and their performance may suffer.
|
81
|
+
#
|
82
|
+
# @param version [Symbol, String]
|
83
|
+
# The major version of the service to be used. By default :v1
|
84
|
+
# is used.
|
85
|
+
# @overload new(version:, credentials:, scopes:, client_config:, timeout:)
|
86
|
+
# @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
|
87
|
+
# Provides the means for authenticating requests made by the client. This parameter can
|
88
|
+
# be many types.
|
89
|
+
# A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
|
90
|
+
# authenticating requests made by this client.
|
91
|
+
# A `String` will be treated as the path to the keyfile to be used for the construction of
|
92
|
+
# credentials for this client.
|
93
|
+
# A `Hash` will be treated as the contents of a keyfile to be used for the construction of
|
94
|
+
# credentials for this client.
|
95
|
+
# A `GRPC::Core::Channel` will be used to make calls through.
|
96
|
+
# A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
|
97
|
+
# should already be composed with a `GRPC::Core::CallCredentials` object.
|
98
|
+
# A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
|
99
|
+
# metadata for requests, generally, to give OAuth credentials.
|
100
|
+
# @param scopes [Array<String>]
|
101
|
+
# The OAuth scopes for this service. This parameter is ignored if
|
102
|
+
# an updater_proc is supplied.
|
103
|
+
# @param client_config [Hash]
|
104
|
+
# A Hash for call options for each method. See
|
105
|
+
# Google::Gax#construct_settings for the structure of
|
106
|
+
# this data. Falls back to the default config if not specified
|
107
|
+
# or the specified config is missing data points.
|
108
|
+
# @param timeout [Numeric]
|
109
|
+
# The default timeout, in seconds, for calls made through this client.
|
110
|
+
def self.new(*args, version: :v1, **kwargs)
|
111
|
+
unless AVAILABLE_VERSIONS.include?(version.to_s.downcase)
|
112
|
+
raise "The version: #{version} is not available. The available versions " \
|
113
|
+
"are: [#{AVAILABLE_VERSIONS.join(", ")}]"
|
114
|
+
end
|
115
|
+
|
116
|
+
require "#{FILE_DIR}/#{version.to_s.downcase}"
|
117
|
+
version_module = Google::Cloud::Spanner::Admin::Instance
|
118
|
+
.constants
|
119
|
+
.select {|sym| sym.to_s.downcase == version.to_s.downcase}
|
120
|
+
.first
|
121
|
+
Google::Cloud::Spanner::Admin::Instance.const_get(version_module).new(*args, **kwargs)
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|