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,45 +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
- module Google
17
- module Type
18
- # Represents an expression text. Example:
19
- #
20
- # title: "User account presence"
21
- # description: "Determines whether the request has a user account"
22
- # expression: "size(request.user) > 0"
23
- # @!attribute [rw] expression
24
- # @return [String]
25
- # Textual representation of an expression in
26
- # Common Expression Language syntax.
27
- #
28
- # The application context of the containing message determines which
29
- # well-known feature set of CEL is supported.
30
- # @!attribute [rw] title
31
- # @return [String]
32
- # An optional title for the expression, i.e. a short string describing
33
- # its purpose. This can be used e.g. in UIs which allow to enter the
34
- # expression.
35
- # @!attribute [rw] description
36
- # @return [String]
37
- # An optional description of the expression. This is a longer text which
38
- # describes the expression, e.g. when hovered over it in a UI.
39
- # @!attribute [rw] location
40
- # @return [String]
41
- # An optional string indicating the location of the expression for error
42
- # reporting, e.g. a file name and a position in the file.
43
- class Expr; end
44
- end
45
- end
@@ -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 V2beta2
18
- class CloudTasksClient
19
- # Alias for Google::Cloud::Tasks::V2beta2::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::V2beta2::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::V2beta2::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,58 +0,0 @@
1
- # Generated by the protocol buffer compiler. DO NOT EDIT!
2
- # source: google/cloud/tasks/v2beta2/queue.proto
3
-
4
-
5
- require 'google/protobuf'
6
-
7
- require 'google/api/resource_pb'
8
- require 'google/cloud/tasks/v2beta2/target_pb'
9
- require 'google/protobuf/duration_pb'
10
- require 'google/protobuf/timestamp_pb'
11
- require 'google/api/annotations_pb'
12
- Google::Protobuf::DescriptorPool.generated_pool.build do
13
- add_message "google.cloud.tasks.v2beta2.Queue" do
14
- optional :name, :string, 1
15
- optional :rate_limits, :message, 5, "google.cloud.tasks.v2beta2.RateLimits"
16
- optional :retry_config, :message, 6, "google.cloud.tasks.v2beta2.RetryConfig"
17
- optional :state, :enum, 7, "google.cloud.tasks.v2beta2.Queue.State"
18
- optional :purge_time, :message, 8, "google.protobuf.Timestamp"
19
- oneof :target_type do
20
- optional :app_engine_http_target, :message, 3, "google.cloud.tasks.v2beta2.AppEngineHttpTarget"
21
- optional :pull_target, :message, 4, "google.cloud.tasks.v2beta2.PullTarget"
22
- end
23
- end
24
- add_enum "google.cloud.tasks.v2beta2.Queue.State" do
25
- value :STATE_UNSPECIFIED, 0
26
- value :RUNNING, 1
27
- value :PAUSED, 2
28
- value :DISABLED, 3
29
- end
30
- add_message "google.cloud.tasks.v2beta2.RateLimits" do
31
- optional :max_tasks_dispatched_per_second, :double, 1
32
- optional :max_burst_size, :int32, 2
33
- optional :max_concurrent_tasks, :int32, 3
34
- end
35
- add_message "google.cloud.tasks.v2beta2.RetryConfig" do
36
- optional :max_retry_duration, :message, 3, "google.protobuf.Duration"
37
- optional :min_backoff, :message, 4, "google.protobuf.Duration"
38
- optional :max_backoff, :message, 5, "google.protobuf.Duration"
39
- optional :max_doublings, :int32, 6
40
- oneof :num_attempts do
41
- optional :max_attempts, :int32, 1
42
- optional :unlimited_attempts, :bool, 2
43
- end
44
- end
45
- end
46
-
47
- module Google
48
- module Cloud
49
- module Tasks
50
- module V2beta2
51
- Queue = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.tasks.v2beta2.Queue").msgclass
52
- Queue::State = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.tasks.v2beta2.Queue.State").enummodule
53
- RateLimits = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.tasks.v2beta2.RateLimits").msgclass
54
- RetryConfig = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.tasks.v2beta2.RetryConfig").msgclass
55
- end
56
- end
57
- end
58
- end
@@ -1,54 +0,0 @@
1
- # Generated by the protocol buffer compiler. DO NOT EDIT!
2
- # source: google/cloud/tasks/v2beta2/target.proto
3
-
4
-
5
- require 'google/protobuf'
6
-
7
- require 'google/api/annotations_pb'
8
- Google::Protobuf::DescriptorPool.generated_pool.build do
9
- add_message "google.cloud.tasks.v2beta2.PullTarget" do
10
- end
11
- add_message "google.cloud.tasks.v2beta2.PullMessage" do
12
- optional :payload, :bytes, 1
13
- optional :tag, :string, 2
14
- end
15
- add_message "google.cloud.tasks.v2beta2.AppEngineHttpTarget" do
16
- optional :app_engine_routing_override, :message, 1, "google.cloud.tasks.v2beta2.AppEngineRouting"
17
- end
18
- add_message "google.cloud.tasks.v2beta2.AppEngineHttpRequest" do
19
- optional :http_method, :enum, 1, "google.cloud.tasks.v2beta2.HttpMethod"
20
- optional :app_engine_routing, :message, 2, "google.cloud.tasks.v2beta2.AppEngineRouting"
21
- optional :relative_url, :string, 3
22
- map :headers, :string, :string, 4
23
- optional :payload, :bytes, 5
24
- end
25
- add_message "google.cloud.tasks.v2beta2.AppEngineRouting" do
26
- optional :service, :string, 1
27
- optional :version, :string, 2
28
- optional :instance, :string, 3
29
- optional :host, :string, 4
30
- end
31
- add_enum "google.cloud.tasks.v2beta2.HttpMethod" do
32
- value :HTTP_METHOD_UNSPECIFIED, 0
33
- value :POST, 1
34
- value :GET, 2
35
- value :HEAD, 3
36
- value :PUT, 4
37
- value :DELETE, 5
38
- end
39
- end
40
-
41
- module Google
42
- module Cloud
43
- module Tasks
44
- module V2beta2
45
- PullTarget = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.tasks.v2beta2.PullTarget").msgclass
46
- PullMessage = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.tasks.v2beta2.PullMessage").msgclass
47
- AppEngineHttpTarget = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.tasks.v2beta2.AppEngineHttpTarget").msgclass
48
- AppEngineHttpRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.tasks.v2beta2.AppEngineHttpRequest").msgclass
49
- AppEngineRouting = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.tasks.v2beta2.AppEngineRouting").msgclass
50
- HttpMethod = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.tasks.v2beta2.HttpMethod").enummodule
51
- end
52
- end
53
- end
54
- end
@@ -1,54 +0,0 @@
1
- # Generated by the protocol buffer compiler. DO NOT EDIT!
2
- # source: google/cloud/tasks/v2beta2/task.proto
3
-
4
-
5
- require 'google/protobuf'
6
-
7
- require 'google/api/resource_pb'
8
- require 'google/cloud/tasks/v2beta2/target_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.v2beta2.Task" do
14
- optional :name, :string, 1
15
- optional :schedule_time, :message, 5, "google.protobuf.Timestamp"
16
- optional :create_time, :message, 6, "google.protobuf.Timestamp"
17
- optional :status, :message, 7, "google.cloud.tasks.v2beta2.TaskStatus"
18
- optional :view, :enum, 8, "google.cloud.tasks.v2beta2.Task.View"
19
- oneof :payload_type do
20
- optional :app_engine_http_request, :message, 3, "google.cloud.tasks.v2beta2.AppEngineHttpRequest"
21
- optional :pull_message, :message, 4, "google.cloud.tasks.v2beta2.PullMessage"
22
- end
23
- end
24
- add_enum "google.cloud.tasks.v2beta2.Task.View" do
25
- value :VIEW_UNSPECIFIED, 0
26
- value :BASIC, 1
27
- value :FULL, 2
28
- end
29
- add_message "google.cloud.tasks.v2beta2.TaskStatus" do
30
- optional :attempt_dispatch_count, :int32, 1
31
- optional :attempt_response_count, :int32, 2
32
- optional :first_attempt_status, :message, 3, "google.cloud.tasks.v2beta2.AttemptStatus"
33
- optional :last_attempt_status, :message, 4, "google.cloud.tasks.v2beta2.AttemptStatus"
34
- end
35
- add_message "google.cloud.tasks.v2beta2.AttemptStatus" do
36
- optional :schedule_time, :message, 1, "google.protobuf.Timestamp"
37
- optional :dispatch_time, :message, 2, "google.protobuf.Timestamp"
38
- optional :response_time, :message, 3, "google.protobuf.Timestamp"
39
- optional :response_status, :message, 4, "google.rpc.Status"
40
- end
41
- end
42
-
43
- module Google
44
- module Cloud
45
- module Tasks
46
- module V2beta2
47
- Task = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.tasks.v2beta2.Task").msgclass
48
- Task::View = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.tasks.v2beta2.Task.View").enummodule
49
- TaskStatus = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.tasks.v2beta2.TaskStatus").msgclass
50
- AttemptStatus = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.tasks.v2beta2.AttemptStatus").msgclass
51
- end
52
- end
53
- end
54
- 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/v2beta3/cloud_tasks_client"
17
- require "google/cloud/tasks/v2beta3/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 V2beta3
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::V2beta3::CloudTasksClient.new(**kwargs)
143
- end
144
- end
145
- end
146
- end
147
- end
@@ -1,1233 +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/v2beta3/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/v2beta3/cloudtasks_pb"
29
- require "google/cloud/tasks/v2beta3/credentials"
30
- require "google/cloud/tasks/version"
31
-
32
- module Google
33
- module Cloud
34
- module Tasks
35
- module V2beta3
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::V2beta3::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/v2beta3/cloudtasks_services_pb"
182
-
183
- credentials ||= Google::Cloud::Tasks::V2beta3::Credentials.default
184
-
185
- if credentials.is_a?(String) || credentials.is_a?(Hash)
186
- updater_proc = Google::Cloud::Tasks::V2beta3::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.v2beta3.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::V2beta3::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
- @run_task = Google::Gax.create_api_call(
366
- @cloud_tasks_stub.method(:run_task),
367
- defaults["run_task"],
368
- exception_transformer: exception_transformer,
369
- params_extractor: proc do |request|
370
- {'name' => request.name}
371
- end
372
- )
373
- end
374
-
375
- # Service calls
376
-
377
- # Lists queues.
378
- #
379
- # Queues are returned in lexicographical order.
380
- #
381
- # @param parent [String]
382
- # Required. The location name.
383
- # For example: `projects/PROJECT_ID/locations/LOCATION_ID`
384
- # @param filter [String]
385
- # `filter` can be used to specify a subset of queues. Any {Google::Cloud::Tasks::V2beta3::Queue Queue}
386
- # field can be used as a filter and several operators as supported.
387
- # For example: `<=, <, >=, >, !=, =, :`. The filter syntax is the same as
388
- # described in
389
- # [Stackdriver's Advanced Logs
390
- # Filters](https://cloud.google.com/logging/docs/view/advanced_filters).
391
- #
392
- # Sample filter "state: PAUSED".
393
- #
394
- # Note that using filters might cause fewer queues than the
395
- # requested page_size to be returned.
396
- # @param page_size [Integer]
397
- # The maximum number of resources contained in the underlying API
398
- # response. If page streaming is performed per-resource, this
399
- # parameter does not affect the return value. If page streaming is
400
- # performed per-page, this determines the maximum number of
401
- # resources in a page.
402
- # @param options [Google::Gax::CallOptions]
403
- # Overrides the default settings for this call, e.g, timeout,
404
- # retries, etc.
405
- # @yield [result, operation] Access the result along with the RPC operation
406
- # @yieldparam result [Google::Gax::PagedEnumerable<Google::Cloud::Tasks::V2beta3::Queue>]
407
- # @yieldparam operation [GRPC::ActiveCall::Operation]
408
- # @return [Google::Gax::PagedEnumerable<Google::Cloud::Tasks::V2beta3::Queue>]
409
- # An enumerable of Google::Cloud::Tasks::V2beta3::Queue instances.
410
- # See Google::Gax::PagedEnumerable documentation for other
411
- # operations such as per-page iteration or access to the response
412
- # object.
413
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
414
- # @example
415
- # require "google/cloud/tasks"
416
- #
417
- # cloud_tasks_client = Google::Cloud::Tasks.new(version: :v2beta3)
418
- # formatted_parent = Google::Cloud::Tasks::V2beta3::CloudTasksClient.location_path("[PROJECT]", "[LOCATION]")
419
- #
420
- # # Iterate over all results.
421
- # cloud_tasks_client.list_queues(formatted_parent).each do |element|
422
- # # Process element.
423
- # end
424
- #
425
- # # Or iterate over results one page at a time.
426
- # cloud_tasks_client.list_queues(formatted_parent).each_page do |page|
427
- # # Process each page at a time.
428
- # page.each do |element|
429
- # # Process element.
430
- # end
431
- # end
432
-
433
- def list_queues \
434
- parent,
435
- filter: nil,
436
- page_size: nil,
437
- options: nil,
438
- &block
439
- req = {
440
- parent: parent,
441
- filter: filter,
442
- page_size: page_size
443
- }.delete_if { |_, v| v.nil? }
444
- req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta3::ListQueuesRequest)
445
- @list_queues.call(req, options, &block)
446
- end
447
-
448
- # Gets a queue.
449
- #
450
- # @param name [String]
451
- # Required. The resource name of the queue. For example:
452
- # `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`
453
- # @param options [Google::Gax::CallOptions]
454
- # Overrides the default settings for this call, e.g, timeout,
455
- # retries, etc.
456
- # @yield [result, operation] Access the result along with the RPC operation
457
- # @yieldparam result [Google::Cloud::Tasks::V2beta3::Queue]
458
- # @yieldparam operation [GRPC::ActiveCall::Operation]
459
- # @return [Google::Cloud::Tasks::V2beta3::Queue]
460
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
461
- # @example
462
- # require "google/cloud/tasks"
463
- #
464
- # cloud_tasks_client = Google::Cloud::Tasks.new(version: :v2beta3)
465
- # formatted_name = Google::Cloud::Tasks::V2beta3::CloudTasksClient.queue_path("[PROJECT]", "[LOCATION]", "[QUEUE]")
466
- # response = cloud_tasks_client.get_queue(formatted_name)
467
-
468
- def get_queue \
469
- name,
470
- options: nil,
471
- &block
472
- req = {
473
- name: name
474
- }.delete_if { |_, v| v.nil? }
475
- req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta3::GetQueueRequest)
476
- @get_queue.call(req, options, &block)
477
- end
478
-
479
- # Creates a queue.
480
- #
481
- # Queues created with this method allow tasks to live for a maximum of 31
482
- # days. After a task is 31 days old, the task will be deleted regardless of whether
483
- # it was dispatched or not.
484
- #
485
- # WARNING: Using this method may have unintended side effects if you are
486
- # using an App Engine `queue.yaml` or `queue.xml` file to manage your queues.
487
- # Read
488
- # [Overview of Queue Management and
489
- # queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) before using
490
- # this method.
491
- #
492
- # @param parent [String]
493
- # Required. The location name in which the queue will be created.
494
- # For example: `projects/PROJECT_ID/locations/LOCATION_ID`
495
- #
496
- # The list of allowed locations can be obtained by calling Cloud
497
- # Tasks' implementation of
498
- # {Google::Cloud::Location::Locations::ListLocations ListLocations}.
499
- # @param queue [Google::Cloud::Tasks::V2beta3::Queue | Hash]
500
- # Required. The queue to create.
501
- #
502
- # {Google::Cloud::Tasks::V2beta3::Queue#name Queue's name} cannot be the same as an existing queue.
503
- # A hash of the same form as `Google::Cloud::Tasks::V2beta3::Queue`
504
- # can also be provided.
505
- # @param options [Google::Gax::CallOptions]
506
- # Overrides the default settings for this call, e.g, timeout,
507
- # retries, etc.
508
- # @yield [result, operation] Access the result along with the RPC operation
509
- # @yieldparam result [Google::Cloud::Tasks::V2beta3::Queue]
510
- # @yieldparam operation [GRPC::ActiveCall::Operation]
511
- # @return [Google::Cloud::Tasks::V2beta3::Queue]
512
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
513
- # @example
514
- # require "google/cloud/tasks"
515
- #
516
- # cloud_tasks_client = Google::Cloud::Tasks.new(version: :v2beta3)
517
- # formatted_parent = Google::Cloud::Tasks::V2beta3::CloudTasksClient.location_path("[PROJECT]", "[LOCATION]")
518
- #
519
- # # TODO: Initialize `queue`:
520
- # queue = {}
521
- # response = cloud_tasks_client.create_queue(formatted_parent, queue)
522
-
523
- def create_queue \
524
- parent,
525
- queue,
526
- options: nil,
527
- &block
528
- req = {
529
- parent: parent,
530
- queue: queue
531
- }.delete_if { |_, v| v.nil? }
532
- req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta3::CreateQueueRequest)
533
- @create_queue.call(req, options, &block)
534
- end
535
-
536
- # Updates a queue.
537
- #
538
- # This method creates the queue if it does not exist and updates
539
- # the queue if it does exist.
540
- #
541
- # Queues created with this method allow tasks to live for a maximum of 31
542
- # days. After a task is 31 days old, the task will be deleted regardless of whether
543
- # it was dispatched or not.
544
- #
545
- # WARNING: Using this method may have unintended side effects if you are
546
- # using an App Engine `queue.yaml` or `queue.xml` file to manage your queues.
547
- # Read
548
- # [Overview of Queue Management and
549
- # queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) before using
550
- # this method.
551
- #
552
- # @param queue [Google::Cloud::Tasks::V2beta3::Queue | Hash]
553
- # Required. The queue to create or update.
554
- #
555
- # The queue's {Google::Cloud::Tasks::V2beta3::Queue#name name} must be specified.
556
- #
557
- # Output only fields cannot be modified using UpdateQueue.
558
- # Any value specified for an output only field will be ignored.
559
- # The queue's {Google::Cloud::Tasks::V2beta3::Queue#name name} cannot be changed.
560
- # A hash of the same form as `Google::Cloud::Tasks::V2beta3::Queue`
561
- # can also be provided.
562
- # @param update_mask [Google::Protobuf::FieldMask | Hash]
563
- # A mask used to specify which fields of the queue are being updated.
564
- #
565
- # If empty, then all fields will be updated.
566
- # A hash of the same form as `Google::Protobuf::FieldMask`
567
- # can also be provided.
568
- # @param options [Google::Gax::CallOptions]
569
- # Overrides the default settings for this call, e.g, timeout,
570
- # retries, etc.
571
- # @yield [result, operation] Access the result along with the RPC operation
572
- # @yieldparam result [Google::Cloud::Tasks::V2beta3::Queue]
573
- # @yieldparam operation [GRPC::ActiveCall::Operation]
574
- # @return [Google::Cloud::Tasks::V2beta3::Queue]
575
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
576
- # @example
577
- # require "google/cloud/tasks"
578
- #
579
- # cloud_tasks_client = Google::Cloud::Tasks.new(version: :v2beta3)
580
- #
581
- # # TODO: Initialize `queue`:
582
- # queue = {}
583
- # response = cloud_tasks_client.update_queue(queue)
584
-
585
- def update_queue \
586
- queue,
587
- update_mask: nil,
588
- options: nil,
589
- &block
590
- req = {
591
- queue: queue,
592
- update_mask: update_mask
593
- }.delete_if { |_, v| v.nil? }
594
- req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta3::UpdateQueueRequest)
595
- @update_queue.call(req, options, &block)
596
- end
597
-
598
- # Deletes a queue.
599
- #
600
- # This command will delete the queue even if it has tasks in it.
601
- #
602
- # Note: If you delete a queue, a queue with the same name can't be created
603
- # for 7 days.
604
- #
605
- # WARNING: Using this method may have unintended side effects if you are
606
- # using an App Engine `queue.yaml` or `queue.xml` file to manage your queues.
607
- # Read
608
- # [Overview of Queue Management and
609
- # queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) before using
610
- # this method.
611
- #
612
- # @param name [String]
613
- # Required. The queue name. For example:
614
- # `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`
615
- # @param options [Google::Gax::CallOptions]
616
- # Overrides the default settings for this call, e.g, timeout,
617
- # retries, etc.
618
- # @yield [result, operation] Access the result along with the RPC operation
619
- # @yieldparam result []
620
- # @yieldparam operation [GRPC::ActiveCall::Operation]
621
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
622
- # @example
623
- # require "google/cloud/tasks"
624
- #
625
- # cloud_tasks_client = Google::Cloud::Tasks.new(version: :v2beta3)
626
- # formatted_name = Google::Cloud::Tasks::V2beta3::CloudTasksClient.queue_path("[PROJECT]", "[LOCATION]", "[QUEUE]")
627
- # cloud_tasks_client.delete_queue(formatted_name)
628
-
629
- def delete_queue \
630
- name,
631
- options: nil,
632
- &block
633
- req = {
634
- name: name
635
- }.delete_if { |_, v| v.nil? }
636
- req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta3::DeleteQueueRequest)
637
- @delete_queue.call(req, options, &block)
638
- nil
639
- end
640
-
641
- # Purges a queue by deleting all of its tasks.
642
- #
643
- # All tasks created before this method is called are permanently deleted.
644
- #
645
- # Purge operations can take up to one minute to take effect. Tasks
646
- # might be dispatched before the purge takes effect. A purge is irreversible.
647
- #
648
- # @param name [String]
649
- # Required. The queue name. For example:
650
- # `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID`
651
- # @param options [Google::Gax::CallOptions]
652
- # Overrides the default settings for this call, e.g, timeout,
653
- # retries, etc.
654
- # @yield [result, operation] Access the result along with the RPC operation
655
- # @yieldparam result [Google::Cloud::Tasks::V2beta3::Queue]
656
- # @yieldparam operation [GRPC::ActiveCall::Operation]
657
- # @return [Google::Cloud::Tasks::V2beta3::Queue]
658
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
659
- # @example
660
- # require "google/cloud/tasks"
661
- #
662
- # cloud_tasks_client = Google::Cloud::Tasks.new(version: :v2beta3)
663
- # formatted_name = Google::Cloud::Tasks::V2beta3::CloudTasksClient.queue_path("[PROJECT]", "[LOCATION]", "[QUEUE]")
664
- # response = cloud_tasks_client.purge_queue(formatted_name)
665
-
666
- def purge_queue \
667
- name,
668
- options: nil,
669
- &block
670
- req = {
671
- name: name
672
- }.delete_if { |_, v| v.nil? }
673
- req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta3::PurgeQueueRequest)
674
- @purge_queue.call(req, options, &block)
675
- end
676
-
677
- # Pauses the queue.
678
- #
679
- # If a queue is paused then the system will stop dispatching tasks
680
- # until the queue is resumed via
681
- # {Google::Cloud::Tasks::V2beta3::CloudTasks::ResumeQueue ResumeQueue}. Tasks can still be added
682
- # when the queue is paused. A queue is paused if its
683
- # {Google::Cloud::Tasks::V2beta3::Queue#state state} is {Google::Cloud::Tasks::V2beta3::Queue::State::PAUSED PAUSED}.
684
- #
685
- # @param name [String]
686
- # Required. The queue name. For example:
687
- # `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID`
688
- # @param options [Google::Gax::CallOptions]
689
- # Overrides the default settings for this call, e.g, timeout,
690
- # retries, etc.
691
- # @yield [result, operation] Access the result along with the RPC operation
692
- # @yieldparam result [Google::Cloud::Tasks::V2beta3::Queue]
693
- # @yieldparam operation [GRPC::ActiveCall::Operation]
694
- # @return [Google::Cloud::Tasks::V2beta3::Queue]
695
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
696
- # @example
697
- # require "google/cloud/tasks"
698
- #
699
- # cloud_tasks_client = Google::Cloud::Tasks.new(version: :v2beta3)
700
- # formatted_name = Google::Cloud::Tasks::V2beta3::CloudTasksClient.queue_path("[PROJECT]", "[LOCATION]", "[QUEUE]")
701
- # response = cloud_tasks_client.pause_queue(formatted_name)
702
-
703
- def pause_queue \
704
- name,
705
- options: nil,
706
- &block
707
- req = {
708
- name: name
709
- }.delete_if { |_, v| v.nil? }
710
- req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta3::PauseQueueRequest)
711
- @pause_queue.call(req, options, &block)
712
- end
713
-
714
- # Resume a queue.
715
- #
716
- # This method resumes a queue after it has been
717
- # {Google::Cloud::Tasks::V2beta3::Queue::State::PAUSED PAUSED} or
718
- # {Google::Cloud::Tasks::V2beta3::Queue::State::DISABLED DISABLED}. The state of a queue is stored
719
- # in the queue's {Google::Cloud::Tasks::V2beta3::Queue#state state}; after calling this method it
720
- # will be set to {Google::Cloud::Tasks::V2beta3::Queue::State::RUNNING RUNNING}.
721
- #
722
- # WARNING: Resuming many high-QPS queues at the same time can
723
- # lead to target overloading. If you are resuming high-QPS
724
- # queues, follow the 500/50/5 pattern described in
725
- # [Managing Cloud Tasks Scaling
726
- # Risks](https://cloud.google.com/tasks/docs/manage-cloud-task-scaling).
727
- #
728
- # @param name [String]
729
- # Required. The queue name. For example:
730
- # `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID`
731
- # @param options [Google::Gax::CallOptions]
732
- # Overrides the default settings for this call, e.g, timeout,
733
- # retries, etc.
734
- # @yield [result, operation] Access the result along with the RPC operation
735
- # @yieldparam result [Google::Cloud::Tasks::V2beta3::Queue]
736
- # @yieldparam operation [GRPC::ActiveCall::Operation]
737
- # @return [Google::Cloud::Tasks::V2beta3::Queue]
738
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
739
- # @example
740
- # require "google/cloud/tasks"
741
- #
742
- # cloud_tasks_client = Google::Cloud::Tasks.new(version: :v2beta3)
743
- # formatted_name = Google::Cloud::Tasks::V2beta3::CloudTasksClient.queue_path("[PROJECT]", "[LOCATION]", "[QUEUE]")
744
- # response = cloud_tasks_client.resume_queue(formatted_name)
745
-
746
- def resume_queue \
747
- name,
748
- options: nil,
749
- &block
750
- req = {
751
- name: name
752
- }.delete_if { |_, v| v.nil? }
753
- req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta3::ResumeQueueRequest)
754
- @resume_queue.call(req, options, &block)
755
- end
756
-
757
- # Gets the access control policy for a {Google::Cloud::Tasks::V2beta3::Queue Queue}.
758
- # Returns an empty policy if the resource exists and does not have a policy
759
- # set.
760
- #
761
- # Authorization requires the following
762
- # [Google IAM](https://cloud.google.com/iam) permission on the specified
763
- # resource parent:
764
- #
765
- # * `cloudtasks.queues.getIamPolicy`
766
- #
767
- # @param resource [String]
768
- # REQUIRED: The resource for which the policy is being requested.
769
- # See the operation documentation for the appropriate value for this field.
770
- # @param options_ [Google::Iam::V1::GetPolicyOptions | Hash]
771
- # OPTIONAL: A `GetPolicyOptions` object for specifying options to
772
- # `GetIamPolicy`. This field is only used by Cloud IAM.
773
- # A hash of the same form as `Google::Iam::V1::GetPolicyOptions`
774
- # can also be provided.
775
- # @param options [Google::Gax::CallOptions]
776
- # Overrides the default settings for this call, e.g, timeout,
777
- # retries, etc.
778
- # @yield [result, operation] Access the result along with the RPC operation
779
- # @yieldparam result [Google::Iam::V1::Policy]
780
- # @yieldparam operation [GRPC::ActiveCall::Operation]
781
- # @return [Google::Iam::V1::Policy]
782
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
783
- # @example
784
- # require "google/cloud/tasks"
785
- #
786
- # cloud_tasks_client = Google::Cloud::Tasks.new(version: :v2beta3)
787
- #
788
- # # TODO: Initialize `resource`:
789
- # resource = ''
790
- # response = cloud_tasks_client.get_iam_policy(resource)
791
-
792
- def get_iam_policy \
793
- resource,
794
- options_: nil,
795
- options: nil,
796
- &block
797
- req = {
798
- resource: resource,
799
- options: options_
800
- }.delete_if { |_, v| v.nil? }
801
- req = Google::Gax::to_proto(req, Google::Iam::V1::GetIamPolicyRequest)
802
- @get_iam_policy.call(req, options, &block)
803
- end
804
-
805
- # Sets the access control policy for a {Google::Cloud::Tasks::V2beta3::Queue Queue}. Replaces any existing
806
- # policy.
807
- #
808
- # Note: The Cloud Console does not check queue-level IAM permissions yet.
809
- # Project-level permissions are required to use the Cloud Console.
810
- #
811
- # Authorization requires the following
812
- # [Google IAM](https://cloud.google.com/iam) permission on the specified
813
- # resource parent:
814
- #
815
- # * `cloudtasks.queues.setIamPolicy`
816
- #
817
- # @param resource [String]
818
- # REQUIRED: The resource for which the policy is being specified.
819
- # See the operation documentation for the appropriate value for this field.
820
- # @param policy [Google::Iam::V1::Policy | Hash]
821
- # REQUIRED: The complete policy to be applied to the `resource`. The size of
822
- # the policy is limited to a few 10s of KB. An empty policy is a
823
- # valid policy but certain Cloud Platform services (such as Projects)
824
- # might reject them.
825
- # A hash of the same form as `Google::Iam::V1::Policy`
826
- # can also be provided.
827
- # @param options [Google::Gax::CallOptions]
828
- # Overrides the default settings for this call, e.g, timeout,
829
- # retries, etc.
830
- # @yield [result, operation] Access the result along with the RPC operation
831
- # @yieldparam result [Google::Iam::V1::Policy]
832
- # @yieldparam operation [GRPC::ActiveCall::Operation]
833
- # @return [Google::Iam::V1::Policy]
834
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
835
- # @example
836
- # require "google/cloud/tasks"
837
- #
838
- # cloud_tasks_client = Google::Cloud::Tasks.new(version: :v2beta3)
839
- #
840
- # # TODO: Initialize `resource`:
841
- # resource = ''
842
- #
843
- # # TODO: Initialize `policy`:
844
- # policy = {}
845
- # response = cloud_tasks_client.set_iam_policy(resource, policy)
846
-
847
- def set_iam_policy \
848
- resource,
849
- policy,
850
- options: nil,
851
- &block
852
- req = {
853
- resource: resource,
854
- policy: policy
855
- }.delete_if { |_, v| v.nil? }
856
- req = Google::Gax::to_proto(req, Google::Iam::V1::SetIamPolicyRequest)
857
- @set_iam_policy.call(req, options, &block)
858
- end
859
-
860
- # Returns permissions that a caller has on a {Google::Cloud::Tasks::V2beta3::Queue Queue}.
861
- # If the resource does not exist, this will return an empty set of
862
- # permissions, not a {Google::Rpc::Code::NOT_FOUND NOT_FOUND} error.
863
- #
864
- # Note: This operation is designed to be used for building permission-aware
865
- # UIs and command-line tools, not for authorization checking. This operation
866
- # may "fail open" without warning.
867
- #
868
- # @param resource [String]
869
- # REQUIRED: The resource for which the policy detail is being requested.
870
- # See the operation documentation for the appropriate value for this field.
871
- # @param permissions [Array<String>]
872
- # The set of permissions to check for the `resource`. Permissions with
873
- # wildcards (such as '*' or 'storage.*') are not allowed. For more
874
- # information see
875
- # [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions).
876
- # @param options [Google::Gax::CallOptions]
877
- # Overrides the default settings for this call, e.g, timeout,
878
- # retries, etc.
879
- # @yield [result, operation] Access the result along with the RPC operation
880
- # @yieldparam result [Google::Iam::V1::TestIamPermissionsResponse]
881
- # @yieldparam operation [GRPC::ActiveCall::Operation]
882
- # @return [Google::Iam::V1::TestIamPermissionsResponse]
883
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
884
- # @example
885
- # require "google/cloud/tasks"
886
- #
887
- # cloud_tasks_client = Google::Cloud::Tasks.new(version: :v2beta3)
888
- #
889
- # # TODO: Initialize `resource`:
890
- # resource = ''
891
- #
892
- # # TODO: Initialize `permissions`:
893
- # permissions = []
894
- # response = cloud_tasks_client.test_iam_permissions(resource, permissions)
895
-
896
- def test_iam_permissions \
897
- resource,
898
- permissions,
899
- options: nil,
900
- &block
901
- req = {
902
- resource: resource,
903
- permissions: permissions
904
- }.delete_if { |_, v| v.nil? }
905
- req = Google::Gax::to_proto(req, Google::Iam::V1::TestIamPermissionsRequest)
906
- @test_iam_permissions.call(req, options, &block)
907
- end
908
-
909
- # Lists the tasks in a queue.
910
- #
911
- # By default, only the {Google::Cloud::Tasks::V2beta3::Task::View::BASIC BASIC} view is retrieved
912
- # due to performance considerations;
913
- # {Google::Cloud::Tasks::V2beta3::ListTasksRequest#response_view response_view} controls the
914
- # subset of information which is returned.
915
- #
916
- # The tasks may be returned in any order. The ordering may change at any
917
- # time.
918
- #
919
- # @param parent [String]
920
- # Required. The queue name. For example:
921
- # `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`
922
- # @param response_view [Google::Cloud::Tasks::V2beta3::Task::View]
923
- # The response_view specifies which subset of the {Google::Cloud::Tasks::V2beta3::Task Task} will be
924
- # returned.
925
- #
926
- # By default response_view is {Google::Cloud::Tasks::V2beta3::Task::View::BASIC BASIC}; not all
927
- # information is retrieved by default because some data, such as
928
- # payloads, might be desirable to return only when needed because
929
- # of its large size or because of the sensitivity of data that it
930
- # contains.
931
- #
932
- # Authorization for {Google::Cloud::Tasks::V2beta3::Task::View::FULL FULL} requires
933
- # `cloudtasks.tasks.fullView` [Google IAM](https://cloud.google.com/iam/)
934
- # permission on the {Google::Cloud::Tasks::V2beta3::Task Task} resource.
935
- # @param page_size [Integer]
936
- # The maximum number of resources contained in the underlying API
937
- # response. If page streaming is performed per-resource, this
938
- # parameter does not affect the return value. If page streaming is
939
- # performed per-page, this determines the maximum number of
940
- # resources in a page.
941
- # @param options [Google::Gax::CallOptions]
942
- # Overrides the default settings for this call, e.g, timeout,
943
- # retries, etc.
944
- # @yield [result, operation] Access the result along with the RPC operation
945
- # @yieldparam result [Google::Gax::PagedEnumerable<Google::Cloud::Tasks::V2beta3::Task>]
946
- # @yieldparam operation [GRPC::ActiveCall::Operation]
947
- # @return [Google::Gax::PagedEnumerable<Google::Cloud::Tasks::V2beta3::Task>]
948
- # An enumerable of Google::Cloud::Tasks::V2beta3::Task instances.
949
- # See Google::Gax::PagedEnumerable documentation for other
950
- # operations such as per-page iteration or access to the response
951
- # object.
952
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
953
- # @example
954
- # require "google/cloud/tasks"
955
- #
956
- # cloud_tasks_client = Google::Cloud::Tasks.new(version: :v2beta3)
957
- # formatted_parent = Google::Cloud::Tasks::V2beta3::CloudTasksClient.queue_path("[PROJECT]", "[LOCATION]", "[QUEUE]")
958
- #
959
- # # Iterate over all results.
960
- # cloud_tasks_client.list_tasks(formatted_parent).each do |element|
961
- # # Process element.
962
- # end
963
- #
964
- # # Or iterate over results one page at a time.
965
- # cloud_tasks_client.list_tasks(formatted_parent).each_page do |page|
966
- # # Process each page at a time.
967
- # page.each do |element|
968
- # # Process element.
969
- # end
970
- # end
971
-
972
- def list_tasks \
973
- parent,
974
- response_view: nil,
975
- page_size: nil,
976
- options: nil,
977
- &block
978
- req = {
979
- parent: parent,
980
- response_view: response_view,
981
- page_size: page_size
982
- }.delete_if { |_, v| v.nil? }
983
- req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta3::ListTasksRequest)
984
- @list_tasks.call(req, options, &block)
985
- end
986
-
987
- # Gets a task.
988
- #
989
- # @param name [String]
990
- # Required. The task name. For example:
991
- # `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`
992
- # @param response_view [Google::Cloud::Tasks::V2beta3::Task::View]
993
- # The response_view specifies which subset of the {Google::Cloud::Tasks::V2beta3::Task Task} will be
994
- # returned.
995
- #
996
- # By default response_view is {Google::Cloud::Tasks::V2beta3::Task::View::BASIC BASIC}; not all
997
- # information is retrieved by default because some data, such as
998
- # payloads, might be desirable to return only when needed because
999
- # of its large size or because of the sensitivity of data that it
1000
- # contains.
1001
- #
1002
- # Authorization for {Google::Cloud::Tasks::V2beta3::Task::View::FULL FULL} requires
1003
- # `cloudtasks.tasks.fullView` [Google IAM](https://cloud.google.com/iam/)
1004
- # permission on the {Google::Cloud::Tasks::V2beta3::Task Task} resource.
1005
- # @param options [Google::Gax::CallOptions]
1006
- # Overrides the default settings for this call, e.g, timeout,
1007
- # retries, etc.
1008
- # @yield [result, operation] Access the result along with the RPC operation
1009
- # @yieldparam result [Google::Cloud::Tasks::V2beta3::Task]
1010
- # @yieldparam operation [GRPC::ActiveCall::Operation]
1011
- # @return [Google::Cloud::Tasks::V2beta3::Task]
1012
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
1013
- # @example
1014
- # require "google/cloud/tasks"
1015
- #
1016
- # cloud_tasks_client = Google::Cloud::Tasks.new(version: :v2beta3)
1017
- # formatted_name = Google::Cloud::Tasks::V2beta3::CloudTasksClient.task_path("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]")
1018
- # response = cloud_tasks_client.get_task(formatted_name)
1019
-
1020
- def get_task \
1021
- name,
1022
- response_view: nil,
1023
- options: nil,
1024
- &block
1025
- req = {
1026
- name: name,
1027
- response_view: response_view
1028
- }.delete_if { |_, v| v.nil? }
1029
- req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta3::GetTaskRequest)
1030
- @get_task.call(req, options, &block)
1031
- end
1032
-
1033
- # Creates a task and adds it to a queue.
1034
- #
1035
- # Tasks cannot be updated after creation; there is no UpdateTask command.
1036
- #
1037
- # * The maximum task size is 100KB.
1038
- #
1039
- # @param parent [String]
1040
- # Required. The queue name. For example:
1041
- # `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`
1042
- #
1043
- # The queue must already exist.
1044
- # @param task [Google::Cloud::Tasks::V2beta3::Task | Hash]
1045
- # Required. The task to add.
1046
- #
1047
- # Task names have the following format:
1048
- # `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`.
1049
- # The user can optionally specify a task {Google::Cloud::Tasks::V2beta3::Task#name name}. If a
1050
- # name is not specified then the system will generate a random
1051
- # unique task id, which will be set in the task returned in the
1052
- # {Google::Cloud::Tasks::V2beta3::Task#name response}.
1053
- #
1054
- # If {Google::Cloud::Tasks::V2beta3::Task#schedule_time schedule_time} is not set or is in the
1055
- # past then Cloud Tasks will set it to the current time.
1056
- #
1057
- # Task De-duplication:
1058
- #
1059
- # Explicitly specifying a task ID enables task de-duplication. If
1060
- # a task's ID is identical to that of an existing task or a task
1061
- # that was deleted or executed recently then the call will fail
1062
- # with {Google::Rpc::Code::ALREADY_EXISTS ALREADY_EXISTS}.
1063
- # If the task's queue was created using Cloud Tasks, then another task with
1064
- # the same name can't be created for ~1hour after the original task was
1065
- # deleted or executed. If the task's queue was created using queue.yaml or
1066
- # queue.xml, then another task with the same name can't be created
1067
- # for ~9days after the original task was deleted or executed.
1068
- #
1069
- # Because there is an extra lookup cost to identify duplicate task
1070
- # names, these {Google::Cloud::Tasks::V2beta3::CloudTasks::CreateTask CreateTask} calls have significantly
1071
- # increased latency. Using hashed strings for the task id or for
1072
- # the prefix of the task id is recommended. Choosing task ids that
1073
- # are sequential or have sequential prefixes, for example using a
1074
- # timestamp, causes an increase in latency and error rates in all
1075
- # task commands. The infrastructure relies on an approximately
1076
- # uniform distribution of task ids to store and serve tasks
1077
- # efficiently.
1078
- # A hash of the same form as `Google::Cloud::Tasks::V2beta3::Task`
1079
- # can also be provided.
1080
- # @param response_view [Google::Cloud::Tasks::V2beta3::Task::View]
1081
- # The response_view specifies which subset of the {Google::Cloud::Tasks::V2beta3::Task Task} will be
1082
- # returned.
1083
- #
1084
- # By default response_view is {Google::Cloud::Tasks::V2beta3::Task::View::BASIC BASIC}; not all
1085
- # information is retrieved by default because some data, such as
1086
- # payloads, might be desirable to return only when needed because
1087
- # of its large size or because of the sensitivity of data that it
1088
- # contains.
1089
- #
1090
- # Authorization for {Google::Cloud::Tasks::V2beta3::Task::View::FULL FULL} requires
1091
- # `cloudtasks.tasks.fullView` [Google IAM](https://cloud.google.com/iam/)
1092
- # permission on the {Google::Cloud::Tasks::V2beta3::Task Task} resource.
1093
- # @param options [Google::Gax::CallOptions]
1094
- # Overrides the default settings for this call, e.g, timeout,
1095
- # retries, etc.
1096
- # @yield [result, operation] Access the result along with the RPC operation
1097
- # @yieldparam result [Google::Cloud::Tasks::V2beta3::Task]
1098
- # @yieldparam operation [GRPC::ActiveCall::Operation]
1099
- # @return [Google::Cloud::Tasks::V2beta3::Task]
1100
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
1101
- # @example
1102
- # require "google/cloud/tasks"
1103
- #
1104
- # cloud_tasks_client = Google::Cloud::Tasks.new(version: :v2beta3)
1105
- # formatted_parent = Google::Cloud::Tasks::V2beta3::CloudTasksClient.queue_path("[PROJECT]", "[LOCATION]", "[QUEUE]")
1106
- #
1107
- # # TODO: Initialize `task`:
1108
- # task = {}
1109
- # response = cloud_tasks_client.create_task(formatted_parent, task)
1110
-
1111
- def create_task \
1112
- parent,
1113
- task,
1114
- response_view: nil,
1115
- options: nil,
1116
- &block
1117
- req = {
1118
- parent: parent,
1119
- task: task,
1120
- response_view: response_view
1121
- }.delete_if { |_, v| v.nil? }
1122
- req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta3::CreateTaskRequest)
1123
- @create_task.call(req, options, &block)
1124
- end
1125
-
1126
- # Deletes a task.
1127
- #
1128
- # A task can be deleted if it is scheduled or dispatched. A task
1129
- # cannot be deleted if it has executed successfully or permanently
1130
- # failed.
1131
- #
1132
- # @param name [String]
1133
- # Required. The task name. For example:
1134
- # `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`
1135
- # @param options [Google::Gax::CallOptions]
1136
- # Overrides the default settings for this call, e.g, timeout,
1137
- # retries, etc.
1138
- # @yield [result, operation] Access the result along with the RPC operation
1139
- # @yieldparam result []
1140
- # @yieldparam operation [GRPC::ActiveCall::Operation]
1141
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
1142
- # @example
1143
- # require "google/cloud/tasks"
1144
- #
1145
- # cloud_tasks_client = Google::Cloud::Tasks.new(version: :v2beta3)
1146
- # formatted_name = Google::Cloud::Tasks::V2beta3::CloudTasksClient.task_path("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]")
1147
- # cloud_tasks_client.delete_task(formatted_name)
1148
-
1149
- def delete_task \
1150
- name,
1151
- options: nil,
1152
- &block
1153
- req = {
1154
- name: name
1155
- }.delete_if { |_, v| v.nil? }
1156
- req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta3::DeleteTaskRequest)
1157
- @delete_task.call(req, options, &block)
1158
- nil
1159
- end
1160
-
1161
- # Forces a task to run now.
1162
- #
1163
- # When this method is called, Cloud Tasks will dispatch the task, even if
1164
- # the task is already running, the queue has reached its {Google::Cloud::Tasks::V2beta3::RateLimits RateLimits} or
1165
- # is {Google::Cloud::Tasks::V2beta3::Queue::State::PAUSED PAUSED}.
1166
- #
1167
- # This command is meant to be used for manual debugging. For
1168
- # example, {Google::Cloud::Tasks::V2beta3::CloudTasks::RunTask RunTask} can be used to retry a failed
1169
- # task after a fix has been made or to manually force a task to be
1170
- # dispatched now.
1171
- #
1172
- # The dispatched task is returned. That is, the task that is returned
1173
- # contains the {Task#status status} after the task is dispatched but
1174
- # before the task is received by its target.
1175
- #
1176
- # If Cloud Tasks receives a successful response from the task's
1177
- # target, then the task will be deleted; otherwise the task's
1178
- # {Google::Cloud::Tasks::V2beta3::Task#schedule_time schedule_time} will be reset to the time that
1179
- # {Google::Cloud::Tasks::V2beta3::CloudTasks::RunTask RunTask} was called plus the retry delay specified
1180
- # in the queue's {Google::Cloud::Tasks::V2beta3::RetryConfig RetryConfig}.
1181
- #
1182
- # {Google::Cloud::Tasks::V2beta3::CloudTasks::RunTask RunTask} returns
1183
- # {Google::Rpc::Code::NOT_FOUND NOT_FOUND} when it is called on a
1184
- # task that has already succeeded or permanently failed.
1185
- #
1186
- # @param name [String]
1187
- # Required. The task name. For example:
1188
- # `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`
1189
- # @param response_view [Google::Cloud::Tasks::V2beta3::Task::View]
1190
- # The response_view specifies which subset of the {Google::Cloud::Tasks::V2beta3::Task Task} will be
1191
- # returned.
1192
- #
1193
- # By default response_view is {Google::Cloud::Tasks::V2beta3::Task::View::BASIC BASIC}; not all
1194
- # information is retrieved by default because some data, such as
1195
- # payloads, might be desirable to return only when needed because
1196
- # of its large size or because of the sensitivity of data that it
1197
- # contains.
1198
- #
1199
- # Authorization for {Google::Cloud::Tasks::V2beta3::Task::View::FULL FULL} requires
1200
- # `cloudtasks.tasks.fullView` [Google IAM](https://cloud.google.com/iam/)
1201
- # permission on the {Google::Cloud::Tasks::V2beta3::Task Task} resource.
1202
- # @param options [Google::Gax::CallOptions]
1203
- # Overrides the default settings for this call, e.g, timeout,
1204
- # retries, etc.
1205
- # @yield [result, operation] Access the result along with the RPC operation
1206
- # @yieldparam result [Google::Cloud::Tasks::V2beta3::Task]
1207
- # @yieldparam operation [GRPC::ActiveCall::Operation]
1208
- # @return [Google::Cloud::Tasks::V2beta3::Task]
1209
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
1210
- # @example
1211
- # require "google/cloud/tasks"
1212
- #
1213
- # cloud_tasks_client = Google::Cloud::Tasks.new(version: :v2beta3)
1214
- # formatted_name = Google::Cloud::Tasks::V2beta3::CloudTasksClient.task_path("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]")
1215
- # response = cloud_tasks_client.run_task(formatted_name)
1216
-
1217
- def run_task \
1218
- name,
1219
- response_view: nil,
1220
- options: nil,
1221
- &block
1222
- req = {
1223
- name: name,
1224
- response_view: response_view
1225
- }.delete_if { |_, v| v.nil? }
1226
- req = Google::Gax::to_proto(req, Google::Cloud::Tasks::V2beta3::RunTaskRequest)
1227
- @run_task.call(req, options, &block)
1228
- end
1229
- end
1230
- end
1231
- end
1232
- end
1233
- end