google-cloud-tasks 1.5.0 → 2.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +2 -1
  3. data/AUTHENTICATION.md +51 -59
  4. data/LICENSE.md +203 -0
  5. data/MIGRATING.md +320 -0
  6. data/README.md +37 -24
  7. data/lib/{google/cloud/tasks/v2beta2/doc/google/protobuf/empty.rb → google-cloud-tasks.rb} +4 -14
  8. data/lib/google/cloud/tasks.rb +88 -117
  9. data/lib/google/cloud/tasks/version.rb +6 -2
  10. metadata +78 -115
  11. data/LICENSE +0 -201
  12. data/lib/google/cloud/tasks/v2.rb +0 -147
  13. data/lib/google/cloud/tasks/v2/cloud_tasks_client.rb +0 -1233
  14. data/lib/google/cloud/tasks/v2/cloud_tasks_client_config.json +0 -106
  15. data/lib/google/cloud/tasks/v2/cloudtasks_pb.rb +0 -100
  16. data/lib/google/cloud/tasks/v2/cloudtasks_services_pb.rb +0 -203
  17. data/lib/google/cloud/tasks/v2/credentials.rb +0 -41
  18. data/lib/google/cloud/tasks/v2/doc/google/cloud/tasks/v2/cloudtasks.rb +0 -312
  19. data/lib/google/cloud/tasks/v2/doc/google/cloud/tasks/v2/queue.rb +0 -348
  20. data/lib/google/cloud/tasks/v2/doc/google/cloud/tasks/v2/target.rb +0 -414
  21. data/lib/google/cloud/tasks/v2/doc/google/cloud/tasks/v2/task.rb +0 -175
  22. data/lib/google/cloud/tasks/v2/doc/google/iam/v1/iam_policy.rb +0 -64
  23. data/lib/google/cloud/tasks/v2/doc/google/iam/v1/options.rb +0 -33
  24. data/lib/google/cloud/tasks/v2/doc/google/iam/v1/policy.rb +0 -151
  25. data/lib/google/cloud/tasks/v2/doc/google/protobuf/any.rb +0 -131
  26. data/lib/google/cloud/tasks/v2/doc/google/protobuf/duration.rb +0 -91
  27. data/lib/google/cloud/tasks/v2/doc/google/protobuf/empty.rb +0 -29
  28. data/lib/google/cloud/tasks/v2/doc/google/protobuf/field_mask.rb +0 -222
  29. data/lib/google/cloud/tasks/v2/doc/google/protobuf/timestamp.rb +0 -113
  30. data/lib/google/cloud/tasks/v2/doc/google/rpc/status.rb +0 -39
  31. data/lib/google/cloud/tasks/v2/doc/google/type/expr.rb +0 -45
  32. data/lib/google/cloud/tasks/v2/helpers.rb +0 -49
  33. data/lib/google/cloud/tasks/v2/queue_pb.rb +0 -56
  34. data/lib/google/cloud/tasks/v2/target_pb.rb +0 -66
  35. data/lib/google/cloud/tasks/v2/task_pb.rb +0 -51
  36. data/lib/google/cloud/tasks/v2beta2.rb +0 -147
  37. data/lib/google/cloud/tasks/v2beta2/cloud_tasks_client.rb +0 -1605
  38. data/lib/google/cloud/tasks/v2beta2/cloud_tasks_client_config.json +0 -126
  39. data/lib/google/cloud/tasks/v2beta2/cloudtasks_pb.rb +0 -133
  40. data/lib/google/cloud/tasks/v2beta2/cloudtasks_services_pb.rb +0 -258
  41. data/lib/google/cloud/tasks/v2beta2/credentials.rb +0 -41
  42. data/lib/google/cloud/tasks/v2beta2/doc/google/cloud/tasks/v2beta2/cloudtasks.rb +0 -483
  43. data/lib/google/cloud/tasks/v2beta2/doc/google/cloud/tasks/v2beta2/queue.rb +0 -336
  44. data/lib/google/cloud/tasks/v2beta2/doc/google/cloud/tasks/v2beta2/target.rb +0 -377
  45. data/lib/google/cloud/tasks/v2beta2/doc/google/cloud/tasks/v2beta2/task.rb +0 -166
  46. data/lib/google/cloud/tasks/v2beta2/doc/google/iam/v1/iam_policy.rb +0 -64
  47. data/lib/google/cloud/tasks/v2beta2/doc/google/iam/v1/options.rb +0 -33
  48. data/lib/google/cloud/tasks/v2beta2/doc/google/iam/v1/policy.rb +0 -151
  49. data/lib/google/cloud/tasks/v2beta2/doc/google/protobuf/any.rb +0 -131
  50. data/lib/google/cloud/tasks/v2beta2/doc/google/protobuf/duration.rb +0 -91
  51. data/lib/google/cloud/tasks/v2beta2/doc/google/protobuf/field_mask.rb +0 -222
  52. data/lib/google/cloud/tasks/v2beta2/doc/google/protobuf/timestamp.rb +0 -113
  53. data/lib/google/cloud/tasks/v2beta2/doc/google/rpc/status.rb +0 -39
  54. data/lib/google/cloud/tasks/v2beta2/doc/google/type/expr.rb +0 -45
  55. data/lib/google/cloud/tasks/v2beta2/helpers.rb +0 -49
  56. data/lib/google/cloud/tasks/v2beta2/queue_pb.rb +0 -58
  57. data/lib/google/cloud/tasks/v2beta2/target_pb.rb +0 -54
  58. data/lib/google/cloud/tasks/v2beta2/task_pb.rb +0 -54
  59. data/lib/google/cloud/tasks/v2beta3.rb +0 -147
  60. data/lib/google/cloud/tasks/v2beta3/cloud_tasks_client.rb +0 -1233
  61. data/lib/google/cloud/tasks/v2beta3/cloud_tasks_client_config.json +0 -106
  62. data/lib/google/cloud/tasks/v2beta3/cloudtasks_pb.rb +0 -101
  63. data/lib/google/cloud/tasks/v2beta3/cloudtasks_services_pb.rb +0 -203
  64. data/lib/google/cloud/tasks/v2beta3/credentials.rb +0 -41
  65. data/lib/google/cloud/tasks/v2beta3/doc/google/cloud/tasks/v2beta3/cloudtasks.rb +0 -312
  66. data/lib/google/cloud/tasks/v2beta3/doc/google/cloud/tasks/v2beta3/queue.rb +0 -342
  67. data/lib/google/cloud/tasks/v2beta3/doc/google/cloud/tasks/v2beta3/target.rb +0 -431
  68. data/lib/google/cloud/tasks/v2beta3/doc/google/cloud/tasks/v2beta3/task.rb +0 -177
  69. data/lib/google/cloud/tasks/v2beta3/doc/google/iam/v1/iam_policy.rb +0 -64
  70. data/lib/google/cloud/tasks/v2beta3/doc/google/iam/v1/options.rb +0 -33
  71. data/lib/google/cloud/tasks/v2beta3/doc/google/iam/v1/policy.rb +0 -151
  72. data/lib/google/cloud/tasks/v2beta3/doc/google/protobuf/any.rb +0 -131
  73. data/lib/google/cloud/tasks/v2beta3/doc/google/protobuf/duration.rb +0 -91
  74. data/lib/google/cloud/tasks/v2beta3/doc/google/protobuf/empty.rb +0 -29
  75. data/lib/google/cloud/tasks/v2beta3/doc/google/protobuf/field_mask.rb +0 -222
  76. data/lib/google/cloud/tasks/v2beta3/doc/google/protobuf/timestamp.rb +0 -113
  77. data/lib/google/cloud/tasks/v2beta3/doc/google/rpc/status.rb +0 -39
  78. data/lib/google/cloud/tasks/v2beta3/doc/google/type/expr.rb +0 -45
  79. data/lib/google/cloud/tasks/v2beta3/helpers.rb +0 -49
  80. data/lib/google/cloud/tasks/v2beta3/queue_pb.rb +0 -59
  81. data/lib/google/cloud/tasks/v2beta3/target_pb.rb +0 -69
  82. data/lib/google/cloud/tasks/v2beta3/task_pb.rb +0 -52
