Skip to content

migrate code from googleapis/nodejs-tasks #2792

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 120 commits into from
Nov 3, 2022
Merged
Show file tree
Hide file tree
Changes from 119 commits
Commits
Show all changes
120 commits
Select commit Hold shift + click to select a range
771540f
feat: generate the API (#1)
jkwlui Jun 13, 2018
76f8680
Drop node:4 and node:9 builds (#8)
jkwlui Jun 14, 2018
1ff1ec9
fix: update dependencies, run synth (#20)
JustinBeckwith Jun 28, 2018
2544a53
Add Tasks Samples and Tests (#14)
averikitsch Jun 28, 2018
72a007e
fix(deps): update dependency yargs to v12 (#22)
renovate[bot] Jun 29, 2018
eb63161
chore(deps): lock file maintenance (#23)
renovate[bot] Jul 3, 2018
767b4ce
chore(deps): lock file maintenance (#25)
renovate[bot] Jul 10, 2018
99d7af3
docs: updated gcloud command (#29)
averikitsch Jul 16, 2018
23b1afb
docs: update pull queue command (#30)
averikitsch Jul 16, 2018
b48438a
chore(deps): lock file maintenance (#31)
renovate[bot] Jul 17, 2018
09126a6
chore(deps): lock file maintenance (#34)
renovate[bot] Jul 24, 2018
ccde17a
fix: samples to require node>=8 (#37)
jkwlui Jul 26, 2018
10eb658
chore(deps): lock file maintenance (#40)
renovate[bot] Jul 31, 2018
56faad8
chore: ignore package-lock.json (#45)
JustinBeckwith Aug 7, 2018
1b26c28
Release nodejs-tasks v0.1.1 (#60)
JustinBeckwith Aug 30, 2018
9bf1d3c
Release nodejs-tasks v0.2.0 (#64)
jkwlui Sep 8, 2018
c2e9b57
feat: Release @google-cloud/tasks v0.2.1 (#73)
jkwlui Sep 13, 2018
bc0eec7
Update Cloud Tasks Sample (#67)
averikitsch Sep 13, 2018
5b34fd2
Release v0.2.2 (#76)
jkwlui Sep 13, 2018
31adcbf
chore(deps): update dependency sinon to v6.3.3 (#79)
renovate[bot] Sep 17, 2018
24ee5df
update tasks samples to support new api version (#83)
bart-at-google Sep 21, 2018
33831a2
chore(deps): update dependency sinon to v7 (#93)
renovate[bot] Oct 15, 2018
978735a
chore(deps): update dependency @google-cloud/nodejs-repo-tools to v3 …
renovate[bot] Nov 10, 2018
5aaa74c
refactor(samples): convert sample tests from ava to mocha (#126)
nareshqlogic Nov 19, 2018
e809288
docs(samples): updated samples code to use async await (#129)
praveenqlogic Nov 23, 2018
2b27844
samples: add queue create and delete samples (#142)
JustinBeckwith Dec 12, 2018
6a392d5
Release v0.3.0 (#162)
JustinBeckwith Feb 1, 2019
3a7d8bc
fix(deps): update dependency yargs to v13 (#171)
renovate[bot] Feb 12, 2019
73129da
chore(deps): update dependency mocha to v6 (#176)
renovate[bot] Feb 19, 2019
4494037
Release v0.4.0 (#182)
JustinBeckwith Mar 7, 2019
c26a94f
feat: add v2 of the tasks API (#192)
JustinBeckwith Mar 22, 2019
7327dbb
Release @google-cloud/tasks v0.5.0 (#193)
JustinBeckwith Mar 22, 2019
56fa69a
refactor: use execSync for tests (#195)
JustinBeckwith Apr 4, 2019
2539f9e
refactor: wrap execSync with encoding: utf-8 (#196)
jkwlui Apr 5, 2019
34864b3
docs(samples): Add HTTP Push Queue Sample (#199)
averikitsch Apr 10, 2019
1e50cd3
docs(samples): Add HTTP Task Sample with Authentication Token (#200)
averikitsch Apr 16, 2019
db3ab95
docs(samples): Update service account for tests (#204)
averikitsch Apr 23, 2019
c03a4c1
docs: generate docs for ga release (#221)
bcoe May 13, 2019
f021868
chore: release 1.0.0 (#222)
bcoe May 13, 2019
bc80737
docs(samples): Update ReadMe and comments for samples (#225)
averikitsch May 15, 2019
6dcac00
docs: update readme to match quickstart (#226)
yoshi-automation May 16, 2019
00dc7aa
chore: do not require projectId env for sample tests (#235)
JustinBeckwith May 28, 2019
e561126
chore: release 1.1.0 (#240)
yoshi-automation Jun 5, 2019
f615737
docs: fix HTTP acronym (#241)
grant Jun 10, 2019
b5f86b2
docs(samples): Update metadata and arguments (#242)
averikitsch Jun 11, 2019
64d776b
docs: update return type in jsdoc for Buffers (#243)
yoshi-automation Jun 12, 2019
2a7e409
chore: release 1.1.1 (#245)
yoshi-automation Jun 14, 2019
93a6e14
chore: release 1.1.2 (#251)
yoshi-automation Jun 26, 2019
77757a9
chore: release 1.2.0 (#256)
yoshi-automation Jul 2, 2019
cd6d28e
chore: release 1.2.1 (#263)
yoshi-automation Aug 5, 2019
3624596
fix(deps): update dependency yargs to v14
renovate-bot Aug 20, 2019
0637b2b
chore: release 1.3.0 (#269)
yoshi-automation Aug 28, 2019
1c0d541
chore: release 1.4.0 (#273)
yoshi-automation Sep 16, 2019
7710ed5
feat: simplify Node sample (#278)
grant Sep 18, 2019
7b2eb7b
refactor: simplify cloud_tasks_create_http_task_with_token (#280)
grant Sep 20, 2019
0bb61de
refactor: style fixes for tasks_quickstart (#281)
grant Sep 20, 2019
6e271cb
chore: release 1.5.1 (#298)
release-please[bot] Oct 22, 2019
faaf165
feat: introduces HTTP targets to default v2 API (#300)
yoshi-automation Nov 1, 2019
7e9c665
chore: release 1.6.0 (#301)
release-please[bot] Nov 13, 2019
77271c2
fix(deps): update dependency yargs to v15 (#308)
renovate-bot Nov 18, 2019
e297c31
chore: release 1.6.1 (#309)
release-please[bot] Nov 18, 2019
eff8460
chore: update license headers (#310)
JustinBeckwith Nov 25, 2019
9c5042f
docs: update jsdoc license/samples-README (#323)
bcoe Dec 26, 2019
e1cecb6
refactor: use explicit mocha imports (#327)
JustinBeckwith Dec 30, 2019
d73219d
feat: move library to typescript code generation (#317)
xiaozhenliu-gg5 Jan 3, 2020
3023499
chore: release 1.7.0
release-please[bot] Jan 6, 2020
0d0e029
chore(deps): update dependency mocha to v7 (#330)
renovate-bot Jan 6, 2020
a02bde1
chore: release 1.7.1 (#333)
release-please[bot] Jan 9, 2020
d779cf3
chore: release 1.7.2 (#341)
release-please[bot] Jan 30, 2020
8c4c4aa
chore: release 1.7.3 (#352)
release-please[bot] Feb 7, 2020
f470a95
chore: release 1.8.0 (#359)
release-please[bot] Mar 2, 2020
a7b0558
chore(deps): update dependency uuid to v7 (#368)
renovate-bot Mar 3, 2020
33071ea
chore: release 1.9.0 (#371)
release-please[bot] Mar 11, 2020
ba5a859
feat!: drop node8 support, support for async iterators (#388)
alexander-fenster Mar 31, 2020
833679c
chore: release 2.0.0 (#389)
release-please[bot] Apr 8, 2020
a079521
fix: remove unused files from package (#404)
JustinBeckwith Apr 13, 2020
45b92ca
chore(deps): update dependency uuid to v8 (#412)
renovate-bot May 1, 2020
676d3c8
chore(deps): update dependency mocha to v8 (#423)
renovate-bot Jun 11, 2020
f6ea60d
chore: release 2.0.1 (#401)
release-please[bot] Jun 16, 2020
729b18b
chore: release 2.1.0 (#428)
release-please[bot] Jul 7, 2020
6d23f87
fix(deps): update dependency yargs to v16 (#460)
renovate-bot Sep 9, 2020
617ee59
chore: release 2.1.1 (#461)
release-please[bot] Sep 17, 2020
39d788b
docs(samples): add region tags for sample browser (#474)
averikitsch Oct 21, 2020
acb9c06
docs(samples): update samples to latest standards (#475)
JustinBeckwith Oct 21, 2020
3dfac09
fix(samples): region tag collided with tasks-api (#476)
bcoe Oct 21, 2020
8b6e1e1
chore: release 2.1.2 (#477)
release-please[bot] Oct 27, 2020
7c23593
chore: release 2.1.3 (#488)
release-please[bot] Dec 2, 2020
169a092
fix(samples): remove unused variables (#492)
averikitsch Dec 21, 2020
72b1918
chore: release 2.2.0 (#497)
release-please[bot] Jan 12, 2021
7db06fc
chore: release 2.3.0 (#500)
release-please[bot] Jan 22, 2021
c9e2bdf
chore: release 2.3.1 (#520)
release-please[bot] May 13, 2021
aa1d954
chore: release 2.3.2 (#530)
release-please[bot] May 25, 2021
be9afc1
chore: release 2.3.3 (#541)
release-please[bot] Jun 30, 2021
193784c
chore: release 2.3.4 (#545)
release-please[bot] Jun 30, 2021
8816944
chore: release 2.3.5 (#547)
release-please[bot] Jul 12, 2021
7e6e091
chore: release 2.3.6 (#550)
release-please[bot] Jul 19, 2021
43f3039
samples: Make inputs clear (#555)
averikitsch Aug 5, 2021
bfe8db6
chore: release 2.4.0 (#563)
release-please[bot] Sep 7, 2021
f1dd210
chore: release 2.4.1 (#564)
release-please[bot] Sep 7, 2021
001bf68
fix(build): set default branch to main (#565)
bcoe Sep 10, 2021
e845522
chore: release 2.4.2 (#566)
release-please[bot] Sep 10, 2021
98f0dd7
chore: release 2.5.0 (#583)
release-please[bot] Dec 9, 2021
1c233fe
chore(main): release 2.6.0 (#612)
release-please[bot] May 6, 2022
601846c
build!: update library to use Node 12 (#625)
sofisl May 19, 2022
bf5288a
chore(main): release 3.0.0 (#626)
release-please[bot] Jun 9, 2022
6d01d80
chore(main): release 3.0.1 (#632)
release-please[bot] Jun 30, 2022
73fbfac
chore(main): release 3.0.2 (#646)
release-please[bot] Aug 26, 2022
a292a8b
chore(main): release 3.0.3 (#651)
release-please[bot] Sep 7, 2022
f31aae4
chore(deps): update dependency uuid to v9 (#652)
renovate-bot Sep 9, 2022
944fbbf
fix: wrapping param inSeconds with parseInt to ensure correct additio…
pattishin Sep 13, 2022
92d6a3c
fix(issue-640): adding headers in task request samples (#642)
pattishin Sep 15, 2022
f86589d
chore(main): release 3.0.4 (#656)
release-please[bot] Sep 23, 2022
96f3e12
Merge remote-tracking branch 'migration/main' into nodejs-tasks-migra…
grayside Oct 26, 2022
0c33e63
testing(cloud-tasks): add github workflow driver
grayside Oct 26, 2022
da45cb7
testing(cloud-tasks): Increase timeout from 2000ms to 5000ms
grayside Oct 26, 2022
360ad00
refactor: move library samples into snippets sub-directory
grayside Nov 3, 2022
05a466f
testing(cloud-tasks): Increase timeout from 5000ms to 7000ms
grayside Nov 3, 2022
f21ac96
testing(cloud-tasks): Increase timeout from 7000ms to 10000ms
grayside Nov 3, 2022
c171892
testing(cloud-tasks): Increase timeout from 10000ms to 30000ms
grayside Nov 3, 2022
4be0c8c
Merge branch 'main' into nodejs-tasks-migration
grayside Nov 3, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions .github/workflows/cloud-tasks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: cloud-tasks
on:
push:
branches:
- main
paths:
- 'cloud-tasks/snippets/*.js'
pull_request:
paths:
- 'cloud-tasks/snippets/*.js'
pull_request_target:
types: [labeled]
schedule:
- cron: '0 0 * * 0'
jobs:
test:
if: ${{ github.event.action != 'labeled' || github.event.label.name == 'actions:force-run' }}
runs-on: ubuntu-latest
timeout-minutes: 60
permissions:
contents: 'write'
pull-requests: 'write'
id-token: 'write'
steps:
- uses: 'google-github-actions/[email protected]'
with:
workload_identity_provider: 'projects/1046198160504/locations/global/workloadIdentityPools/github-actions-pool/providers/github-actions-provider'
service_account: '[email protected]'
create_credentials_file: 'true'
access_token_lifetime: 600s
- uses: actions/checkout@v3
with:
ref: ${{github.event.pull_request.head.ref}}
repository: ${{github.event.pull_request.head.repo.full_name}}
- uses: actions/setup-node@v2
with:
node-version: 16
- run: npm install
working-directory: cloud-tasks/snippets
- run: npm test
working-directory: cloud-tasks/snippets
env:
MOCHA_REPORTER_SUITENAME: cloud_tasks
MOCHA_REPORTER_OUTPUT: cloud_tasks_sponge_log.xml
MOCHA_REPORTER: xunit
- if: ${{ github.event.action == 'labeled' && github.event.label.name == 'actions:force-run' }}
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
try {
await github.rest.issues.removeLabel({
name: 'actions:force-run',
owner: 'GoogleCloudPlatform',
repo: 'nodejs-docs-samples',
issue_number: context.payload.pull_request.number
});
} catch (e) {
if (!e.message.includes('Label does not exist')) {
throw e;
}
}
- if: ${{ github.event_name == 'schedule'}}
run: |
curl https://github.com/googleapis/repo-automation-bots/releases/download/flakybot-1.1.0/flakybot -o flakybot -s -L
chmod +x ./flakybot
./flakybot --repo GoogleCloudPlatform/nodejs-docs-samples --commit_hash ${{github.sha}} --build_url https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}
20 changes: 20 additions & 0 deletions cloud-tasks/snippets/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Use the official Node.js 10 image.
# https://hub.docker.com/_/node
FROM node:10

# Create and change to the app directory.
WORKDIR /usr/src/app

# Copy application dependency manifests to the container image.
# A wildcard is used to ensure both package.json AND package-lock.json are copied.
# Copying this separately prevents re-running npm install on every code change.
COPY package.json package*.json ./

# Install production dependencies.
RUN npm install --only=production

# Copy local code to the container image.
COPY . .

# Run the web service on container startup.
CMD [ "npm", "start" ]
14 changes: 14 additions & 0 deletions cloud-tasks/snippets/app.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright 2019 Google LLC
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

runtime: nodejs10
89 changes: 89 additions & 0 deletions cloud-tasks/snippets/createHttpTask.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
// Copyright 2019 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

'use strict';

// sample-metadata:
// title: Cloud Tasks Create HTTP Target
// description: Create Cloud Tasks with a HTTP Target
// usage: node createHttpTask.js <projectId> <queueName> <location> <url> <payload> <delayInSeconds>

/**
* Create a task with an HTTP target for a given queue with an arbitrary payload.
*/
function main(
project = 'my-project-id', // Your GCP Project id
queue = 'my-appengine-queue', // Name of your Queue
location = 'us-central1', // The GCP region of your queue
url = 'https://example.com/taskhandler', // The full url path that the request will be sent to
payload = 'Hello, World!', // The task HTTP request body
inSeconds = 0 // Delay in task execution
) {
// [START cloud_tasks_create_http_task]
// Imports the Google Cloud Tasks library.
const {CloudTasksClient} = require('@google-cloud/tasks');

// Instantiates a client.
const client = new CloudTasksClient();

async function createHttpTask() {
// TODO(developer): Uncomment these lines and replace with your values.
// const project = 'my-project-id';
// const queue = 'my-queue';
// const location = 'us-central1';
// const url = 'https://example.com/taskhandler';
// const payload = 'Hello, World!';
// const inSeconds = 180;

// Construct the fully qualified queue name.
const parent = client.queuePath(project, location, queue);

const task = {
httpRequest: {
headers: {
'Content-Type': 'text/plain',
},
httpMethod: 'POST',
url,
},
};

if (payload) {
task.httpRequest.body = Buffer.from(payload).toString('base64');
}

if (inSeconds) {
// The time when the task is scheduled to be attempted.
task.scheduleTime = {
seconds: parseInt(inSeconds) + Date.now() / 1000,
};
}

// Send create task request.
console.log('Sending task:');
console.log(task);
const request = {parent: parent, task: task};
const [response] = await client.createTask(request);
console.log(`Created task ${response.name}`);
}
createHttpTask();
// [END cloud_tasks_create_http_task]
}

process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});

main(...process.argv.slice(2));
86 changes: 86 additions & 0 deletions cloud-tasks/snippets/createHttpTaskWithToken.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
// Copyright 2019 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

'use strict';

// sample-metadata:
// title: Cloud Tasks Create HTTP Target with Token
// description: Create Cloud Tasks with a HTTP Target with Token
// usage: node createHttpTaskWithToken.js <projectId> <queueName> <location> <url> <serviceAccountEmail> <payload> <delayInSeconds>

/**
* Create a task with an HTTP target for a given queue with an arbitrary payload.
*/
function main(
project = 'my-project-id', // Your GCP Project id
queue = 'my-queue', // Name of your Queue
location = 'us-central1', // The GCP region of your queue
url = 'https://example.com/taskhandler', // The full url path that the request will be sent to
serviceAccountEmail = 'client@<project-id>.iam.gserviceaccount.com', // Cloud IAM service account
payload = 'Hello, World!' // The task HTTP request body
) {
// [START cloud_tasks_create_http_task_with_token]
// Imports the Google Cloud Tasks library.
const {CloudTasksClient} = require('@google-cloud/tasks');

// Instantiates a client.
const client = new CloudTasksClient();

async function createHttpTaskWithToken() {
// TODO(developer): Uncomment these lines and replace with your values.
// const project = 'my-project-id';
// const queue = 'my-queue';
// const location = 'us-central1';
// const url = 'https://example.com/taskhandler';
// const serviceAccountEmail = 'client@<project-id>.iam.gserviceaccount.com';
// const payload = 'Hello, World!';

// Construct the fully qualified queue name.
const parent = client.queuePath(project, location, queue);

const task = {
httpRequest: {
headers: {
'Content-Type': 'text/plain',
},
httpMethod: 'POST',
url,
oidcToken: {
serviceAccountEmail,
},
},
};

if (payload) {
task.httpRequest.body = Buffer.from(payload).toString('base64');
}

console.log('Sending task:');
console.log(task);
// Send create task request.
const request = {parent: parent, task: task};
const [response] = await client.createTask(request);
const name = response.name;
console.log(`Created task ${name}`);
}
createHttpTaskWithToken();
// [END cloud_tasks_create_http_task_with_token]
}

process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});

main(...process.argv.slice(2));
59 changes: 59 additions & 0 deletions cloud-tasks/snippets/createQueue.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// Copyright 2018 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

'use strict';

/**
* Create a new Task Queue
*/
function main(
project = 'my-project-id', // Your GCP Project id
queue = 'my-appengine-queue', // Name of the Queue to create
location = 'us-central1' // The GCP region in which to create the queue
) {
// [START cloud_tasks_create_queue]
// Imports the Google Cloud Tasks library.
const cloudTasks = require('@google-cloud/tasks');

// Instantiates a client.
const client = new cloudTasks.CloudTasksClient();

async function createQueue() {
// Send create queue request.
const [response] = await client.createQueue({
// The fully qualified path to the location where the queue is created
parent: client.locationPath(project, location),
queue: {
// The fully qualified path to the queue
name: client.queuePath(project, location, queue),
appEngineHttpQueue: {
appEngineRoutingOverride: {
// The App Engine service that will receive the tasks.
service: 'default',
},
},
},
});
console.log(`Created queue ${response.name}`);
}
createQueue();
// [END cloud_tasks_create_queue]
}

process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});

main(...process.argv.slice(2));
Loading