google-cloud-tasks 2.6.1 → 3.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/.yardopts +0 -1
- data/README.md +31 -11
- data/lib/google/cloud/tasks/version.rb +1 -1
- data/lib/google/cloud/tasks.rb +36 -0
- metadata +8 -58
- data/MIGRATING.md +0 -320
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a6867b578c3c33a6dd49695eb021261cc82f086cc22fb75fd43edabbbc34268
|
4
|
+
data.tar.gz: f10b8289bdc9dad4f9b89cdb5677744049819a40558ea94332185309ecf47618
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 94e590034e1e15f8f003b580ef860167665827e5add33930f51b24f78b2fb6e4592c407f6f3bafb48da9dd94a419989c22dda1b81602550f71e4330a40a1ff2d
|
7
|
+
data.tar.gz: f63f000f19bcdadc8b6bfa3daaf5302c437e1be09086c0c7803556dab4a09a2107cfb85240004c0e907d30e94a203d51fdf9196df7d6f0a840c070553e144750
|
data/.yardopts
CHANGED
data/README.md
CHANGED
@@ -16,9 +16,7 @@ for this library, google-cloud-tasks, to see the convenience methods for
|
|
16
16
|
constructing client objects. Reference documentation for the client objects
|
17
17
|
themselves can be found in the client library documentation for the versioned
|
18
18
|
client gems:
|
19
|
-
[google-cloud-tasks-v2](https://cloud.google.com/ruby/docs/reference/google-cloud-tasks-v2/latest)
|
20
|
-
[google-cloud-tasks-v2beta2](https://cloud.google.com/ruby/docs/reference/google-cloud-tasks-v2beta2/latest),
|
21
|
-
[google-cloud-tasks-v2beta3](https://cloud.google.com/ruby/docs/reference/google-cloud-tasks-v2beta3/latest).
|
19
|
+
[google-cloud-tasks-v2](https://cloud.google.com/ruby/docs/reference/google-cloud-tasks-v2/latest).
|
22
20
|
|
23
21
|
See also the [Product Documentation](https://cloud.google.com/tasks)
|
24
22
|
for more usage information.
|
@@ -36,17 +34,39 @@ In order to use this library, you first need to go through the following steps:
|
|
36
34
|
1. [Enable the API.](https://console.cloud.google.com/apis/library/cloudtasks.googleapis.com)
|
37
35
|
1. {file:AUTHENTICATION.md Set up authentication.}
|
38
36
|
|
39
|
-
##
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
37
|
+
## Debug Logging
|
38
|
+
|
39
|
+
This library comes with opt-in Debug Logging that can help you troubleshoot
|
40
|
+
your application's integration with the API. When logging is activated, key
|
41
|
+
events such as requests and responses, along with data payloads and metadata
|
42
|
+
such as headers and client configuration, are logged to the standard error
|
43
|
+
stream.
|
44
|
+
|
45
|
+
**WARNING:** Client Library Debug Logging includes your data payloads in
|
46
|
+
plaintext, which could include sensitive data such as PII for yourself or your
|
47
|
+
customers, private keys, or other security data that could be compromising if
|
48
|
+
leaked. Always practice good data hygiene with your application logs, and follow
|
49
|
+
the principle of least access. Google also recommends that Client Library Debug
|
50
|
+
Logging be enabled only temporarily during active debugging, and not used
|
51
|
+
permanently in production.
|
52
|
+
|
53
|
+
To enable logging, set the environment variable `GOOGLE_SDK_RUBY_LOGGING_GEMS`
|
54
|
+
to the value `all`. Alternatively, you can set the value to a comma-delimited
|
55
|
+
list of client library gem names. This will select the default logging behavior,
|
56
|
+
which writes logs to the standard error stream. On a local workstation, this may
|
57
|
+
result in logs appearing on the console. When running on a Google Cloud hosting
|
58
|
+
service such as [Google Cloud Run](https://cloud.google.com/run), this generally
|
59
|
+
results in logs appearing alongside your application logs in the
|
60
|
+
[Google Cloud Logging](https://cloud.google.com/logging/) service.
|
61
|
+
|
62
|
+
Debug logging also requires that the versioned clients for this service be
|
63
|
+
sufficiently recent, released after about Dec 10, 2024. If logging is not
|
64
|
+
working, try updating the versioned clients in your bundle or installed gems:
|
65
|
+
[google-cloud-tasks-v2](https://cloud.google.com/ruby/docs/reference/google-cloud-tasks-v2/latest).
|
46
66
|
|
47
67
|
## Supported Ruby Versions
|
48
68
|
|
49
|
-
This library is supported on Ruby
|
69
|
+
This library is supported on Ruby 3.0+.
|
50
70
|
|
51
71
|
Google provides official support for Ruby versions that are actively supported
|
52
72
|
by Ruby Core—that is, Ruby versions that are either in normal maintenance or
|
data/lib/google/cloud/tasks.rb
CHANGED
@@ -58,6 +58,11 @@ module Google
|
|
58
58
|
# You can also specify a different transport by passing `:rest` or `:grpc` in
|
59
59
|
# the `transport` parameter.
|
60
60
|
#
|
61
|
+
# Raises an exception if the currently installed versioned client gem for the
|
62
|
+
# given API version does not support the given transport of the CloudTasks service.
|
63
|
+
# You can determine whether the method will succeed by calling
|
64
|
+
# {Google::Cloud::Tasks.cloud_tasks_available?}.
|
65
|
+
#
|
61
66
|
# ## About CloudTasks
|
62
67
|
#
|
63
68
|
# Cloud Tasks allows developers to manage the execution of background
|
@@ -80,6 +85,37 @@ module Google
|
|
80
85
|
service_module.const_get(:Client).new(&block)
|
81
86
|
end
|
82
87
|
|
88
|
+
##
|
89
|
+
# Determines whether the CloudTasks service is supported by the current client.
|
90
|
+
# If true, you can retrieve a client object by calling {Google::Cloud::Tasks.cloud_tasks}.
|
91
|
+
# If false, that method will raise an exception. This could happen if the given
|
92
|
+
# API version does not exist or does not support the CloudTasks service,
|
93
|
+
# or if the versioned client gem needs an update to support the CloudTasks service.
|
94
|
+
#
|
95
|
+
# @param version [::String, ::Symbol] The API version to connect to. Optional.
|
96
|
+
# Defaults to `:v2`.
|
97
|
+
# @param transport [:grpc, :rest] The transport to use. Defaults to `:grpc`.
|
98
|
+
# @return [boolean] Whether the service is available.
|
99
|
+
#
|
100
|
+
def self.cloud_tasks_available? version: :v2, transport: :grpc
|
101
|
+
require "google/cloud/tasks/#{version.to_s.downcase}"
|
102
|
+
package_name = Google::Cloud::Tasks
|
103
|
+
.constants
|
104
|
+
.select { |sym| sym.to_s.downcase == version.to_s.downcase.tr("_", "") }
|
105
|
+
.first
|
106
|
+
return false unless package_name
|
107
|
+
service_module = Google::Cloud::Tasks.const_get package_name
|
108
|
+
return false unless service_module.const_defined? :CloudTasks
|
109
|
+
service_module = service_module.const_get :CloudTasks
|
110
|
+
if transport == :rest
|
111
|
+
return false unless service_module.const_defined? :Rest
|
112
|
+
service_module = service_module.const_get :Rest
|
113
|
+
end
|
114
|
+
service_module.const_defined? :Client
|
115
|
+
rescue ::LoadError
|
116
|
+
false
|
117
|
+
end
|
118
|
+
|
83
119
|
##
|
84
120
|
# Configure the google-cloud-tasks library.
|
85
121
|
#
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: google-cloud-tasks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Google LLC
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-02-13 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: google-cloud-core
|
@@ -28,62 +27,16 @@ dependencies:
|
|
28
27
|
name: google-cloud-tasks-v2
|
29
28
|
requirement: !ruby/object:Gem::Requirement
|
30
29
|
requirements:
|
31
|
-
- - "
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0.10'
|
34
|
-
- - "<"
|
35
|
-
- !ruby/object:Gem::Version
|
36
|
-
version: 2.a
|
37
|
-
type: :runtime
|
38
|
-
prerelease: false
|
39
|
-
version_requirements: !ruby/object:Gem::Requirement
|
40
|
-
requirements:
|
41
|
-
- - ">="
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
version: '0.10'
|
44
|
-
- - "<"
|
45
|
-
- !ruby/object:Gem::Version
|
46
|
-
version: 2.a
|
47
|
-
- !ruby/object:Gem::Dependency
|
48
|
-
name: google-cloud-tasks-v2beta2
|
49
|
-
requirement: !ruby/object:Gem::Requirement
|
50
|
-
requirements:
|
51
|
-
- - ">="
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version: '0.11'
|
54
|
-
- - "<"
|
55
|
-
- !ruby/object:Gem::Version
|
56
|
-
version: 2.a
|
57
|
-
type: :runtime
|
58
|
-
prerelease: false
|
59
|
-
version_requirements: !ruby/object:Gem::Requirement
|
60
|
-
requirements:
|
61
|
-
- - ">="
|
62
|
-
- !ruby/object:Gem::Version
|
63
|
-
version: '0.11'
|
64
|
-
- - "<"
|
65
|
-
- !ruby/object:Gem::Version
|
66
|
-
version: 2.a
|
67
|
-
- !ruby/object:Gem::Dependency
|
68
|
-
name: google-cloud-tasks-v2beta3
|
69
|
-
requirement: !ruby/object:Gem::Requirement
|
70
|
-
requirements:
|
71
|
-
- - ">="
|
72
|
-
- !ruby/object:Gem::Version
|
73
|
-
version: '0.12'
|
74
|
-
- - "<"
|
30
|
+
- - "~>"
|
75
31
|
- !ruby/object:Gem::Version
|
76
|
-
version: 2
|
32
|
+
version: '1.2'
|
77
33
|
type: :runtime
|
78
34
|
prerelease: false
|
79
35
|
version_requirements: !ruby/object:Gem::Requirement
|
80
36
|
requirements:
|
81
|
-
- - "
|
82
|
-
- !ruby/object:Gem::Version
|
83
|
-
version: '0.12'
|
84
|
-
- - "<"
|
37
|
+
- - "~>"
|
85
38
|
- !ruby/object:Gem::Version
|
86
|
-
version: 2
|
39
|
+
version: '1.2'
|
87
40
|
description: Cloud Tasks is a fully managed service that allows you to manage the
|
88
41
|
execution, dispatch and delivery of a large number of distributed tasks. You can
|
89
42
|
asynchronously perform work outside of a user request. Your tasks can be executed
|
@@ -96,7 +49,6 @@ files:
|
|
96
49
|
- ".yardopts"
|
97
50
|
- AUTHENTICATION.md
|
98
51
|
- LICENSE.md
|
99
|
-
- MIGRATING.md
|
100
52
|
- README.md
|
101
53
|
- lib/google-cloud-tasks.rb
|
102
54
|
- lib/google/cloud/tasks.rb
|
@@ -105,7 +57,6 @@ homepage: https://github.com/googleapis/google-cloud-ruby
|
|
105
57
|
licenses:
|
106
58
|
- Apache-2.0
|
107
59
|
metadata: {}
|
108
|
-
post_install_message:
|
109
60
|
rdoc_options: []
|
110
61
|
require_paths:
|
111
62
|
- lib
|
@@ -113,15 +64,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
113
64
|
requirements:
|
114
65
|
- - ">="
|
115
66
|
- !ruby/object:Gem::Version
|
116
|
-
version: '
|
67
|
+
version: '3.0'
|
117
68
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
118
69
|
requirements:
|
119
70
|
- - ">="
|
120
71
|
- !ruby/object:Gem::Version
|
121
72
|
version: '0'
|
122
73
|
requirements: []
|
123
|
-
rubygems_version: 3.
|
124
|
-
signing_key:
|
74
|
+
rubygems_version: 3.6.3
|
125
75
|
specification_version: 4
|
126
76
|
summary: API Client library for the Cloud Tasks API
|
127
77
|
test_files: []
|
data/MIGRATING.md
DELETED
@@ -1,320 +0,0 @@
|
|
1
|
-
## Migrating to google-cloud-tasks 2.0
|
2
|
-
|
3
|
-
The 2.0 release of the google-cloud-tasks client is a significant upgrade
|
4
|
-
based on a [next-gen code generator](https://github.com/googleapis/gapic-generator-ruby),
|
5
|
-
and includes substantial interface changes. Existing code written for earlier
|
6
|
-
versions of this library will likely require updates to use this version.
|
7
|
-
This document describes the changes that have been made, and what you need to
|
8
|
-
do to update your usage.
|
9
|
-
|
10
|
-
To summarize:
|
11
|
-
|
12
|
-
* The library has been broken out into four libraries. The new gems
|
13
|
-
`google-cloud-tasks-v2`, `google-cloud-tasks-v2beta2`, and `google-cloud-tasks-v2beta3` contain the
|
14
|
-
actual client classes for the various versions of the Cloud Tasks
|
15
|
-
service, and the gem `google-cloud-tasks` now simply provides a
|
16
|
-
convenience wrapper. See [Library Structure](#library-structure) for more
|
17
|
-
info.
|
18
|
-
* The library uses a new configuration mechanism giving you closer control
|
19
|
-
over endpoint address, network timeouts, and retry. See
|
20
|
-
[Client Configuration](#client-configuration) for more info. Furthermore,
|
21
|
-
when creating a client object, you can customize its configuration in a
|
22
|
-
block rather than passing arguments to the constructor. See
|
23
|
-
[Creating Clients](#creating-clients) for more info.
|
24
|
-
* Previously, positional arguments were used to indicate required arguments.
|
25
|
-
Now, all method arguments are keyword arguments, with documentation that
|
26
|
-
specifies whether they are required or optional. Additionally, you can pass
|
27
|
-
a proto request object instead of separate arguments. See
|
28
|
-
[Passing Arguments](#passing-arguments) for more info.
|
29
|
-
* Previously, some client classes included helper methods for constructing
|
30
|
-
resource paths. These methods now take keyword rather than positional
|
31
|
-
arguments, and are also available in a separate paths module. See
|
32
|
-
[Resource Path Helpers](#resource-path-helpers) for more info.
|
33
|
-
* Previously, clients reported RPC errors by raising instances of
|
34
|
-
`Google::Gax::GaxError` and its subclasses. Now, RPC exceptions are of type
|
35
|
-
`Google::Cloud::Error` and its subclasses. See
|
36
|
-
[Handling Errors](#handling-errors) for more info.
|
37
|
-
* Some classes have moved into different namespaces. See
|
38
|
-
[Class Namespaces](#class-namespaces) for more info.
|
39
|
-
|
40
|
-
### Library Structure
|
41
|
-
|
42
|
-
Older 1.x releases of the `google-cloud-tasks` gem were all-in-one gems that
|
43
|
-
included potentially multiple clients for multiple versions of the Cloud
|
44
|
-
Tasks service. The `Google::Cloud::Tasks.new` factory method would
|
45
|
-
return you an instance of a `Google::Cloud::Tasks::V2::CloudTasksClient`
|
46
|
-
object for the V2 version of the service (or other corresponding classes for
|
47
|
-
other versions of the service). All these classes were defined in the same gem.
|
48
|
-
|
49
|
-
With the 2.0 release, the `google-cloud-tasks` gem still provides factory
|
50
|
-
methods for obtaining clients. (The method signatures will have changed. See
|
51
|
-
[Creating Clients](#creating-clients) for details.) However, the actual client
|
52
|
-
classes have been moved into separate gems, one per service version. The
|
53
|
-
`Google::Cloud::Tasks::V2::CloudTasks::Client` class, along with its
|
54
|
-
helpers and data types, is now part of the `google-cloud-tasks-v2` gem.
|
55
|
-
Corresponding classes for other versions of the service are similarly moved to
|
56
|
-
other gems with the version in the gem name.
|
57
|
-
|
58
|
-
For normal usage, you can continue to install the `google-cloud-tasks` gem
|
59
|
-
(which will bring in the versioned client gems as dependencies) and continue to
|
60
|
-
use factory methods to create clients. However, you may alternatively choose to
|
61
|
-
install only one of the versioned gems. For example, if you know you will use only
|
62
|
-
`V2` of the service, you can install `google-cloud-tasks-v2` by itself, and
|
63
|
-
construct instances of the
|
64
|
-
`Google::Cloud::Tasks::V2::CloudTasks::Client` client class directly.
|
65
|
-
|
66
|
-
### Client Configuration
|
67
|
-
|
68
|
-
In older releases, if you wanted to customize performance parameters or
|
69
|
-
low-level behavior of the client (such as credentials, timeouts, or
|
70
|
-
instrumentation), you would pass a variety of keyword arguments to the client
|
71
|
-
constructor. It was also extremely difficult to customize the default settings.
|
72
|
-
|
73
|
-
With the 2.0 release, a configuration interface provides control over these
|
74
|
-
parameters, including defaults for all instances of a client, and settings for
|
75
|
-
each specific client instance. For example, to set default credentials and
|
76
|
-
timeout for all Tasks V1 clients:
|
77
|
-
|
78
|
-
```
|
79
|
-
Google::Cloud::Tasks::V2::CloudTasks::Client.configure do |config|
|
80
|
-
config.credentials = "/path/to/credentials.json"
|
81
|
-
config.timeout = 10.0
|
82
|
-
end
|
83
|
-
```
|
84
|
-
|
85
|
-
Individual RPCs can also be configured independently. For example, to set the
|
86
|
-
timeout for the `list_queues` call:
|
87
|
-
|
88
|
-
```
|
89
|
-
Google::Cloud::Tasks::V2::CloudTasks::Client.configure do |config|
|
90
|
-
config.rpcs.list_queues.timeout = 20.0
|
91
|
-
end
|
92
|
-
```
|
93
|
-
|
94
|
-
Defaults for certain configurations can be set for all Cloud Tasks versions
|
95
|
-
globally:
|
96
|
-
|
97
|
-
```
|
98
|
-
Google::Cloud::Tasks.configure do |config|
|
99
|
-
config.credentials = "/path/to/credentials.json"
|
100
|
-
config.timeout = 10.0
|
101
|
-
end
|
102
|
-
```
|
103
|
-
|
104
|
-
Finally, you can override the configuration for each client instance. See the
|
105
|
-
next section on [Creating Clients](#creating-clients) for details.
|
106
|
-
|
107
|
-
### Creating Clients
|
108
|
-
|
109
|
-
In older releases, to create a client object, you would use the
|
110
|
-
`Google::Cloud::Tasks.new` class method. Keyword arguments were available to
|
111
|
-
select a service version and to configure parameters such as credentials and
|
112
|
-
timeouts.
|
113
|
-
|
114
|
-
With the 2.0 release, use the `Google::Cloud::Tasks.cloud_tasks` class
|
115
|
-
method to create a client object. You may select a service version using the
|
116
|
-
`:version` keyword argument. However, other configuration parameters should be
|
117
|
-
set in a configuration block when you create the client.
|
118
|
-
|
119
|
-
Old:
|
120
|
-
```
|
121
|
-
client = Google::Cloud::Tasks.new credentials: "/path/to/credentials.json"
|
122
|
-
```
|
123
|
-
|
124
|
-
New:
|
125
|
-
```
|
126
|
-
client = Google::Cloud::Tasks.cloud_tasks do |config|
|
127
|
-
config.credentials = "/path/to/credentials.json"
|
128
|
-
end
|
129
|
-
```
|
130
|
-
|
131
|
-
The configuration block is optional. If you do not provide it, or you do not
|
132
|
-
set some configuration parameters, then the default configuration is used. See
|
133
|
-
[Client Configuration](#client-configuration).
|
134
|
-
|
135
|
-
### Passing Arguments
|
136
|
-
|
137
|
-
In older releases, required arguments would be passed as positional method
|
138
|
-
arguments, while optional arguments would be passed as keyword arguments.
|
139
|
-
|
140
|
-
With the 2.0 release, all RPC arguments are passed as keyword arguments,
|
141
|
-
regardless of whether they are required or optional. For example:
|
142
|
-
|
143
|
-
Old:
|
144
|
-
```
|
145
|
-
client = Google::Cloud::Tasks.new
|
146
|
-
|
147
|
-
parent = "projects/my-project/locations/-"
|
148
|
-
|
149
|
-
# Parent is a positional argument, while page_size is a keyword argument.
|
150
|
-
response = client.list_queues parent, page_size: 10
|
151
|
-
```
|
152
|
-
|
153
|
-
New:
|
154
|
-
```
|
155
|
-
client = Google::Cloud::Tasks.cloud_tasks
|
156
|
-
|
157
|
-
parent = "projects/my-project/locations/-"
|
158
|
-
|
159
|
-
# Both parent and page_size are keyword arguments.
|
160
|
-
response = client.list_queues parent: parent, page_size: 10
|
161
|
-
```
|
162
|
-
|
163
|
-
In the 2.0 release, it is also possible to pass a request object, either
|
164
|
-
as a hash or as a protocol buffer.
|
165
|
-
|
166
|
-
New:
|
167
|
-
```
|
168
|
-
client = Google::Cloud::Tasks.cloud_tasks
|
169
|
-
|
170
|
-
request = Google::Cloud::Tasks::V2::ListQueuesRequest.new(
|
171
|
-
parent: "projects/my-project/locations/-",
|
172
|
-
page_size: 10
|
173
|
-
)
|
174
|
-
|
175
|
-
# Pass a request object as a positional argument:
|
176
|
-
response = client.list_queues request
|
177
|
-
```
|
178
|
-
|
179
|
-
Finally, in older releases, to provide call options, you would pass a
|
180
|
-
`Google::Gax::CallOptions` object with the `:options` keyword argument. In the
|
181
|
-
2.0 release, pass call options using a _second set_ of keyword arguments.
|
182
|
-
|
183
|
-
Old:
|
184
|
-
```
|
185
|
-
client = Google::Cloud::Tasks.new
|
186
|
-
|
187
|
-
parent = "projects/my-project/locations/-"
|
188
|
-
|
189
|
-
options = Google::Gax::CallOptions.new timeout: 10.0
|
190
|
-
|
191
|
-
response = client.list_queues parent, page_size: 10, options: options
|
192
|
-
```
|
193
|
-
|
194
|
-
New:
|
195
|
-
```
|
196
|
-
client = Google::Cloud::Tasks.cloud_tasks
|
197
|
-
|
198
|
-
parent = "projects/my-project/locations/-"
|
199
|
-
|
200
|
-
# Use a hash to wrap the normal call arguments (or pass a request object), and
|
201
|
-
# then add further keyword arguments for the call options.
|
202
|
-
response = client.list_queues(
|
203
|
-
{ parent: parent, page_size: 10 },
|
204
|
-
timeout: 10.0
|
205
|
-
)
|
206
|
-
```
|
207
|
-
|
208
|
-
### Resource Path Helpers
|
209
|
-
|
210
|
-
The client library includes helper methods for generating the resource path
|
211
|
-
strings passed to many calls. These helpers have changed in two ways:
|
212
|
-
|
213
|
-
* In older releases, they are both _class_ methods and _instance_ methods on
|
214
|
-
the client class. In the 2.0 release, they are _instance methods only_.
|
215
|
-
However, they are also available on a separate paths module that you can
|
216
|
-
include elsewhere for convenience.
|
217
|
-
* In older releases, arguments to a resource path helper are passed as
|
218
|
-
_positional_ arguments. In the 2.0 release, they are passed as named _keyword_
|
219
|
-
arguments.
|
220
|
-
|
221
|
-
Following is an example involving using a resource path helper.
|
222
|
-
|
223
|
-
Old:
|
224
|
-
```
|
225
|
-
client = Google::Cloud::Tasks.new
|
226
|
-
|
227
|
-
# Call the helper using positional arguments.
|
228
|
-
parent = client.location_path "my-project", "-"
|
229
|
-
|
230
|
-
response = client.list_queues parent
|
231
|
-
```
|
232
|
-
|
233
|
-
New:
|
234
|
-
```
|
235
|
-
client = Google::Cloud::Tasks.cloud_tasks
|
236
|
-
|
237
|
-
# Call the helper using keyword arguments
|
238
|
-
parent = client.location_path project: "my-project", location: "-"
|
239
|
-
|
240
|
-
response = client.list_queues parent: parent
|
241
|
-
```
|
242
|
-
|
243
|
-
In the 2.0 client, you can also use the paths module as a convenience module.
|
244
|
-
|
245
|
-
New:
|
246
|
-
```
|
247
|
-
# Bring the path helper methods into the current class
|
248
|
-
include Google::Cloud::Tasks::V2::CloudTasks::Paths
|
249
|
-
|
250
|
-
def foo
|
251
|
-
client = Google::Cloud::Tasks.cloud_tasks
|
252
|
-
|
253
|
-
# Call the included helper method
|
254
|
-
parent = location_path project: "my-project", location: "-"
|
255
|
-
|
256
|
-
response = client.list_queues parent: parent
|
257
|
-
|
258
|
-
# Do something with response...
|
259
|
-
end
|
260
|
-
```
|
261
|
-
|
262
|
-
### Handling Errors
|
263
|
-
|
264
|
-
The client reports standard
|
265
|
-
[gRPC error codes](https://github.com/grpc/grpc/blob/master/doc/statuscodes.md)
|
266
|
-
by raising exceptions. In older releases, these exceptions were located in the
|
267
|
-
`Google::Gax` namespace and were subclasses of the `Google::Gax::GaxError` base
|
268
|
-
exception class, defined in the `google-gax` gem. However, these classes were
|
269
|
-
different from the standard exceptions (subclasses of `Google::Cloud::Error`)
|
270
|
-
thrown by other client libraries such as `google-cloud-storage`.
|
271
|
-
|
272
|
-
The 2.0 client library now uses the `Google::Cloud::Error` exception hierarchy,
|
273
|
-
for consistency across all the Google Cloud client libraries. In general, these
|
274
|
-
exceptions have the same name as their counterparts from older releases, but
|
275
|
-
are located in the `Google::Cloud` namespace rather than the `Google::Gax`
|
276
|
-
namespace.
|
277
|
-
|
278
|
-
Old:
|
279
|
-
```
|
280
|
-
client = Google::Cloud::Tasks.new
|
281
|
-
|
282
|
-
parent = "projects/my-project/locations/-"
|
283
|
-
|
284
|
-
begin
|
285
|
-
response = client.list_queues parent, page_size: 10
|
286
|
-
rescue Google::Gax::Error => e
|
287
|
-
# Handle exceptions that subclass Google::Gax::Error
|
288
|
-
end
|
289
|
-
```
|
290
|
-
|
291
|
-
New:
|
292
|
-
```
|
293
|
-
client = Google::Cloud::Tasks.cloud_tasks
|
294
|
-
|
295
|
-
parent = "projects/my-project/locations/-"
|
296
|
-
|
297
|
-
begin
|
298
|
-
response = client.list_queues parent: parent, page_size: 10
|
299
|
-
rescue Google::Cloud::Error => e
|
300
|
-
# Handle exceptions that subclass Google::Cloud::Error
|
301
|
-
end
|
302
|
-
```
|
303
|
-
|
304
|
-
### Class Namespaces
|
305
|
-
|
306
|
-
In older releases, the client object was of class
|
307
|
-
`Google::Cloud::Tasks::V2::CloudTasksClient`.
|
308
|
-
In the 2.0 release, the client object is of class
|
309
|
-
`Google::Cloud::Tasks::V2::CloudTasks::Client`.
|
310
|
-
Note that most users will use the `Google::Cloud::Tasks.cloud_tasks`
|
311
|
-
factory method to create instances of the client object, so you may not need to
|
312
|
-
reference the actual class directly.
|
313
|
-
See [Creating Clients](#creating-clients).
|
314
|
-
|
315
|
-
In older releases, the credentials object was of class
|
316
|
-
`Google::Cloud::Tasks::V2::Credentials`.
|
317
|
-
In the 2.0 release, the credentials object is of class
|
318
|
-
`Google::Cloud::Tasks::V2::CloudTasks::Credentials`.
|
319
|
-
Again, most users will not need to reference this class directly.
|
320
|
-
See [Client Configuration](#client-configuration).
|