3
3
[ ![ Open in Cloud Shell] [ shell_img ]] [ shell_link ]
4
4
5
5
[ 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
7
7
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.
14
10
15
11
` create_http_task.py ` is a simple command-line program to create
16
12
tasks to be pushed to an URL endpoint.
17
13
18
14
` create_http_task_with_token.py ` is a simple command-line program to create
19
15
tasks to be pushed to an URL endpoint with authorization header.
20
16
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
-
27
17
## Prerequisites to run locally:
28
18
29
19
Please 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
35
25
36
26
## Creating a queue
37
27
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:
39
30
40
31
```
41
- gcloud beta tasks queues create-app-engine-queue my-appengine -queue
32
+ gcloud beta tasks queues create my-queue
42
33
```
43
34
44
- Note: A newly created queue will route to the default App Engine service and
45
- version unless configured to do otherwise.
46
-
47
35
## Run the Sample Using the Command Line
48
36
49
37
Set environment variables:
@@ -58,25 +46,25 @@ Then the queue ID, as specified at queue creation time. Queue IDs already
58
46
created can be listed with ` gcloud beta tasks queues list ` .
59
47
60
48
```
61
- export QUEUE_ID=my-appengine- queue
49
+ export QUEUE_ID=my-queue
62
50
```
63
51
64
52
And 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
66
54
the "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
68
56
location is "us-central1").
69
57
70
58
```
71
59
export LOCATION_ID=us-central1
72
60
```
73
61
74
- ### Using HTTP Push Queues
62
+ ### Creating Tasks with HTTP Targets
75
63
76
64
Set 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:
78
66
```
79
- export URL=https://<project_id>.appspot. com/example_task_handler
67
+ export URL=https://example. com/task_handler
80
68
```
81
69
82
70
Running the sample will create a task and send the task to the specific URL
0 commit comments