|
1 | 1 | # Google Cloud Tasks Samples |
2 | 2 |
|
3 | | -This sample demonstrates using the Cloud Tasks client library. These code snippets |
4 | | -are not executable, but are a copy-and-pasteable resource for your own code |
5 | | -base. For executable code, see the [App Engine Quickstart](https://cloud.google.com/tasks/docs/quickstart-appengine). |
6 | | - |
7 | | -See the [Cloud Tasks documentation](https://cloud.google.com/tasks/docs/) for more info on [Creating HTTP Target tasks](https://cloud.google.com/tasks/docs/creating-http-target-tasks). |
8 | | - |
9 | | -`CreateHttpTask.java` constructs a task with an HTTP target and pushes it |
10 | | -to your queue. |
11 | | - |
12 | | -`CreateHttpTask.java` constructs a task with an HTTP target and OIDC token and |
13 | | -pushes it to your queue. |
14 | | - |
15 | | -## Initial Setup |
16 | | - |
17 | | - * Set up a Google Cloud Project and enable billing. |
18 | | - * Enable the |
19 | | - [Cloud Tasks API](https://console.cloud.google.com/launcher/details/google/cloudtasks.googleapis.com). |
20 | | - * Download and install the [Cloud SDK](https://cloud.google.com/sdk). |
21 | | - * Download and install [Maven](http://maven.apache.org/install.html). |
22 | | - * Set up [Google Application Credentials](https://cloud.google.com/docs/authentication/getting-started). |
23 | | - |
24 | | -## Creating a queue |
25 | | - |
26 | | -To create a queue using the Cloud SDK, use the following `gcloud` command: |
27 | | - |
28 | | -``` |
29 | | -gcloud tasks queues create <QUEUE_NAME> |
30 | | -``` |
31 | | - |
32 | | -The location of your queue is the same as your Google Cloud Project. It can be discovered by using the following `gcloud` command: |
33 | | - |
34 | | -``` |
35 | | -gcloud tasks queues describe <QUEUE_NAME> |
36 | | -``` |
37 | | -the location embedded in the "name" value (for instance, if the name is |
38 | | -"projects/my-project/locations/us-central1/queues/my-queue", then the |
39 | | -location is "us-central1"). |
40 | | - |
41 | | -## Creating Tasks with HTTP Targets |
42 | | - |
43 | | -Set an endpoint to your task handler by replacing the variable `url` with your |
44 | | -HTTP target in `CreateHttpTask.java`. |
45 | | - |
46 | | -The sample will create a task and add it to your queue. As the queue processes |
47 | | -each task, it will send the task to the specific URL endpoint. |
48 | | - |
49 | | -## Using HTTP Targets with Authentication Tokens |
50 | | - |
51 | | -Set an endpoint to your task handler by replacing the variable `url` with your |
52 | | -HTTP target in `CreateHttpTaskWithToken.java`. |
53 | | - |
54 | | -Your Cloud Tasks [service account][sa], |
55 | | - |
56 | | -have the role of: `Service Account Token Creator` to generate a tokens. |
57 | | - |
58 | | -Create or use an existing [service account][sa] to authenticate the OIDC token. |
59 | | - |
60 | | -[sa]: https://cloud.google.com/iam/docs/service-accounts |
| 3 | +These samples have moved to [googleapis/java-tasks](https://github.com/googleapis/java-tasks/tree/master/samples). |
0 commit comments