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.
- checksums.yaml +4 -4
- data/AUTHENTICATION.md +1 -1
- data/CHANGELOG.md +51 -0
- data/CONTRIBUTING.md +5 -5
- data/TROUBLESHOOTING.md +0 -6
- data/lib/google-cloud-spanner.rb +23 -13
- data/lib/google/cloud/spanner.rb +8 -9
- data/lib/google/cloud/spanner/admin/database/credentials.rb +2 -2
- data/lib/google/cloud/spanner/admin/instance/credentials.rb +2 -2
- data/lib/google/cloud/spanner/backup.rb +315 -0
- data/lib/google/cloud/spanner/backup/job.rb +274 -0
- data/lib/google/cloud/spanner/backup/job/list.rb +177 -0
- data/lib/google/cloud/spanner/backup/list.rb +169 -0
- data/lib/google/cloud/spanner/backup/restore/job.rb +246 -0
- data/lib/google/cloud/spanner/batch_client.rb +7 -5
- data/lib/google/cloud/spanner/batch_snapshot.rb +49 -16
- data/lib/google/cloud/spanner/batch_update.rb +1 -1
- data/lib/google/cloud/spanner/client.rb +65 -16
- data/lib/google/cloud/spanner/commit.rb +14 -14
- data/lib/google/cloud/spanner/convert.rb +7 -7
- data/lib/google/cloud/spanner/credentials.rb +2 -2
- data/lib/google/cloud/spanner/data.rb +2 -2
- data/lib/google/cloud/spanner/database.rb +275 -15
- data/lib/google/cloud/spanner/database/backup_info.rb +105 -0
- data/lib/google/cloud/spanner/database/job.rb +5 -2
- data/lib/google/cloud/spanner/database/job/list.rb +177 -0
- data/lib/google/cloud/spanner/database/list.rb +1 -1
- data/lib/google/cloud/spanner/database/restore_info.rb +63 -0
- data/lib/google/cloud/spanner/fields.rb +8 -8
- data/lib/google/cloud/spanner/instance.rb +401 -8
- data/lib/google/cloud/spanner/instance/config.rb +1 -1
- data/lib/google/cloud/spanner/instance/config/list.rb +1 -1
- data/lib/google/cloud/spanner/instance/job.rb +2 -2
- data/lib/google/cloud/spanner/instance/list.rb +1 -1
- data/lib/google/cloud/spanner/partition.rb +4 -4
- data/lib/google/cloud/spanner/policy.rb +2 -2
- data/lib/google/cloud/spanner/project.rb +31 -6
- data/lib/google/cloud/spanner/results.rb +4 -2
- data/lib/google/cloud/spanner/service.rb +231 -240
- data/lib/google/cloud/spanner/session.rb +46 -15
- data/lib/google/cloud/spanner/snapshot.rb +28 -5
- data/lib/google/cloud/spanner/transaction.rb +51 -7
- data/lib/google/cloud/spanner/version.rb +1 -1
- metadata +28 -104
- data/lib/google/cloud/spanner/admin/database.rb +0 -148
- data/lib/google/cloud/spanner/admin/database/v1.rb +0 -146
- data/lib/google/cloud/spanner/admin/database/v1/credentials.rb +0 -46
- data/lib/google/cloud/spanner/admin/database/v1/database_admin_client.rb +0 -791
- data/lib/google/cloud/spanner/admin/database/v1/database_admin_client_config.json +0 -71
- data/lib/google/cloud/spanner/admin/database/v1/doc/google/iam/v1/iam_policy.rb +0 -64
- data/lib/google/cloud/spanner/admin/database/v1/doc/google/iam/v1/options.rb +0 -33
- data/lib/google/cloud/spanner/admin/database/v1/doc/google/iam/v1/policy.rb +0 -151
- data/lib/google/cloud/spanner/admin/database/v1/doc/google/longrunning/operations.rb +0 -51
- data/lib/google/cloud/spanner/admin/database/v1/doc/google/protobuf/any.rb +0 -131
- data/lib/google/cloud/spanner/admin/database/v1/doc/google/protobuf/empty.rb +0 -29
- data/lib/google/cloud/spanner/admin/database/v1/doc/google/rpc/status.rb +0 -39
- data/lib/google/cloud/spanner/admin/database/v1/doc/google/spanner/admin/database/v1/spanner_database_admin.rb +0 -201
- data/lib/google/cloud/spanner/admin/database/v1/doc/google/type/expr.rb +0 -45
- data/lib/google/cloud/spanner/admin/instance.rb +0 -164
- data/lib/google/cloud/spanner/admin/instance/v1.rb +0 -162
- data/lib/google/cloud/spanner/admin/instance/v1/credentials.rb +0 -46
- data/lib/google/cloud/spanner/admin/instance/v1/doc/google/iam/v1/iam_policy.rb +0 -64
- data/lib/google/cloud/spanner/admin/instance/v1/doc/google/iam/v1/options.rb +0 -33
- data/lib/google/cloud/spanner/admin/instance/v1/doc/google/iam/v1/policy.rb +0 -151
- data/lib/google/cloud/spanner/admin/instance/v1/doc/google/longrunning/operations.rb +0 -51
- data/lib/google/cloud/spanner/admin/instance/v1/doc/google/protobuf/any.rb +0 -131
- data/lib/google/cloud/spanner/admin/instance/v1/doc/google/protobuf/empty.rb +0 -29
- data/lib/google/cloud/spanner/admin/instance/v1/doc/google/protobuf/field_mask.rb +0 -222
- data/lib/google/cloud/spanner/admin/instance/v1/doc/google/rpc/status.rb +0 -39
- data/lib/google/cloud/spanner/admin/instance/v1/doc/google/spanner/admin/instance/v1/spanner_instance_admin.rb +0 -341
- data/lib/google/cloud/spanner/admin/instance/v1/doc/google/type/expr.rb +0 -45
- data/lib/google/cloud/spanner/admin/instance/v1/instance_admin_client.rb +0 -972
- data/lib/google/cloud/spanner/admin/instance/v1/instance_admin_client_config.json +0 -76
- data/lib/google/cloud/spanner/v1.rb +0 -16
- data/lib/google/cloud/spanner/v1/credentials.rb +0 -42
- data/lib/google/cloud/spanner/v1/doc/google/protobuf/any.rb +0 -131
- data/lib/google/cloud/spanner/v1/doc/google/protobuf/duration.rb +0 -91
- data/lib/google/cloud/spanner/v1/doc/google/protobuf/empty.rb +0 -29
- data/lib/google/cloud/spanner/v1/doc/google/protobuf/struct.rb +0 -74
- data/lib/google/cloud/spanner/v1/doc/google/protobuf/timestamp.rb +0 -113
- data/lib/google/cloud/spanner/v1/doc/google/rpc/status.rb +0 -39
- data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/keys.rb +0 -150
- data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/mutation.rb +0 -88
- data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/query_plan.rb +0 -121
- data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/result_set.rb +0 -190
- data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/spanner.rb +0 -581
- data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/transaction.rb +0 -432
- data/lib/google/cloud/spanner/v1/doc/google/spanner/v1/type.rb +0 -112
- data/lib/google/cloud/spanner/v1/spanner_client.rb +0 -1509
- data/lib/google/cloud/spanner/v1/spanner_client_config.json +0 -121
- data/lib/google/spanner/admin/database/v1/spanner_database_admin_pb.rb +0 -88
- data/lib/google/spanner/admin/database/v1/spanner_database_admin_services_pb.rb +0 -99
- data/lib/google/spanner/admin/instance/v1/spanner_instance_admin_pb.rb +0 -125
- data/lib/google/spanner/admin/instance/v1/spanner_instance_admin_services_pb.rb +0 -182
- data/lib/google/spanner/v1/keys_pb.rb +0 -34
- data/lib/google/spanner/v1/mutation_pb.rb +0 -39
- data/lib/google/spanner/v1/query_plan_pb.rb +0 -48
- data/lib/google/spanner/v1/result_set_pb.rb +0 -48
- data/lib/google/spanner/v1/spanner_pb.rb +0 -174
- data/lib/google/spanner/v1/spanner_services_pb.rb +0 -188
- data/lib/google/spanner/v1/transaction_pb.rb +0 -56
- data/lib/google/spanner/v1/type_pb.rb +0 -44
|
@@ -1,148 +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 Database Admin API ([Alpha](https://github.com/googleapis/google-cloud-ruby#versioning))
|
|
27
|
-
#
|
|
28
|
-
# [Cloud Spanner Database 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 Database 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 Database 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 Database
|
|
81
|
-
# rubocop:enable LineLength
|
|
82
|
-
|
|
83
|
-
FILE_DIR = File.realdirpath(Pathname.new(__FILE__).join("..").join("database"))
|
|
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 Database Admin API
|
|
93
|
-
#
|
|
94
|
-
# The Cloud Spanner Database Admin API can be used to create, drop, and
|
|
95
|
-
# list databases. It also enables updating the schema of pre-existing
|
|
96
|
-
# databases.
|
|
97
|
-
#
|
|
98
|
-
# @param version [Symbol, String]
|
|
99
|
-
# The major version of the service to be used. By default :v1
|
|
100
|
-
# is used.
|
|
101
|
-
# @overload new(version:, credentials:, scopes:, client_config:, timeout:)
|
|
102
|
-
# @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
|
|
103
|
-
# Provides the means for authenticating requests made by the client. This parameter can
|
|
104
|
-
# be many types.
|
|
105
|
-
# A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
|
|
106
|
-
# authenticating requests made by this client.
|
|
107
|
-
# A `String` will be treated as the path to the keyfile to be used for the construction of
|
|
108
|
-
# credentials for this client.
|
|
109
|
-
# A `Hash` will be treated as the contents of a keyfile to be used for the construction of
|
|
110
|
-
# credentials for this client.
|
|
111
|
-
# A `GRPC::Core::Channel` will be used to make calls through.
|
|
112
|
-
# A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
|
|
113
|
-
# should already be composed with a `GRPC::Core::CallCredentials` object.
|
|
114
|
-
# A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
|
|
115
|
-
# metadata for requests, generally, to give OAuth credentials.
|
|
116
|
-
# @param scopes [Array<String>]
|
|
117
|
-
# The OAuth scopes for this service. This parameter is ignored if
|
|
118
|
-
# an updater_proc is supplied.
|
|
119
|
-
# @param client_config [Hash]
|
|
120
|
-
# A Hash for call options for each method. See
|
|
121
|
-
# Google::Gax#construct_settings for the structure of
|
|
122
|
-
# this data. Falls back to the default config if not specified
|
|
123
|
-
# or the specified config is missing data points.
|
|
124
|
-
# @param timeout [Numeric]
|
|
125
|
-
# The default timeout, in seconds, for calls made through this client.
|
|
126
|
-
# @param metadata [Hash]
|
|
127
|
-
# Default metadata to be sent with each request. This can be overridden on a per call basis.
|
|
128
|
-
# @param exception_transformer [Proc]
|
|
129
|
-
# An optional proc that intercepts any exceptions raised during an API call to inject
|
|
130
|
-
# custom error handling.
|
|
131
|
-
def self.new(*args, version: :v1, **kwargs)
|
|
132
|
-
unless AVAILABLE_VERSIONS.include?(version.to_s.downcase)
|
|
133
|
-
raise "The version: #{version} is not available. The available versions " \
|
|
134
|
-
"are: [#{AVAILABLE_VERSIONS.join(", ")}]"
|
|
135
|
-
end
|
|
136
|
-
|
|
137
|
-
require "#{FILE_DIR}/#{version.to_s.downcase}"
|
|
138
|
-
version_module = Google::Cloud::Spanner::Admin::Database
|
|
139
|
-
.constants
|
|
140
|
-
.select {|sym| sym.to_s.downcase == version.to_s.downcase}
|
|
141
|
-
.first
|
|
142
|
-
Google::Cloud::Spanner::Admin::Database.const_get(version_module).new(*args, **kwargs)
|
|
143
|
-
end
|
|
144
|
-
end
|
|
145
|
-
end
|
|
146
|
-
end
|
|
147
|
-
end
|
|
148
|
-
end
|
|
@@ -1,146 +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/cloud/spanner/admin/database/v1/database_admin_client"
|
|
17
|
-
require "google/spanner/admin/database/v1/spanner_database_admin_pb"
|
|
18
|
-
|
|
19
|
-
module Google
|
|
20
|
-
module Cloud
|
|
21
|
-
module Spanner
|
|
22
|
-
module Admin
|
|
23
|
-
module Database
|
|
24
|
-
# rubocop:disable LineLength
|
|
25
|
-
|
|
26
|
-
##
|
|
27
|
-
# # Ruby Client for Cloud Spanner Database Admin API ([Alpha](https://github.com/googleapis/google-cloud-ruby#versioning))
|
|
28
|
-
#
|
|
29
|
-
# [Cloud Spanner Database Admin API][Product Documentation]:
|
|
30
|
-
#
|
|
31
|
-
# - [Product Documentation][]
|
|
32
|
-
#
|
|
33
|
-
# ## Quick Start
|
|
34
|
-
# In order to use this library, you first need to go through the following
|
|
35
|
-
# steps:
|
|
36
|
-
#
|
|
37
|
-
# 1. [Select or create a Cloud Platform project.](https://console.cloud.google.com/project)
|
|
38
|
-
# 2. [Enable billing for your project.](https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project)
|
|
39
|
-
# 3. [Enable the Cloud Spanner Database Admin API.](https://console.cloud.google.com/apis/library/spanner.googleapis.com)
|
|
40
|
-
# 4. [Setup Authentication.](https://googleapis.dev/ruby/google-cloud-spanner/latest/file.AUTHENTICATION.html)
|
|
41
|
-
#
|
|
42
|
-
# ### Installation
|
|
43
|
-
# ```
|
|
44
|
-
# $ gem install google-cloud-spanner
|
|
45
|
-
# ```
|
|
46
|
-
#
|
|
47
|
-
# ### Next Steps
|
|
48
|
-
# - Read the [Cloud Spanner Database Admin API Product documentation][Product Documentation]
|
|
49
|
-
# to learn more about the product and see How-to Guides.
|
|
50
|
-
# - View this [repository's main README](https://github.com/googleapis/google-cloud-ruby/blob/master/README.md)
|
|
51
|
-
# to see the full list of Cloud APIs that we cover.
|
|
52
|
-
#
|
|
53
|
-
# [Product Documentation]: https://cloud.google.com/spanner
|
|
54
|
-
#
|
|
55
|
-
# ## Enabling Logging
|
|
56
|
-
#
|
|
57
|
-
# To enable logging for this library, set the logger for the underlying [gRPC](https://github.com/grpc/grpc/tree/master/src/ruby) library.
|
|
58
|
-
# 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,
|
|
59
|
-
# or a [`Google::Cloud::Logging::Logger`](https://googleapis.dev/ruby/google-cloud-logging/latest)
|
|
60
|
-
# 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)
|
|
61
|
-
# and the gRPC [spec_helper.rb](https://github.com/grpc/grpc/blob/master/src/ruby/spec/spec_helper.rb) for additional information.
|
|
62
|
-
#
|
|
63
|
-
# Configuring a Ruby stdlib logger:
|
|
64
|
-
#
|
|
65
|
-
# ```ruby
|
|
66
|
-
# require "logger"
|
|
67
|
-
#
|
|
68
|
-
# module MyLogger
|
|
69
|
-
# LOGGER = Logger.new $stderr, level: Logger::WARN
|
|
70
|
-
# def logger
|
|
71
|
-
# LOGGER
|
|
72
|
-
# end
|
|
73
|
-
# end
|
|
74
|
-
#
|
|
75
|
-
# # Define a gRPC module-level logger method before grpc/logconfig.rb loads.
|
|
76
|
-
# module GRPC
|
|
77
|
-
# extend MyLogger
|
|
78
|
-
# end
|
|
79
|
-
# ```
|
|
80
|
-
#
|
|
81
|
-
module V1
|
|
82
|
-
# rubocop:enable LineLength
|
|
83
|
-
|
|
84
|
-
##
|
|
85
|
-
# Cloud Spanner Database Admin API
|
|
86
|
-
#
|
|
87
|
-
# The Cloud Spanner Database Admin API can be used to create, drop, and
|
|
88
|
-
# list databases. It also enables updating the schema of pre-existing
|
|
89
|
-
# databases.
|
|
90
|
-
#
|
|
91
|
-
# @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
|
|
92
|
-
# Provides the means for authenticating requests made by the client. This parameter can
|
|
93
|
-
# be many types.
|
|
94
|
-
# A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
|
|
95
|
-
# authenticating requests made by this client.
|
|
96
|
-
# A `String` will be treated as the path to the keyfile to be used for the construction of
|
|
97
|
-
# credentials for this client.
|
|
98
|
-
# A `Hash` will be treated as the contents of a keyfile to be used for the construction of
|
|
99
|
-
# credentials for this client.
|
|
100
|
-
# A `GRPC::Core::Channel` will be used to make calls through.
|
|
101
|
-
# A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
|
|
102
|
-
# should already be composed with a `GRPC::Core::CallCredentials` object.
|
|
103
|
-
# A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
|
|
104
|
-
# metadata for requests, generally, to give OAuth credentials.
|
|
105
|
-
# @param scopes [Array<String>]
|
|
106
|
-
# The OAuth scopes for this service. This parameter is ignored if
|
|
107
|
-
# an updater_proc is supplied.
|
|
108
|
-
# @param client_config [Hash]
|
|
109
|
-
# A Hash for call options for each method. See
|
|
110
|
-
# Google::Gax#construct_settings for the structure of
|
|
111
|
-
# this data. Falls back to the default config if not specified
|
|
112
|
-
# or the specified config is missing data points.
|
|
113
|
-
# @param timeout [Numeric]
|
|
114
|
-
# The default timeout, in seconds, for calls made through this client.
|
|
115
|
-
# @param metadata [Hash]
|
|
116
|
-
# Default metadata to be sent with each request. This can be overridden on a per call basis.
|
|
117
|
-
# @param exception_transformer [Proc]
|
|
118
|
-
# An optional proc that intercepts any exceptions raised during an API call to inject
|
|
119
|
-
# custom error handling.
|
|
120
|
-
def self.new \
|
|
121
|
-
credentials: nil,
|
|
122
|
-
scopes: nil,
|
|
123
|
-
client_config: nil,
|
|
124
|
-
timeout: nil,
|
|
125
|
-
metadata: nil,
|
|
126
|
-
exception_transformer: nil,
|
|
127
|
-
lib_name: nil,
|
|
128
|
-
lib_version: nil
|
|
129
|
-
kwargs = {
|
|
130
|
-
credentials: credentials,
|
|
131
|
-
scopes: scopes,
|
|
132
|
-
client_config: client_config,
|
|
133
|
-
timeout: timeout,
|
|
134
|
-
metadata: metadata,
|
|
135
|
-
exception_transformer: exception_transformer,
|
|
136
|
-
lib_name: lib_name,
|
|
137
|
-
lib_version: lib_version
|
|
138
|
-
}.select { |_, v| v != nil }
|
|
139
|
-
Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdminClient.new(**kwargs)
|
|
140
|
-
end
|
|
141
|
-
end
|
|
142
|
-
end
|
|
143
|
-
end
|
|
144
|
-
end
|
|
145
|
-
end
|
|
146
|
-
end
|
|
@@ -1,46 +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 "googleauth"
|
|
17
|
-
|
|
18
|
-
module Google
|
|
19
|
-
module Cloud
|
|
20
|
-
module Spanner
|
|
21
|
-
module Admin
|
|
22
|
-
module Database
|
|
23
|
-
module V1
|
|
24
|
-
class Credentials < Google::Auth::Credentials
|
|
25
|
-
SCOPE = [
|
|
26
|
-
"https://www.googleapis.com/auth/cloud-platform",
|
|
27
|
-
"https://www.googleapis.com/auth/spanner.admin"
|
|
28
|
-
].freeze
|
|
29
|
-
PATH_ENV_VARS = %w(SPANNER_ADMIN_DATABASE_CREDENTIALS
|
|
30
|
-
SPANNER_ADMIN_DATABASE_KEYFILE
|
|
31
|
-
GOOGLE_CLOUD_CREDENTIALS
|
|
32
|
-
GOOGLE_CLOUD_KEYFILE
|
|
33
|
-
GCLOUD_KEYFILE)
|
|
34
|
-
JSON_ENV_VARS = %w(SPANNER_ADMIN_DATABASE_CREDENTIALS_JSON
|
|
35
|
-
SPANNER_ADMIN_DATABASE_KEYFILE_JSON
|
|
36
|
-
GOOGLE_CLOUD_CREDENTIALS_JSON
|
|
37
|
-
GOOGLE_CLOUD_KEYFILE_JSON
|
|
38
|
-
GCLOUD_KEYFILE_JSON)
|
|
39
|
-
DEFAULT_PATHS = ["~/.config/gcloud/application_default_credentials.json"]
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
end
|
|
@@ -1,791 +0,0 @@
|
|
|
1
|
-
# Copyright 2020 Google LLC
|
|
2
|
-
#
|
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
# you may not use this file except in compliance with the License.
|
|
5
|
-
# You may obtain a copy of the License at
|
|
6
|
-
#
|
|
7
|
-
# https://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
#
|
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
# See the License for the specific language governing permissions and
|
|
13
|
-
# limitations under the License.
|
|
14
|
-
#
|
|
15
|
-
# EDITING INSTRUCTIONS
|
|
16
|
-
# This file was generated from the file
|
|
17
|
-
# https://github.com/googleapis/googleapis/blob/master/google/spanner/admin/database/v1/spanner_database_admin.proto,
|
|
18
|
-
# and updates to that file get reflected here through a refresh process.
|
|
19
|
-
# For the short term, the refresh process will only be runnable by Google
|
|
20
|
-
# engineers.
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
require "json"
|
|
24
|
-
require "pathname"
|
|
25
|
-
|
|
26
|
-
require "google/gax"
|
|
27
|
-
require "google/gax/operation"
|
|
28
|
-
require "google/longrunning/operations_client"
|
|
29
|
-
|
|
30
|
-
require "google/spanner/admin/database/v1/spanner_database_admin_pb"
|
|
31
|
-
require "google/cloud/spanner/admin/database/v1/credentials"
|
|
32
|
-
require "google/cloud/spanner/version"
|
|
33
|
-
|
|
34
|
-
module Google
|
|
35
|
-
module Cloud
|
|
36
|
-
module Spanner
|
|
37
|
-
module Admin
|
|
38
|
-
module Database
|
|
39
|
-
module V1
|
|
40
|
-
# Cloud Spanner Database Admin API
|
|
41
|
-
#
|
|
42
|
-
# The Cloud Spanner Database Admin API can be used to create, drop, and
|
|
43
|
-
# list databases. It also enables updating the schema of pre-existing
|
|
44
|
-
# databases.
|
|
45
|
-
#
|
|
46
|
-
# @!attribute [r] database_admin_stub
|
|
47
|
-
# @return [Google::Spanner::Admin::Database::V1::DatabaseAdmin::Stub]
|
|
48
|
-
class DatabaseAdminClient
|
|
49
|
-
# @private
|
|
50
|
-
attr_reader :database_admin_stub
|
|
51
|
-
|
|
52
|
-
# The default address of the service.
|
|
53
|
-
SERVICE_ADDRESS = "spanner.googleapis.com".freeze
|
|
54
|
-
|
|
55
|
-
# The default port of the service.
|
|
56
|
-
DEFAULT_SERVICE_PORT = 443
|
|
57
|
-
|
|
58
|
-
# The default set of gRPC interceptors.
|
|
59
|
-
GRPC_INTERCEPTORS = []
|
|
60
|
-
|
|
61
|
-
DEFAULT_TIMEOUT = 30
|
|
62
|
-
|
|
63
|
-
PAGE_DESCRIPTORS = {
|
|
64
|
-
"list_databases" => Google::Gax::PageDescriptor.new(
|
|
65
|
-
"page_token",
|
|
66
|
-
"next_page_token",
|
|
67
|
-
"databases")
|
|
68
|
-
}.freeze
|
|
69
|
-
|
|
70
|
-
private_constant :PAGE_DESCRIPTORS
|
|
71
|
-
|
|
72
|
-
# The scopes needed to make gRPC calls to all of the methods defined in
|
|
73
|
-
# this service.
|
|
74
|
-
ALL_SCOPES = [
|
|
75
|
-
"https://www.googleapis.com/auth/cloud-platform",
|
|
76
|
-
"https://www.googleapis.com/auth/spanner.admin"
|
|
77
|
-
].freeze
|
|
78
|
-
|
|
79
|
-
# @private
|
|
80
|
-
class OperationsClient < Google::Longrunning::OperationsClient
|
|
81
|
-
self::SERVICE_ADDRESS = DatabaseAdminClient::SERVICE_ADDRESS
|
|
82
|
-
self::GRPC_INTERCEPTORS = DatabaseAdminClient::GRPC_INTERCEPTORS
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
DATABASE_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
|
|
86
|
-
"projects/{project}/instances/{instance}/databases/{database}"
|
|
87
|
-
)
|
|
88
|
-
|
|
89
|
-
private_constant :DATABASE_PATH_TEMPLATE
|
|
90
|
-
|
|
91
|
-
INSTANCE_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
|
|
92
|
-
"projects/{project}/instances/{instance}"
|
|
93
|
-
)
|
|
94
|
-
|
|
95
|
-
private_constant :INSTANCE_PATH_TEMPLATE
|
|
96
|
-
|
|
97
|
-
# Returns a fully-qualified database resource name string.
|
|
98
|
-
# @param project [String]
|
|
99
|
-
# @param instance [String]
|
|
100
|
-
# @param database [String]
|
|
101
|
-
# @return [String]
|
|
102
|
-
def self.database_path project, instance, database
|
|
103
|
-
DATABASE_PATH_TEMPLATE.render(
|
|
104
|
-
:"project" => project,
|
|
105
|
-
:"instance" => instance,
|
|
106
|
-
:"database" => database
|
|
107
|
-
)
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
# Returns a fully-qualified instance resource name string.
|
|
111
|
-
# @param project [String]
|
|
112
|
-
# @param instance [String]
|
|
113
|
-
# @return [String]
|
|
114
|
-
def self.instance_path project, instance
|
|
115
|
-
INSTANCE_PATH_TEMPLATE.render(
|
|
116
|
-
:"project" => project,
|
|
117
|
-
:"instance" => instance
|
|
118
|
-
)
|
|
119
|
-
end
|
|
120
|
-
|
|
121
|
-
# @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
|
|
122
|
-
# Provides the means for authenticating requests made by the client. This parameter can
|
|
123
|
-
# be many types.
|
|
124
|
-
# A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
|
|
125
|
-
# authenticating requests made by this client.
|
|
126
|
-
# A `String` will be treated as the path to the keyfile to be used for the construction of
|
|
127
|
-
# credentials for this client.
|
|
128
|
-
# A `Hash` will be treated as the contents of a keyfile to be used for the construction of
|
|
129
|
-
# credentials for this client.
|
|
130
|
-
# A `GRPC::Core::Channel` will be used to make calls through.
|
|
131
|
-
# A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
|
|
132
|
-
# should already be composed with a `GRPC::Core::CallCredentials` object.
|
|
133
|
-
# A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
|
|
134
|
-
# metadata for requests, generally, to give OAuth credentials.
|
|
135
|
-
# @param scopes [Array<String>]
|
|
136
|
-
# The OAuth scopes for this service. This parameter is ignored if
|
|
137
|
-
# an updater_proc is supplied.
|
|
138
|
-
# @param client_config [Hash]
|
|
139
|
-
# A Hash for call options for each method. See
|
|
140
|
-
# Google::Gax#construct_settings for the structure of
|
|
141
|
-
# this data. Falls back to the default config if not specified
|
|
142
|
-
# or the specified config is missing data points.
|
|
143
|
-
# @param timeout [Numeric]
|
|
144
|
-
# The default timeout, in seconds, for calls made through this client.
|
|
145
|
-
# @param metadata [Hash]
|
|
146
|
-
# Default metadata to be sent with each request. This can be overridden on a per call basis.
|
|
147
|
-
# @param service_address [String]
|
|
148
|
-
# Override for the service hostname, or `nil` to leave as the default.
|
|
149
|
-
# @param service_port [Integer]
|
|
150
|
-
# Override for the service port, or `nil` to leave as the default.
|
|
151
|
-
# @param exception_transformer [Proc]
|
|
152
|
-
# An optional proc that intercepts any exceptions raised during an API call to inject
|
|
153
|
-
# custom error handling.
|
|
154
|
-
def initialize \
|
|
155
|
-
credentials: nil,
|
|
156
|
-
scopes: ALL_SCOPES,
|
|
157
|
-
client_config: {},
|
|
158
|
-
timeout: DEFAULT_TIMEOUT,
|
|
159
|
-
metadata: nil,
|
|
160
|
-
service_address: nil,
|
|
161
|
-
service_port: nil,
|
|
162
|
-
exception_transformer: nil,
|
|
163
|
-
lib_name: nil,
|
|
164
|
-
lib_version: ""
|
|
165
|
-
# These require statements are intentionally placed here to initialize
|
|
166
|
-
# the gRPC module only when it's required.
|
|
167
|
-
# See https://github.com/googleapis/toolkit/issues/446
|
|
168
|
-
require "google/gax/grpc"
|
|
169
|
-
require "google/spanner/admin/database/v1/spanner_database_admin_services_pb"
|
|
170
|
-
|
|
171
|
-
credentials ||= Google::Cloud::Spanner::Admin::Database::V1::Credentials.default
|
|
172
|
-
|
|
173
|
-
@operations_client = OperationsClient.new(
|
|
174
|
-
credentials: credentials,
|
|
175
|
-
scopes: scopes,
|
|
176
|
-
client_config: client_config,
|
|
177
|
-
timeout: timeout,
|
|
178
|
-
service_address: service_address,
|
|
179
|
-
service_port: service_port,
|
|
180
|
-
lib_name: lib_name,
|
|
181
|
-
lib_version: lib_version,
|
|
182
|
-
metadata: metadata,
|
|
183
|
-
)
|
|
184
|
-
|
|
185
|
-
if credentials.is_a?(String) || credentials.is_a?(Hash)
|
|
186
|
-
updater_proc = Google::Cloud::Spanner::Admin::Database::V1::Credentials.new(credentials).updater_proc
|
|
187
|
-
end
|
|
188
|
-
if credentials.is_a?(GRPC::Core::Channel)
|
|
189
|
-
channel = credentials
|
|
190
|
-
end
|
|
191
|
-
if credentials.is_a?(GRPC::Core::ChannelCredentials)
|
|
192
|
-
chan_creds = credentials
|
|
193
|
-
end
|
|
194
|
-
if credentials.is_a?(Proc)
|
|
195
|
-
updater_proc = credentials
|
|
196
|
-
end
|
|
197
|
-
if credentials.is_a?(Google::Auth::Credentials)
|
|
198
|
-
updater_proc = credentials.updater_proc
|
|
199
|
-
end
|
|
200
|
-
|
|
201
|
-
package_version = Google::Cloud::Spanner::VERSION
|
|
202
|
-
|
|
203
|
-
google_api_client = "gl-ruby/#{RUBY_VERSION}"
|
|
204
|
-
google_api_client << " #{lib_name}/#{lib_version}" if lib_name
|
|
205
|
-
google_api_client << " gapic/#{package_version} gax/#{Google::Gax::VERSION}"
|
|
206
|
-
google_api_client << " grpc/#{GRPC::VERSION}"
|
|
207
|
-
google_api_client.freeze
|
|
208
|
-
|
|
209
|
-
headers = { :"x-goog-api-client" => google_api_client }
|
|
210
|
-
headers.merge!(metadata) unless metadata.nil?
|
|
211
|
-
client_config_file = Pathname.new(__dir__).join(
|
|
212
|
-
"database_admin_client_config.json"
|
|
213
|
-
)
|
|
214
|
-
defaults = client_config_file.open do |f|
|
|
215
|
-
Google::Gax.construct_settings(
|
|
216
|
-
"google.spanner.admin.database.v1.DatabaseAdmin",
|
|
217
|
-
JSON.parse(f.read),
|
|
218
|
-
client_config,
|
|
219
|
-
Google::Gax::Grpc::STATUS_CODE_NAMES,
|
|
220
|
-
timeout,
|
|
221
|
-
page_descriptors: PAGE_DESCRIPTORS,
|
|
222
|
-
errors: Google::Gax::Grpc::API_ERRORS,
|
|
223
|
-
metadata: headers
|
|
224
|
-
)
|
|
225
|
-
end
|
|
226
|
-
|
|
227
|
-
# Allow overriding the service path/port in subclasses.
|
|
228
|
-
service_path = service_address || self.class::SERVICE_ADDRESS
|
|
229
|
-
port = service_port || self.class::DEFAULT_SERVICE_PORT
|
|
230
|
-
interceptors = self.class::GRPC_INTERCEPTORS
|
|
231
|
-
@database_admin_stub = Google::Gax::Grpc.create_stub(
|
|
232
|
-
service_path,
|
|
233
|
-
port,
|
|
234
|
-
chan_creds: chan_creds,
|
|
235
|
-
channel: channel,
|
|
236
|
-
updater_proc: updater_proc,
|
|
237
|
-
scopes: scopes,
|
|
238
|
-
interceptors: interceptors,
|
|
239
|
-
&Google::Spanner::Admin::Database::V1::DatabaseAdmin::Stub.method(:new)
|
|
240
|
-
)
|
|
241
|
-
|
|
242
|
-
@list_databases = Google::Gax.create_api_call(
|
|
243
|
-
@database_admin_stub.method(:list_databases),
|
|
244
|
-
defaults["list_databases"],
|
|
245
|
-
exception_transformer: exception_transformer,
|
|
246
|
-
params_extractor: proc do |request|
|
|
247
|
-
{'parent' => request.parent}
|
|
248
|
-
end
|
|
249
|
-
)
|
|
250
|
-
@create_database = Google::Gax.create_api_call(
|
|
251
|
-
@database_admin_stub.method(:create_database),
|
|
252
|
-
defaults["create_database"],
|
|
253
|
-
exception_transformer: exception_transformer,
|
|
254
|
-
params_extractor: proc do |request|
|
|
255
|
-
{'parent' => request.parent}
|
|
256
|
-
end
|
|
257
|
-
)
|
|
258
|
-
@get_database = Google::Gax.create_api_call(
|
|
259
|
-
@database_admin_stub.method(:get_database),
|
|
260
|
-
defaults["get_database"],
|
|
261
|
-
exception_transformer: exception_transformer,
|
|
262
|
-
params_extractor: proc do |request|
|
|
263
|
-
{'name' => request.name}
|
|
264
|
-
end
|
|
265
|
-
)
|
|
266
|
-
@update_database_ddl = Google::Gax.create_api_call(
|
|
267
|
-
@database_admin_stub.method(:update_database_ddl),
|
|
268
|
-
defaults["update_database_ddl"],
|
|
269
|
-
exception_transformer: exception_transformer,
|
|
270
|
-
params_extractor: proc do |request|
|
|
271
|
-
{'database' => request.database}
|
|
272
|
-
end
|
|
273
|
-
)
|
|
274
|
-
@drop_database = Google::Gax.create_api_call(
|
|
275
|
-
@database_admin_stub.method(:drop_database),
|
|
276
|
-
defaults["drop_database"],
|
|
277
|
-
exception_transformer: exception_transformer,
|
|
278
|
-
params_extractor: proc do |request|
|
|
279
|
-
{'database' => request.database}
|
|
280
|
-
end
|
|
281
|
-
)
|
|
282
|
-
@get_database_ddl = Google::Gax.create_api_call(
|
|
283
|
-
@database_admin_stub.method(:get_database_ddl),
|
|
284
|
-
defaults["get_database_ddl"],
|
|
285
|
-
exception_transformer: exception_transformer,
|
|
286
|
-
params_extractor: proc do |request|
|
|
287
|
-
{'database' => request.database}
|
|
288
|
-
end
|
|
289
|
-
)
|
|
290
|
-
@set_iam_policy = Google::Gax.create_api_call(
|
|
291
|
-
@database_admin_stub.method(:set_iam_policy),
|
|
292
|
-
defaults["set_iam_policy"],
|
|
293
|
-
exception_transformer: exception_transformer,
|
|
294
|
-
params_extractor: proc do |request|
|
|
295
|
-
{'resource' => request.resource}
|
|
296
|
-
end
|
|
297
|
-
)
|
|
298
|
-
@get_iam_policy = Google::Gax.create_api_call(
|
|
299
|
-
@database_admin_stub.method(:get_iam_policy),
|
|
300
|
-
defaults["get_iam_policy"],
|
|
301
|
-
exception_transformer: exception_transformer,
|
|
302
|
-
params_extractor: proc do |request|
|
|
303
|
-
{'resource' => request.resource}
|
|
304
|
-
end
|
|
305
|
-
)
|
|
306
|
-
@test_iam_permissions = Google::Gax.create_api_call(
|
|
307
|
-
@database_admin_stub.method(:test_iam_permissions),
|
|
308
|
-
defaults["test_iam_permissions"],
|
|
309
|
-
exception_transformer: exception_transformer,
|
|
310
|
-
params_extractor: proc do |request|
|
|
311
|
-
{'resource' => request.resource}
|
|
312
|
-
end
|
|
313
|
-
)
|
|
314
|
-
end
|
|
315
|
-
|
|
316
|
-
# Service calls
|
|
317
|
-
|
|
318
|
-
# Lists Cloud Spanner databases.
|
|
319
|
-
#
|
|
320
|
-
# @param parent [String]
|
|
321
|
-
# Required. The instance whose databases should be listed.
|
|
322
|
-
# Values are of the form `projects/<project>/instances/<instance>`.
|
|
323
|
-
# @param page_size [Integer]
|
|
324
|
-
# The maximum number of resources contained in the underlying API
|
|
325
|
-
# response. If page streaming is performed per-resource, this
|
|
326
|
-
# parameter does not affect the return value. If page streaming is
|
|
327
|
-
# performed per-page, this determines the maximum number of
|
|
328
|
-
# resources in a page.
|
|
329
|
-
# @param options [Google::Gax::CallOptions]
|
|
330
|
-
# Overrides the default settings for this call, e.g, timeout,
|
|
331
|
-
# retries, etc.
|
|
332
|
-
# @yield [result, operation] Access the result along with the RPC operation
|
|
333
|
-
# @yieldparam result [Google::Gax::PagedEnumerable<Google::Spanner::Admin::Database::V1::Database>]
|
|
334
|
-
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
|
335
|
-
# @return [Google::Gax::PagedEnumerable<Google::Spanner::Admin::Database::V1::Database>]
|
|
336
|
-
# An enumerable of Google::Spanner::Admin::Database::V1::Database instances.
|
|
337
|
-
# See Google::Gax::PagedEnumerable documentation for other
|
|
338
|
-
# operations such as per-page iteration or access to the response
|
|
339
|
-
# object.
|
|
340
|
-
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
|
341
|
-
# @example
|
|
342
|
-
# require "google/cloud/spanner/admin/database"
|
|
343
|
-
#
|
|
344
|
-
# database_admin_client = Google::Cloud::Spanner::Admin::Database.new(version: :v1)
|
|
345
|
-
# formatted_parent = Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdminClient.instance_path("[PROJECT]", "[INSTANCE]")
|
|
346
|
-
#
|
|
347
|
-
# # Iterate over all results.
|
|
348
|
-
# database_admin_client.list_databases(formatted_parent).each do |element|
|
|
349
|
-
# # Process element.
|
|
350
|
-
# end
|
|
351
|
-
#
|
|
352
|
-
# # Or iterate over results one page at a time.
|
|
353
|
-
# database_admin_client.list_databases(formatted_parent).each_page do |page|
|
|
354
|
-
# # Process each page at a time.
|
|
355
|
-
# page.each do |element|
|
|
356
|
-
# # Process element.
|
|
357
|
-
# end
|
|
358
|
-
# end
|
|
359
|
-
|
|
360
|
-
def list_databases \
|
|
361
|
-
parent,
|
|
362
|
-
page_size: nil,
|
|
363
|
-
options: nil,
|
|
364
|
-
&block
|
|
365
|
-
req = {
|
|
366
|
-
parent: parent,
|
|
367
|
-
page_size: page_size
|
|
368
|
-
}.delete_if { |_, v| v.nil? }
|
|
369
|
-
req = Google::Gax::to_proto(req, Google::Spanner::Admin::Database::V1::ListDatabasesRequest)
|
|
370
|
-
@list_databases.call(req, options, &block)
|
|
371
|
-
end
|
|
372
|
-
|
|
373
|
-
# Creates a new Cloud Spanner database and starts to prepare it for serving.
|
|
374
|
-
# The returned {Google::Longrunning::Operation long-running operation} will
|
|
375
|
-
# have a name of the format `<database_name>/operations/<operation_id>` and
|
|
376
|
-
# can be used to track preparation of the database. The
|
|
377
|
-
# {Google::Longrunning::Operation#metadata metadata} field type is
|
|
378
|
-
# {Google::Spanner::Admin::Database::V1::CreateDatabaseMetadata CreateDatabaseMetadata}.
|
|
379
|
-
# The {Google::Longrunning::Operation#response response} field type is
|
|
380
|
-
# {Google::Spanner::Admin::Database::V1::Database Database}, if successful.
|
|
381
|
-
#
|
|
382
|
-
# @param parent [String]
|
|
383
|
-
# Required. The name of the instance that will serve the new database.
|
|
384
|
-
# Values are of the form `projects/<project>/instances/<instance>`.
|
|
385
|
-
# @param create_statement [String]
|
|
386
|
-
# Required. A `CREATE DATABASE` statement, which specifies the ID of the
|
|
387
|
-
# new database. The database ID must conform to the regular expression
|
|
388
|
-
# `[a-z][a-z0-9_\-]*[a-z0-9]` and be between 2 and 30 characters in length.
|
|
389
|
-
# If the database ID is a reserved word or if it contains a hyphen, the
|
|
390
|
-
# database ID must be enclosed in backticks (`` ` ``).
|
|
391
|
-
# @param extra_statements [Array<String>]
|
|
392
|
-
# An optional list of DDL statements to run inside the newly created
|
|
393
|
-
# database. Statements can create tables, indexes, etc. These
|
|
394
|
-
# statements execute atomically with the creation of the database:
|
|
395
|
-
# if there is an error in any statement, the database is not created.
|
|
396
|
-
# @param options [Google::Gax::CallOptions]
|
|
397
|
-
# Overrides the default settings for this call, e.g, timeout,
|
|
398
|
-
# retries, etc.
|
|
399
|
-
# @return [Google::Gax::Operation]
|
|
400
|
-
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
|
401
|
-
# @example
|
|
402
|
-
# require "google/cloud/spanner/admin/database"
|
|
403
|
-
#
|
|
404
|
-
# database_admin_client = Google::Cloud::Spanner::Admin::Database.new(version: :v1)
|
|
405
|
-
# formatted_parent = Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdminClient.instance_path("[PROJECT]", "[INSTANCE]")
|
|
406
|
-
#
|
|
407
|
-
# # TODO: Initialize `create_statement`:
|
|
408
|
-
# create_statement = ''
|
|
409
|
-
#
|
|
410
|
-
# # Register a callback during the method call.
|
|
411
|
-
# operation = database_admin_client.create_database(formatted_parent, create_statement) do |op|
|
|
412
|
-
# raise op.results.message if op.error?
|
|
413
|
-
# op_results = op.results
|
|
414
|
-
# # Process the results.
|
|
415
|
-
#
|
|
416
|
-
# metadata = op.metadata
|
|
417
|
-
# # Process the metadata.
|
|
418
|
-
# end
|
|
419
|
-
#
|
|
420
|
-
# # Or use the return value to register a callback.
|
|
421
|
-
# operation.on_done do |op|
|
|
422
|
-
# raise op.results.message if op.error?
|
|
423
|
-
# op_results = op.results
|
|
424
|
-
# # Process the results.
|
|
425
|
-
#
|
|
426
|
-
# metadata = op.metadata
|
|
427
|
-
# # Process the metadata.
|
|
428
|
-
# end
|
|
429
|
-
#
|
|
430
|
-
# # Manually reload the operation.
|
|
431
|
-
# operation.reload!
|
|
432
|
-
#
|
|
433
|
-
# # Or block until the operation completes, triggering callbacks on
|
|
434
|
-
# # completion.
|
|
435
|
-
# operation.wait_until_done!
|
|
436
|
-
|
|
437
|
-
def create_database \
|
|
438
|
-
parent,
|
|
439
|
-
create_statement,
|
|
440
|
-
extra_statements: nil,
|
|
441
|
-
options: nil
|
|
442
|
-
req = {
|
|
443
|
-
parent: parent,
|
|
444
|
-
create_statement: create_statement,
|
|
445
|
-
extra_statements: extra_statements
|
|
446
|
-
}.delete_if { |_, v| v.nil? }
|
|
447
|
-
req = Google::Gax::to_proto(req, Google::Spanner::Admin::Database::V1::CreateDatabaseRequest)
|
|
448
|
-
operation = Google::Gax::Operation.new(
|
|
449
|
-
@create_database.call(req, options),
|
|
450
|
-
@operations_client,
|
|
451
|
-
Google::Spanner::Admin::Database::V1::Database,
|
|
452
|
-
Google::Spanner::Admin::Database::V1::CreateDatabaseMetadata,
|
|
453
|
-
call_options: options
|
|
454
|
-
)
|
|
455
|
-
operation.on_done { |operation| yield(operation) } if block_given?
|
|
456
|
-
operation
|
|
457
|
-
end
|
|
458
|
-
|
|
459
|
-
# Gets the state of a Cloud Spanner database.
|
|
460
|
-
#
|
|
461
|
-
# @param name [String]
|
|
462
|
-
# Required. The name of the requested database. Values are of the form
|
|
463
|
-
# `projects/<project>/instances/<instance>/databases/<database>`.
|
|
464
|
-
# @param options [Google::Gax::CallOptions]
|
|
465
|
-
# Overrides the default settings for this call, e.g, timeout,
|
|
466
|
-
# retries, etc.
|
|
467
|
-
# @yield [result, operation] Access the result along with the RPC operation
|
|
468
|
-
# @yieldparam result [Google::Spanner::Admin::Database::V1::Database]
|
|
469
|
-
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
|
470
|
-
# @return [Google::Spanner::Admin::Database::V1::Database]
|
|
471
|
-
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
|
472
|
-
# @example
|
|
473
|
-
# require "google/cloud/spanner/admin/database"
|
|
474
|
-
#
|
|
475
|
-
# database_admin_client = Google::Cloud::Spanner::Admin::Database.new(version: :v1)
|
|
476
|
-
# formatted_name = Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdminClient.database_path("[PROJECT]", "[INSTANCE]", "[DATABASE]")
|
|
477
|
-
# response = database_admin_client.get_database(formatted_name)
|
|
478
|
-
|
|
479
|
-
def get_database \
|
|
480
|
-
name,
|
|
481
|
-
options: nil,
|
|
482
|
-
&block
|
|
483
|
-
req = {
|
|
484
|
-
name: name
|
|
485
|
-
}.delete_if { |_, v| v.nil? }
|
|
486
|
-
req = Google::Gax::to_proto(req, Google::Spanner::Admin::Database::V1::GetDatabaseRequest)
|
|
487
|
-
@get_database.call(req, options, &block)
|
|
488
|
-
end
|
|
489
|
-
|
|
490
|
-
# Updates the schema of a Cloud Spanner database by
|
|
491
|
-
# creating/altering/dropping tables, columns, indexes, etc. The returned
|
|
492
|
-
# {Google::Longrunning::Operation long-running operation} will have a name of
|
|
493
|
-
# the format `<database_name>/operations/<operation_id>` and can be used to
|
|
494
|
-
# track execution of the schema change(s). The
|
|
495
|
-
# {Google::Longrunning::Operation#metadata metadata} field type is
|
|
496
|
-
# {Google::Spanner::Admin::Database::V1::UpdateDatabaseDdlMetadata UpdateDatabaseDdlMetadata}.
|
|
497
|
-
# The operation has no response.
|
|
498
|
-
#
|
|
499
|
-
# @param database [String]
|
|
500
|
-
# Required. The database to update.
|
|
501
|
-
# @param statements [Array<String>]
|
|
502
|
-
# Required. DDL statements to be applied to the database.
|
|
503
|
-
# @param operation_id [String]
|
|
504
|
-
# If empty, the new update request is assigned an
|
|
505
|
-
# automatically-generated operation ID. Otherwise, `operation_id`
|
|
506
|
-
# is used to construct the name of the resulting
|
|
507
|
-
# {Google::Longrunning::Operation Operation}.
|
|
508
|
-
#
|
|
509
|
-
# Specifying an explicit operation ID simplifies determining
|
|
510
|
-
# whether the statements were executed in the event that the
|
|
511
|
-
# {Google::Spanner::Admin::Database::V1::DatabaseAdmin::UpdateDatabaseDdl UpdateDatabaseDdl}
|
|
512
|
-
# call is replayed, or the return value is otherwise lost: the
|
|
513
|
-
# {Google::Spanner::Admin::Database::V1::UpdateDatabaseDdlRequest#database database}
|
|
514
|
-
# and `operation_id` fields can be combined to form the
|
|
515
|
-
# {Google::Longrunning::Operation#name name} of the resulting
|
|
516
|
-
# {Google::Longrunning::Operation longrunning::Operation}:
|
|
517
|
-
# `<database>/operations/<operation_id>`.
|
|
518
|
-
#
|
|
519
|
-
# `operation_id` should be unique within the database, and must be
|
|
520
|
-
# a valid identifier: `[a-z][a-z0-9_]*`. Note that
|
|
521
|
-
# automatically-generated operation IDs always begin with an
|
|
522
|
-
# underscore. If the named operation already exists,
|
|
523
|
-
# {Google::Spanner::Admin::Database::V1::DatabaseAdmin::UpdateDatabaseDdl UpdateDatabaseDdl}
|
|
524
|
-
# returns `ALREADY_EXISTS`.
|
|
525
|
-
# @param options [Google::Gax::CallOptions]
|
|
526
|
-
# Overrides the default settings for this call, e.g, timeout,
|
|
527
|
-
# retries, etc.
|
|
528
|
-
# @return [Google::Gax::Operation]
|
|
529
|
-
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
|
530
|
-
# @example
|
|
531
|
-
# require "google/cloud/spanner/admin/database"
|
|
532
|
-
#
|
|
533
|
-
# database_admin_client = Google::Cloud::Spanner::Admin::Database.new(version: :v1)
|
|
534
|
-
# formatted_database = Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdminClient.database_path("[PROJECT]", "[INSTANCE]", "[DATABASE]")
|
|
535
|
-
#
|
|
536
|
-
# # TODO: Initialize `statements`:
|
|
537
|
-
# statements = []
|
|
538
|
-
#
|
|
539
|
-
# # Register a callback during the method call.
|
|
540
|
-
# operation = database_admin_client.update_database_ddl(formatted_database, statements) do |op|
|
|
541
|
-
# raise op.results.message if op.error?
|
|
542
|
-
# op_results = op.results
|
|
543
|
-
# # Process the results.
|
|
544
|
-
#
|
|
545
|
-
# metadata = op.metadata
|
|
546
|
-
# # Process the metadata.
|
|
547
|
-
# end
|
|
548
|
-
#
|
|
549
|
-
# # Or use the return value to register a callback.
|
|
550
|
-
# operation.on_done 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
|
-
# # Manually reload the operation.
|
|
560
|
-
# operation.reload!
|
|
561
|
-
#
|
|
562
|
-
# # Or block until the operation completes, triggering callbacks on
|
|
563
|
-
# # completion.
|
|
564
|
-
# operation.wait_until_done!
|
|
565
|
-
|
|
566
|
-
def update_database_ddl \
|
|
567
|
-
database,
|
|
568
|
-
statements,
|
|
569
|
-
operation_id: nil,
|
|
570
|
-
options: nil
|
|
571
|
-
req = {
|
|
572
|
-
database: database,
|
|
573
|
-
statements: statements,
|
|
574
|
-
operation_id: operation_id
|
|
575
|
-
}.delete_if { |_, v| v.nil? }
|
|
576
|
-
req = Google::Gax::to_proto(req, Google::Spanner::Admin::Database::V1::UpdateDatabaseDdlRequest)
|
|
577
|
-
operation = Google::Gax::Operation.new(
|
|
578
|
-
@update_database_ddl.call(req, options),
|
|
579
|
-
@operations_client,
|
|
580
|
-
Google::Protobuf::Empty,
|
|
581
|
-
Google::Spanner::Admin::Database::V1::UpdateDatabaseDdlMetadata,
|
|
582
|
-
call_options: options
|
|
583
|
-
)
|
|
584
|
-
operation.on_done { |operation| yield(operation) } if block_given?
|
|
585
|
-
operation
|
|
586
|
-
end
|
|
587
|
-
|
|
588
|
-
# Drops (aka deletes) a Cloud Spanner database.
|
|
589
|
-
#
|
|
590
|
-
# @param database [String]
|
|
591
|
-
# Required. The database to be dropped.
|
|
592
|
-
# @param options [Google::Gax::CallOptions]
|
|
593
|
-
# Overrides the default settings for this call, e.g, timeout,
|
|
594
|
-
# retries, etc.
|
|
595
|
-
# @yield [result, operation] Access the result along with the RPC operation
|
|
596
|
-
# @yieldparam result []
|
|
597
|
-
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
|
598
|
-
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
|
599
|
-
# @example
|
|
600
|
-
# require "google/cloud/spanner/admin/database"
|
|
601
|
-
#
|
|
602
|
-
# database_admin_client = Google::Cloud::Spanner::Admin::Database.new(version: :v1)
|
|
603
|
-
# formatted_database = Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdminClient.database_path("[PROJECT]", "[INSTANCE]", "[DATABASE]")
|
|
604
|
-
# database_admin_client.drop_database(formatted_database)
|
|
605
|
-
|
|
606
|
-
def drop_database \
|
|
607
|
-
database,
|
|
608
|
-
options: nil,
|
|
609
|
-
&block
|
|
610
|
-
req = {
|
|
611
|
-
database: database
|
|
612
|
-
}.delete_if { |_, v| v.nil? }
|
|
613
|
-
req = Google::Gax::to_proto(req, Google::Spanner::Admin::Database::V1::DropDatabaseRequest)
|
|
614
|
-
@drop_database.call(req, options, &block)
|
|
615
|
-
nil
|
|
616
|
-
end
|
|
617
|
-
|
|
618
|
-
# Returns the schema of a Cloud Spanner database as a list of formatted
|
|
619
|
-
# DDL statements. This method does not show pending schema updates, those may
|
|
620
|
-
# be queried using the {Google::Longrunning::Operations Operations} API.
|
|
621
|
-
#
|
|
622
|
-
# @param database [String]
|
|
623
|
-
# Required. The database whose schema we wish to get.
|
|
624
|
-
# @param options [Google::Gax::CallOptions]
|
|
625
|
-
# Overrides the default settings for this call, e.g, timeout,
|
|
626
|
-
# retries, etc.
|
|
627
|
-
# @yield [result, operation] Access the result along with the RPC operation
|
|
628
|
-
# @yieldparam result [Google::Spanner::Admin::Database::V1::GetDatabaseDdlResponse]
|
|
629
|
-
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
|
630
|
-
# @return [Google::Spanner::Admin::Database::V1::GetDatabaseDdlResponse]
|
|
631
|
-
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
|
632
|
-
# @example
|
|
633
|
-
# require "google/cloud/spanner/admin/database"
|
|
634
|
-
#
|
|
635
|
-
# database_admin_client = Google::Cloud::Spanner::Admin::Database.new(version: :v1)
|
|
636
|
-
# formatted_database = Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdminClient.database_path("[PROJECT]", "[INSTANCE]", "[DATABASE]")
|
|
637
|
-
# response = database_admin_client.get_database_ddl(formatted_database)
|
|
638
|
-
|
|
639
|
-
def get_database_ddl \
|
|
640
|
-
database,
|
|
641
|
-
options: nil,
|
|
642
|
-
&block
|
|
643
|
-
req = {
|
|
644
|
-
database: database
|
|
645
|
-
}.delete_if { |_, v| v.nil? }
|
|
646
|
-
req = Google::Gax::to_proto(req, Google::Spanner::Admin::Database::V1::GetDatabaseDdlRequest)
|
|
647
|
-
@get_database_ddl.call(req, options, &block)
|
|
648
|
-
end
|
|
649
|
-
|
|
650
|
-
# Sets the access control policy on a database resource.
|
|
651
|
-
# Replaces any existing policy.
|
|
652
|
-
#
|
|
653
|
-
# Authorization requires `spanner.databases.setIamPolicy`
|
|
654
|
-
# permission on {Google::Iam::V1::SetIamPolicyRequest#resource resource}.
|
|
655
|
-
#
|
|
656
|
-
# @param resource [String]
|
|
657
|
-
# REQUIRED: The resource for which the policy is being specified.
|
|
658
|
-
# See the operation documentation for the appropriate value for this field.
|
|
659
|
-
# @param policy [Google::Iam::V1::Policy | Hash]
|
|
660
|
-
# REQUIRED: The complete policy to be applied to the `resource`. The size of
|
|
661
|
-
# the policy is limited to a few 10s of KB. An empty policy is a
|
|
662
|
-
# valid policy but certain Cloud Platform services (such as Projects)
|
|
663
|
-
# might reject them.
|
|
664
|
-
# A hash of the same form as `Google::Iam::V1::Policy`
|
|
665
|
-
# can also be provided.
|
|
666
|
-
# @param options [Google::Gax::CallOptions]
|
|
667
|
-
# Overrides the default settings for this call, e.g, timeout,
|
|
668
|
-
# retries, etc.
|
|
669
|
-
# @yield [result, operation] Access the result along with the RPC operation
|
|
670
|
-
# @yieldparam result [Google::Iam::V1::Policy]
|
|
671
|
-
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
|
672
|
-
# @return [Google::Iam::V1::Policy]
|
|
673
|
-
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
|
674
|
-
# @example
|
|
675
|
-
# require "google/cloud/spanner/admin/database"
|
|
676
|
-
#
|
|
677
|
-
# database_admin_client = Google::Cloud::Spanner::Admin::Database.new(version: :v1)
|
|
678
|
-
# formatted_resource = Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdminClient.database_path("[PROJECT]", "[INSTANCE]", "[DATABASE]")
|
|
679
|
-
#
|
|
680
|
-
# # TODO: Initialize `policy`:
|
|
681
|
-
# policy = {}
|
|
682
|
-
# response = database_admin_client.set_iam_policy(formatted_resource, policy)
|
|
683
|
-
|
|
684
|
-
def set_iam_policy \
|
|
685
|
-
resource,
|
|
686
|
-
policy,
|
|
687
|
-
options: nil,
|
|
688
|
-
&block
|
|
689
|
-
req = {
|
|
690
|
-
resource: resource,
|
|
691
|
-
policy: policy
|
|
692
|
-
}.delete_if { |_, v| v.nil? }
|
|
693
|
-
req = Google::Gax::to_proto(req, Google::Iam::V1::SetIamPolicyRequest)
|
|
694
|
-
@set_iam_policy.call(req, options, &block)
|
|
695
|
-
end
|
|
696
|
-
|
|
697
|
-
# Gets the access control policy for a database resource.
|
|
698
|
-
# Returns an empty policy if a database exists but does
|
|
699
|
-
# not have a policy set.
|
|
700
|
-
#
|
|
701
|
-
# Authorization requires `spanner.databases.getIamPolicy` permission on
|
|
702
|
-
# {Google::Iam::V1::GetIamPolicyRequest#resource resource}.
|
|
703
|
-
#
|
|
704
|
-
# @param resource [String]
|
|
705
|
-
# REQUIRED: The resource for which the policy is being requested.
|
|
706
|
-
# See the operation documentation for the appropriate value for this field.
|
|
707
|
-
# @param options_ [Google::Iam::V1::GetPolicyOptions | Hash]
|
|
708
|
-
# OPTIONAL: A `GetPolicyOptions` object for specifying options to
|
|
709
|
-
# `GetIamPolicy`. This field is only used by Cloud IAM.
|
|
710
|
-
# A hash of the same form as `Google::Iam::V1::GetPolicyOptions`
|
|
711
|
-
# can also be provided.
|
|
712
|
-
# @param options [Google::Gax::CallOptions]
|
|
713
|
-
# Overrides the default settings for this call, e.g, timeout,
|
|
714
|
-
# retries, etc.
|
|
715
|
-
# @yield [result, operation] Access the result along with the RPC operation
|
|
716
|
-
# @yieldparam result [Google::Iam::V1::Policy]
|
|
717
|
-
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
|
718
|
-
# @return [Google::Iam::V1::Policy]
|
|
719
|
-
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
|
720
|
-
# @example
|
|
721
|
-
# require "google/cloud/spanner/admin/database"
|
|
722
|
-
#
|
|
723
|
-
# database_admin_client = Google::Cloud::Spanner::Admin::Database.new(version: :v1)
|
|
724
|
-
# formatted_resource = Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdminClient.database_path("[PROJECT]", "[INSTANCE]", "[DATABASE]")
|
|
725
|
-
# response = database_admin_client.get_iam_policy(formatted_resource)
|
|
726
|
-
|
|
727
|
-
def get_iam_policy \
|
|
728
|
-
resource,
|
|
729
|
-
options_: nil,
|
|
730
|
-
options: nil,
|
|
731
|
-
&block
|
|
732
|
-
req = {
|
|
733
|
-
resource: resource,
|
|
734
|
-
options: options_
|
|
735
|
-
}.delete_if { |_, v| v.nil? }
|
|
736
|
-
req = Google::Gax::to_proto(req, Google::Iam::V1::GetIamPolicyRequest)
|
|
737
|
-
@get_iam_policy.call(req, options, &block)
|
|
738
|
-
end
|
|
739
|
-
|
|
740
|
-
# Returns permissions that the caller has on the specified database resource.
|
|
741
|
-
#
|
|
742
|
-
# Attempting this RPC on a non-existent Cloud Spanner database will
|
|
743
|
-
# result in a NOT_FOUND error if the user has
|
|
744
|
-
# `spanner.databases.list` permission on the containing Cloud
|
|
745
|
-
# Spanner instance. Otherwise returns an empty set of permissions.
|
|
746
|
-
#
|
|
747
|
-
# @param resource [String]
|
|
748
|
-
# REQUIRED: The resource for which the policy detail is being requested.
|
|
749
|
-
# See the operation documentation for the appropriate value for this field.
|
|
750
|
-
# @param permissions [Array<String>]
|
|
751
|
-
# The set of permissions to check for the `resource`. Permissions with
|
|
752
|
-
# wildcards (such as '*' or 'storage.*') are not allowed. For more
|
|
753
|
-
# information see
|
|
754
|
-
# [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions).
|
|
755
|
-
# @param options [Google::Gax::CallOptions]
|
|
756
|
-
# Overrides the default settings for this call, e.g, timeout,
|
|
757
|
-
# retries, etc.
|
|
758
|
-
# @yield [result, operation] Access the result along with the RPC operation
|
|
759
|
-
# @yieldparam result [Google::Iam::V1::TestIamPermissionsResponse]
|
|
760
|
-
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
|
761
|
-
# @return [Google::Iam::V1::TestIamPermissionsResponse]
|
|
762
|
-
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
|
763
|
-
# @example
|
|
764
|
-
# require "google/cloud/spanner/admin/database"
|
|
765
|
-
#
|
|
766
|
-
# database_admin_client = Google::Cloud::Spanner::Admin::Database.new(version: :v1)
|
|
767
|
-
# formatted_resource = Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdminClient.database_path("[PROJECT]", "[INSTANCE]", "[DATABASE]")
|
|
768
|
-
#
|
|
769
|
-
# # TODO: Initialize `permissions`:
|
|
770
|
-
# permissions = []
|
|
771
|
-
# response = database_admin_client.test_iam_permissions(formatted_resource, permissions)
|
|
772
|
-
|
|
773
|
-
def test_iam_permissions \
|
|
774
|
-
resource,
|
|
775
|
-
permissions,
|
|
776
|
-
options: nil,
|
|
777
|
-
&block
|
|
778
|
-
req = {
|
|
779
|
-
resource: resource,
|
|
780
|
-
permissions: permissions
|
|
781
|
-
}.delete_if { |_, v| v.nil? }
|
|
782
|
-
req = Google::Gax::to_proto(req, Google::Iam::V1::TestIamPermissionsRequest)
|
|
783
|
-
@test_iam_permissions.call(req, options, &block)
|
|
784
|
-
end
|
|
785
|
-
end
|
|
786
|
-
end
|
|
787
|
-
end
|
|
788
|
-
end
|
|
789
|
-
end
|
|
790
|
-
end
|
|
791
|
-
end
|