33[ ![ Open in Cloud Shell] [ shell_img ]] [ shell_link ]
44
55[ shell_img ] : http://gstatic.com/cloudssh/images/open-btn.png
6- [ shell_link ] : https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=appengine/flexible/ tasks/README.md
6+ [ shell_link ] : https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=tasks/README.md
77
8- Sample command-line programs for interacting with the Cloud Tasks API
9- .
10-
11- App Engine queues push tasks to an App Engine HTTP target. This directory
12- contains both the App Engine app to deploy, as well as the snippets to run
13- locally to push tasks to it, which could also be called on App Engine.
8+ This sample demonstrates how to use the
9+ [ Cloud Tasks] ( https://cloud.google.com/tasks/docs/ ) client library.
1410
1511` create_http_task.py ` is a simple command-line program to create
1612tasks to be pushed to an URL endpoint.
1713
1814` create_http_task_with_token.py ` is a simple command-line program to create
1915tasks to be pushed to an URL endpoint with authorization header.
2016
21- ` main.py ` is the main App Engine app. This app serves as an endpoint to receive
22- App Engine task attempts.
23-
24- ` app.yaml ` configures the App Engine app.
25-
26-
2717## Prerequisites to run locally:
2818
2919Please refer to [ Setting Up a Python Development Environment] ( https://cloud.google.com/python/setup ) .
@@ -35,15 +25,13 @@ To set up authentication, please refer to our
3525
3626## Creating a queue
3727
38- To create a queue using the Cloud SDK, use the following gcloud command:
28+ To create a queue (named ` my-queue ` ) using the Cloud SDK, use the following
29+ gcloud command:
3930
4031```
41- gcloud beta tasks queues create-app-engine-queue my-appengine -queue
32+ gcloud beta tasks queues create my-queue
4233```
4334
44- Note: A newly created queue will route to the default App Engine service and
45- version unless configured to do otherwise.
46-
4735## Run the Sample Using the Command Line
4836
4937Set environment variables:
@@ -58,25 +46,25 @@ Then the queue ID, as specified at queue creation time. Queue IDs already
5846created can be listed with ` gcloud beta tasks queues list ` .
5947
6048```
61- export QUEUE_ID=my-appengine- queue
49+ export QUEUE_ID=my-queue
6250```
6351
6452And finally the location ID, which can be discovered with
65- ` gcloud beta tasks queues describe $QUEUE_ID ` , with the location embedded in
53+ ` gcloud beta tasks queues describe my-queue ` , with the location embedded in
6654the "name" value (for instance, if the name is
67- "projects/my-project/locations/us-central1/queues/my-appengine- queue", then the
55+ "projects/my-project/locations/us-central1/queues/my-queue", then the
6856location is "us-central1").
6957
7058```
7159export LOCATION_ID=us-central1
7260```
7361
74- ### Using HTTP Push Queues
62+ ### Creating Tasks with HTTP Targets
7563
7664Set an environment variable for the endpoint to your task handler. This is an
77- example url to send requests to the App Engine task handler :
65+ example url:
7866```
79- export URL=https://<project_id>.appspot. com/example_task_handler
67+ export URL=https://example. com/task_handler
8068```
8169
8270Running the sample will create a task and send the task to the specific URL
0 commit comments