Skip to content

Commit 3d3f679

Browse files
docs(samples): add auto-generated samples for Node with api short name in region tag (#571)
- [ ] Regenerate this pull request now. PiperOrigin-RevId: 399287285 Source-Link: googleapis/googleapis@1575986 Source-Link: googleapis/googleapis-gen@b27fff6 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYjI3ZmZmNjIzYTVkOGQ1ODZiNzAzYjVlNDkxOTg1NmFiZTdjMmViMyJ9
1 parent 8665cf4 commit 3d3f679

File tree

55 files changed

+3465
-12
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+3465
-12
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
// Copyright 2021 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
'use strict';
16+
17+
function main(parent, queue) {
18+
// [START cloudtasks_v2_generated_CloudTasks_CreateQueue_async]
19+
/**
20+
* TODO(developer): Uncomment these variables before running the sample.
21+
*/
22+
/**
23+
* Required. The location name in which the queue will be created.
24+
* For example: `projects/PROJECT_ID/locations/LOCATION_ID`
25+
* The list of allowed locations can be obtained by calling Cloud
26+
* Tasks' implementation of
27+
* [ListLocations][google.cloud.location.Locations.ListLocations].
28+
*/
29+
// const parent = 'abc123'
30+
/**
31+
* Required. The queue to create.
32+
* [Queue's name][google.cloud.tasks.v2.Queue.name] cannot be the same as an existing queue.
33+
*/
34+
// const queue = ''
35+
36+
// Imports the Tasks library
37+
const {CloudTasksClient} = require('@google-cloud/tasks').v2;
38+
39+
// Instantiates a client
40+
const tasksClient = new CloudTasksClient();
41+
42+
async function createQueue() {
43+
// Construct request
44+
const request = {
45+
parent,
46+
queue,
47+
};
48+
49+
// Run request
50+
const response = await tasksClient.createQueue(request);
51+
console.log(response);
52+
}
53+
54+
createQueue();
55+
// [END cloudtasks_v2_generated_CloudTasks_CreateQueue_async]
56+
}
57+
58+
process.on('unhandledRejection', err => {
59+
console.error(err.message);
60+
process.exitCode = 1;
61+
});
62+
main(...process.argv.slice(2));
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
// Copyright 2021 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
'use strict';
16+
17+
function main(parent, task) {
18+
// [START cloudtasks_v2_generated_CloudTasks_CreateTask_async]
19+
/**
20+
* TODO(developer): Uncomment these variables before running the sample.
21+
*/
22+
/**
23+
* Required. The queue name. For example:
24+
* `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`
25+
* The queue must already exist.
26+
*/
27+
// const parent = 'abc123'
28+
/**
29+
* Required. The task to add.
30+
* Task names have the following format:
31+
* `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`.
32+
* The user can optionally specify a task [name][google.cloud.tasks.v2.Task.name]. If a
33+
* name is not specified then the system will generate a random
34+
* unique task id, which will be set in the task returned in the
35+
* [response][google.cloud.tasks.v2.Task.name].
36+
* If [schedule_time][google.cloud.tasks.v2.Task.schedule_time] is not set or is in the
37+
* past then Cloud Tasks will set it to the current time.
38+
* Task De-duplication:
39+
* Explicitly specifying a task ID enables task de-duplication. If
40+
* a task's ID is identical to that of an existing task or a task
41+
* that was deleted or executed recently then the call will fail
42+
* with [ALREADY_EXISTS][google.rpc.Code.ALREADY_EXISTS].
43+
* If the task's queue was created using Cloud Tasks, then another task with
44+
* the same name can't be created for ~1hour after the original task was
45+
* deleted or executed. If the task's queue was created using queue.yaml or
46+
* queue.xml, then another task with the same name can't be created
47+
* for ~9days after the original task was deleted or executed.
48+
* Because there is an extra lookup cost to identify duplicate task
49+
* names, these [CreateTask][google.cloud.tasks.v2.CloudTasks.CreateTask] calls have significantly
50+
* increased latency. Using hashed strings for the task id or for
51+
* the prefix of the task id is recommended. Choosing task ids that
52+
* are sequential or have sequential prefixes, for example using a
53+
* timestamp, causes an increase in latency and error rates in all
54+
* task commands. The infrastructure relies on an approximately
55+
* uniform distribution of task ids to store and serve tasks
56+
* efficiently.
57+
*/
58+
// const task = ''
59+
/**
60+
* The response_view specifies which subset of the [Task][google.cloud.tasks.v2.Task] will be
61+
* returned.
62+
* By default response_view is [BASIC][google.cloud.tasks.v2.Task.View.BASIC]; not all
63+
* information is retrieved by default because some data, such as
64+
* payloads, might be desirable to return only when needed because
65+
* of its large size or because of the sensitivity of data that it
66+
* contains.
67+
* Authorization for [FULL][google.cloud.tasks.v2.Task.View.FULL] requires
68+
* `cloudtasks.tasks.fullView` [Google IAM](https://cloud.google.com/iam/)
69+
* permission on the [Task][google.cloud.tasks.v2.Task] resource.
70+
*/
71+
// const responseView = ''
72+
73+
// Imports the Tasks library
74+
const {CloudTasksClient} = require('@google-cloud/tasks').v2;
75+
76+
// Instantiates a client
77+
const tasksClient = new CloudTasksClient();
78+
79+
async function createTask() {
80+
// Construct request
81+
const request = {
82+
parent,
83+
task,
84+
};
85+
86+
// Run request
87+
const response = await tasksClient.createTask(request);
88+
console.log(response);
89+
}
90+
91+
createTask();
92+
// [END cloudtasks_v2_generated_CloudTasks_CreateTask_async]
93+
}
94+
95+
process.on('unhandledRejection', err => {
96+
console.error(err.message);
97+
process.exitCode = 1;
98+
});
99+
main(...process.argv.slice(2));
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// Copyright 2021 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
'use strict';
16+
17+
function main(name) {
18+
// [START cloudtasks_v2_generated_CloudTasks_DeleteQueue_async]
19+
/**
20+
* TODO(developer): Uncomment these variables before running the sample.
21+
*/
22+
/**
23+
* Required. The queue name. For example:
24+
* `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`
25+
*/
26+
// const name = 'abc123'
27+
28+
// Imports the Tasks library
29+
const {CloudTasksClient} = require('@google-cloud/tasks').v2;
30+
31+
// Instantiates a client
32+
const tasksClient = new CloudTasksClient();
33+
34+
async function deleteQueue() {
35+
// Construct request
36+
const request = {
37+
name,
38+
};
39+
40+
// Run request
41+
const response = await tasksClient.deleteQueue(request);
42+
console.log(response);
43+
}
44+
45+
deleteQueue();
46+
// [END cloudtasks_v2_generated_CloudTasks_DeleteQueue_async]
47+
}
48+
49+
process.on('unhandledRejection', err => {
50+
console.error(err.message);
51+
process.exitCode = 1;
52+
});
53+
main(...process.argv.slice(2));
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// Copyright 2021 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
'use strict';
16+
17+
function main(name) {
18+
// [START cloudtasks_v2_generated_CloudTasks_DeleteTask_async]
19+
/**
20+
* TODO(developer): Uncomment these variables before running the sample.
21+
*/
22+
/**
23+
* Required. The task name. For example:
24+
* `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`
25+
*/
26+
// const name = 'abc123'
27+
28+
// Imports the Tasks library
29+
const {CloudTasksClient} = require('@google-cloud/tasks').v2;
30+
31+
// Instantiates a client
32+
const tasksClient = new CloudTasksClient();
33+
34+
async function deleteTask() {
35+
// Construct request
36+
const request = {
37+
name,
38+
};
39+
40+
// Run request
41+
const response = await tasksClient.deleteTask(request);
42+
console.log(response);
43+
}
44+
45+
deleteTask();
46+
// [END cloudtasks_v2_generated_CloudTasks_DeleteTask_async]
47+
}
48+
49+
process.on('unhandledRejection', err => {
50+
console.error(err.message);
51+
process.exitCode = 1;
52+
});
53+
main(...process.argv.slice(2));
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
// Copyright 2021 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
'use strict';
16+
17+
function main(resource) {
18+
// [START cloudtasks_v2_generated_CloudTasks_GetIamPolicy_async]
19+
/**
20+
* TODO(developer): Uncomment these variables before running the sample.
21+
*/
22+
/**
23+
* REQUIRED: The resource for which the policy is being requested.
24+
* See the operation documentation for the appropriate value for this field.
25+
*/
26+
// const resource = 'abc123'
27+
/**
28+
* OPTIONAL: A `GetPolicyOptions` object for specifying options to
29+
* `GetIamPolicy`. This field is only used by Cloud IAM.
30+
*/
31+
// const options = ''
32+
33+
// Imports the Tasks library
34+
const {CloudTasksClient} = require('@google-cloud/tasks').v2;
35+
36+
// Instantiates a client
37+
const tasksClient = new CloudTasksClient();
38+
39+
async function getIamPolicy() {
40+
// Construct request
41+
const request = {
42+
resource,
43+
};
44+
45+
// Run request
46+
const response = await tasksClient.getIamPolicy(request);
47+
console.log(response);
48+
}
49+
50+
getIamPolicy();
51+
// [END cloudtasks_v2_generated_CloudTasks_GetIamPolicy_async]
52+
}
53+
54+
process.on('unhandledRejection', err => {
55+
console.error(err.message);
56+
process.exitCode = 1;
57+
});
58+
main(...process.argv.slice(2));
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// Copyright 2021 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
'use strict';
16+
17+
function main(name) {
18+
// [START cloudtasks_v2_generated_CloudTasks_GetQueue_async]
19+
/**
20+
* TODO(developer): Uncomment these variables before running the sample.
21+
*/
22+
/**
23+
* Required. The resource name of the queue. For example:
24+
* `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`
25+
*/
26+
// const name = 'abc123'
27+
28+
// Imports the Tasks library
29+
const {CloudTasksClient} = require('@google-cloud/tasks').v2;
30+
31+
// Instantiates a client
32+
const tasksClient = new CloudTasksClient();
33+
34+
async function getQueue() {
35+
// Construct request
36+
const request = {
37+
name,
38+
};
39+
40+
// Run request
41+
const response = await tasksClient.getQueue(request);
42+
console.log(response);
43+
}
44+
45+
getQueue();
46+
// [END cloudtasks_v2_generated_CloudTasks_GetQueue_async]
47+
}
48+
49+
process.on('unhandledRejection', err => {
50+
console.error(err.message);
51+
process.exitCode = 1;
52+
});
53+
main(...process.argv.slice(2));

0 commit comments

Comments
 (0)