Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
167 commits
Select commit Hold shift + click to select a range
7438b7a
Added sendgrid example app. Also used for Compute Engine snippet.
jmdobry Dec 4, 2015
709e78f
Add Logging examples.
jmdobry Jan 14, 2016
3a31963
Added 14 Google App Engine samples.
jmdobry Jan 19, 2016
5631b87
New Compute Engine samples.
jmdobry Apr 5, 2016
d4efa92
Upgraded dependencies, no longer testing on Node v0.10, switched to C…
jmdobry Apr 13, 2016
46065ae
Added requested Mailjet samples.
jmdobry Apr 19, 2016
d6fbdee
Switched from JSHint to Semistandard and upgraded dependencies.
jmdobry May 23, 2016
fb1a954
Finished a bunch more Readme files.
jmdobry May 25, 2016
b325808
Update mailjet.js (#125)
Jun 14, 2016
31d119b
Refactored tests (#159)
jmdobry Aug 3, 2016
e0ae1f9
* Refactored Pub/Sub samples into nice command-line programs, like th…
jmdobry Aug 10, 2016
aeae10f
Switch to individual API packages. (#169)
jmdobry Aug 16, 2016
8ebb25b
Upgrade Sendgrid version in Compute sample (#211)
Sep 13, 2016
b3f7a9a
Upgrade apps for env:flex. (#241)
jmdobry Oct 20, 2016
fc82baf
Revert "Upgrade apps for env:flex." (#242)
jmdobry Oct 20, 2016
c415867
Upgrade GAE apps to env: flex (#253)
jmdobry Nov 14, 2016
bda9ae7
Update storage samples. (#263)
jmdobry Dec 9, 2016
46a615a
Switch from Mocha to Ava for faster tests (#289)
jmdobry Jan 6, 2017
f95cd05
Switch to Yarn for CI build. (#290)
jmdobry Jan 9, 2017
d09061c
Vision snippets. (#294)
jmdobry Jan 10, 2017
e3b2ec6
Update dependencies.
jmdobry Feb 6, 2017
2a66881
Travis: fix failing tests + update dependencies (#335)
Apr 5, 2017
3a20220
Cleanup App Engine samples and re-work tests. (#354)
jmdobry Apr 24, 2017
910cf7d
Upgrade to repo tools v1.4.7 (#370)
jmdobry May 2, 2017
ae1d2e0
Upgrade repo tools and regenerate READMEs. (#384)
jmdobry May 10, 2017
976fad7
Upgrade repo tools and regenerate READMEs.
jmdobry May 16, 2017
4a7e88b
Add + run dependency updating (bash) script (#401)
Jun 19, 2017
d2a1435
Update dependencies + fix a few tests (#448)
Aug 5, 2017
60165ca
Build updates. (#462)
jmdobry Aug 23, 2017
466cf5b
Update dependencies (#468)
Aug 31, 2017
997ef66
Repo Migration (#7)
lukesneeringer Oct 31, 2017
c6778d4
Version bump to 0.8.0 (#8)
lukesneeringer Oct 31, 2017
202a1aa
0.9.1 (#42)
stephenplusplus Feb 16, 2018
8bcc28f
v0.10.0 (#54)
stephenplusplus Mar 16, 2018
94c91b9
Upgrade repo-tools and regenerate scaffolding. (#55)
jmdobry Mar 16, 2018
7cb4104
Update @google-cloud/common to the latest version 🚀 (#57)
greenkeeper[bot] Mar 22, 2018
df9923d
Fix link (#62)
jmdobry Apr 10, 2018
10e554a
Fix quickstart code sample (#69)
fhinkel Apr 27, 2018
aea1cff
chore: lock files maintenance (#71)
alexander-fenster May 2, 2018
b8abb73
Update repo-tools to 2.3.0 (#72)
fhinkel May 2, 2018
26533b0
Fix Readme.md in /samples (#73)
fhinkel May 2, 2018
c17e035
test: make samples tests pass (#77)
alexander-fenster May 7, 2018
7af5d2c
chore: lock files maintenance (#78)
alexander-fenster May 8, 2018
4e23a7e
Add sample demonstrating startup script (#80)
fhinkel May 9, 2018
e580c8d
Increase timeout in startup sample test (#86)
fhinkel May 21, 2018
3400fd4
Fix problem with multiple deletes in test (#85)
fhinkel May 21, 2018
b1810ca
chore: lock files maintenance (#88)
alexander-fenster May 22, 2018
9553194
Simplify JS and use HTML standard (#91)
fhinkel May 23, 2018
cfceefd
Fix formatting (#92)
fhinkel May 29, 2018
1b0f6b1
fix: update all the dependencies (#95)
JustinBeckwith Jun 10, 2018
141d2e4
Add mailjet and sendgrid back in (#110)
fhinkel Jun 21, 2018
ad5a948
chore: update sample lockfiles (#117)
JustinBeckwith Jun 25, 2018
720199f
refactor: drop repo-tool as an exec wrapper (#118)
JustinBeckwith Jun 26, 2018
a7d3d25
chore(deps): update dependency ava to v0.25.0 (#120)
renovate[bot] Jun 27, 2018
791be92
chore(deps): update dependency @google-cloud/nodejs-repo-tools to v2.…
renovate[bot] Jun 27, 2018
be470a1
chore(deps): lock file maintenance (#123)
renovate[bot] Jul 3, 2018
4065392
chore(deps): lock file maintenance (#127)
renovate[bot] Jul 10, 2018
6c5ba3f
fix: drop support for node.js 4.x and 9.x (#126)
JustinBeckwith Jul 10, 2018
7d8d3a7
chore(deps): lock file maintenance (#128)
renovate[bot] Jul 10, 2018
5a2a548
chore(deps): lock file maintenance (#129)
renovate[bot] Jul 10, 2018
2cd7e82
chore(deps): update dependency @google-cloud/nodejs-repo-tools to v2.…
renovate[bot] Jul 12, 2018
c7b89d4
chore(deps): lock file maintenance (#131)
renovate[bot] Jul 17, 2018
bf99b98
chore(deps): lock file maintenance (#134)
renovate[bot] Jul 24, 2018
cdd71a8
chore: require node 8 for samples (#136)
JustinBeckwith Jul 30, 2018
77ac1f7
chore(deps): lock file maintenance (#138)
renovate[bot] Jul 31, 2018
ad22db7
chore(deps): lock file maintenance (#141)
renovate[bot] Aug 7, 2018
dc7ffd4
chore: ignore package-lock.json (#142)
JustinBeckwith Aug 7, 2018
95fd544
fix(deps): update dependency googleapis to v33 (#144)
renovate[bot] Aug 22, 2018
ecc2917
Enable no-var in eslint (#153)
JustinBeckwith Sep 18, 2018
625d3c6
Enable prefer-const in the eslint config (#155)
JustinBeckwith Sep 20, 2018
51126e2
fix(deps): update dependency googleapis to v34 (#162)
renovate[bot] Sep 28, 2018
22c773a
docs(samples): update samples to use async/await and mocha (#183)
muraliQlogic Nov 3, 2018
cb299f6
fix(deps): upgrade to the latest gce-images (#201)
JustinBeckwith Nov 9, 2018
2b1ea4f
chore(deps): update dependency @google-cloud/nodejs-repo-tools to v3 …
renovate[bot] Nov 10, 2018
a7a47f7
fix(deps): update dependency googleapis to v35 (#205)
renovate[bot] Nov 10, 2018
07d6b98
fix(deps): update dependency googleapis to v36 (#225)
renovate[bot] Dec 7, 2018
48b4df1
fix: improve the samples and tests (#236)
JustinBeckwith Dec 12, 2018
8eb3805
chore: remove repo-tools from a few spots (#239)
JustinBeckwith Dec 15, 2018
59bd9b2
Release v0.11.0 (#242)
JustinBeckwith Dec 21, 2018
4570b4e
fix: modernize the samples (#240)
JustinBeckwith Dec 22, 2018
ecb278d
docs: use the latest sendgrid npm module (#246)
JustinBeckwith Jan 2, 2019
f0bc54a
fix(deps): update dependency nodemailer to v5 (#247)
renovate[bot] Jan 14, 2019
24e2d8b
build: check broken links in generated docs (#248)
jkwlui Jan 14, 2019
ce73236
chore(deps): update dependency mocha to v6 (#269)
renovate[bot] Feb 19, 2019
887f964
Release v0.12.0 (#276)
JustinBeckwith Mar 13, 2019
19b9efc
fix(deps): update dependency nodemailer to v6
renovate[bot] Mar 25, 2019
b5d5872
refactor: use execSync for tests (#286)
JustinBeckwith Apr 12, 2019
7e005ea
docs: use repo-metadata to generate README (#289)
JustinBeckwith Apr 30, 2019
779956f
chore: release 1.0.0 (#312)
yoshi-automation May 20, 2019
6bed0eb
chore: release 1.0.1 (#314)
yoshi-automation May 22, 2019
69cdbfe
chore: release 1.1.0 (#324)
yoshi-automation Jun 20, 2019
eb2d0f2
chore: release 1.1.1 (#334)
yoshi-automation Jun 26, 2019
785524c
chore: release 1.1.2 (#340)
yoshi-automation Aug 1, 2019
7325604
chore: release 1.1.3 (#345)
yoshi-automation Aug 26, 2019
bfd4662
chore: release 1.1.4 (#347)
yoshi-automation Aug 28, 2019
1ecc47c
chore: release 1.1.5 (#351)
yoshi-automation Sep 10, 2019
a265f0d
chore: release 1.1.6 (#366)
release-please[bot] Nov 15, 2019
02b443e
chore: update license headers
JustinBeckwith Nov 25, 2019
682dbe6
chore: release 1.1.7 (#372)
release-please[bot] Dec 2, 2019
c34528c
chore: release 1.1.8 (#376)
release-please[bot] Dec 5, 2019
c297c44
chore(deps): update dependency mocha to v7 (#386)
renovate-bot Jan 6, 2020
1d10403
chore: release 1.2.0 (#393)
release-please[bot] Jan 23, 2020
00b41d7
chore(deps): update dependency uuid to v7
renovate-bot Feb 26, 2020
148124b
fix(deps): update dependency @sendgrid/mail to v7 (#424)
renovate-bot Apr 2, 2020
2d84f02
build!: update to latest version of gts and typescript (#433)
sofisl Apr 15, 2020
8824d92
chore(deps): update dependency uuid to v8 (#441)
renovate-bot May 1, 2020
953ae54
chore: release 2.0.0 (#436)
release-please[bot] Jun 5, 2020
c58f0ef
chore(deps): update dependency mocha to v8 (#447)
renovate-bot Jun 11, 2020
fc0f733
test: cleanup logic causes errors (#452)
Jun 18, 2020
bc317ac
chore: release 2.0.1 (#446)
release-please[bot] Jun 29, 2020
f8d8715
chore: release 2.0.2 (#462)
release-please[bot] Jul 9, 2020
89aedd8
chore: release 2.0.3 (#473)
release-please[bot] Jul 27, 2020
ff3060b
chore: release 2.1.0 (#481)
release-please[bot] Aug 10, 2020
e066e52
test: remove prettier dep fixing linting (#497)
Sep 25, 2020
4538d7f
chore: release 2.2.0 (#501)
release-please[bot] Sep 30, 2020
dfb1595
chore: release 2.3.0 (#508)
release-please[bot] Oct 15, 2020
bf8e619
chore: release 2.4.0 (#517)
release-please[bot] Nov 5, 2020
853b741
chore: release 2.4.1 (#524)
release-please[bot] Dec 2, 2020
6b45c72
chore: release 2.4.2 (#535)
release-please[bot] Jan 8, 2021
4a305eb
chore: release 2.4.3 (#542)
release-please[bot] Jan 27, 2021
2f2c9c6
chore: release 2.4.4 (#552)
release-please[bot] May 5, 2021
6ddc4e7
docs: fixes small typo (#553)
haraldreingruber May 19, 2021
45b3fea
chore: release 2.5.0 (#561)
release-please[bot] May 25, 2021
5200b62
chore: release 2.5.1 (#571)
release-please[bot] Jun 10, 2021
f75c2e7
chore: release 2.6.0 (#583)
release-please[bot] Jun 29, 2021
2dd1d37
feat!: new generated version of compute API (#537)
alexander-fenster Aug 11, 2021
d46441f
chore(compute): change LRO wrappers (#605)
FrodoTheTrue Aug 12, 2021
7fe2c45
chore(samples): remove default rest and compute_protos (#608)
FrodoTheTrue Aug 13, 2021
509efb4
chore: release 3.0.0 (#599)
release-please[bot] Aug 17, 2021
5274f07
feat: add minimum wrapper for compute LRO method (#618)
summer-ji-eng Sep 13, 2021
5c1403f
test: address race condition with setUsageExportBucket (#622)
Sep 14, 2021
1b88fca
chore(samples): start/stop samples (#631)
FrodoTheTrue Oct 15, 2021
792790d
chore(docs): firewall samples
FrodoTheTrue Oct 19, 2021
32c4160
chore(samples): create instance from template samples (#640)
FrodoTheTrue Nov 10, 2021
7196384
test: retry flaky firewall tests (#646)
Nov 11, 2021
7c0e003
chore(samples): add custom hostname instances samples (#650)
FrodoTheTrue Dec 14, 2021
658913b
chore(samples): update enums and style (#656)
FrodoTheTrue Dec 16, 2021
458fe2e
fix(deps): update google-gax with http grpc status code mapping (#655)
summer-ji-eng Jan 11, 2022
b540fb1
fix!: drop support for Node.js 10 (#668)
alexander-fenster Jan 11, 2022
13e6ed8
chore(samples): bump version in samples (#658)
FrodoTheTrue Jan 12, 2022
f2efdd4
chore(samples): add create start instance samples
FrodoTheTrue Jan 18, 2022
9d6a635
chore(samples): add periodical instances deletion (#680)
FrodoTheTrue Feb 8, 2022
96cdf2d
chore(main): release 3.1.2 (#689)
release-please[bot] Feb 16, 2022
c11cc67
chore(samples): fix function name (#694)
FrodoTheTrue Feb 24, 2022
1857a33
chore(samples): add delete protection samples (#696)
FrodoTheTrue Mar 8, 2022
dbddad1
chore(samples): add create instance templates samples (#695)
FrodoTheTrue Mar 9, 2022
f02e83d
chore(samples): create windows images samples (#703)
FrodoTheTrue Mar 22, 2022
65382ce
chore(samples): add creating managing windows instances samples (#704)
FrodoTheTrue Mar 22, 2022
1c63fa7
chore(samples): add test comments (#705)
FrodoTheTrue Mar 24, 2022
29147d2
chore(main): release 3.2.0 (#711)
release-please[bot] Apr 13, 2022
6c5f3cc
chore(main): release 3.2.1 (#713)
release-please[bot] May 9, 2022
4666632
chore(samples): fix function name (#719)
FrodoTheTrue May 17, 2022
9cce226
build: update library to use Node 12 (#729)
sofisl May 19, 2022
15063e8
chore(deps): update dependency @google-cloud/storage to v6 (#734)
renovate-bot Jun 6, 2022
4cb733f
chore(main): release 3.3.0 (#731)
release-please[bot] Jun 6, 2022
6ee9020
chore(samples): add suspend/resume samples (#735)
FrodoTheTrue Jun 7, 2022
28c9c3e
chore(samples): add preemptible vm samples (#732)
FrodoTheTrue Jun 7, 2022
8fc7a65
chore(samples): minor changes in a sample comment
savija-tv Jun 20, 2022
4c4258b
chore(main): release 3.4.0 (#749)
release-please[bot] Jul 4, 2022
c944ecc
test(samples): do not try creating an instance if it already exists (…
sofisl Jul 13, 2022
91769bf
chore(samples): add moving instances between zones samples (#747)
FrodoTheTrue Jul 14, 2022
a1ca168
chore(samples): add custom machine type samples (#742)
FrodoTheTrue Jul 20, 2022
cc2c540
test: turn off flaky tests (#791)
Sep 8, 2022
c7da965
chore(main): release 3.5.0 (#776)
release-please[bot] Sep 8, 2022
a366f61
chore(deps): update dependency uuid to v9 (#789)
renovate-bot Sep 8, 2022
e294626
chore(main): release 3.5.1 (#793)
release-please[bot] Oct 6, 2022
7c9f0a6
Merge remote-tracking branch 'migration/main' into nodejs-compute-mig…
Nov 15, 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
96 changes: 96 additions & 0 deletions compute/create-instance-templates/createTemplate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
// Copyright 2022 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.

/**
* Creates a new instance template with the provided name and a specific instance configuration.
*
* @param {string} projectId - Project ID or project number of the Cloud project you use.
* @param {string} templateName - Name of the new template to create.
*/
function main(projectId, templateName) {
// [START compute_template_create]
/**
* TODO(developer): Uncomment and replace these variables before running the sample.
*/
// const projectId = 'YOUR_PROJECT_ID';
// const templateName = 'your_template_name';

const compute = require('@google-cloud/compute');

// Create a new instance template with the provided name and a specific instance configuration.
async function createTemplate() {
const instanceTemplatesClient = new compute.InstanceTemplatesClient();

const [response] = await instanceTemplatesClient.insert({
project: projectId,
instanceTemplateResource: {
name: templateName,
properties: {
disks: [
{
// The template describes the size and source image of the boot disk
// to attach to the instance.
initializeParams: {
diskSizeGb: '250',
sourceImage:
'projects/debian-cloud/global/images/family/debian-11',
},
autoDelete: true,
boot: true,
},
],
machineType: 'e2-standard-4',
// The template connects the instance to the `default` network,
// without specifying a subnetwork.
networkInterfaces: [
{
// Use the network interface provided in the networkName argument.
name: 'global/networks/default',
// The template lets the instance use an external IP address.
accessConfigs: [
{
name: 'External NAT',
type: 'ONE_TO_ONE_NAT',
networkTier: 'PREMIUM',
},
],
},
],
},
},
});
let operation = response.latestResponse;
const operationsClient = new compute.GlobalOperationsClient();

// Wait for the create operation to complete.
while (operation.status !== 'DONE') {
[operation] = await operationsClient.wait({
operation: operation.name,
project: projectId,
});
}

console.log('Instance template created.');
}

createTemplate();
// [END compute_template_create]
}

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

main(...process.argv.slice(2));
84 changes: 84 additions & 0 deletions compute/create-instance-templates/createTemplateFromInstance.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
// Copyright 2022 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.

/**
* Creates a new instance template based on an existing instance.
*
* @param {string} projectId - Project ID or project number of the Cloud project you use.
* @param {string} instance - The instance to base the new template on. This value uses
* the following format: "projects/{project}/zones/{zone}/instances/{instance_name}"
* @param {string} templateName - Name of the new template to create.
*/
function main(projectId, instance, templateName) {
// [START compute_template_create_from_instance]
/**
* TODO(developer): Uncomment and replace these variables before running the sample.
*/
// const projectId = 'YOUR_PROJECT_ID';
// const instance = 'projects/project/zones/zone/instances/instance';
// const templateName = 'your_template_name';

const compute = require('@google-cloud/compute');

// Create a new instance template based on an existing instance.
// This new template specifies a different boot disk.
async function createTemplateFromInstance() {
const instanceTemplatesClient = new compute.InstanceTemplatesClient();

const [response] = await instanceTemplatesClient.insert({
project: projectId,
instanceTemplateResource: {
name: templateName,
sourceInstance: instance,
sourceInstanceParams: {
diskConfigs: [
{
// Device name must match the name of a disk attached to the instance
// your template is based on.
deviceName: 'disk-1',
// Replace the original boot disk image used in your instance with a Rocky Linux image.
instantiateFrom: 'CUSTOM_IMAGE',
customImage:
'projects/rocky-linux-cloud/global/images/family/rocky-linux-8',
// Override the auto_delete setting.
autoDelete: true,
},
],
},
},
});
let operation = response.latestResponse;
const operationsClient = new compute.GlobalOperationsClient();

// Wait for the create operation to complete.
while (operation.status !== 'DONE') {
[operation] = await operationsClient.wait({
operation: operation.name,
project: projectId,
});
}

console.log('Instance template created.');
}

createTemplateFromInstance();
// [END compute_template_create_from_instance]
}

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

main(...process.argv.slice(2));
95 changes: 95 additions & 0 deletions compute/create-instance-templates/createTemplateWithSubnet.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
// Copyright 2022 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.

/**
* Creates an instance template that uses a provided subnet.
*
* @param {string} projectId - Project ID or project number of the Cloud project you use.
* @param {string} network - The network to be used in the new template. This value uses
* the following format: "projects/{project}/global/networks/{network}"
* @param {string} subnetwork - The subnetwork to be used in the new template. This value
* uses the following format: "projects/{project}/regions/{region}/subnetworks/{subnetwork}"
* @param {string} templateName - Name of the new template to create.
*/
function main(projectId, network, subnetwork, templateName) {
// [START compute_template_create_with_subnet]
/**
* TODO(developer): Uncomment and replace these variables before running the sample.
*/
// const projectId = 'YOUR_PROJECT_ID';
// const network = 'projects/project/global/networks/network';
// const subnetwork = 'projects/project/regions/region/subnetworks/subnetwork';
// const templateName = 'your_template_name';

const compute = require('@google-cloud/compute');

// Create an instance template that uses a provided subnet.
async function createTemplateWithSubnet() {
const instanceTemplatesClient = new compute.InstanceTemplatesClient();

const [response] = await instanceTemplatesClient.insert({
project: projectId,
instanceTemplateResource: {
name: templateName,
properties: {
// The template describes the size and source image of the boot disk
// to attach to the instance.
disks: [
{
// The template describes the size and source image of the boot disk
// to attach to the instance.
initializeParams: {
diskSizeGb: '250',
sourceImage:
'projects/debian-cloud/global/images/family/debian-11',
},
autoDelete: true,
boot: true,
},
],
machineType: 'e2-standard-4',
// The template connects the instance to the specified network and subnetwork.
networkInterfaces: [
{
network,
subnetwork,
},
],
},
},
});
let operation = response.latestResponse;
const operationsClient = new compute.GlobalOperationsClient();

// Wait for the create operation to complete.
while (operation.status !== 'DONE') {
[operation] = await operationsClient.wait({
operation: operation.name,
project: projectId,
});
}

console.log('Instance template created.');
}

createTemplateWithSubnet();
// [END compute_template_create_with_subnet]
}

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

main(...process.argv.slice(2));
62 changes: 62 additions & 0 deletions compute/create-instance-templates/deleteInstanceTemplate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// Copyright 2022 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.

/**
* Deletes an instance template.
*
* @param {string} projectId - Project ID or project number of the Cloud project you use.
* @param {string} templateName - Name of the template to delete.
*/
function main(projectId, templateName) {
// [START compute_template_delete]
/**
* TODO(developer): Uncomment and replace these variables before running the sample.
*/
// const projectId = 'YOUR_PROJECT_ID';
// const templateName = 'your_template_name';

const compute = require('@google-cloud/compute');

// Delete an instance template.
async function deleteInstanceTemplate() {
const instanceTemplatesClient = new compute.InstanceTemplatesClient();

const [response] = await instanceTemplatesClient.delete({
project: projectId,
instanceTemplate: templateName,
});
let operation = response.latestResponse;
const operationsClient = new compute.GlobalOperationsClient();

// Wait for the create operation to complete.
while (operation.status !== 'DONE') {
[operation] = await operationsClient.wait({
operation: operation.name,
project: projectId,
});
}

console.log('Instance template deleted.');
}

deleteInstanceTemplate();
// [END compute_template_delete]
}

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

main(...process.argv.slice(2));
54 changes: 54 additions & 0 deletions compute/create-instance-templates/getInstanceTemplate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// Copyright 2022 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.

/**
* Retrieves an instance template, which you can use to create virtual machine
* (VM) instances and managed instance groups (MIGs).
*
* @param {string} projectId - Project ID or project number of the Cloud project you use.
* @param {string} templateName - Name of the template to retrieve.
*/
function main(projectId, templateName) {
// [START compute_template_get]
/**
* TODO(developer): Uncomment and replace these variables before running the sample.
*/
// const projectId = 'YOUR_PROJECT_ID';
// const templateName = 'your_template_name';

const compute = require('@google-cloud/compute');

// Retrieve an instance template, which you can use to create
// virtual machine (VM) instances and managed instance groups (MIGs).
async function getInstanceTemplate() {
const instanceTemplatesClient = new compute.InstanceTemplatesClient();

const [instance] = await instanceTemplatesClient.get({
project: projectId,
instanceTemplate: templateName,
});

console.log('Instance template:', instance);
}

getInstanceTemplate();
// [END compute_template_get]
}

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

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