Skip to content

Commit 104aaf5

Browse files
author
Benjamin E. Coe
authored
docs: generate docs for ga release (#221)
1 parent 99ea91c commit 104aaf5

17 files changed

Lines changed: 415 additions & 256 deletions

File tree

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"name": "tasks",
3+
"name_pretty": "Cloud Tasks",
4+
"product_documentation": "https://cloud.google.com/tasks/docs/",
5+
"client_documentation": "https://cloud.google.com/nodejs/docs/reference/tasks/latest/",
6+
"issue_tracker": "https://issuetracker.google.com/savedsearches/5433985",
7+
"release_level": "ga",
8+
"language": "nodejs",
9+
"repo": "googleapis/nodejs-tasks",
10+
"distribution_name": "@google-cloud/tasks",
11+
"api_id": "tasks.googleapis.com",
12+
"requires_billing": true
13+
}
Lines changed: 87 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
[//]: # "This README.md file is auto-generated, all changes to this file will be lost."
2-
[//]: # "To regenerate it, use `npm run generate-scaffolding`."
2+
[//]: # "To regenerate it, use `python -m synthtool`."
33
<img src="https://avatars2.githubusercontent.com/u/2810941?v=3&s=96" alt="Google Cloud Platform logo" title="Google Cloud Platform" align="right" height="96" width="96"/>
44

5-
# [Google Cloud Tasks: Node.js Client](https://github.com/googleapis/nodejs-tasks)
5+
# [Cloud Tasks: Node.js Client](https://github.com/googleapis/nodejs-tasks)
66

7-
[![release level](https://img.shields.io/badge/release%20level-alpha-orange.svg?style&#x3D;flat)](https://cloud.google.com/terms/launch-stages)
7+
[![release level](https://img.shields.io/badge/release%20level-general%20availability%20%28GA%29-brightgreen.svg?style=flat)](https://cloud.google.com/terms/launch-stages)
88
[![npm version](https://img.shields.io/npm/v/@google-cloud/tasks.svg)](https://www.npmjs.org/package/@google-cloud/tasks)
99
[![codecov](https://img.shields.io/codecov/c/github/googleapis/nodejs-tasks/master.svg?style=flat)](https://codecov.io/gh/googleapis/nodejs-tasks)
1010

11-
> Node.js idiomatic client for [Cloud Tasks][product-docs].
1211

13-
Manages the execution of large numbers of distributed requests.
12+
13+
14+
Cloud Tasks API client for Node.js
1415

1516

1617
* [Cloud Tasks Node.js Client API Reference][client-docs]
17-
* [github.com/googleapis/nodejs-tasks](https://github.com/googleapis/nodejs-tasks)
1818
* [Cloud Tasks Documentation][product-docs]
19+
* [github.com/googleapis/nodejs-tasks](https://github.com/googleapis/nodejs-tasks)
1920

2021
Read more about the client libraries for Cloud APIs, including the older
2122
Google APIs Client Libraries, in [Client Libraries Explained][explained].
@@ -24,69 +25,102 @@ Google APIs Client Libraries, in [Client Libraries Explained][explained].
2425

2526
**Table of contents:**
2627

27-
* [Using the client library](#using-the-client-library)
28+
29+
* [Quickstart](#quickstart)
30+
* [Before you begin](#before-you-begin)
31+
* [Installing the client library](#installing-the-client-library)
32+
* [Using the client library](#using-the-client-library)
2833
* [Samples](#samples)
2934
* [Versioning](#versioning)
3035
* [Contributing](#contributing)
3136
* [License](#license)
3237

33-
## Using the client library
38+
## Quickstart
3439

35-
1. [Select or create a Cloud Platform project][projects].
40+
### Before you begin
3641

42+
1. [Select or create a Cloud Platform project][projects].
3743
1. [Enable billing for your project][billing].
38-
39-
1. [Enable the Google Cloud Tasks API][enable_api].
40-
44+
1. [Enable the Cloud Tasks API][enable_api].
4145
1. [Set up authentication with a service account][auth] so you can access the
4246
API from your local workstation.
4347

44-
1. Install the client library:
48+
### Installing the client library
49+
50+
```bash
51+
npm install @google-cloud/tasks
52+
```
4553

46-
npm install --save @google-cloud/tasks
4754

48-
1. Try an example:
55+
### Using the client library
4956

50-
```js
51-
// Imports the Google Cloud client library
52-
const {CloudTasksClient} = require('@google-cloud/tasks');
57+
```javascript
58+
// Imports the Google Cloud Tasks library.
59+
const {CloudTasksClient} = require('@google-cloud/tasks');
5360

54-
async function quickstart(
55-
projectId = 'your-project-id', // Your Google Cloud Platform project ID
56-
queue = 'my-appengine-queue', // Name of the Queue to create
57-
location = 'us-central-1' // The region in which to create the queue
58-
) {
59-
// Instantiates a client
61+
// Instantiates a client.
6062
const client = new CloudTasksClient();
6163

62-
// Send create queue request.
63-
const [response] = await client.createQueue({
64-
// The fully qualified path to the location where the queue is created
65-
parent: client.locationPath(projectId, location),
66-
queue: {
67-
// The fully qualified path to the queue
68-
name: client.queuePath(projectId, location, queue),
69-
appEngineHttpQueue: {
70-
appEngineRoutingOverride: {
71-
// The App Engine service that will receive the tasks.
72-
service: 'default',
73-
},
74-
},
64+
// TODO(developer): Uncomment these lines and replace with your values.
65+
// const project = 'my-project-id';
66+
// const queue = 'my-appengine-queue';
67+
// const location = 'us-central1';
68+
// const options = {payload: 'hello'};
69+
70+
// Construct the fully qualified queue name.
71+
const parent = client.queuePath(project, location, queue);
72+
73+
const task = {
74+
appEngineHttpRequest: {
75+
httpMethod: 'POST',
76+
relativeUri: '/log_payload',
7577
},
76-
});
77-
console.log(`Created queue ${response.name}`);
78-
}
78+
};
79+
80+
if (payload) {
81+
task.appEngineHttpRequest.body = Buffer.from(payload).toString('base64');
82+
}
83+
84+
if (inSeconds) {
85+
task.scheduleTime = {
86+
seconds: inSeconds + Date.now() / 1000,
87+
};
88+
}
89+
90+
const request = {
91+
parent: parent,
92+
task: task,
93+
};
94+
95+
console.log('Sending task:');
96+
console.log(task);
97+
// Send create task request.
98+
const [response] = await client.createTask(request);
99+
const name = response.name;
100+
console.log(`Created task ${name}`);
101+
102+
79103
```
80104

105+
106+
81107
## Samples
82108

83109
Samples are in the [`samples/`](https://github.com/googleapis/nodejs-tasks/tree/master/samples) directory. The samples' `README.md`
84110
has instructions for running the samples.
85111

86112
| Sample | Source Code | Try it |
87113
| --------------------------- | --------------------------------- | ------ |
88-
| Queues | [source code](https://github.com/googleapis/nodejs-tasks/blob/master/samples/createQueue.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-tasks&page=editor&open_in_editor=samples/createQueue.js,samples/README.md) |
89-
| Tasks | [source code](https://github.com/googleapis/nodejs-tasks/blob/master/samples/createTask.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-tasks&page=editor&open_in_editor=samples/createTask.js,samples/README.md) |
114+
| Create Http Task | [source code](https://github.com/googleapis/nodejs-tasks/blob/master/samples/createHttpTask.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-tasks&page=editor&open_in_editor=samples/createHttpTask.js,samples/README.md) |
115+
| Create Http Task With Token | [source code](https://github.com/googleapis/nodejs-tasks/blob/master/samples/createHttpTaskWithToken.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-tasks&page=editor&open_in_editor=samples/createHttpTaskWithToken.js,samples/README.md) |
116+
| Create Queue | [source code](https://github.com/googleapis/nodejs-tasks/blob/master/samples/createQueue.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-tasks&page=editor&open_in_editor=samples/createQueue.js,samples/README.md) |
117+
| Create Task | [source code](https://github.com/googleapis/nodejs-tasks/blob/master/samples/createTask.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-tasks&page=editor&open_in_editor=samples/createTask.js,samples/README.md) |
118+
| Delete Queue | [source code](https://github.com/googleapis/nodejs-tasks/blob/master/samples/deleteQueue.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-tasks&page=editor&open_in_editor=samples/deleteQueue.js,samples/README.md) |
119+
| List Queues | [source code](https://github.com/googleapis/nodejs-tasks/blob/master/samples/listQueues.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-tasks&page=editor&open_in_editor=samples/listQueues.js,samples/README.md) |
120+
| Quickstart | [source code](https://github.com/googleapis/nodejs-tasks/blob/master/samples/quickstart.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-tasks&page=editor&open_in_editor=samples/quickstart.js,samples/README.md) |
121+
| Server | [source code](https://github.com/googleapis/nodejs-tasks/blob/master/samples/server.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-tasks&page=editor&open_in_editor=samples/server.js,samples/README.md) |
122+
123+
90124

91125
The [Cloud Tasks Node.js Client API Reference][client-docs] documentation
92126
also contains samples.
@@ -95,9 +129,16 @@ also contains samples.
95129

96130
This library follows [Semantic Versioning](http://semver.org/).
97131

98-
This library is considered to be in **alpha**. This means it is still a
99-
work-in-progress and under active development. Any release is subject to
100-
backwards-incompatible changes at any time.
132+
133+
This library is considered to be **General Availability (GA)**. This means it
134+
is stable; the code surface will not change in backwards-incompatible ways
135+
unless absolutely necessary (e.g. because of critical security issues) or with
136+
an extensive deprecation period. Issues and requests against **GA** libraries
137+
are addressed with the highest priority.
138+
139+
140+
141+
101142

102143
More Information: [Google Cloud Platform Launch Stages][launch_stages]
103144

@@ -119,4 +160,4 @@ See [LICENSE](https://github.com/googleapis/nodejs-tasks/blob/master/LICENSE)
119160
[projects]: https://console.cloud.google.com/project
120161
[billing]: https://support.google.com/cloud/answer/6293499#enable-billing
121162
[enable_api]: https://console.cloud.google.com/flows/enableapi?apiid=tasks.googleapis.com
122-
[auth]: https://cloud.google.com/docs/authentication/getting-started
163+
[auth]: https://cloud.google.com/docs/authentication/getting-started

packages/google-cloud-tasks/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"docs": "jsdoc -c .jsdoc.js",
4040
"system-test": "mocha system-test/ smoke-test/ --timeout 600000",
4141
"fix": "eslint '**/*.js' --fix",
42-
"docs-test": "linkinator docs -r --skip www.googleapis.com",
42+
"docs-test": "linkinator docs -r --skip 'www.googleapis.com|github.com/googleapis/nodejs-tasks/blob/master/samples/quickstart.js'",
4343
"predocs-test": "npm run docs"
4444
},
4545
"dependencies": {

packages/google-cloud-tasks/protos/google/cloud/tasks/v2/cloudtasks.proto

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ package google.cloud.tasks.v2;
1919

2020
import "google/api/annotations.proto";
2121
import "google/api/resource.proto";
22-
import "google/protobuf/empty.proto";
23-
import "google/protobuf/field_mask.proto";
24-
import "google/cloud/tasks/v2/task.proto";
2522
import "google/cloud/tasks/v2/queue.proto";
23+
import "google/cloud/tasks/v2/task.proto";
2624
import "google/iam/v1/iam_policy.proto";
2725
import "google/iam/v1/policy.proto";
26+
import "google/protobuf/empty.proto";
27+
import "google/protobuf/field_mask.proto";
2828
import "google/rpc/code.proto";
2929

3030
option go_package = "google.golang.org/genproto/googleapis/cloud/tasks/v2;tasks";
@@ -33,7 +33,6 @@ option java_outer_classname = "CloudTasksProto";
3333
option java_package = "com.google.cloud.tasks.v2";
3434
option objc_class_prefix = "TASKS";
3535

36-
3736
// Cloud Tasks allows developers to manage the execution of background
3837
// work in their applications.
3938
service CloudTasks {
@@ -62,8 +61,9 @@ service CloudTasks {
6261
// WARNING: Using this method may have unintended side effects if you are
6362
// using an App Engine `queue.yaml` or `queue.xml` file to manage your queues.
6463
// Read
65-
// [Overview of Queue Management and queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml)
66-
// before using this method.
64+
// [Overview of Queue Management and
65+
// queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) before using
66+
// this method.
6767
rpc CreateQueue(CreateQueueRequest) returns (Queue) {
6868
option (google.api.http) = {
6969
post: "/v2/{parent=projects/*/locations/*}/queues"
@@ -83,8 +83,9 @@ service CloudTasks {
8383
// WARNING: Using this method may have unintended side effects if you are
8484
// using an App Engine `queue.yaml` or `queue.xml` file to manage your queues.
8585
// Read
86-
// [Overview of Queue Management and queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml)
87-
// before using this method.
86+
// [Overview of Queue Management and
87+
// queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) before using
88+
// this method.
8889
rpc UpdateQueue(UpdateQueueRequest) returns (Queue) {
8990
option (google.api.http) = {
9091
patch: "/v2/{queue.name=projects/*/locations/*/queues/*}"
@@ -102,8 +103,9 @@ service CloudTasks {
102103
// WARNING: Using this method may have unintended side effects if you are
103104
// using an App Engine `queue.yaml` or `queue.xml` file to manage your queues.
104105
// Read
105-
// [Overview of Queue Management and queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml)
106-
// before using this method.
106+
// [Overview of Queue Management and
107+
// queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) before using
108+
// this method.
107109
rpc DeleteQueue(DeleteQueueRequest) returns (google.protobuf.Empty) {
108110
option (google.api.http) = {
109111
delete: "/v2/{name=projects/*/locations/*/queues/*}"
@@ -148,7 +150,8 @@ service CloudTasks {
148150
// WARNING: Resuming many high-QPS queues at the same time can
149151
// lead to target overloading. If you are resuming high-QPS
150152
// queues, follow the 500/50/5 pattern described in
151-
// [Managing Cloud Tasks Scaling Risks](https://cloud.google.com/tasks/docs/manage-cloud-task-scaling).
153+
// [Managing Cloud Tasks Scaling
154+
// Risks](https://cloud.google.com/tasks/docs/manage-cloud-task-scaling).
152155
rpc ResumeQueue(ResumeQueueRequest) returns (Queue) {
153156
option (google.api.http) = {
154157
post: "/v2/{name=projects/*/locations/*/queues/*}:resume"
@@ -230,8 +233,7 @@ service CloudTasks {
230233
//
231234
// Tasks cannot be updated after creation; there is no UpdateTask command.
232235
//
233-
// * For [App Engine queues][google.cloud.tasks.v2.AppEngineHttpQueue], the maximum task size is
234-
// 100KB.
236+
// * The maximum task size is 100KB.
235237
rpc CreateTask(CreateTaskRequest) returns (Task) {
236238
option (google.api.http) = {
237239
post: "/v2/{parent=projects/*/locations/*/queues/*}/tasks"
@@ -294,7 +296,8 @@ message ListQueuesRequest {
294296
// field can be used as a filter and several operators as supported.
295297
// For example: `<=, <, >=, >, !=, =, :`. The filter syntax is the same as
296298
// described in
297-
// [Stackdriver's Advanced Logs Filters](https://cloud.google.com/logging/docs/view/advanced_filters).
299+
// [Stackdriver's Advanced Logs
300+
// Filters](https://cloud.google.com/logging/docs/view/advanced_filters).
298301
//
299302
// Sample filter "state: PAUSED".
300303
//
@@ -445,13 +448,14 @@ message ListTasksRequest {
445448
// permission on the [Task][google.cloud.tasks.v2.Task] resource.
446449
Task.View response_view = 2;
447450

448-
// Requested page size. Fewer tasks than requested might be returned.
451+
// Maximum page size.
452+
//
453+
// Fewer tasks than requested might be returned, even if more tasks exist; use
454+
// [next_page_token][google.cloud.tasks.v2.ListTasksResponse.next_page_token] in the response to
455+
// determine if more tasks exist.
449456
//
450-
// The maximum page size is 1000. If unspecified, the page size will
451-
// be the maximum. Fewer tasks than requested might be returned,
452-
// even if more tasks exist; use
453-
// [next_page_token][google.cloud.tasks.v2.ListTasksResponse.next_page_token] in the
454-
// response to determine if more tasks exist.
457+
// The maximum page size is 1000. If unspecified, the page size will be the
458+
// maximum.
455459
int32 page_size = 3;
456460

457461
// A token identifying the page of results to return.

packages/google-cloud-tasks/protos/google/cloud/tasks/v2/queue.proto

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ option java_multiple_files = true;
2828
option java_outer_classname = "QueueProto";
2929
option java_package = "com.google.cloud.tasks.v2";
3030

31-
3231
// A queue is a container of related tasks. Queues are configured to manage
3332
// how those tasks are dispatched. Configurable properties include rate limits,
3433
// retry options, queue types, and others.

packages/google-cloud-tasks/protos/google/cloud/tasks/v2/target.proto

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,11 @@ option java_multiple_files = true;
2424
option java_outer_classname = "TargetProto";
2525
option java_package = "com.google.cloud.tasks.v2";
2626

27-
2827
// App Engine HTTP request.
2928
//
3029
// The message defines the HTTP request that is sent to an App Engine app when
3130
// the task is dispatched.
3231
//
33-
// This proto can only be used for tasks in a queue which has
34-
// [app_engine_http_queue][Queue.app_engine_http_queue] set.
35-
//
3632
// Using [AppEngineHttpRequest][google.cloud.tasks.v2.AppEngineHttpRequest] requires
3733
// [`appengine.applications.get`](https://cloud.google.com/appengine/docs/admin-api/access-control)
3834
// Google IAM permission for the project
@@ -78,13 +74,17 @@ option java_package = "com.google.cloud.tasks.v2";
7874
// required`](https://cloud.google.com/appengine/docs/standard/python/config/appref)
7975
// Task dispatches also do not follow redirects.
8076
//
81-
// The task attempt has succeeded if the app's request handler returns
82-
// an HTTP response code in the range [`200` - `299`]. `503` is
83-
// considered an App Engine system error instead of an application
84-
// error. Requests returning error `503` will be retried regardless of
85-
// retry configuration and not counted against retry counts.
86-
// Any other response code or a failure to receive a response before the
87-
// deadline is a failed attempt.
77+
// The task attempt has succeeded if the app's request handler returns an HTTP
78+
// response code in the range [`200` - `299`]. The task attempt has failed if
79+
// the app's handler returns a non-2xx response code or Cloud Tasks does
80+
// not receive response before the [deadline][google.cloud.tasks.v2.Task.dispatch_deadline]. Failed
81+
// tasks will be retried according to the
82+
// [retry configuration][Queue.RetryConfig]. `503` (Service Unavailable) is
83+
// considered an App Engine system error instead of an application error and
84+
// will cause Cloud Tasks' traffic congestion control to temporarily throttle
85+
// the queue's dispatches. Unlike other types of task targets, a `429` (Too Many
86+
// Requests) response from an app handler does not cause traffic congestion
87+
// control to throttle the queue.
8888
message AppEngineHttpRequest {
8989
// The HTTP method to use for the request. The default is POST.
9090
//

packages/google-cloud-tasks/protos/google/cloud/tasks/v2/task.proto

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ option java_multiple_files = true;
2929
option java_outer_classname = "TaskProto";
3030
option java_package = "com.google.cloud.tasks.v2";
3131

32-
3332
// A unit of scheduled work.
3433
message Task {
3534
// The view specifies a subset of [Task][google.cloud.tasks.v2.Task] data.

packages/google-cloud-tasks/protos/google/cloud/tasks/v2beta3/cloudtasks.proto

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,7 @@ service CloudTasks {
233233
//
234234
// Tasks cannot be updated after creation; there is no UpdateTask command.
235235
//
236-
// * For [App Engine queues][google.cloud.tasks.v2beta3.AppEngineHttpQueue], the maximum task size is
237-
// 100KB.
236+
// * The maximum task size is 100KB.
238237
rpc CreateTask(CreateTaskRequest) returns (Task) {
239238
option (google.api.http) = {
240239
post: "/v2beta3/{parent=projects/*/locations/*/queues/*}/tasks"

0 commit comments

Comments
 (0)