@@ -1,49 +0,0 @@
1
- # Copyright 2018 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
- module Google
15
- module Cloud
16
- module Tasks
17
- module V2
18
- class CloudTasksClient
19
- # Alias for Google::Cloud::Tasks::V2::CloudTasksClient.location_path.
20
- # @param project [String]
21
- # @param location [String]
22
- # @return [String]
23
- def location_path project, location
24
- self.class.location_path project, location
25
- end
26
-
27
- # Alias for Google::Cloud::Tasks::V2::CloudTasksClient.queue_path.
28
- # @param project [String]
29
- # @param location [String]
30
- # @param queue [String]
31
- # @return [String]
32
- def queue_path project, location, queue
33
- self.class.queue_path project, location, queue
34
- end
35
-
36
- # Alias for Google::Cloud::Tasks::V2::CloudTasksClient.task_path.
37
- # @param project [String]
38
- # @param location [String]
39
- # @param queue [String]
40
- # @param task [String]
41
- # @return [String]
42
- def task_path project, location, queue, task
43
- self.class.task_path project, location, queue, task
44
- end
45
- end
46
- end
47
- end
48
- end
49
- end
@@ -1,56 +0,0 @@
1
- # Generated by the protocol buffer compiler. DO NOT EDIT!
2
- # source: google/cloud/tasks/v2/queue.proto
3
-
4
-
5
- require 'google/protobuf'
6
-
7
- require 'google/cloud/tasks/v2/target_pb'
8
- require 'google/protobuf/duration_pb'
9
- require 'google/protobuf/timestamp_pb'
10
- require 'google/api/annotations_pb'
11
- Google::Protobuf::DescriptorPool.generated_pool.build do
12
- add_message "google.cloud.tasks.v2.Queue" do
13
- optional :name, :string, 1
14
- optional :app_engine_routing_override, :message, 2, "google.cloud.tasks.v2.AppEngineRouting"
15
- optional :rate_limits, :message, 3, "google.cloud.tasks.v2.RateLimits"
16
- optional :retry_config, :message, 4, "google.cloud.tasks.v2.RetryConfig"
17
- optional :state, :enum, 5, "google.cloud.tasks.v2.Queue.State"
18
- optional :purge_time, :message, 6, "google.protobuf.Timestamp"
19
- optional :stackdriver_logging_config, :message, 9, "google.cloud.tasks.v2.StackdriverLoggingConfig"
20
- end
21
- add_enum "google.cloud.tasks.v2.Queue.State" do
22
- value :STATE_UNSPECIFIED, 0
23
- value :RUNNING, 1
24
- value :PAUSED, 2
25
- value :DISABLED, 3
26
- end
27
- add_message "google.cloud.tasks.v2.RateLimits" do
28
- optional :max_dispatches_per_second, :double, 1
29
- optional :max_burst_size, :int32, 2
30
- optional :max_concurrent_dispatches, :int32, 3
31
- end
32
- add_message "google.cloud.tasks.v2.RetryConfig" do
33
- optional :max_attempts, :int32, 1
34
- optional :max_retry_duration, :message, 2, "google.protobuf.Duration"
35
- optional :min_backoff, :message, 3, "google.protobuf.Duration"
36
- optional :max_backoff, :message, 4, "google.protobuf.Duration"
37
- optional :max_doublings, :int32, 5
38
- end
39
- add_message "google.cloud.tasks.v2.StackdriverLoggingConfig" do
40
- optional :sampling_ratio, :double, 1
41
- end
42
- end
43
-
44
- module Google
45
- module Cloud
46
- module Tasks
47
- module V2
48
- Queue = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.tasks.v2.Queue").msgclass
49
- Queue::State = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.tasks.v2.Queue.State").enummodule
50
- RateLimits = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.tasks.v2.RateLimits").msgclass
51
- RetryConfig = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.tasks.v2.RetryConfig").msgclass
52
- StackdriverLoggingConfig = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.tasks.v2.StackdriverLoggingConfig").msgclass
53
- end
54
- end
55
- end
56
- end
@@ -1,66 +0,0 @@
1
- # Generated by the protocol buffer compiler. DO NOT EDIT!
2
- # source: google/cloud/tasks/v2/target.proto
3
-
4
-
5
- require 'google/protobuf'
6
-
7
- require 'google/api/field_behavior_pb'
8
- require 'google/api/annotations_pb'
9
- Google::Protobuf::DescriptorPool.generated_pool.build do
10
- add_message "google.cloud.tasks.v2.HttpRequest" do
11
- optional :url, :string, 1
12
- optional :http_method, :enum, 2, "google.cloud.tasks.v2.HttpMethod"
13
- map :headers, :string, :string, 3
14
- optional :body, :bytes, 4
15
- oneof :authorization_header do
16
- optional :oauth_token, :message, 5, "google.cloud.tasks.v2.OAuthToken"
17
- optional :oidc_token, :message, 6, "google.cloud.tasks.v2.OidcToken"
18
- end
19
- end
20
- add_message "google.cloud.tasks.v2.AppEngineHttpRequest" do
21
- optional :http_method, :enum, 1, "google.cloud.tasks.v2.HttpMethod"
22
- optional :app_engine_routing, :message, 2, "google.cloud.tasks.v2.AppEngineRouting"
23
- optional :relative_uri, :string, 3
24
- map :headers, :string, :string, 4
25
- optional :body, :bytes, 5
26
- end
27
- add_message "google.cloud.tasks.v2.AppEngineRouting" do
28
- optional :service, :string, 1
29
- optional :version, :string, 2
30
- optional :instance, :string, 3
31
- optional :host, :string, 4
32
- end
33
- add_message "google.cloud.tasks.v2.OAuthToken" do
34
- optional :service_account_email, :string, 1
35
- optional :scope, :string, 2
36
- end
37
- add_message "google.cloud.tasks.v2.OidcToken" do
38
- optional :service_account_email, :string, 1
39
- optional :audience, :string, 2
40
- end
41
- add_enum "google.cloud.tasks.v2.HttpMethod" do
42
- value :HTTP_METHOD_UNSPECIFIED, 0
43
- value :POST, 1
44
- value :GET, 2
45
- value :HEAD, 3
46
- value :PUT, 4
47
- value :DELETE, 5
48
- value :PATCH, 6
49
- value :OPTIONS, 7
50
- end
51
- end
52
-
53
- module Google
54
- module Cloud
55
- module Tasks
56
- module V2
57
- HttpRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.tasks.v2.HttpRequest").msgclass
58
- AppEngineHttpRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.tasks.v2.AppEngineHttpRequest").msgclass
59
- AppEngineRouting = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.tasks.v2.AppEngineRouting").msgclass
60
- OAuthToken = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.tasks.v2.OAuthToken").msgclass
61
- OidcToken = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.tasks.v2.OidcToken").msgclass
62
- HttpMethod = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.tasks.v2.HttpMethod").enummodule
63
- end
64
- end
65
- end
66
- end
@@ -1,51 +0,0 @@
1
- # Generated by the protocol buffer compiler. DO NOT EDIT!
2
- # source: google/cloud/tasks/v2/task.proto
3
-
4
-
5
- require 'google/protobuf'
6
-
7
- require 'google/cloud/tasks/v2/target_pb'
8
- require 'google/protobuf/duration_pb'
9
- require 'google/protobuf/timestamp_pb'
10
- require 'google/rpc/status_pb'
11
- require 'google/api/annotations_pb'
12
- Google::Protobuf::DescriptorPool.generated_pool.build do
13
- add_message "google.cloud.tasks.v2.Task" do
14
- optional :name, :string, 1
15
- optional :schedule_time, :message, 4, "google.protobuf.Timestamp"
16
- optional :create_time, :message, 5, "google.protobuf.Timestamp"
17
- optional :dispatch_deadline, :message, 6, "google.protobuf.Duration"
18
- optional :dispatch_count, :int32, 7
19
- optional :response_count, :int32, 8
20
- optional :first_attempt, :message, 9, "google.cloud.tasks.v2.Attempt"
21
- optional :last_attempt, :message, 10, "google.cloud.tasks.v2.Attempt"
22
- optional :view, :enum, 11, "google.cloud.tasks.v2.Task.View"
23
- oneof :message_type do
24
- optional :app_engine_http_request, :message, 2, "google.cloud.tasks.v2.AppEngineHttpRequest"
25
- optional :http_request, :message, 3, "google.cloud.tasks.v2.HttpRequest"
26
- end
27
- end
28
- add_enum "google.cloud.tasks.v2.Task.View" do
29
- value :VIEW_UNSPECIFIED, 0
30
- value :BASIC, 1
31
- value :FULL, 2
32
- end
33
- add_message "google.cloud.tasks.v2.Attempt" do
34
- optional :schedule_time, :message, 1, "google.protobuf.Timestamp"
35
- optional :dispatch_time, :message, 2, "google.protobuf.Timestamp"
36
- optional :response_time, :message, 3, "google.protobuf.Timestamp"
37
- optional :response_status, :message, 4, "google.rpc.Status"
38
- end
39
- end
40
-
41
- module Google
42
- module Cloud
43
- module Tasks
44
- module V2
45
- Task = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.tasks.v2.Task").msgclass
46
- Task::View = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.tasks.v2.Task.View").enummodule
47
- Attempt = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.tasks.v2.Attempt").msgclass
48
- end
49
- end
50
- end
51
- end
@@ -1,147 +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/tasks/v2beta2/cloud_tasks_client"
17
- require "google/cloud/tasks/v2beta2/helpers"
18
-
19
- module Google
20
- module Cloud
21
- module Tasks
22
- # rubocop:disable LineLength
23
-
24
- ##
25
- # # Ruby Client for Cloud Tasks API
26
- #
27
- # [Cloud Tasks API][Product Documentation]:
28
- # Manages the execution of large numbers of distributed requests.
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 billing for your project.](https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project)
37
- # 3. [Enable the Cloud Tasks API.](https://console.cloud.google.com/apis/library/tasks.googleapis.com)
38
- # 4. [Setup Authentication.](https://googleapis.dev/ruby/google-cloud-tasks/latest/file.AUTHENTICATION.html)
39
- #
40
- # ### Installation
41
- # ```
42
- # $ gem install google-cloud-tasks
43
- # ```
44
- #
45
- # ### Next Steps
46
- # - Read the [Cloud Tasks API Product documentation][Product Documentation]
47
- # to learn more about the product and see How-to Guides.
48
- # - View this [repository's main README](https://github.com/googleapis/google-cloud-ruby/blob/master/README.md)
49
- # to see the full list of Cloud APIs that we cover.
50
- #
51
- # [Product Documentation]: https://cloud.google.com/tasks
52
- #
53
- # ## Enabling Logging
54
- #
55
- # To enable logging for this library, set the logger for the underlying [gRPC](https://github.com/grpc/grpc/tree/master/src/ruby) library.
56
- # 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,
57
- # or a [`Google::Cloud::Logging::Logger`](https://googleapis.dev/ruby/google-cloud-logging/latest)
58
- # 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)
59
- # and the gRPC [spec_helper.rb](https://github.com/grpc/grpc/blob/master/src/ruby/spec/spec_helper.rb) for additional information.
60
- #
61
- # Configuring a Ruby stdlib logger:
62
- #
63
- # ```ruby
64
- # require "logger"
65
- #
66
- # module MyLogger
67
- # LOGGER = Logger.new $stderr, level: Logger::WARN
68
- # def logger
69
- # LOGGER
70
- # end
71
- # end
72
- #
73
- # # Define a gRPC module-level logger method before grpc/logconfig.rb loads.
74
- # module GRPC
75
- # extend MyLogger
76
- # end
77
- # ```
78
- #
79
- module V2beta2
80
- # rubocop:enable LineLength
81
-
82
- ##
83
- # Cloud Tasks allows developers to manage the execution of background
84
- # work in their applications.
85
- #
86
- # @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
87
- # Provides the means for authenticating requests made by the client. This parameter can
88
- # be many types.
89
- # A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
90
- # authenticating requests made by this client.
91
- # A `String` will be treated as the path to the keyfile to be used for the construction of
92
- # credentials for this client.
93
- # A `Hash` will be treated as the contents of a keyfile to be used for the construction of
94
- # credentials for this client.
95
- # A `GRPC::Core::Channel` will be used to make calls through.
96
- # A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
97
- # should already be composed with a `GRPC::Core::CallCredentials` object.
98
- # A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
99
- # metadata for requests, generally, to give OAuth credentials.
100
- # @param scopes [Array<String>]
101
- # The OAuth scopes for this service. This parameter is ignored if
102
- # an updater_proc is supplied.
103
- # @param client_config [Hash]
104
- # A Hash for call options for each method. See
105
- # Google::Gax#construct_settings for the structure of
106
- # this data. Falls back to the default config if not specified
107
- # or the specified config is missing data points.
108
- # @param timeout [Numeric]
109
- # The default timeout, in seconds, for calls made through this client.
110
- # @param metadata [Hash]
111
- # Default metadata to be sent with each request. This can be overridden on a per call basis.
112
- # @param service_address [String]
113
- # Override for the service hostname, or `nil` to leave as the default.
114
- # @param service_port [Integer]
115
- # Override for the service port, or `nil` to leave as the default.
116
- # @param exception_transformer [Proc]
117
- # An optional proc that intercepts any exceptions raised during an API call to inject
118
- # custom error handling.
119
- def self.new \
120
- credentials: nil,
121
- scopes: nil,
122
- client_config: nil,
123
- timeout: nil,
124
- metadata: nil,
125
- service_address: nil,
126
- service_port: nil,
127
- exception_transformer: nil,
128
- lib_name: nil,
129
- lib_version: nil
130
- kwargs = {
131
- credentials: credentials,
132
- scopes: scopes,
133
- client_config: client_config,
134
- timeout: timeout,
135
- metadata: metadata,
136
- exception_transformer: exception_transformer,
137
- lib_name: lib_name,
138
- service_address: service_address,
139
- service_port: service_port,
140
- lib_version: lib_version
141
- }.select { |_, v| v != nil }
142
- Google::Cloud::Tasks::V2beta2::CloudTasksClient.new(**kwargs)
143
- end
144
- end
145
- end
146
- end
147
- end
@@ -1,1605 +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/cloud/tasks/v2beta2/cloudtasks.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
-
28
- require "google/cloud/tasks/v2beta2/cloudtasks_pb"
29
- require "google/cloud/tasks/v2beta2/credentials"
30
- require "google/cloud/tasks/version"
31
-
32
- module Google
33
- module Cloud
34
- module Tasks
35
- module V2beta2
36
- # Cloud Tasks allows developers to manage the execution of background
37
- # work in their applications.
38
- #
39
- # @!attribute [r] cloud_tasks_stub
40
- # @return [Google::Cloud::Tasks::V2beta2::CloudTasks::Stub]
41
- class CloudTasksClient
42
- # @private
43
- attr_reader :cloud_tasks_stub
44
-
45
- # The default address of the service.
46
- SERVICE_ADDRESS = "cloudtasks.googleapis.com".freeze
47
-
48
- # The default port of the service.
49
- DEFAULT_SERVICE_PORT = 443
50
-
51
- # The default set of gRPC interceptors.
52
- GRPC_INTERCEPTORS = []
53
-
54
- DEFAULT_TIMEOUT = 30
55
-
56
- PAGE_DESCRIPTORS = {
57
- "list_queues" => Google::Gax::PageDescriptor.new(
58
- "page_token",
59
- "next_page_token",
60
- "queues"),
61
- "list_tasks" => Google::Gax::PageDescriptor.new(
62
- "page_token",
63
- "next_page_token",
64
- "tasks")
65
- }.freeze
66
-
67
- private_constant :PAGE_DESCRIPTORS
68
-
69
- # The scopes needed to make gRPC calls to all of the methods defined in
70
- # this service.
71
- ALL_SCOPES = [
72
- "https://www.googleapis.com/auth/cloud-platform"
73
- ].freeze
74
-
75
-
76
- LOCATION_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
77
- "projects/{project}/locations/{location}"
78
- )
79
-
80
- private_constant :LOCATION_PATH_TEMPLATE
81
-
82
- QUEUE_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
83
- "projects/{project}/locations/{location}/queues/{queue}"
84
- )
85
-
86
- private_constant :QUEUE_PATH_TEMPLATE
87
-
88
- TASK_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
89
- "projects/{project}/locations/{location}/queues/{queue}/tasks/{task}"
90
- )
91
-
92
- private_constant :TASK_PATH_TEMPLATE
93
-
94
- # Returns a fully-qualified location resource name string.
95
- # @param project [String]
96
- # @param location [String]
97
- # @return [String]
98
- def self.location_path project, location
99
- LOCATION_PATH_TEMPLATE.render(
100
- :"project" => project,
101
- :"location" => location
102
- )
103
- end
104
-
105
- # Returns a fully-qualified queue resource name string.
106
- # @param project [String]
107
- # @param location [String]
108
- # @param queue [String]
109
- # @return [String]
110
- def self.queue_path project, location, queue
111
- QUEUE_PATH_TEMPLATE.render(
112
- :"project" => project,
113
- :"location" => location,
114
- :"queue" => queue
115
- )
116
- end
117
-
118
- # Returns a fully-qualified task resource name string.
119
- # @param project [String]
120
- # @param location [String]
121
- # @param queue [String]
122
- # @param task [String]
123
- # @return [String]
124
- def self.task_path project, location, queue, task
125
- TASK_PATH_TEMPLATE.render(
126
- :"project" => project,
127
- :"location" => location,
128
- :"queue" => queue,
129
- :"task" => task
130
- )
131
- end
132
-
133
- # @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
134
- # Provides the means for authenticating requests made by the client. This parameter can
135
- # be many types.
136
- # A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
137
- # authenticating requests made by this client.
138
- # A `String` will be treated as the path to the keyfile to be used for the construction of
139
- # credentials for this client.
140
- # A `Hash` will be treated as the contents of a keyfile to be used for the construction of
141
- # credentials for this client.
142
- # A `GRPC::Core::Channel` will be used to make calls through.
143
- # A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
144
- # should already be composed with a `GRPC::Core::CallCredentials` object.
145
- # A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
146
- # metadata for requests, generally, to give OAuth credentials.
147
- # @param scopes [Array<String>]
148
- # The OAuth scopes for this service. This parameter is ignored if
149
- # an updater_proc is supplied.
150
- # @param client_config [Hash]
151
- # A Hash for call options for each method. See
152
- # Google::Gax#construct_settings for the structure of
153
- # this data. Falls back to the default config if not specified
154
- # or the specified config is missing data points.
155
- # @param timeout [Numeric]
156
- # The default timeout, in seconds, for calls made through this client.
157
- # @param metadata [Hash]
158
- # Default metadata to be sent with each request. This can be overridden on a per call basis.
159
- # @param service_address [String]
160
- # Override for the service hostname, or `nil` to leave as the default.
161
- # @param service_port [Integer]
162
- # Override for the service port, or `nil` to leave as the default.
163
- # @param exception_transformer [Proc]
164
- # An optional proc that intercepts any exceptions raised during an API call to inject
165
- # custom error handling.
166
- def initialize \
167
- credentials: nil,
168
- scopes: ALL_SCOPES,
169
- client_config: {},
170
- timeout: DEFAULT_TIMEOUT,
171
- metadata: nil,
172
- service_address: nil,
173
- service_port: nil,
174
- exception_transformer: nil,
175
- lib_name: nil,
176
- lib_version: ""
177
- # These require statements are intentionally placed here to initialize
178
- # the gRPC module only when it's required.
179
- # See https://github.com/googleapis/toolkit/issues/446
180
- require "google/gax/grpc"
181
- require "google/cloud/tasks/v2beta2/cloudtasks_services_pb"
182
-
183
- credentials ||= Google::Cloud::Tasks::V2beta2::Credentials.default
184
-
185
- if credentials.is_a?(String) || credentials.is_a?(Hash)
186
- updater_proc = Google::Cloud::Tasks::V2beta2::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::Tasks::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
- if credentials.respond_to?(:quota_project_id) && credentials.quota_project_id
211
- headers[:"x-goog-user-project"] = credentials.quota_project_id
212
- end
213
- headers.merge!(metadata) unless metadata.nil?
214
- client_config_file = Pathname.new(__dir__).join(
215
- "cloud_tasks_client_config.json"
216
- )
217
- defaults = client_config_file.open do |f|
218
- Google::Gax.construct_settings(
219
- "google.cloud.tasks.v2beta2.CloudTasks",
220
- JSON.parse(f.read),
221
- client_config,
222
- Google::Gax::Grpc::STATUS_CODE_NAMES,
223
- timeout,
224
- page_descriptors: PAGE_DESCRIPTORS,
225
- errors: Google::Gax::Grpc::API_ERRORS,
226
- metadata: headers
227
- )
228
- end
229
-
230
- # Allow overriding the service path/port in subclasses.
231
- service_path = service_address || self.class::SERVICE_ADDRESS
232
- port = service_port || self.class::DEFAULT_SERVICE_PORT
233
- interceptors = self.class::GRPC_INTERCEPTORS
234
- @cloud_tasks_stub = Google::Gax::Grpc.create_stub(
235
- service_path,
236
- port,
237
- chan_creds: chan_creds,
238
- channel: channel,
239
- updater_proc: updater_proc,
240
- scopes: scopes,
241
- interceptors: interceptors,
242
- &Google::Cloud::Tasks::V2beta2::CloudTasks::Stub.method(:new)
243
- )
244
-
245
- @list_queues = Google::Gax.create_api_call(
246
- @cloud_tasks_stub.method(:list_queues),
247
- defaults["list_queues"],
248
- exception_transformer: exception_transformer,
249
- params_extractor: proc do |request|
250
- {'parent' => request.parent}
251
- end
252
- )
253
- @get_queue = Google::Gax.create_api_call(
254
- @cloud_tasks_stub.method(:get_queue),
255
- defaults["get_queue"],
256
- exception_transformer: exception_transformer,
257
- params_extractor: proc do |request|
258
- {'name' => request.name}
259
- end
260
- )
261
- @create_queue = Google::Gax.create_api_call(
262
- @cloud_tasks_stub.method(:create_queue),
263
- defaults["create_queue"],
264
- exception_transformer: exception_transformer,
265
- params_extractor: proc do |request|
266
- {'parent' => request.parent}
267
- end
268
- )
269
- @update_queue = Google::Gax.create_api_call(
270
- @cloud_tasks_stub.method(:update_queue),
271
- defaults["update_queue"],
272
- exception_transformer: exception_transformer,
273
- params_extractor: proc do |request|
274
- {'queue.name' => request.queue.name}
275
- end
276
- )
277
- @delete_queue = Google::Gax.create_api_call(
278
- @cloud_tasks_stub.method(:delete_queue),
279
- defaults["delete_queue"],
280
- exception_transformer: exception_transformer,
281
- params_extractor: proc do |request|
282
- {'name' => request.name}
283
- end
284
- )
285
- @purge_queue = Google::Gax.create_api_call(
286
- @cloud_tasks_stub.method(:purge_queue),
287
- defaults["purge_queue"],
288
- exception_transformer: exception_transformer,
289
- params_extractor: proc do |request|
290
- {'name' => request.name}
291
- end
292
- )
293
- @pause_queue = Google::Gax.create_api_call(
294
- @cloud_tasks_stub.method(:pause_queue),
295
- defaults["pause_queue"],
296
- exception_transformer: exception_transformer,
297
- params_extractor: proc do |request|
298
- {'name' => request.name}
299
- end
300
- )
301
- @resume_queue = Google::Gax.create_api_call(
302
- @cloud_tasks_stub.method(:resume_queue),
303
- defaults["resume_queue"],
304
- exception_transformer: exception_transformer,
305
- params_extractor: proc do |request|
306
- {'name' => request.name}
307
- end
308
- )
309
- @get_iam_policy = Google::Gax.create_api_call(
310
- @cloud_tasks_stub.method(:get_iam_policy),
311
- defaults["get_iam_policy"],
312
- exception_transformer: exception_transformer,
313
- params_extractor: proc do |request|
314
- {'resource' => request.resource}
315
- end
316
- )
317
- @set_iam_policy = Google::Gax.create_api_call(
318
- @cloud_tasks_stub.method(:set_iam_policy),
319
- defaults["set_iam_policy"],
320
- exception_transformer: exception_transformer,
321
- params_extractor: proc do |request|
322
- {'resource' => request.resource}
323
- end
324
- )
325
- @test_iam_permissions = Google::Gax.create_api_call(
326
- @cloud_tasks_stub.method(:test_iam_permissions),
327
- defaults["test_iam_permissions"],
328
- exception_transformer: exception_transformer,
329
- params_extractor: proc do |request|
330
- {'resource' => request.resource}
331
- end
332
- )
333
- @list_tasks = Google::Gax.create_api_call(
334
- @cloud_tasks_stub.method(:list_tasks),
335
- defaults["list_tasks"],
336
- exception_transformer: exception_transformer,
337
- params_extractor: proc do |request|
338
- {'parent' => request.parent}
339
- end
340
- )
341
- @get_task = Google::Gax.create_api_call(
342
- @cloud_tasks_stub.method(:get_task),
343
- defaults["get_task"],
344
- exception_transformer: exception_transformer,
345
- params_extractor: proc do |request|
346
- {'name' => request.name}
347
- end
348
- )
349
- @create_task = Google::Gax.create_api_call(
350
- @cloud_tasks_stub.method(:create_task),
351
- defaults["create_task"],
352
- exception_transformer: exception_transformer,
353
- params_extractor: proc do |request|
354
- {'parent' => request.parent}
355
- end
356
- )
357
- @delete_task = Google::Gax.create_api_call(
358
- @cloud_tasks_stub.method(:delete_task),
359
- defaults["delete_task"],
360
- exception_transformer: exception_transformer,
361
- params_extractor: proc do |request|
362
- {'name' => request.name}
363
- end
364
- )
365
- @lease_tasks = Google::Gax.create_api_call(
366
- @cloud_tasks_stub.method(:lease_tasks),
367
- defaults["lease_tasks"],
368
- exception_transformer: exception_transformer,
369
- params_extractor: proc do |request|
370
- {'parent' => request.parent}
371
- end
372
- )
373
- @acknowledge_task = Google::Gax.create_api_call(
374
- @cloud_tasks_stub.method(:acknowledge_task),
375
- defaults["acknowledge_task"],
376
- exception_transformer: exception_transformer,
377
- params_extractor: proc do |request|
378
- {'name' => request.name}
379
- end
380
- )
381
- @renew_lease = Google::Gax.create_api_call(
382
- @cloud_tasks_stub.method(:renew_lease),
383
- defaults["renew_lease"],
384
- exception_transformer: exception_transformer,
385
- params_extractor: proc do |request|
386
- {'name' => request.name}
387
- end
388
- )
389
- @cancel_lease = Google::Gax.create_api_call(
390
- @cloud_tasks_stub.method(:cancel_lease),
391
- defaults["cancel_lease"],
392
- exception_transformer: exception_transformer,
393
- params_extractor: proc do |request|
394
- {'name' => request.name}
395
- end
396
- )
397
- @run_task = Google::Gax.create_api_call(
398
- @cloud_tasks_stub.method(:run_task),
399
- defaults["run_task"],
400
- exception_transformer: exception_transformer,
401
- params_extractor: proc do |request|
402
- {'name' => request.name}
403
- end
404
- )
405
- end
406
-
407
- # Service calls
408
-
409
- # Lists queues.
410
- #
411
- # Queues are returned in lexicographical order.
412
- #
413
- # @param parent [String]
414
- # Required. The location name.
415
- # For example: `projects/PROJECT_ID/locations/LOCATION_ID`
416
- # @param filter [String]
417
- # `filter` can be used to specify a subset of queues. Any {Google::Cloud::Tasks::V2beta2::Queue Queue}
418
- # field can be used as a filter and several operators as supported.
419
- # For example: `<=, <, >=, >, !=, =, :`. The filter syntax is the same as
420
- # described in
421
- # [Stackdriver's Advanced Logs
422
- # Filters](https://cloud.google.com/logging/docs/view/advanced_filters).
423
- #
424
- # Sample filter "app_engine_http_target: *".
425
- #
426
- # Note that using filters might cause fewer queues than the
427
- # requested_page size to be returned.
428
- # @param page_size [Integer]
429
- # The maximum number of resources contained in the underlying API
430
- # response. If page streaming is performed per-resource, this
431
- # parameter does not affect the return value. If page streaming is
432
- # performed per-page, this determines the maximum number of
433
- # resources in a page.
434
- # @param options [Google::Gax::CallOptions]
435
- # Overrides the default settings for this call, e.g, timeout,
436
- # retries, etc.
437
- # @yield [result, operation] Access the result along with the RPC operation
438
- # @yieldparam result [Google::Gax::PagedEnumerable<Google::Cloud::Tasks::V2beta2::Queue>]
439
- # @yieldparam operation [GRPC::ActiveCall::Operation]
440
- # @return [Google::Gax::PagedEnumerable<Google::Cloud::Tasks::V2beta2::Queue>]
441
- # An enumerable of Google::Cloud::Tasks::V2beta2::Queue instances.
442
- # See Google::Gax::PagedEnumerable documentation for other
443
- # operations such as per-page iteration or access to the response
444
- # object.
445
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
446
- # @example
447
- # require "google/cloud/tasks"
448
- #
449
- # cloud_tasks_client = Google::Cloud::Tasks.new(version: :v2beta2)
450
- # formatted_parent = Google::Cloud::Tasks::V2beta2::CloudTasksClient.location_path("[PROJECT]", "[LOCATION]")
451
- #
452
- # # Iterate over all results.
453
- # cloud_tasks_client.list_queues(formatted_parent).each do |element|
454
- # # Process element.
455
- # end
456
- #
457
- # # Or iterate over results one page at a time.
458
- # cloud_tasks_client.list_queues(formatted_parent).each_page do |page|
459
- # # Process each page at a time.
460
- # page.each do |element|
461
- # # Process element.
462
- # end
463
- # end
464
-
465
- def list_queues \
466
- parent,
467
- filter: nil,
468
- page_size: nil,
469
- options: nil,
470
- &block
471
- req = {
472
- parent: parent,
473
- filter: filter,
474
- page_size: page_size
475
- }.delete_if { |_, v| v.nil? }
476
- req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta2::ListQueuesRequest)
477
- @list_queues.call(req, options, &block)
478
- end
479
-
480
- # Gets a queue.
481
- #
482
- # @param name [String]
483
- # Required. The resource name of the queue. For example:
484
- # `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`
485
- # @param options [Google::Gax::CallOptions]
486
- # Overrides the default settings for this call, e.g, timeout,
487
- # retries, etc.
488
- # @yield [result, operation] Access the result along with the RPC operation
489
- # @yieldparam result [Google::Cloud::Tasks::V2beta2::Queue]
490
- # @yieldparam operation [GRPC::ActiveCall::Operation]
491
- # @return [Google::Cloud::Tasks::V2beta2::Queue]
492
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
493
- # @example
494
- # require "google/cloud/tasks"
495
- #
496
- # cloud_tasks_client = Google::Cloud::Tasks.new(version: :v2beta2)
497
- # formatted_name = Google::Cloud::Tasks::V2beta2::CloudTasksClient.queue_path("[PROJECT]", "[LOCATION]", "[QUEUE]")
498
- # response = cloud_tasks_client.get_queue(formatted_name)
499
-
500
- def get_queue \
501
- name,
502
- options: nil,
503
- &block
504
- req = {
505
- name: name
506
- }.delete_if { |_, v| v.nil? }
507
- req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta2::GetQueueRequest)
508
- @get_queue.call(req, options, &block)
509
- end
510
-
511
- # Creates a queue.
512
- #
513
- # Queues created with this method allow tasks to live for a maximum of 31
514
- # days. After a task is 31 days old, the task will be deleted regardless of whether
515
- # it was dispatched or not.
516
- #
517
- # WARNING: Using this method may have unintended side effects if you are
518
- # using an App Engine `queue.yaml` or `queue.xml` file to manage your queues.
519
- # Read
520
- # [Overview of Queue Management and
521
- # queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) before using
522
- # this method.
523
- #
524
- # @param parent [String]
525
- # Required. The location name in which the queue will be created.
526
- # For example: `projects/PROJECT_ID/locations/LOCATION_ID`
527
- #
528
- # The list of allowed locations can be obtained by calling Cloud
529
- # Tasks' implementation of
530
- # {Google::Cloud::Location::Locations::ListLocations ListLocations}.
531
- # @param queue [Google::Cloud::Tasks::V2beta2::Queue | Hash]
532
- # Required. The queue to create.
533
- #
534
- # {Google::Cloud::Tasks::V2beta2::Queue#name Queue's name} cannot be the same as an existing queue.
535
- # A hash of the same form as `Google::Cloud::Tasks::V2beta2::Queue`
536
- # can also be provided.
537
- # @param options [Google::Gax::CallOptions]
538
- # Overrides the default settings for this call, e.g, timeout,
539
- # retries, etc.
540
- # @yield [result, operation] Access the result along with the RPC operation
541
- # @yieldparam result [Google::Cloud::Tasks::V2beta2::Queue]
542
- # @yieldparam operation [GRPC::ActiveCall::Operation]
543
- # @return [Google::Cloud::Tasks::V2beta2::Queue]
544
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
545
- # @example
546
- # require "google/cloud/tasks"
547
- #
548
- # cloud_tasks_client = Google::Cloud::Tasks.new(version: :v2beta2)
549
- # formatted_parent = Google::Cloud::Tasks::V2beta2::CloudTasksClient.location_path("[PROJECT]", "[LOCATION]")
550
- #
551
- # # TODO: Initialize `queue`:
552
- # queue = {}
553
- # response = cloud_tasks_client.create_queue(formatted_parent, queue)
554
-
555
- def create_queue \
556
- parent,
557
- queue,
558
- options: nil,
559
- &block
560
- req = {
561
- parent: parent,
562
- queue: queue
563
- }.delete_if { |_, v| v.nil? }
564
- req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta2::CreateQueueRequest)
565
- @create_queue.call(req, options, &block)
566
- end
567
-
568
- # Updates a queue.
569
- #
570
- # This method creates the queue if it does not exist and updates
571
- # the queue if it does exist.
572
- #
573
- # Queues created with this method allow tasks to live for a maximum of 31
574
- # days. After a task is 31 days old, the task will be deleted regardless of whether
575
- # it was dispatched or not.
576
- #
577
- # WARNING: Using this method may have unintended side effects if you are
578
- # using an App Engine `queue.yaml` or `queue.xml` file to manage your queues.
579
- # Read
580
- # [Overview of Queue Management and
581
- # queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) before using
582
- # this method.
583
- #
584
- # @param queue [Google::Cloud::Tasks::V2beta2::Queue | Hash]
585
- # Required. The queue to create or update.
586
- #
587
- # The queue's {Google::Cloud::Tasks::V2beta2::Queue#name name} must be specified.
588
- #
589
- # Output only fields cannot be modified using UpdateQueue.
590
- # Any value specified for an output only field will be ignored.
591
- # The queue's {Google::Cloud::Tasks::V2beta2::Queue#name name} cannot be changed.
592
- # A hash of the same form as `Google::Cloud::Tasks::V2beta2::Queue`
593
- # can also be provided.
594
- # @param update_mask [Google::Protobuf::FieldMask | Hash]
595
- # A mask used to specify which fields of the queue are being updated.
596
- #
597
- # If empty, then all fields will be updated.
598
- # A hash of the same form as `Google::Protobuf::FieldMask`
599
- # can also be provided.
600
- # @param options [Google::Gax::CallOptions]
601
- # Overrides the default settings for this call, e.g, timeout,
602
- # retries, etc.
603
- # @yield [result, operation] Access the result along with the RPC operation
604
- # @yieldparam result [Google::Cloud::Tasks::V2beta2::Queue]
605
- # @yieldparam operation [GRPC::ActiveCall::Operation]
606
- # @return [Google::Cloud::Tasks::V2beta2::Queue]
607
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
608
- # @example
609
- # require "google/cloud/tasks"
610
- #
611
- # cloud_tasks_client = Google::Cloud::Tasks.new(version: :v2beta2)
612
- #
613
- # # TODO: Initialize `queue`:
614
- # queue = {}
615
- # response = cloud_tasks_client.update_queue(queue)
616
-
617
- def update_queue \
618
- queue,
619
- update_mask: nil,
620
- options: nil,
621
- &block
622
- req = {
623
- queue: queue,
624
- update_mask: update_mask
625
- }.delete_if { |_, v| v.nil? }
626
- req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta2::UpdateQueueRequest)
627
- @update_queue.call(req, options, &block)
628
- end
629
-
630
- # Deletes a queue.
631
- #
632
- # This command will delete the queue even if it has tasks in it.
633
- #
634
- # Note: If you delete a queue, a queue with the same name can't be created
635
- # for 7 days.
636
- #
637
- # WARNING: Using this method may have unintended side effects if you are
638
- # using an App Engine `queue.yaml` or `queue.xml` file to manage your queues.
639
- # Read
640
- # [Overview of Queue Management and
641
- # queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) before using
642
- # this method.
643
- #
644
- # @param name [String]
645
- # Required. The queue name. For example:
646
- # `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`
647
- # @param options [Google::Gax::CallOptions]
648
- # Overrides the default settings for this call, e.g, timeout,
649
- # retries, etc.
650
- # @yield [result, operation] Access the result along with the RPC operation
651
- # @yieldparam result []
652
- # @yieldparam operation [GRPC::ActiveCall::Operation]
653
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
654
- # @example
655
- # require "google/cloud/tasks"
656
- #
657
- # cloud_tasks_client = Google::Cloud::Tasks.new(version: :v2beta2)
658
- # formatted_name = Google::Cloud::Tasks::V2beta2::CloudTasksClient.queue_path("[PROJECT]", "[LOCATION]", "[QUEUE]")
659
- # cloud_tasks_client.delete_queue(formatted_name)
660
-
661
- def delete_queue \
662
- name,
663
- options: nil,
664
- &block
665
- req = {
666
- name: name
667
- }.delete_if { |_, v| v.nil? }
668
- req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta2::DeleteQueueRequest)
669
- @delete_queue.call(req, options, &block)
670
- nil
671
- end
672
-
673
- # Purges a queue by deleting all of its tasks.
674
- #
675
- # All tasks created before this method is called are permanently deleted.
676
- #
677
- # Purge operations can take up to one minute to take effect. Tasks
678
- # might be dispatched before the purge takes effect. A purge is irreversible.
679
- #
680
- # @param name [String]
681
- # Required. The queue name. For example:
682
- # `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID`
683
- # @param options [Google::Gax::CallOptions]
684
- # Overrides the default settings for this call, e.g, timeout,
685
- # retries, etc.
686
- # @yield [result, operation] Access the result along with the RPC operation
687
- # @yieldparam result [Google::Cloud::Tasks::V2beta2::Queue]
688
- # @yieldparam operation [GRPC::ActiveCall::Operation]
689
- # @return [Google::Cloud::Tasks::V2beta2::Queue]
690
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
691
- # @example
692
- # require "google/cloud/tasks"
693
- #
694
- # cloud_tasks_client = Google::Cloud::Tasks.new(version: :v2beta2)
695
- # formatted_name = Google::Cloud::Tasks::V2beta2::CloudTasksClient.queue_path("[PROJECT]", "[LOCATION]", "[QUEUE]")
696
- # response = cloud_tasks_client.purge_queue(formatted_name)
697
-
698
- def purge_queue \
699
- name,
700
- options: nil,
701
- &block
702
- req = {
703
- name: name
704
- }.delete_if { |_, v| v.nil? }
705
- req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta2::PurgeQueueRequest)
706
- @purge_queue.call(req, options, &block)
707
- end
708
-
709
- # Pauses the queue.
710
- #
711
- # If a queue is paused then the system will stop dispatching tasks
712
- # until the queue is resumed via
713
- # {Google::Cloud::Tasks::V2beta2::CloudTasks::ResumeQueue ResumeQueue}. Tasks can still be added
714
- # when the queue is paused. A queue is paused if its
715
- # {Google::Cloud::Tasks::V2beta2::Queue#state state} is {Google::Cloud::Tasks::V2beta2::Queue::State::PAUSED PAUSED}.
716
- #
717
- # @param name [String]
718
- # Required. The queue name. For example:
719
- # `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID`
720
- # @param options [Google::Gax::CallOptions]
721
- # Overrides the default settings for this call, e.g, timeout,
722
- # retries, etc.
723
- # @yield [result, operation] Access the result along with the RPC operation
724
- # @yieldparam result [Google::Cloud::Tasks::V2beta2::Queue]
725
- # @yieldparam operation [GRPC::ActiveCall::Operation]
726
- # @return [Google::Cloud::Tasks::V2beta2::Queue]
727
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
728
- # @example
729
- # require "google/cloud/tasks"
730
- #
731
- # cloud_tasks_client = Google::Cloud::Tasks.new(version: :v2beta2)
732
- # formatted_name = Google::Cloud::Tasks::V2beta2::CloudTasksClient.queue_path("[PROJECT]", "[LOCATION]", "[QUEUE]")
733
- # response = cloud_tasks_client.pause_queue(formatted_name)
734
-
735
- def pause_queue \
736
- name,
737
- options: nil,
738
- &block
739
- req = {
740
- name: name
741
- }.delete_if { |_, v| v.nil? }
742
- req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta2::PauseQueueRequest)
743
- @pause_queue.call(req, options, &block)
744
- end
745
-
746
- # Resume a queue.
747
- #
748
- # This method resumes a queue after it has been
749
- # {Google::Cloud::Tasks::V2beta2::Queue::State::PAUSED PAUSED} or
750
- # {Google::Cloud::Tasks::V2beta2::Queue::State::DISABLED DISABLED}. The state of a queue is stored
751
- # in the queue's {Google::Cloud::Tasks::V2beta2::Queue#state state}; after calling this method it
752
- # will be set to {Google::Cloud::Tasks::V2beta2::Queue::State::RUNNING RUNNING}.
753
- #
754
- # WARNING: Resuming many high-QPS queues at the same time can
755
- # lead to target overloading. If you are resuming high-QPS
756
- # queues, follow the 500/50/5 pattern described in
757
- # [Managing Cloud Tasks Scaling
758
- # Risks](https://cloud.google.com/tasks/docs/manage-cloud-task-scaling).
759
- #
760
- # @param name [String]
761
- # Required. The queue name. For example:
762
- # `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID`
763
- # @param options [Google::Gax::CallOptions]
764
- # Overrides the default settings for this call, e.g, timeout,
765
- # retries, etc.
766
- # @yield [result, operation] Access the result along with the RPC operation
767
- # @yieldparam result [Google::Cloud::Tasks::V2beta2::Queue]
768
- # @yieldparam operation [GRPC::ActiveCall::Operation]
769
- # @return [Google::Cloud::Tasks::V2beta2::Queue]
770
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
771
- # @example
772
- # require "google/cloud/tasks"
773
- #
774
- # cloud_tasks_client = Google::Cloud::Tasks.new(version: :v2beta2)
775
- # formatted_name = Google::Cloud::Tasks::V2beta2::CloudTasksClient.queue_path("[PROJECT]", "[LOCATION]", "[QUEUE]")
776
- # response = cloud_tasks_client.resume_queue(formatted_name)
777
-
778
- def resume_queue \
779
- name,
780
- options: nil,
781
- &block
782
- req = {
783
- name: name
784
- }.delete_if { |_, v| v.nil? }
785
- req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta2::ResumeQueueRequest)
786
- @resume_queue.call(req, options, &block)
787
- end
788
-
789
- # Gets the access control policy for a {Google::Cloud::Tasks::V2beta2::Queue Queue}.
790
- # Returns an empty policy if the resource exists and does not have a policy
791
- # set.
792
- #
793
- # Authorization requires the following
794
- # [Google IAM](https://cloud.google.com/iam) permission on the specified
795
- # resource parent:
796
- #
797
- # * `cloudtasks.queues.getIamPolicy`
798
- #
799
- # @param resource [String]
800
- # REQUIRED: The resource for which the policy is being requested.
801
- # See the operation documentation for the appropriate value for this field.
802
- # @param options_ [Google::Iam::V1::GetPolicyOptions | Hash]
803
- # OPTIONAL: A `GetPolicyOptions` object for specifying options to
804
- # `GetIamPolicy`. This field is only used by Cloud IAM.
805
- # A hash of the same form as `Google::Iam::V1::GetPolicyOptions`
806
- # can also be provided.
807
- # @param options [Google::Gax::CallOptions]
808
- # Overrides the default settings for this call, e.g, timeout,
809
- # retries, etc.
810
- # @yield [result, operation] Access the result along with the RPC operation
811
- # @yieldparam result [Google::Iam::V1::Policy]
812
- # @yieldparam operation [GRPC::ActiveCall::Operation]
813
- # @return [Google::Iam::V1::Policy]
814
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
815
- # @example
816
- # require "google/cloud/tasks"
817
- #
818
- # cloud_tasks_client = Google::Cloud::Tasks.new(version: :v2beta2)
819
- #
820
- # # TODO: Initialize `resource`:
821
- # resource = ''
822
- # response = cloud_tasks_client.get_iam_policy(resource)
823
-
824
- def get_iam_policy \
825
- resource,
826
- options_: nil,
827
- options: nil,
828
- &block
829
- req = {
830
- resource: resource,
831
- options: options_
832
- }.delete_if { |_, v| v.nil? }
833
- req = Google::Gax::to_proto(req, Google::Iam::V1::GetIamPolicyRequest)
834
- @get_iam_policy.call(req, options, &block)
835
- end
836
-
837
- # Sets the access control policy for a {Google::Cloud::Tasks::V2beta2::Queue Queue}. Replaces any existing
838
- # policy.
839
- #
840
- # Note: The Cloud Console does not check queue-level IAM permissions yet.
841
- # Project-level permissions are required to use the Cloud Console.
842
- #
843
- # Authorization requires the following
844
- # [Google IAM](https://cloud.google.com/iam) permission on the specified
845
- # resource parent:
846
- #
847
- # * `cloudtasks.queues.setIamPolicy`
848
- #
849
- # @param resource [String]
850
- # REQUIRED: The resource for which the policy is being specified.
851
- # See the operation documentation for the appropriate value for this field.
852
- # @param policy [Google::Iam::V1::Policy | Hash]
853
- # REQUIRED: The complete policy to be applied to the `resource`. The size of
854
- # the policy is limited to a few 10s of KB. An empty policy is a
855
- # valid policy but certain Cloud Platform services (such as Projects)
856
- # might reject them.
857
- # A hash of the same form as `Google::Iam::V1::Policy`
858
- # can also be provided.
859
- # @param options [Google::Gax::CallOptions]
860
- # Overrides the default settings for this call, e.g, timeout,
861
- # retries, etc.
862
- # @yield [result, operation] Access the result along with the RPC operation
863
- # @yieldparam result [Google::Iam::V1::Policy]
864
- # @yieldparam operation [GRPC::ActiveCall::Operation]
865
- # @return [Google::Iam::V1::Policy]
866
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
867
- # @example
868
- # require "google/cloud/tasks"
869
- #
870
- # cloud_tasks_client = Google::Cloud::Tasks.new(version: :v2beta2)
871
- #
872
- # # TODO: Initialize `resource`:
873
- # resource = ''
874
- #
875
- # # TODO: Initialize `policy`:
876
- # policy = {}
877
- # response = cloud_tasks_client.set_iam_policy(resource, policy)
878
-
879
- def set_iam_policy \
880
- resource,
881
- policy,
882
- options: nil,
883
- &block
884
- req = {
885
- resource: resource,
886
- policy: policy
887
- }.delete_if { |_, v| v.nil? }
888
- req = Google::Gax::to_proto(req, Google::Iam::V1::SetIamPolicyRequest)
889
- @set_iam_policy.call(req, options, &block)
890
- end
891
-
892
- # Returns permissions that a caller has on a {Google::Cloud::Tasks::V2beta2::Queue Queue}.
893
- # If the resource does not exist, this will return an empty set of
894
- # permissions, not a {Google::Rpc::Code::NOT_FOUND NOT_FOUND} error.
895
- #
896
- # Note: This operation is designed to be used for building permission-aware
897
- # UIs and command-line tools, not for authorization checking. This operation
898
- # may "fail open" without warning.
899
- #
900
- # @param resource [String]
901
- # REQUIRED: The resource for which the policy detail is being requested.
902
- # See the operation documentation for the appropriate value for this field.
903
- # @param permissions [Array<String>]
904
- # The set of permissions to check for the `resource`. Permissions with
905
- # wildcards (such as '*' or 'storage.*') are not allowed. For more
906
- # information see
907
- # [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions).
908
- # @param options [Google::Gax::CallOptions]
909
- # Overrides the default settings for this call, e.g, timeout,
910
- # retries, etc.
911
- # @yield [result, operation] Access the result along with the RPC operation
912
- # @yieldparam result [Google::Iam::V1::TestIamPermissionsResponse]
913
- # @yieldparam operation [GRPC::ActiveCall::Operation]
914
- # @return [Google::Iam::V1::TestIamPermissionsResponse]
915
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
916
- # @example
917
- # require "google/cloud/tasks"
918
- #
919
- # cloud_tasks_client = Google::Cloud::Tasks.new(version: :v2beta2)
920
- #
921
- # # TODO: Initialize `resource`:
922
- # resource = ''
923
- #
924
- # # TODO: Initialize `permissions`:
925
- # permissions = []
926
- # response = cloud_tasks_client.test_iam_permissions(resource, permissions)
927
-
928
- def test_iam_permissions \
929
- resource,
930
- permissions,
931
- options: nil,
932
- &block
933
- req = {
934
- resource: resource,
935
- permissions: permissions
936
- }.delete_if { |_, v| v.nil? }
937
- req = Google::Gax::to_proto(req, Google::Iam::V1::TestIamPermissionsRequest)
938
- @test_iam_permissions.call(req, options, &block)
939
- end
940
-
941
- # Lists the tasks in a queue.
942
- #
943
- # By default, only the {Google::Cloud::Tasks::V2beta2::Task::View::BASIC BASIC} view is retrieved
944
- # due to performance considerations;
945
- # {Google::Cloud::Tasks::V2beta2::ListTasksRequest#response_view response_view} controls the
946
- # subset of information which is returned.
947
- #
948
- # The tasks may be returned in any order. The ordering may change at any
949
- # time.
950
- #
951
- # @param parent [String]
952
- # Required. The queue name. For example:
953
- # `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`
954
- # @param response_view [Google::Cloud::Tasks::V2beta2::Task::View]
955
- # The response_view specifies which subset of the {Google::Cloud::Tasks::V2beta2::Task Task} will be
956
- # returned.
957
- #
958
- # By default response_view is {Google::Cloud::Tasks::V2beta2::Task::View::BASIC BASIC}; not all
959
- # information is retrieved by default because some data, such as
960
- # payloads, might be desirable to return only when needed because
961
- # of its large size or because of the sensitivity of data that it
962
- # contains.
963
- #
964
- # Authorization for {Google::Cloud::Tasks::V2beta2::Task::View::FULL FULL} requires
965
- # `cloudtasks.tasks.fullView` [Google IAM](https://cloud.google.com/iam/)
966
- # permission on the {Google::Cloud::Tasks::V2beta2::Task Task} resource.
967
- # @param page_size [Integer]
968
- # The maximum number of resources contained in the underlying API
969
- # response. If page streaming is performed per-resource, this
970
- # parameter does not affect the return value. If page streaming is
971
- # performed per-page, this determines the maximum number of
972
- # resources in a page.
973
- # @param options [Google::Gax::CallOptions]
974
- # Overrides the default settings for this call, e.g, timeout,
975
- # retries, etc.
976
- # @yield [result, operation] Access the result along with the RPC operation
977
- # @yieldparam result [Google::Gax::PagedEnumerable<Google::Cloud::Tasks::V2beta2::Task>]
978
- # @yieldparam operation [GRPC::ActiveCall::Operation]
979
- # @return [Google::Gax::PagedEnumerable<Google::Cloud::Tasks::V2beta2::Task>]
980
- # An enumerable of Google::Cloud::Tasks::V2beta2::Task instances.
981
- # See Google::Gax::PagedEnumerable documentation for other
982
- # operations such as per-page iteration or access to the response
983
- # object.
984
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
985
- # @example
986
- # require "google/cloud/tasks"
987
- #
988
- # cloud_tasks_client = Google::Cloud::Tasks.new(version: :v2beta2)
989
- # formatted_parent = Google::Cloud::Tasks::V2beta2::CloudTasksClient.queue_path("[PROJECT]", "[LOCATION]", "[QUEUE]")
990
- #
991
- # # Iterate over all results.
992
- # cloud_tasks_client.list_tasks(formatted_parent).each do |element|
993
- # # Process element.
994
- # end
995
- #
996
- # # Or iterate over results one page at a time.
997
- # cloud_tasks_client.list_tasks(formatted_parent).each_page do |page|
998
- # # Process each page at a time.
999
- # page.each do |element|
1000
- # # Process element.
1001
- # end
1002
- # end
1003
-
1004
- def list_tasks \
1005
- parent,
1006
- response_view: nil,
1007
- page_size: nil,
1008
- options: nil,
1009
- &block
1010
- req = {
1011
- parent: parent,
1012
- response_view: response_view,
1013
- page_size: page_size
1014
- }.delete_if { |_, v| v.nil? }
1015
- req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta2::ListTasksRequest)
1016
- @list_tasks.call(req, options, &block)
1017
- end
1018
-
1019
- # Gets a task.
1020
- #
1021
- # @param name [String]
1022
- # Required. The task name. For example:
1023
- # `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`
1024
- # @param response_view [Google::Cloud::Tasks::V2beta2::Task::View]
1025
- # The response_view specifies which subset of the {Google::Cloud::Tasks::V2beta2::Task Task} will be
1026
- # returned.
1027
- #
1028
- # By default response_view is {Google::Cloud::Tasks::V2beta2::Task::View::BASIC BASIC}; not all
1029
- # information is retrieved by default because some data, such as
1030
- # payloads, might be desirable to return only when needed because
1031
- # of its large size or because of the sensitivity of data that it
1032
- # contains.
1033
- #
1034
- # Authorization for {Google::Cloud::Tasks::V2beta2::Task::View::FULL FULL} requires
1035
- # `cloudtasks.tasks.fullView` [Google IAM](https://cloud.google.com/iam/)
1036
- # permission on the {Google::Cloud::Tasks::V2beta2::Task Task} resource.
1037
- # @param options [Google::Gax::CallOptions]
1038
- # Overrides the default settings for this call, e.g, timeout,
1039
- # retries, etc.
1040
- # @yield [result, operation] Access the result along with the RPC operation
1041
- # @yieldparam result [Google::Cloud::Tasks::V2beta2::Task]
1042
- # @yieldparam operation [GRPC::ActiveCall::Operation]
1043
- # @return [Google::Cloud::Tasks::V2beta2::Task]
1044
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
1045
- # @example
1046
- # require "google/cloud/tasks"
1047
- #
1048
- # cloud_tasks_client = Google::Cloud::Tasks.new(version: :v2beta2)
1049
- # formatted_name = Google::Cloud::Tasks::V2beta2::CloudTasksClient.task_path("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]")
1050
- # response = cloud_tasks_client.get_task(formatted_name)
1051
-
1052
- def get_task \
1053
- name,
1054
- response_view: nil,
1055
- options: nil,
1056
- &block
1057
- req = {
1058
- name: name,
1059
- response_view: response_view
1060
- }.delete_if { |_, v| v.nil? }
1061
- req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta2::GetTaskRequest)
1062
- @get_task.call(req, options, &block)
1063
- end
1064
-
1065
- # Creates a task and adds it to a queue.
1066
- #
1067
- # Tasks cannot be updated after creation; there is no UpdateTask command.
1068
- #
1069
- # * For {Google::Cloud::Tasks::V2beta2::AppEngineHttpTarget App Engine queues}, the maximum task size is
1070
- # 100KB.
1071
- # * For {Google::Cloud::Tasks::V2beta2::PullTarget pull queues}, the maximum task size is 1MB.
1072
- #
1073
- # @param parent [String]
1074
- # Required. The queue name. For example:
1075
- # `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`
1076
- #
1077
- # The queue must already exist.
1078
- # @param task [Google::Cloud::Tasks::V2beta2::Task | Hash]
1079
- # Required. The task to add.
1080
- #
1081
- # Task names have the following format:
1082
- # `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`.
1083
- # The user can optionally specify a task {Google::Cloud::Tasks::V2beta2::Task#name name}. If a
1084
- # name is not specified then the system will generate a random
1085
- # unique task id, which will be set in the task returned in the
1086
- # {Google::Cloud::Tasks::V2beta2::Task#name response}.
1087
- #
1088
- # If {Google::Cloud::Tasks::V2beta2::Task#schedule_time schedule_time} is not set or is in the
1089
- # past then Cloud Tasks will set it to the current time.
1090
- #
1091
- # Task De-duplication:
1092
- #
1093
- # Explicitly specifying a task ID enables task de-duplication. If
1094
- # a task's ID is identical to that of an existing task or a task
1095
- # that was deleted or completed recently then the call will fail
1096
- # with {Google::Rpc::Code::ALREADY_EXISTS ALREADY_EXISTS}.
1097
- # If the task's queue was created using Cloud Tasks, then another task with
1098
- # the same name can't be created for ~1hour after the original task was
1099
- # deleted or completed. If the task's queue was created using queue.yaml or
1100
- # queue.xml, then another task with the same name can't be created
1101
- # for ~9days after the original task was deleted or completed.
1102
- #
1103
- # Because there is an extra lookup cost to identify duplicate task
1104
- # names, these {Google::Cloud::Tasks::V2beta2::CloudTasks::CreateTask CreateTask} calls have significantly
1105
- # increased latency. Using hashed strings for the task id or for
1106
- # the prefix of the task id is recommended. Choosing task ids that
1107
- # are sequential or have sequential prefixes, for example using a
1108
- # timestamp, causes an increase in latency and error rates in all
1109
- # task commands. The infrastructure relies on an approximately
1110
- # uniform distribution of task ids to store and serve tasks
1111
- # efficiently.
1112
- # A hash of the same form as `Google::Cloud::Tasks::V2beta2::Task`
1113
- # can also be provided.
1114
- # @param response_view [Google::Cloud::Tasks::V2beta2::Task::View]
1115
- # The response_view specifies which subset of the {Google::Cloud::Tasks::V2beta2::Task Task} will be
1116
- # returned.
1117
- #
1118
- # By default response_view is {Google::Cloud::Tasks::V2beta2::Task::View::BASIC BASIC}; not all
1119
- # information is retrieved by default because some data, such as
1120
- # payloads, might be desirable to return only when needed because
1121
- # of its large size or because of the sensitivity of data that it
1122
- # contains.
1123
- #
1124
- # Authorization for {Google::Cloud::Tasks::V2beta2::Task::View::FULL FULL} requires
1125
- # `cloudtasks.tasks.fullView` [Google IAM](https://cloud.google.com/iam/)
1126
- # permission on the {Google::Cloud::Tasks::V2beta2::Task Task} resource.
1127
- # @param options [Google::Gax::CallOptions]
1128
- # Overrides the default settings for this call, e.g, timeout,
1129
- # retries, etc.
1130
- # @yield [result, operation] Access the result along with the RPC operation
1131
- # @yieldparam result [Google::Cloud::Tasks::V2beta2::Task]
1132
- # @yieldparam operation [GRPC::ActiveCall::Operation]
1133
- # @return [Google::Cloud::Tasks::V2beta2::Task]
1134
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
1135
- # @example
1136
- # require "google/cloud/tasks"
1137
- #
1138
- # cloud_tasks_client = Google::Cloud::Tasks.new(version: :v2beta2)
1139
- # formatted_parent = Google::Cloud::Tasks::V2beta2::CloudTasksClient.queue_path("[PROJECT]", "[LOCATION]", "[QUEUE]")
1140
- #
1141
- # # TODO: Initialize `task`:
1142
- # task = {}
1143
- # response = cloud_tasks_client.create_task(formatted_parent, task)
1144
-
1145
- def create_task \
1146
- parent,
1147
- task,
1148
- response_view: nil,
1149
- options: nil,
1150
- &block
1151
- req = {
1152
- parent: parent,
1153
- task: task,
1154
- response_view: response_view
1155
- }.delete_if { |_, v| v.nil? }
1156
- req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta2::CreateTaskRequest)
1157
- @create_task.call(req, options, &block)
1158
- end
1159
-
1160
- # Deletes a task.
1161
- #
1162
- # A task can be deleted if it is scheduled or dispatched. A task
1163
- # cannot be deleted if it has completed successfully or permanently
1164
- # failed.
1165
- #
1166
- # @param name [String]
1167
- # Required. The task name. For example:
1168
- # `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`
1169
- # @param options [Google::Gax::CallOptions]
1170
- # Overrides the default settings for this call, e.g, timeout,
1171
- # retries, etc.
1172
- # @yield [result, operation] Access the result along with the RPC operation
1173
- # @yieldparam result []
1174
- # @yieldparam operation [GRPC::ActiveCall::Operation]
1175
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
1176
- # @example
1177
- # require "google/cloud/tasks"
1178
- #
1179
- # cloud_tasks_client = Google::Cloud::Tasks.new(version: :v2beta2)
1180
- # formatted_name = Google::Cloud::Tasks::V2beta2::CloudTasksClient.task_path("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]")
1181
- # cloud_tasks_client.delete_task(formatted_name)
1182
-
1183
- def delete_task \
1184
- name,
1185
- options: nil,
1186
- &block
1187
- req = {
1188
- name: name
1189
- }.delete_if { |_, v| v.nil? }
1190
- req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta2::DeleteTaskRequest)
1191
- @delete_task.call(req, options, &block)
1192
- nil
1193
- end
1194
-
1195
- # Leases tasks from a pull queue for
1196
- # {Google::Cloud::Tasks::V2beta2::LeaseTasksRequest#lease_duration lease_duration}.
1197
- #
1198
- # This method is invoked by the worker to obtain a lease. The
1199
- # worker must acknowledge the task via
1200
- # {Google::Cloud::Tasks::V2beta2::CloudTasks::AcknowledgeTask AcknowledgeTask} after they have
1201
- # performed the work associated with the task.
1202
- #
1203
- # The {Google::Cloud::Tasks::V2beta2::PullMessage#payload payload} is intended to store data that
1204
- # the worker needs to perform the work associated with the task. To
1205
- # return the payloads in the {Google::Cloud::Tasks::V2beta2::LeaseTasksResponse response}, set
1206
- # {Google::Cloud::Tasks::V2beta2::LeaseTasksRequest#response_view response_view} to
1207
- # {Google::Cloud::Tasks::V2beta2::Task::View::FULL FULL}.
1208
- #
1209
- # A maximum of 10 qps of {Google::Cloud::Tasks::V2beta2::CloudTasks::LeaseTasks LeaseTasks}
1210
- # requests are allowed per
1211
- # queue. {Google::Rpc::Code::RESOURCE_EXHAUSTED RESOURCE_EXHAUSTED}
1212
- # is returned when this limit is
1213
- # exceeded. {Google::Rpc::Code::RESOURCE_EXHAUSTED RESOURCE_EXHAUSTED}
1214
- # is also returned when
1215
- # {Google::Cloud::Tasks::V2beta2::RateLimits#max_tasks_dispatched_per_second max_tasks_dispatched_per_second}
1216
- # is exceeded.
1217
- #
1218
- # @param parent [String]
1219
- # Required. The queue name. For example:
1220
- # `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`
1221
- # @param lease_duration [Google::Protobuf::Duration | Hash]
1222
- # Required. The duration of the lease.
1223
- #
1224
- # Each task returned in the {Google::Cloud::Tasks::V2beta2::LeaseTasksResponse response} will
1225
- # have its {Google::Cloud::Tasks::V2beta2::Task#schedule_time schedule_time} set to the current
1226
- # time plus the `lease_duration`. The task is leased until its
1227
- # {Google::Cloud::Tasks::V2beta2::Task#schedule_time schedule_time}; thus, the task will not be
1228
- # returned to another {Google::Cloud::Tasks::V2beta2::CloudTasks::LeaseTasks LeaseTasks} call
1229
- # before its {Google::Cloud::Tasks::V2beta2::Task#schedule_time schedule_time}.
1230
- #
1231
- #
1232
- # After the worker has successfully finished the work associated
1233
- # with the task, the worker must call via
1234
- # {Google::Cloud::Tasks::V2beta2::CloudTasks::AcknowledgeTask AcknowledgeTask} before the
1235
- # {Google::Cloud::Tasks::V2beta2::Task#schedule_time schedule_time}. Otherwise the task will be
1236
- # returned to a later {Google::Cloud::Tasks::V2beta2::CloudTasks::LeaseTasks LeaseTasks} call so
1237
- # that another worker can retry it.
1238
- #
1239
- # The maximum lease duration is 1 week.
1240
- # `lease_duration` will be truncated to the nearest second.
1241
- # A hash of the same form as `Google::Protobuf::Duration`
1242
- # can also be provided.
1243
- # @param max_tasks [Integer]
1244
- # The maximum number of tasks to lease.
1245
- #
1246
- # The system will make a best effort to return as close to as
1247
- # `max_tasks` as possible.
1248
- #
1249
- # The largest that `max_tasks` can be is 1000.
1250
- #
1251
- # The maximum total size of a {Google::Cloud::Tasks::V2beta2::LeaseTasksResponse lease tasks response} is
1252
- # 32 MB. If the sum of all task sizes requested reaches this limit,
1253
- # fewer tasks than requested are returned.
1254
- # @param response_view [Google::Cloud::Tasks::V2beta2::Task::View]
1255
- # The response_view specifies which subset of the {Google::Cloud::Tasks::V2beta2::Task Task} will be
1256
- # returned.
1257
- #
1258
- # By default response_view is {Google::Cloud::Tasks::V2beta2::Task::View::BASIC BASIC}; not all
1259
- # information is retrieved by default because some data, such as
1260
- # payloads, might be desirable to return only when needed because
1261
- # of its large size or because of the sensitivity of data that it
1262
- # contains.
1263
- #
1264
- # Authorization for {Google::Cloud::Tasks::V2beta2::Task::View::FULL FULL} requires
1265
- # `cloudtasks.tasks.fullView` [Google IAM](https://cloud.google.com/iam/)
1266
- # permission on the {Google::Cloud::Tasks::V2beta2::Task Task} resource.
1267
- # @param filter [String]
1268
- # `filter` can be used to specify a subset of tasks to lease.
1269
- #
1270
- # When `filter` is set to `tag=<my-tag>` then the
1271
- # {Google::Cloud::Tasks::V2beta2::LeaseTasksResponse response} will contain only tasks whose
1272
- # {Google::Cloud::Tasks::V2beta2::PullMessage#tag tag} is equal to `<my-tag>`. `<my-tag>` must be
1273
- # less than 500 characters.
1274
- #
1275
- # When `filter` is set to `tag_function=oldest_tag()`, only tasks which have
1276
- # the same tag as the task with the oldest
1277
- # {Google::Cloud::Tasks::V2beta2::Task#schedule_time schedule_time} will be returned.
1278
- #
1279
- # Grammar Syntax:
1280
- #
1281
- # * `filter = "tag=" tag | "tag_function=" function`
1282
- #
1283
- # * `tag = string`
1284
- #
1285
- # * `function = "oldest_tag()"`
1286
- #
1287
- # The `oldest_tag()` function returns tasks which have the same tag as the
1288
- # oldest task (ordered by schedule time).
1289
- #
1290
- # SDK compatibility: Although the SDK allows tags to be either
1291
- # string or
1292
- # [bytes](https://cloud.google.com/appengine/docs/standard/java/javadoc/com/google/appengine/api/taskqueue/TaskOptions.html#tag-byte:A-),
1293
- # only UTF-8 encoded tags can be used in Cloud Tasks. Tag which
1294
- # aren't UTF-8 encoded can't be used in the
1295
- # {Google::Cloud::Tasks::V2beta2::LeaseTasksRequest#filter filter} and the task's
1296
- # {Google::Cloud::Tasks::V2beta2::PullMessage#tag tag} will be displayed as empty in Cloud Tasks.
1297
- # @param options [Google::Gax::CallOptions]
1298
- # Overrides the default settings for this call, e.g, timeout,
1299
- # retries, etc.
1300
- # @yield [result, operation] Access the result along with the RPC operation
1301
- # @yieldparam result [Google::Cloud::Tasks::V2beta2::LeaseTasksResponse]
1302
- # @yieldparam operation [GRPC::ActiveCall::Operation]
1303
- # @return [Google::Cloud::Tasks::V2beta2::LeaseTasksResponse]
1304
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
1305
- # @example
1306
- # require "google/cloud/tasks"
1307
- #
1308
- # cloud_tasks_client = Google::Cloud::Tasks.new(version: :v2beta2)
1309
- # formatted_parent = Google::Cloud::Tasks::V2beta2::CloudTasksClient.queue_path("[PROJECT]", "[LOCATION]", "[QUEUE]")
1310
- #
1311
- # # TODO: Initialize `lease_duration`:
1312
- # lease_duration = {}
1313
- # response = cloud_tasks_client.lease_tasks(formatted_parent, lease_duration)
1314
-
1315
- def lease_tasks \
1316
- parent,
1317
- lease_duration,
1318
- max_tasks: nil,
1319
- response_view: nil,
1320
- filter: nil,
1321
- options: nil,
1322
- &block
1323
- req = {
1324
- parent: parent,
1325
- lease_duration: lease_duration,
1326
- max_tasks: max_tasks,
1327
- response_view: response_view,
1328
- filter: filter
1329
- }.delete_if { |_, v| v.nil? }
1330
- req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta2::LeaseTasksRequest)
1331
- @lease_tasks.call(req, options, &block)
1332
- end
1333
-
1334
- # Acknowledges a pull task.
1335
- #
1336
- # The worker, that is, the entity that
1337
- # {Google::Cloud::Tasks::V2beta2::CloudTasks::LeaseTasks leased} this task must call this method
1338
- # to indicate that the work associated with the task has finished.
1339
- #
1340
- # The worker must acknowledge a task within the
1341
- # {Google::Cloud::Tasks::V2beta2::LeaseTasksRequest#lease_duration lease_duration} or the lease
1342
- # will expire and the task will become available to be leased
1343
- # again. After the task is acknowledged, it will not be returned
1344
- # by a later {Google::Cloud::Tasks::V2beta2::CloudTasks::LeaseTasks LeaseTasks},
1345
- # {Google::Cloud::Tasks::V2beta2::CloudTasks::GetTask GetTask}, or
1346
- # {Google::Cloud::Tasks::V2beta2::CloudTasks::ListTasks ListTasks}.
1347
- #
1348
- # @param name [String]
1349
- # Required. The task name. For example:
1350
- # `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`
1351
- # @param schedule_time [Google::Protobuf::Timestamp | Hash]
1352
- # Required. The task's current schedule time, available in the
1353
- # {Google::Cloud::Tasks::V2beta2::Task#schedule_time schedule_time} returned by
1354
- # {Google::Cloud::Tasks::V2beta2::CloudTasks::LeaseTasks LeaseTasks} response or
1355
- # {Google::Cloud::Tasks::V2beta2::CloudTasks::RenewLease RenewLease} response. This restriction is
1356
- # to ensure that your worker currently holds the lease.
1357
- # A hash of the same form as `Google::Protobuf::Timestamp`
1358
- # can also be provided.
1359
- # @param options [Google::Gax::CallOptions]
1360
- # Overrides the default settings for this call, e.g, timeout,
1361
- # retries, etc.
1362
- # @yield [result, operation] Access the result along with the RPC operation
1363
- # @yieldparam result []
1364
- # @yieldparam operation [GRPC::ActiveCall::Operation]
1365
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
1366
- # @example
1367
- # require "google/cloud/tasks"
1368
- #
1369
- # cloud_tasks_client = Google::Cloud::Tasks.new(version: :v2beta2)
1370
- # formatted_name = Google::Cloud::Tasks::V2beta2::CloudTasksClient.task_path("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]")
1371
- #
1372
- # # TODO: Initialize `schedule_time`:
1373
- # schedule_time = {}
1374
- # cloud_tasks_client.acknowledge_task(formatted_name, schedule_time)
1375
-
1376
- def acknowledge_task \
1377
- name,
1378
- schedule_time,
1379
- options: nil,
1380
- &block
1381
- req = {
1382
- name: name,
1383
- schedule_time: schedule_time
1384
- }.delete_if { |_, v| v.nil? }
1385
- req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta2::AcknowledgeTaskRequest)
1386
- @acknowledge_task.call(req, options, &block)
1387
- nil
1388
- end
1389
-
1390
- # Renew the current lease of a pull task.
1391
- #
1392
- # The worker can use this method to extend the lease by a new
1393
- # duration, starting from now. The new task lease will be
1394
- # returned in the task's {Google::Cloud::Tasks::V2beta2::Task#schedule_time schedule_time}.
1395
- #
1396
- # @param name [String]
1397
- # Required. The task name. For example:
1398
- # `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`
1399
- # @param schedule_time [Google::Protobuf::Timestamp | Hash]
1400
- # Required. The task's current schedule time, available in the
1401
- # {Google::Cloud::Tasks::V2beta2::Task#schedule_time schedule_time} returned by
1402
- # {Google::Cloud::Tasks::V2beta2::CloudTasks::LeaseTasks LeaseTasks} response or
1403
- # {Google::Cloud::Tasks::V2beta2::CloudTasks::RenewLease RenewLease} response. This restriction is
1404
- # to ensure that your worker currently holds the lease.
1405
- # A hash of the same form as `Google::Protobuf::Timestamp`
1406
- # can also be provided.
1407
- # @param lease_duration [Google::Protobuf::Duration | Hash]
1408
- # Required. The desired new lease duration, starting from now.
1409
- #
1410
- #
1411
- # The maximum lease duration is 1 week.
1412
- # `lease_duration` will be truncated to the nearest second.
1413
- # A hash of the same form as `Google::Protobuf::Duration`
1414
- # can also be provided.
1415
- # @param response_view [Google::Cloud::Tasks::V2beta2::Task::View]
1416
- # The response_view specifies which subset of the {Google::Cloud::Tasks::V2beta2::Task Task} will be
1417
- # returned.
1418
- #
1419
- # By default response_view is {Google::Cloud::Tasks::V2beta2::Task::View::BASIC BASIC}; not all
1420
- # information is retrieved by default because some data, such as
1421
- # payloads, might be desirable to return only when needed because
1422
- # of its large size or because of the sensitivity of data that it
1423
- # contains.
1424
- #
1425
- # Authorization for {Google::Cloud::Tasks::V2beta2::Task::View::FULL FULL} requires
1426
- # `cloudtasks.tasks.fullView` [Google IAM](https://cloud.google.com/iam/)
1427
- # permission on the {Google::Cloud::Tasks::V2beta2::Task Task} resource.
1428
- # @param options [Google::Gax::CallOptions]
1429
- # Overrides the default settings for this call, e.g, timeout,
1430
- # retries, etc.
1431
- # @yield [result, operation] Access the result along with the RPC operation
1432
- # @yieldparam result [Google::Cloud::Tasks::V2beta2::Task]
1433
- # @yieldparam operation [GRPC::ActiveCall::Operation]
1434
- # @return [Google::Cloud::Tasks::V2beta2::Task]
1435
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
1436
- # @example
1437
- # require "google/cloud/tasks"
1438
- #
1439
- # cloud_tasks_client = Google::Cloud::Tasks.new(version: :v2beta2)
1440
- # formatted_name = Google::Cloud::Tasks::V2beta2::CloudTasksClient.task_path("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]")
1441
- #
1442
- # # TODO: Initialize `schedule_time`:
1443
- # schedule_time = {}
1444
- #
1445
- # # TODO: Initialize `lease_duration`:
1446
- # lease_duration = {}
1447
- # response = cloud_tasks_client.renew_lease(formatted_name, schedule_time, lease_duration)
1448
-
1449
- def renew_lease \
1450
- name,
1451
- schedule_time,
1452
- lease_duration,
1453
- response_view: nil,
1454
- options: nil,
1455
- &block
1456
- req = {
1457
- name: name,
1458
- schedule_time: schedule_time,
1459
- lease_duration: lease_duration,
1460
- response_view: response_view
1461
- }.delete_if { |_, v| v.nil? }
1462
- req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta2::RenewLeaseRequest)
1463
- @renew_lease.call(req, options, &block)
1464
- end
1465
-
1466
- # Cancel a pull task's lease.
1467
- #
1468
- # The worker can use this method to cancel a task's lease by
1469
- # setting its {Google::Cloud::Tasks::V2beta2::Task#schedule_time schedule_time} to now. This will
1470
- # make the task available to be leased to the next caller of
1471
- # {Google::Cloud::Tasks::V2beta2::CloudTasks::LeaseTasks LeaseTasks}.
1472
- #
1473
- # @param name [String]
1474
- # Required. The task name. For example:
1475
- # `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`
1476
- # @param schedule_time [Google::Protobuf::Timestamp | Hash]
1477
- # Required. The task's current schedule time, available in the
1478
- # {Google::Cloud::Tasks::V2beta2::Task#schedule_time schedule_time} returned by
1479
- # {Google::Cloud::Tasks::V2beta2::CloudTasks::LeaseTasks LeaseTasks} response or
1480
- # {Google::Cloud::Tasks::V2beta2::CloudTasks::RenewLease RenewLease} response. This restriction is
1481
- # to ensure that your worker currently holds the lease.
1482
- # A hash of the same form as `Google::Protobuf::Timestamp`
1483
- # can also be provided.
1484
- # @param response_view [Google::Cloud::Tasks::V2beta2::Task::View]
1485
- # The response_view specifies which subset of the {Google::Cloud::Tasks::V2beta2::Task Task} will be
1486
- # returned.
1487
- #
1488
- # By default response_view is {Google::Cloud::Tasks::V2beta2::Task::View::BASIC BASIC}; not all
1489
- # information is retrieved by default because some data, such as
1490
- # payloads, might be desirable to return only when needed because
1491
- # of its large size or because of the sensitivity of data that it
1492
- # contains.
1493
- #
1494
- # Authorization for {Google::Cloud::Tasks::V2beta2::Task::View::FULL FULL} requires
1495
- # `cloudtasks.tasks.fullView` [Google IAM](https://cloud.google.com/iam/)
1496
- # permission on the {Google::Cloud::Tasks::V2beta2::Task Task} resource.
1497
- # @param options [Google::Gax::CallOptions]
1498
- # Overrides the default settings for this call, e.g, timeout,
1499
- # retries, etc.
1500
- # @yield [result, operation] Access the result along with the RPC operation
1501
- # @yieldparam result [Google::Cloud::Tasks::V2beta2::Task]
1502
- # @yieldparam operation [GRPC::ActiveCall::Operation]
1503
- # @return [Google::Cloud::Tasks::V2beta2::Task]
1504
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
1505
- # @example
1506
- # require "google/cloud/tasks"
1507
- #
1508
- # cloud_tasks_client = Google::Cloud::Tasks.new(version: :v2beta2)
1509
- # formatted_name = Google::Cloud::Tasks::V2beta2::CloudTasksClient.task_path("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]")
1510
- #
1511
- # # TODO: Initialize `schedule_time`:
1512
- # schedule_time = {}
1513
- # response = cloud_tasks_client.cancel_lease(formatted_name, schedule_time)
1514
-
1515
- def cancel_lease \
1516
- name,
1517
- schedule_time,
1518
- response_view: nil,
1519
- options: nil,
1520
- &block
1521
- req = {
1522
- name: name,
1523
- schedule_time: schedule_time,
1524
- response_view: response_view
1525
- }.delete_if { |_, v| v.nil? }
1526
- req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta2::CancelLeaseRequest)
1527
- @cancel_lease.call(req, options, &block)
1528
- end
1529
-
1530
- # Forces a task to run now.
1531
- #
1532
- # When this method is called, Cloud Tasks will dispatch the task, even if
1533
- # the task is already running, the queue has reached its {Google::Cloud::Tasks::V2beta2::RateLimits RateLimits} or
1534
- # is {Google::Cloud::Tasks::V2beta2::Queue::State::PAUSED PAUSED}.
1535
- #
1536
- # This command is meant to be used for manual debugging. For
1537
- # example, {Google::Cloud::Tasks::V2beta2::CloudTasks::RunTask RunTask} can be used to retry a failed
1538
- # task after a fix has been made or to manually force a task to be
1539
- # dispatched now.
1540
- #
1541
- # The dispatched task is returned. That is, the task that is returned
1542
- # contains the {Google::Cloud::Tasks::V2beta2::Task#status status} after the task is dispatched but
1543
- # before the task is received by its target.
1544
- #
1545
- # If Cloud Tasks receives a successful response from the task's
1546
- # target, then the task will be deleted; otherwise the task's
1547
- # {Google::Cloud::Tasks::V2beta2::Task#schedule_time schedule_time} will be reset to the time that
1548
- # {Google::Cloud::Tasks::V2beta2::CloudTasks::RunTask RunTask} was called plus the retry delay specified
1549
- # in the queue's {Google::Cloud::Tasks::V2beta2::RetryConfig RetryConfig}.
1550
- #
1551
- # {Google::Cloud::Tasks::V2beta2::CloudTasks::RunTask RunTask} returns
1552
- # {Google::Rpc::Code::NOT_FOUND NOT_FOUND} when it is called on a
1553
- # task that has already succeeded or permanently failed.
1554
- #
1555
- # {Google::Cloud::Tasks::V2beta2::CloudTasks::RunTask RunTask} cannot be called on a
1556
- # {Google::Cloud::Tasks::V2beta2::PullMessage pull task}.
1557
- #
1558
- # @param name [String]
1559
- # Required. The task name. For example:
1560
- # `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`
1561
- # @param response_view [Google::Cloud::Tasks::V2beta2::Task::View]
1562
- # The response_view specifies which subset of the {Google::Cloud::Tasks::V2beta2::Task Task} will be
1563
- # returned.
1564
- #
1565
- # By default response_view is {Google::Cloud::Tasks::V2beta2::Task::View::BASIC BASIC}; not all
1566
- # information is retrieved by default because some data, such as
1567
- # payloads, might be desirable to return only when needed because
1568
- # of its large size or because of the sensitivity of data that it
1569
- # contains.
1570
- #
1571
- # Authorization for {Google::Cloud::Tasks::V2beta2::Task::View::FULL FULL} requires
1572
- # `cloudtasks.tasks.fullView` [Google IAM](https://cloud.google.com/iam/)
1573
- # permission on the {Google::Cloud::Tasks::V2beta2::Task Task} resource.
1574
- # @param options [Google::Gax::CallOptions]
1575
- # Overrides the default settings for this call, e.g, timeout,
1576
- # retries, etc.
1577
- # @yield [result, operation] Access the result along with the RPC operation
1578
- # @yieldparam result [Google::Cloud::Tasks::V2beta2::Task]
1579
- # @yieldparam operation [GRPC::ActiveCall::Operation]
1580
- # @return [Google::Cloud::Tasks::V2beta2::Task]
1581
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
1582
- # @example
1583
- # require "google/cloud/tasks"
1584
- #
1585
- # cloud_tasks_client = Google::Cloud::Tasks.new(version: :v2beta2)
1586
- # formatted_name = Google::Cloud::Tasks::V2beta2::CloudTasksClient.task_path("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]")
1587
- # response = cloud_tasks_client.run_task(formatted_name)
1588
-
1589
- def run_task \
1590
- name,
1591
- response_view: nil,
1592
- options: nil,
1593
- &block
1594
- req = {
1595
- name: name,
1596
- response_view: response_view
1597
- }.delete_if { |_, v| v.nil? }
1598
- req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta2::RunTaskRequest)
1599
- @run_task.call(req, options, &block)
1600
- end
1601
- end
1602
- end
1603
- end
1604
- end
1605
- end