Skip to content

Instantly share code, notes, and snippets.

@calorie
Created September 29, 2022 10:57
Show Gist options
  • Save calorie/c4315b27eca724e4bfeda128d92b23f7 to your computer and use it in GitHub Desktop.
Save calorie/c4315b27eca724e4bfeda128d92b23f7 to your computer and use it in GitHub Desktop.
require 'google/cloud/tasks/v2'
http_method = 'POST'
url = ''
project = ''
location = ''
queue = ''
parent = "projects/#{project}/locations/#{location}/queues/#{queue}"
http_request = ::Google::Cloud::Tasks::V2::HttpRequest.new
http_request.http_method = http_method
http_request.url = url
task = ::Google::Cloud::Tasks::V2::Task.new
task.http_request = http_request
request = ::Google::Cloud::Tasks::V2::CreateTaskRequest.new(parent: parent, task: task)
client = ::Google::Cloud::Tasks::V2::CloudTasks::Client.new
result = client.create_task request
puts result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment