google-cloud-spanner 1.0.0 → 1.1.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 +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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 1add7ab9a3b78c54ef296d7e366b29f5ddeeb0faf9eed896d8ab083c12328634
|
4
|
+
data.tar.gz: e46bb01d063d498e0675a7e27af8fe3fac6c014f84d70539a1ae6e8c3be0ed55
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb362ee20082a2999811b513ba91fdf3991b73719c4d2cab8ccc2102de08aa3f26dc13636b36c139b8affac07b395d4d2c68a6b440221fb02c21d3e1e51e2cde
|
7
|
+
data.tar.gz: d0854595641328c2f90b741e174c01f2f3f2ca960c0a1b7a9f6e317e1ed326dd75fa75bba0657e12ebe4e112526a9d8b006296838c16791aed67467add975a20
|
data/lib/google-cloud-spanner.rb
CHANGED
@@ -13,9 +13,9 @@
|
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
15
|
##
|
16
|
-
# This file is here to be autorequired by bundler, so that the
|
17
|
-
# #spanner methods can be available, but
|
18
|
-
# be loaded until required and used.
|
16
|
+
# This file is here to be autorequired by bundler, so that the
|
17
|
+
# Google::Cloud.spanner and Google::Cloud#spanner methods can be available, but
|
18
|
+
# the library and all dependencies won't be loaded until required and used.
|
19
19
|
|
20
20
|
|
21
21
|
gem "google-cloud-core"
|
@@ -71,10 +71,12 @@ module Google
|
|
71
71
|
# For more information on connecting to Google Cloud see the [Authentication
|
72
72
|
# Guide](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/guides/authentication).
|
73
73
|
#
|
74
|
-
# @param [String]
|
75
|
-
# connecting to.
|
76
|
-
#
|
77
|
-
#
|
74
|
+
# @param [String] project_id Project identifier for the Spanner service you
|
75
|
+
# are connecting to. If not present, the default project for the
|
76
|
+
# credentials is used.
|
77
|
+
# @param [String, Hash, Google::Auth::Credentials] credentials The path to
|
78
|
+
# the keyfile as a String, the contents of the keyfile as a Hash, or a
|
79
|
+
# Google::Auth::Credentials object. (See {Spanner::Credentials})
|
78
80
|
# @param [String, Array<String>] scope The OAuth 2.0 scopes controlling the
|
79
81
|
# set of resources and operations that the connection can access. See
|
80
82
|
# [Using OAuth 2.0 to Access Google
|
@@ -95,10 +97,11 @@ module Google
|
|
95
97
|
#
|
96
98
|
# spanner = Google::Cloud.spanner
|
97
99
|
#
|
98
|
-
def self.spanner
|
99
|
-
client_config: nil
|
100
|
+
def self.spanner project_id = nil, credentials = nil, scope: nil,
|
101
|
+
timeout: nil, client_config: nil
|
100
102
|
require "google/cloud/spanner"
|
101
|
-
Google::Cloud::Spanner.new
|
103
|
+
Google::Cloud::Spanner.new project_id: project_id,
|
104
|
+
credentials: credentials,
|
102
105
|
scope: scope, timeout: timeout,
|
103
106
|
client_config: client_config
|
104
107
|
end
|
data/lib/google/cloud/spanner.rb
CHANGED
@@ -339,10 +339,12 @@ module Google
|
|
339
339
|
# [Authentication
|
340
340
|
# Guide](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/guides/authentication).
|
341
341
|
#
|
342
|
-
# @param [String]
|
343
|
-
# are connecting to.
|
344
|
-
#
|
345
|
-
#
|
342
|
+
# @param [String] project_id Project identifier for the Spanner service
|
343
|
+
# you are connecting to. If not present, the default project for the
|
344
|
+
# credentials is used.
|
345
|
+
# @param [String, Hash, Google::Auth::Credentials] credentials The path to
|
346
|
+
# the keyfile as a String, the contents of the keyfile as a Hash, or a
|
347
|
+
# Google::Auth::Credentials object. (See {Spanner::Credentials})
|
346
348
|
# @param [String, Array<String>] scope The OAuth 2.0 scopes controlling
|
347
349
|
# the set of resources and operations that the connection can access.
|
348
350
|
# See [Using OAuth 2.0 to Access Google
|
@@ -355,6 +357,9 @@ module Google
|
|
355
357
|
# @param [Integer] timeout Default timeout to use in requests. Optional.
|
356
358
|
# @param [Hash] client_config A hash of values to override the default
|
357
359
|
# behavior of the API client. Optional.
|
360
|
+
# @param [String] project Alias for the `project_id` argument. Deprecated.
|
361
|
+
# @param [String] keyfile Alias for the `credentials` argument.
|
362
|
+
# Deprecated.
|
358
363
|
#
|
359
364
|
# @return [Google::Cloud::Spanner::Project]
|
360
365
|
#
|
@@ -363,23 +368,21 @@ module Google
|
|
363
368
|
#
|
364
369
|
# spanner = Google::Cloud::Spanner.new
|
365
370
|
#
|
366
|
-
def self.new
|
367
|
-
client_config: nil
|
368
|
-
|
369
|
-
|
370
|
-
fail ArgumentError, "
|
371
|
+
def self.new project_id: nil, credentials: nil, scope: nil, timeout: nil,
|
372
|
+
client_config: nil, project: nil, keyfile: nil
|
373
|
+
project_id ||= (project || Spanner::Project.default_project_id)
|
374
|
+
project_id = project_id.to_s # Always cast to a string
|
375
|
+
fail ArgumentError, "project_id is missing" if project_id.empty?
|
371
376
|
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
credentials = Google::Cloud::Spanner::Credentials.new(
|
376
|
-
keyfile, scope: scope)
|
377
|
+
credentials ||= (keyfile || Spanner::Credentials.default(scope: scope))
|
378
|
+
unless credentials.is_a? Google::Auth::Credentials
|
379
|
+
credentials = Spanner::Credentials.new credentials, scope: scope
|
377
380
|
end
|
378
381
|
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
382
|
+
Spanner::Project.new(
|
383
|
+
Spanner::Service.new(
|
384
|
+
project_id, credentials, timeout: timeout,
|
385
|
+
client_config: client_config))
|
383
386
|
end
|
384
387
|
end
|
385
388
|
end
|
@@ -0,0 +1,111 @@
|
|
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 Database Admin API ([Alpha](https://github.com/GoogleCloudPlatform/google-cloud-ruby#versioning))
|
26
|
+
#
|
27
|
+
# [Cloud Spanner Database 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 Database Admin API.](https://console.cloud.google.com/apis/api/spanner-admin-database)
|
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 Database 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-database
|
46
|
+
#
|
47
|
+
#
|
48
|
+
module Database
|
49
|
+
# rubocop:enable LineLength
|
50
|
+
|
51
|
+
FILE_DIR = File.realdirpath(Pathname.new(__FILE__).join("..").join("database"))
|
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 Database Admin API
|
61
|
+
#
|
62
|
+
# The Cloud Spanner Database Admin API can be used to create, drop, and
|
63
|
+
# list databases. It also enables updating the schema of pre-existing
|
64
|
+
# databases.
|
65
|
+
#
|
66
|
+
# @param version [Symbol, String]
|
67
|
+
# The major version of the service to be used. By default :v1
|
68
|
+
# is used.
|
69
|
+
# @overload new(version:, credentials:, scopes:, client_config:, timeout:)
|
70
|
+
# @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
|
71
|
+
# Provides the means for authenticating requests made by the client. This parameter can
|
72
|
+
# be many types.
|
73
|
+
# A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
|
74
|
+
# authenticating requests made by this client.
|
75
|
+
# A `String` will be treated as the path to the keyfile to be used for the construction of
|
76
|
+
# credentials for this client.
|
77
|
+
# A `Hash` will be treated as the contents of a keyfile to be used for the construction of
|
78
|
+
# credentials for this client.
|
79
|
+
# A `GRPC::Core::Channel` will be used to make calls through.
|
80
|
+
# A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
|
81
|
+
# should already be composed with a `GRPC::Core::CallCredentials` object.
|
82
|
+
# A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
|
83
|
+
# metadata for requests, generally, to give OAuth credentials.
|
84
|
+
# @param scopes [Array<String>]
|
85
|
+
# The OAuth scopes for this service. This parameter is ignored if
|
86
|
+
# an updater_proc is supplied.
|
87
|
+
# @param client_config [Hash]
|
88
|
+
# A Hash for call options for each method. See
|
89
|
+
# Google::Gax#construct_settings for the structure of
|
90
|
+
# this data. Falls back to the default config if not specified
|
91
|
+
# or the specified config is missing data points.
|
92
|
+
# @param timeout [Numeric]
|
93
|
+
# The default timeout, in seconds, for calls made through this client.
|
94
|
+
def self.new(*args, version: :v1, **kwargs)
|
95
|
+
unless AVAILABLE_VERSIONS.include?(version.to_s.downcase)
|
96
|
+
raise "The version: #{version} is not available. The available versions " \
|
97
|
+
"are: [#{AVAILABLE_VERSIONS.join(", ")}]"
|
98
|
+
end
|
99
|
+
|
100
|
+
require "#{FILE_DIR}/#{version.to_s.downcase}"
|
101
|
+
version_module = Google::Cloud::Spanner::Admin::Database
|
102
|
+
.constants
|
103
|
+
.select {|sym| sym.to_s.downcase == version.to_s.downcase}
|
104
|
+
.first
|
105
|
+
Google::Cloud::Spanner::Admin::Database.const_get(version_module).new(*args, **kwargs)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
@@ -0,0 +1,35 @@
|
|
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 "googleauth"
|
16
|
+
|
17
|
+
module Google
|
18
|
+
module Cloud
|
19
|
+
module Spanner
|
20
|
+
module Admin
|
21
|
+
module Database
|
22
|
+
class Credentials < Google::Auth::Credentials
|
23
|
+
SCOPE = [
|
24
|
+
"https://www.googleapis.com/auth/cloud-platform",
|
25
|
+
"https://www.googleapis.com/auth/spanner.admin"
|
26
|
+
].freeze
|
27
|
+
PATH_ENV_VARS = %w(SPANNER_ADMIN_DATABASE_KEYFILE, GOOGLE_CLOUD_KEYFILE, GCLOUD_KEYFILE)
|
28
|
+
JSON_ENV_VARS = %w(SPANNER_ADMIN_DATABASE_KEYFILE_JSON, GOOGLE_CLOUD_KEYFILE_JSON, GCLOUD_KEYFILE_JSON)
|
29
|
+
DEFAULT_PATHS = ["~/.config/gcloud/application_default_credentials.json"]
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -1,5 +1,4 @@
|
|
1
|
-
|
2
|
-
# Copyright 2016 Google Inc. All rights reserved.
|
1
|
+
# Copyright 2017, Google Inc. All rights reserved.
|
3
2
|
#
|
4
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
4
|
# you may not use this file except in compliance with the License.
|
@@ -13,5 +12,103 @@
|
|
13
12
|
# See the License for the specific language governing permissions and
|
14
13
|
# limitations under the License.
|
15
14
|
|
16
|
-
|
17
15
|
require "google/cloud/spanner/admin/database/v1/database_admin_client"
|
16
|
+
|
17
|
+
module Google
|
18
|
+
module Cloud
|
19
|
+
module Spanner
|
20
|
+
module Admin
|
21
|
+
# rubocop:disable LineLength
|
22
|
+
|
23
|
+
##
|
24
|
+
# # Ruby Client for Cloud Spanner Database Admin API ([Alpha](https://github.com/GoogleCloudPlatform/google-cloud-ruby#versioning))
|
25
|
+
#
|
26
|
+
# [Cloud Spanner Database Admin API][Product Documentation]:
|
27
|
+
#
|
28
|
+
# - [Product Documentation][]
|
29
|
+
#
|
30
|
+
# ## Quick Start
|
31
|
+
# In order to use this library, you first need to go through the following
|
32
|
+
# steps:
|
33
|
+
#
|
34
|
+
# 1. [Select or create a Cloud Platform project.](https://console.cloud.google.com/project)
|
35
|
+
# 2. [Enable the Cloud Spanner Database Admin API.](https://console.cloud.google.com/apis/api/spanner-admin-database)
|
36
|
+
# 3. [Setup Authentication.](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud/master/guides/authentication)
|
37
|
+
#
|
38
|
+
# ### Next Steps
|
39
|
+
# - Read the [Cloud Spanner Database Admin API Product documentation][Product Documentation]
|
40
|
+
# to learn more about the product and see How-to Guides.
|
41
|
+
# - View this [repository's main README](https://github.com/GoogleCloudPlatform/google-cloud-ruby/blob/master/README.md)
|
42
|
+
# to see the full list of Cloud APIs that we cover.
|
43
|
+
#
|
44
|
+
# [Product Documentation]: https://cloud.google.com/spanner-admin-database
|
45
|
+
#
|
46
|
+
#
|
47
|
+
module Database
|
48
|
+
module V1
|
49
|
+
# rubocop:enable LineLength
|
50
|
+
|
51
|
+
##
|
52
|
+
# Cloud Spanner Database Admin API
|
53
|
+
#
|
54
|
+
# The Cloud Spanner Database Admin API can be used to create, drop, and
|
55
|
+
# list databases. It also enables updating the schema of pre-existing
|
56
|
+
# databases.
|
57
|
+
#
|
58
|
+
# @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
|
59
|
+
# Provides the means for authenticating requests made by the client. This parameter can
|
60
|
+
# be many types.
|
61
|
+
# A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
|
62
|
+
# authenticating requests made by this client.
|
63
|
+
# A `String` will be treated as the path to the keyfile to be used for the construction of
|
64
|
+
# credentials for this client.
|
65
|
+
# A `Hash` will be treated as the contents of a keyfile to be used for the construction of
|
66
|
+
# credentials for this client.
|
67
|
+
# A `GRPC::Core::Channel` will be used to make calls through.
|
68
|
+
# A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
|
69
|
+
# should already be composed with a `GRPC::Core::CallCredentials` object.
|
70
|
+
# A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
|
71
|
+
# metadata for requests, generally, to give OAuth credentials.
|
72
|
+
# @param scopes [Array<String>]
|
73
|
+
# The OAuth scopes for this service. This parameter is ignored if
|
74
|
+
# an updater_proc is supplied.
|
75
|
+
# @param client_config [Hash]
|
76
|
+
# A Hash for call options for each method. See
|
77
|
+
# Google::Gax#construct_settings for the structure of
|
78
|
+
# this data. Falls back to the default config if not specified
|
79
|
+
# or the specified config is missing data points.
|
80
|
+
# @param timeout [Numeric]
|
81
|
+
# The default timeout, in seconds, for calls made through this client.
|
82
|
+
def self.new \
|
83
|
+
service_path: nil,
|
84
|
+
port: nil,
|
85
|
+
channel: nil,
|
86
|
+
chan_creds: nil,
|
87
|
+
updater_proc: nil,
|
88
|
+
credentials: nil,
|
89
|
+
scopes: nil,
|
90
|
+
client_config: nil,
|
91
|
+
timeout: nil,
|
92
|
+
lib_name: nil,
|
93
|
+
lib_version: nil
|
94
|
+
kwargs = {
|
95
|
+
service_path: service_path,
|
96
|
+
port: port,
|
97
|
+
channel: channel,
|
98
|
+
chan_creds: chan_creds,
|
99
|
+
updater_proc: updater_proc,
|
100
|
+
credentials: credentials,
|
101
|
+
scopes: scopes,
|
102
|
+
client_config: client_config,
|
103
|
+
timeout: timeout,
|
104
|
+
lib_name: lib_name,
|
105
|
+
lib_version: lib_version
|
106
|
+
}.select { |_, v| v != nil }
|
107
|
+
Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdminClient.new(**kwargs)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
@@ -30,6 +30,7 @@ require "google/gax/operation"
|
|
30
30
|
require "google/longrunning/operations_client"
|
31
31
|
|
32
32
|
require "google/spanner/admin/database/v1/spanner_database_admin_pb"
|
33
|
+
require "google/cloud/spanner/admin/database/credentials"
|
33
34
|
|
34
35
|
module Google
|
35
36
|
module Cloud
|
@@ -108,50 +109,24 @@ module Google
|
|
108
109
|
)
|
109
110
|
end
|
110
111
|
|
111
|
-
#
|
112
|
-
#
|
113
|
-
#
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
#
|
119
|
-
#
|
120
|
-
#
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
#
|
126
|
-
#
|
127
|
-
#
|
128
|
-
|
129
|
-
DATABASE_PATH_TEMPLATE.match(database_name)["project"]
|
130
|
-
end
|
131
|
-
|
132
|
-
# Parses the instance from a database resource.
|
133
|
-
# @param database_name [String]
|
134
|
-
# @return [String]
|
135
|
-
def self.match_instance_from_database_name database_name
|
136
|
-
DATABASE_PATH_TEMPLATE.match(database_name)["instance"]
|
137
|
-
end
|
138
|
-
|
139
|
-
# Parses the database from a database resource.
|
140
|
-
# @param database_name [String]
|
141
|
-
# @return [String]
|
142
|
-
def self.match_database_from_database_name database_name
|
143
|
-
DATABASE_PATH_TEMPLATE.match(database_name)["database"]
|
144
|
-
end
|
145
|
-
|
146
|
-
# @param service_path [String]
|
147
|
-
# The domain name of the API remote host.
|
148
|
-
# @param port [Integer]
|
149
|
-
# The port on which to connect to the remote host.
|
150
|
-
# @param channel [Channel]
|
151
|
-
# A Channel object through which to make calls.
|
152
|
-
# @param chan_creds [Grpc::ChannelCredentials]
|
153
|
-
# A ChannelCredentials for the setting up the RPC client.
|
154
|
-
# @param client_config[Hash]
|
112
|
+
# @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
|
113
|
+
# Provides the means for authenticating requests made by the client. This parameter can
|
114
|
+
# be many types.
|
115
|
+
# A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
|
116
|
+
# authenticating requests made by this client.
|
117
|
+
# A `String` will be treated as the path to the keyfile to be used for the construction of
|
118
|
+
# credentials for this client.
|
119
|
+
# A `Hash` will be treated as the contents of a keyfile to be used for the construction of
|
120
|
+
# credentials for this client.
|
121
|
+
# A `GRPC::Core::Channel` will be used to make calls through.
|
122
|
+
# A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
|
123
|
+
# should already be composed with a `GRPC::Core::CallCredentials` object.
|
124
|
+
# A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
|
125
|
+
# metadata for requests, generally, to give OAuth credentials.
|
126
|
+
# @param scopes [Array<String>]
|
127
|
+
# The OAuth scopes for this service. This parameter is ignored if
|
128
|
+
# an updater_proc is supplied.
|
129
|
+
# @param client_config [Hash]
|
155
130
|
# A Hash for call options for each method. See
|
156
131
|
# Google::Gax#construct_settings for the structure of
|
157
132
|
# this data. Falls back to the default config if not specified
|
@@ -163,11 +138,11 @@ module Google
|
|
163
138
|
port: DEFAULT_SERVICE_PORT,
|
164
139
|
channel: nil,
|
165
140
|
chan_creds: nil,
|
141
|
+
updater_proc: nil,
|
142
|
+
credentials: nil,
|
166
143
|
scopes: ALL_SCOPES,
|
167
144
|
client_config: {},
|
168
145
|
timeout: DEFAULT_TIMEOUT,
|
169
|
-
app_name: nil,
|
170
|
-
app_version: nil,
|
171
146
|
lib_name: nil,
|
172
147
|
lib_version: ""
|
173
148
|
# These require statements are intentionally placed here to initialize
|
@@ -176,27 +151,48 @@ module Google
|
|
176
151
|
require "google/gax/grpc"
|
177
152
|
require "google/spanner/admin/database/v1/spanner_database_admin_services_pb"
|
178
153
|
|
154
|
+
if channel || chan_creds || updater_proc
|
155
|
+
warn "The `channel`, `chan_creds`, and `updater_proc` parameters will be removed " \
|
156
|
+
"on 2017/09/08"
|
157
|
+
credentials ||= channel
|
158
|
+
credentials ||= chan_creds
|
159
|
+
credentials ||= updater_proc
|
160
|
+
end
|
161
|
+
if service_path != SERVICE_ADDRESS || port != DEFAULT_SERVICE_PORT
|
162
|
+
warn "`service_path` and `port` parameters are deprecated and will be removed"
|
163
|
+
end
|
164
|
+
|
165
|
+
credentials ||= Google::Cloud::Spanner::Admin::Database::Credentials.default
|
166
|
+
|
179
167
|
@operations_client = Google::Longrunning::OperationsClient.new(
|
180
168
|
service_path: service_path,
|
181
|
-
|
182
|
-
channel: channel,
|
183
|
-
chan_creds: chan_creds,
|
169
|
+
credentials: credentials,
|
184
170
|
scopes: scopes,
|
185
171
|
client_config: client_config,
|
186
172
|
timeout: timeout,
|
187
|
-
app_name: app_name,
|
188
|
-
app_version: app_version,
|
189
173
|
lib_name: lib_name,
|
190
174
|
lib_version: lib_version,
|
191
175
|
)
|
192
176
|
|
193
|
-
if
|
194
|
-
|
177
|
+
if credentials.is_a?(String) || credentials.is_a?(Hash)
|
178
|
+
updater_proc = Google::Cloud::Spanner::Admin::Database::Credentials.new(credentials).updater_proc
|
179
|
+
end
|
180
|
+
if credentials.is_a?(GRPC::Core::Channel)
|
181
|
+
channel = credentials
|
182
|
+
end
|
183
|
+
if credentials.is_a?(GRPC::Core::ChannelCredentials)
|
184
|
+
chan_creds = credentials
|
185
|
+
end
|
186
|
+
if credentials.is_a?(Proc)
|
187
|
+
updater_proc = credentials
|
188
|
+
end
|
189
|
+
if credentials.is_a?(Google::Auth::Credentials)
|
190
|
+
updater_proc = credentials.updater_proc
|
195
191
|
end
|
196
192
|
|
197
193
|
google_api_client = "gl-ruby/#{RUBY_VERSION}"
|
198
194
|
google_api_client << " #{lib_name}/#{lib_version}" if lib_name
|
199
|
-
google_api_client << " gapic/0.
|
195
|
+
google_api_client << " gapic/0.1.0 gax/#{Google::Gax::VERSION}"
|
200
196
|
google_api_client << " grpc/#{GRPC::VERSION}"
|
201
197
|
google_api_client.freeze
|
202
198
|
|
@@ -221,6 +217,7 @@ module Google
|
|
221
217
|
port,
|
222
218
|
chan_creds: chan_creds,
|
223
219
|
channel: channel,
|
220
|
+
updater_proc: updater_proc,
|
224
221
|
scopes: scopes,
|
225
222
|
&Google::Spanner::Admin::Database::V1::DatabaseAdmin::Stub.method(:new)
|
226
223
|
)
|
@@ -286,12 +283,10 @@ module Google
|
|
286
283
|
# object.
|
287
284
|
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
288
285
|
# @example
|
289
|
-
# require "google/cloud/spanner/admin/database/v1
|
290
|
-
#
|
291
|
-
# DatabaseAdminClient = Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdminClient
|
286
|
+
# require "google/cloud/spanner/admin/database/v1"
|
292
287
|
#
|
293
|
-
# database_admin_client =
|
294
|
-
# formatted_parent = DatabaseAdminClient.instance_path("[PROJECT]", "[INSTANCE]")
|
288
|
+
# database_admin_client = Google::Cloud::Spanner::Admin::Database::V1.new
|
289
|
+
# formatted_parent = Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdminClient.instance_path("[PROJECT]", "[INSTANCE]")
|
295
290
|
#
|
296
291
|
# # Iterate over all results.
|
297
292
|
# database_admin_client.list_databases(formatted_parent).each do |element|
|
@@ -310,21 +305,22 @@ module Google
|
|
310
305
|
parent,
|
311
306
|
page_size: nil,
|
312
307
|
options: nil
|
313
|
-
req =
|
308
|
+
req = {
|
314
309
|
parent: parent,
|
315
310
|
page_size: page_size
|
316
|
-
}.delete_if { |_, v| v.nil? }
|
311
|
+
}.delete_if { |_, v| v.nil? }
|
312
|
+
req = Google::Gax::to_proto(req, Google::Spanner::Admin::Database::V1::ListDatabasesRequest)
|
317
313
|
@list_databases.call(req, options)
|
318
314
|
end
|
319
315
|
|
320
316
|
# Creates a new Cloud Spanner database and starts to prepare it for serving.
|
321
|
-
# The returned
|
317
|
+
# The returned {Google::Longrunning::Operation long-running operation} will
|
322
318
|
# have a name of the format +<database_name>/operations/<operation_id>+ and
|
323
319
|
# can be used to track preparation of the database. The
|
324
|
-
#
|
325
|
-
# CreateDatabaseMetadata. The
|
326
|
-
#
|
327
|
-
# Database, if successful.
|
320
|
+
# {Google::Longrunning::Operation#metadata metadata} field type is
|
321
|
+
# {Google::Spanner::Admin::Database::V1::CreateDatabaseMetadata CreateDatabaseMetadata}. The
|
322
|
+
# {Google::Longrunning::Operation#response response} field type is
|
323
|
+
# {Google::Spanner::Admin::Database::V1::Database Database}, if successful.
|
328
324
|
#
|
329
325
|
# @param parent [String]
|
330
326
|
# Required. The name of the instance that will serve the new database.
|
@@ -333,6 +329,8 @@ module Google
|
|
333
329
|
# Required. A +CREATE DATABASE+ statement, which specifies the ID of the
|
334
330
|
# new database. The database ID must conform to the regular expression
|
335
331
|
# +[a-z][a-z0-9_\-]*[a-z0-9]+ and be between 2 and 30 characters in length.
|
332
|
+
# If the database ID is a reserved word or if it contains a hyphen, the
|
333
|
+
# database ID must be enclosed in backticks (+ + +).
|
336
334
|
# @param extra_statements [Array<String>]
|
337
335
|
# An optional list of DDL statements to run inside the newly created
|
338
336
|
# database. Statements can create tables, indexes, etc. These
|
@@ -344,12 +342,10 @@ module Google
|
|
344
342
|
# @return [Google::Gax::Operation]
|
345
343
|
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
346
344
|
# @example
|
347
|
-
# require "google/cloud/spanner/admin/database/v1
|
345
|
+
# require "google/cloud/spanner/admin/database/v1"
|
348
346
|
#
|
349
|
-
#
|
350
|
-
#
|
351
|
-
# database_admin_client = DatabaseAdminClient.new
|
352
|
-
# formatted_parent = DatabaseAdminClient.instance_path("[PROJECT]", "[INSTANCE]")
|
347
|
+
# database_admin_client = Google::Cloud::Spanner::Admin::Database::V1.new
|
348
|
+
# formatted_parent = Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdminClient.instance_path("[PROJECT]", "[INSTANCE]")
|
353
349
|
# create_statement = ''
|
354
350
|
#
|
355
351
|
# # Register a callback during the method call.
|
@@ -384,11 +380,12 @@ module Google
|
|
384
380
|
create_statement,
|
385
381
|
extra_statements: nil,
|
386
382
|
options: nil
|
387
|
-
req =
|
383
|
+
req = {
|
388
384
|
parent: parent,
|
389
385
|
create_statement: create_statement,
|
390
386
|
extra_statements: extra_statements
|
391
|
-
}.delete_if { |_, v| v.nil? }
|
387
|
+
}.delete_if { |_, v| v.nil? }
|
388
|
+
req = Google::Gax::to_proto(req, Google::Spanner::Admin::Database::V1::CreateDatabaseRequest)
|
392
389
|
operation = Google::Gax::Operation.new(
|
393
390
|
@create_database.call(req, options),
|
394
391
|
@operations_client,
|
@@ -411,30 +408,29 @@ module Google
|
|
411
408
|
# @return [Google::Spanner::Admin::Database::V1::Database]
|
412
409
|
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
413
410
|
# @example
|
414
|
-
# require "google/cloud/spanner/admin/database/v1
|
415
|
-
#
|
416
|
-
# DatabaseAdminClient = Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdminClient
|
411
|
+
# require "google/cloud/spanner/admin/database/v1"
|
417
412
|
#
|
418
|
-
# database_admin_client =
|
419
|
-
# formatted_name = DatabaseAdminClient.database_path("[PROJECT]", "[INSTANCE]", "[DATABASE]")
|
413
|
+
# database_admin_client = Google::Cloud::Spanner::Admin::Database::V1.new
|
414
|
+
# formatted_name = Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdminClient.database_path("[PROJECT]", "[INSTANCE]", "[DATABASE]")
|
420
415
|
# response = database_admin_client.get_database(formatted_name)
|
421
416
|
|
422
417
|
def get_database \
|
423
418
|
name,
|
424
419
|
options: nil
|
425
|
-
req =
|
420
|
+
req = {
|
426
421
|
name: name
|
427
|
-
}.delete_if { |_, v| v.nil? }
|
422
|
+
}.delete_if { |_, v| v.nil? }
|
423
|
+
req = Google::Gax::to_proto(req, Google::Spanner::Admin::Database::V1::GetDatabaseRequest)
|
428
424
|
@get_database.call(req, options)
|
429
425
|
end
|
430
426
|
|
431
427
|
# Updates the schema of a Cloud Spanner database by
|
432
428
|
# creating/altering/dropping tables, columns, indexes, etc. The returned
|
433
|
-
#
|
429
|
+
# {Google::Longrunning::Operation long-running operation} will have a name of
|
434
430
|
# the format +<database_name>/operations/<operation_id>+ and can be used to
|
435
431
|
# track execution of the schema change(s). The
|
436
|
-
#
|
437
|
-
# UpdateDatabaseDdlMetadata. The operation has no response.
|
432
|
+
# {Google::Longrunning::Operation#metadata metadata} field type is
|
433
|
+
# {Google::Spanner::Admin::Database::V1::UpdateDatabaseDdlMetadata UpdateDatabaseDdlMetadata}. The operation has no response.
|
438
434
|
#
|
439
435
|
# @param database [String]
|
440
436
|
# Required. The database to update.
|
@@ -444,21 +440,21 @@ module Google
|
|
444
440
|
# If empty, the new update request is assigned an
|
445
441
|
# automatically-generated operation ID. Otherwise, +operation_id+
|
446
442
|
# is used to construct the name of the resulting
|
447
|
-
# Operation.
|
443
|
+
# {Google::Longrunning::Operation Operation}.
|
448
444
|
#
|
449
445
|
# Specifying an explicit operation ID simplifies determining
|
450
446
|
# whether the statements were executed in the event that the
|
451
|
-
# UpdateDatabaseDdl call is replayed,
|
452
|
-
# or the return value is otherwise lost: the Database and
|
447
|
+
# {Google::Spanner::Admin::Database::V1::DatabaseAdmin::UpdateDatabaseDdl UpdateDatabaseDdl} call is replayed,
|
448
|
+
# or the return value is otherwise lost: the {Google::Spanner::Admin::Database::V1::UpdateDatabaseDdlRequest#database database} and
|
453
449
|
# +operation_id+ fields can be combined to form the
|
454
|
-
#
|
455
|
-
# Longrunning::Operation: +<database>/operations/<operation_id>+.
|
450
|
+
# {Google::Longrunning::Operation#name name} of the resulting
|
451
|
+
# {Google::Longrunning::Operation longrunning::Operation}: +<database>/operations/<operation_id>+.
|
456
452
|
#
|
457
453
|
# +operation_id+ should be unique within the database, and must be
|
458
454
|
# a valid identifier: +[a-z][a-z0-9_]*+. Note that
|
459
455
|
# automatically-generated operation IDs always begin with an
|
460
456
|
# underscore. If the named operation already exists,
|
461
|
-
# UpdateDatabaseDdl returns
|
457
|
+
# {Google::Spanner::Admin::Database::V1::DatabaseAdmin::UpdateDatabaseDdl UpdateDatabaseDdl} returns
|
462
458
|
# +ALREADY_EXISTS+.
|
463
459
|
# @param options [Google::Gax::CallOptions]
|
464
460
|
# Overrides the default settings for this call, e.g, timeout,
|
@@ -466,12 +462,10 @@ module Google
|
|
466
462
|
# @return [Google::Gax::Operation]
|
467
463
|
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
468
464
|
# @example
|
469
|
-
# require "google/cloud/spanner/admin/database/v1
|
465
|
+
# require "google/cloud/spanner/admin/database/v1"
|
470
466
|
#
|
471
|
-
#
|
472
|
-
#
|
473
|
-
# database_admin_client = DatabaseAdminClient.new
|
474
|
-
# formatted_database = DatabaseAdminClient.database_path("[PROJECT]", "[INSTANCE]", "[DATABASE]")
|
467
|
+
# database_admin_client = Google::Cloud::Spanner::Admin::Database::V1.new
|
468
|
+
# formatted_database = Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdminClient.database_path("[PROJECT]", "[INSTANCE]", "[DATABASE]")
|
475
469
|
# statements = []
|
476
470
|
#
|
477
471
|
# # Register a callback during the method call.
|
@@ -506,11 +500,12 @@ module Google
|
|
506
500
|
statements,
|
507
501
|
operation_id: nil,
|
508
502
|
options: nil
|
509
|
-
req =
|
503
|
+
req = {
|
510
504
|
database: database,
|
511
505
|
statements: statements,
|
512
506
|
operation_id: operation_id
|
513
|
-
}.delete_if { |_, v| v.nil? }
|
507
|
+
}.delete_if { |_, v| v.nil? }
|
508
|
+
req = Google::Gax::to_proto(req, Google::Spanner::Admin::Database::V1::UpdateDatabaseDdlRequest)
|
514
509
|
operation = Google::Gax::Operation.new(
|
515
510
|
@update_database_ddl.call(req, options),
|
516
511
|
@operations_client,
|
@@ -531,27 +526,26 @@ module Google
|
|
531
526
|
# retries, etc.
|
532
527
|
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
533
528
|
# @example
|
534
|
-
# require "google/cloud/spanner/admin/database/v1
|
535
|
-
#
|
536
|
-
# DatabaseAdminClient = Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdminClient
|
529
|
+
# require "google/cloud/spanner/admin/database/v1"
|
537
530
|
#
|
538
|
-
# database_admin_client =
|
539
|
-
# formatted_database = DatabaseAdminClient.database_path("[PROJECT]", "[INSTANCE]", "[DATABASE]")
|
531
|
+
# database_admin_client = Google::Cloud::Spanner::Admin::Database::V1.new
|
532
|
+
# formatted_database = Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdminClient.database_path("[PROJECT]", "[INSTANCE]", "[DATABASE]")
|
540
533
|
# database_admin_client.drop_database(formatted_database)
|
541
534
|
|
542
535
|
def drop_database \
|
543
536
|
database,
|
544
537
|
options: nil
|
545
|
-
req =
|
538
|
+
req = {
|
546
539
|
database: database
|
547
|
-
}.delete_if { |_, v| v.nil? }
|
540
|
+
}.delete_if { |_, v| v.nil? }
|
541
|
+
req = Google::Gax::to_proto(req, Google::Spanner::Admin::Database::V1::DropDatabaseRequest)
|
548
542
|
@drop_database.call(req, options)
|
549
543
|
nil
|
550
544
|
end
|
551
545
|
|
552
546
|
# Returns the schema of a Cloud Spanner database as a list of formatted
|
553
547
|
# DDL statements. This method does not show pending schema updates, those may
|
554
|
-
# be queried using the Operations API.
|
548
|
+
# be queried using the {Google::Longrunning::Operations Operations} API.
|
555
549
|
#
|
556
550
|
# @param database [String]
|
557
551
|
# Required. The database whose schema we wish to get.
|
@@ -561,20 +555,19 @@ module Google
|
|
561
555
|
# @return [Google::Spanner::Admin::Database::V1::GetDatabaseDdlResponse]
|
562
556
|
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
563
557
|
# @example
|
564
|
-
# require "google/cloud/spanner/admin/database/v1
|
558
|
+
# require "google/cloud/spanner/admin/database/v1"
|
565
559
|
#
|
566
|
-
#
|
567
|
-
#
|
568
|
-
# database_admin_client = DatabaseAdminClient.new
|
569
|
-
# formatted_database = DatabaseAdminClient.database_path("[PROJECT]", "[INSTANCE]", "[DATABASE]")
|
560
|
+
# database_admin_client = Google::Cloud::Spanner::Admin::Database::V1.new
|
561
|
+
# formatted_database = Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdminClient.database_path("[PROJECT]", "[INSTANCE]", "[DATABASE]")
|
570
562
|
# response = database_admin_client.get_database_ddl(formatted_database)
|
571
563
|
|
572
564
|
def get_database_ddl \
|
573
565
|
database,
|
574
566
|
options: nil
|
575
|
-
req =
|
567
|
+
req = {
|
576
568
|
database: database
|
577
|
-
}.delete_if { |_, v| v.nil? }
|
569
|
+
}.delete_if { |_, v| v.nil? }
|
570
|
+
req = Google::Gax::to_proto(req, Google::Spanner::Admin::Database::V1::GetDatabaseDdlRequest)
|
578
571
|
@get_database_ddl.call(req, options)
|
579
572
|
end
|
580
573
|
|
@@ -582,41 +575,41 @@ module Google
|
|
582
575
|
# existing policy.
|
583
576
|
#
|
584
577
|
# Authorization requires +spanner.databases.setIamPolicy+ permission on
|
585
|
-
#
|
578
|
+
# {Google::Iam::V1::SetIamPolicyRequest#resource resource}.
|
586
579
|
#
|
587
580
|
# @param resource [String]
|
588
581
|
# REQUIRED: The resource for which the policy is being specified.
|
589
582
|
# +resource+ is usually specified as a path. For example, a Project
|
590
583
|
# resource is specified as +projects/{project}+.
|
591
|
-
# @param policy [Google::Iam::V1::Policy]
|
584
|
+
# @param policy [Google::Iam::V1::Policy | Hash]
|
592
585
|
# REQUIRED: The complete policy to be applied to the +resource+. The size of
|
593
586
|
# the policy is limited to a few 10s of KB. An empty policy is a
|
594
587
|
# valid policy but certain Cloud Platform services (such as Projects)
|
595
588
|
# might reject them.
|
589
|
+
# A hash of the same form as `Google::Iam::V1::Policy`
|
590
|
+
# can also be provided.
|
596
591
|
# @param options [Google::Gax::CallOptions]
|
597
592
|
# Overrides the default settings for this call, e.g, timeout,
|
598
593
|
# retries, etc.
|
599
594
|
# @return [Google::Iam::V1::Policy]
|
600
595
|
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
601
596
|
# @example
|
602
|
-
# require "google/cloud/spanner/admin/database/v1
|
603
|
-
#
|
604
|
-
# DatabaseAdminClient = Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdminClient
|
605
|
-
# Policy = Google::Iam::V1::Policy
|
597
|
+
# require "google/cloud/spanner/admin/database/v1"
|
606
598
|
#
|
607
|
-
# database_admin_client =
|
608
|
-
# formatted_resource = DatabaseAdminClient.database_path("[PROJECT]", "[INSTANCE]", "[DATABASE]")
|
609
|
-
# policy =
|
599
|
+
# database_admin_client = Google::Cloud::Spanner::Admin::Database::V1.new
|
600
|
+
# formatted_resource = Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdminClient.database_path("[PROJECT]", "[INSTANCE]", "[DATABASE]")
|
601
|
+
# policy = {}
|
610
602
|
# response = database_admin_client.set_iam_policy(formatted_resource, policy)
|
611
603
|
|
612
604
|
def set_iam_policy \
|
613
605
|
resource,
|
614
606
|
policy,
|
615
607
|
options: nil
|
616
|
-
req =
|
608
|
+
req = {
|
617
609
|
resource: resource,
|
618
610
|
policy: policy
|
619
|
-
}.delete_if { |_, v| v.nil? }
|
611
|
+
}.delete_if { |_, v| v.nil? }
|
612
|
+
req = Google::Gax::to_proto(req, Google::Iam::V1::SetIamPolicyRequest)
|
620
613
|
@set_iam_policy.call(req, options)
|
621
614
|
end
|
622
615
|
|
@@ -624,7 +617,7 @@ module Google
|
|
624
617
|
# policy if a database exists but does not have a policy set.
|
625
618
|
#
|
626
619
|
# Authorization requires +spanner.databases.getIamPolicy+ permission on
|
627
|
-
#
|
620
|
+
# {Google::Iam::V1::GetIamPolicyRequest#resource resource}.
|
628
621
|
#
|
629
622
|
# @param resource [String]
|
630
623
|
# REQUIRED: The resource for which the policy is being requested.
|
@@ -636,20 +629,19 @@ module Google
|
|
636
629
|
# @return [Google::Iam::V1::Policy]
|
637
630
|
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
638
631
|
# @example
|
639
|
-
# require "google/cloud/spanner/admin/database/v1
|
632
|
+
# require "google/cloud/spanner/admin/database/v1"
|
640
633
|
#
|
641
|
-
#
|
642
|
-
#
|
643
|
-
# database_admin_client = DatabaseAdminClient.new
|
644
|
-
# formatted_resource = DatabaseAdminClient.database_path("[PROJECT]", "[INSTANCE]", "[DATABASE]")
|
634
|
+
# database_admin_client = Google::Cloud::Spanner::Admin::Database::V1.new
|
635
|
+
# formatted_resource = Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdminClient.database_path("[PROJECT]", "[INSTANCE]", "[DATABASE]")
|
645
636
|
# response = database_admin_client.get_iam_policy(formatted_resource)
|
646
637
|
|
647
638
|
def get_iam_policy \
|
648
639
|
resource,
|
649
640
|
options: nil
|
650
|
-
req =
|
641
|
+
req = {
|
651
642
|
resource: resource
|
652
|
-
}.delete_if { |_, v| v.nil? }
|
643
|
+
}.delete_if { |_, v| v.nil? }
|
644
|
+
req = Google::Gax::to_proto(req, Google::Iam::V1::GetIamPolicyRequest)
|
653
645
|
@get_iam_policy.call(req, options)
|
654
646
|
end
|
655
647
|
|
@@ -668,19 +660,17 @@ module Google
|
|
668
660
|
# The set of permissions to check for the +resource+. Permissions with
|
669
661
|
# wildcards (such as '*' or 'storage.*') are not allowed. For more
|
670
662
|
# information see
|
671
|
-
#
|
663
|
+
# [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions).
|
672
664
|
# @param options [Google::Gax::CallOptions]
|
673
665
|
# Overrides the default settings for this call, e.g, timeout,
|
674
666
|
# retries, etc.
|
675
667
|
# @return [Google::Iam::V1::TestIamPermissionsResponse]
|
676
668
|
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
677
669
|
# @example
|
678
|
-
# require "google/cloud/spanner/admin/database/v1
|
679
|
-
#
|
680
|
-
# DatabaseAdminClient = Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdminClient
|
670
|
+
# require "google/cloud/spanner/admin/database/v1"
|
681
671
|
#
|
682
|
-
# database_admin_client =
|
683
|
-
# formatted_resource = DatabaseAdminClient.database_path("[PROJECT]", "[INSTANCE]", "[DATABASE]")
|
672
|
+
# database_admin_client = Google::Cloud::Spanner::Admin::Database::V1.new
|
673
|
+
# formatted_resource = Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdminClient.database_path("[PROJECT]", "[INSTANCE]", "[DATABASE]")
|
684
674
|
# permissions = []
|
685
675
|
# response = database_admin_client.test_iam_permissions(formatted_resource, permissions)
|
686
676
|
|
@@ -688,10 +678,11 @@ module Google
|
|
688
678
|
resource,
|
689
679
|
permissions,
|
690
680
|
options: nil
|
691
|
-
req =
|
681
|
+
req = {
|
692
682
|
resource: resource,
|
693
683
|
permissions: permissions
|
694
|
-
}.delete_if { |_, v| v.nil? }
|
684
|
+
}.delete_if { |_, v| v.nil? }
|
685
|
+
req = Google::Gax::to_proto(req, Google::Iam::V1::TestIamPermissionsRequest)
|
695
686
|
@test_iam_permissions.call(req, options)
|
696
687
|
end
|
697
688
|
end
|