Skip to content

Commit 658913b

Browse files
authored
chore(samples): update enums and style (#656)
1 parent 7c0e003 commit 658913b

File tree

7 files changed

+21
-19
lines changed

7 files changed

+21
-19
lines changed

compute/createInstance.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ function main(
5252
// const networkName = 'global/networks/default';
5353

5454
const compute = require('@google-cloud/compute');
55-
const computeProtos = compute.protos.google.cloud.compute.v1;
5655

5756
// Create a new instance with the values provided above in the specified project and zone.
5857
async function createInstance() {
@@ -72,7 +71,7 @@ function main(
7271
},
7372
autoDelete: true,
7473
boot: true,
75-
type: computeProtos.AttachedDisk.Type.PERSISTENT,
74+
type: 'PERSISTENT',
7675
},
7776
],
7877
machineType: `zones/${zone}/machineTypes/${machineType}`,

compute/createInstanceFromTemplateWithOverrides.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ function main(
5151
// const newDiskSourceImage = 'projects/debian-cloud/global/images/family/debian-10';
5252

5353
const compute = require('@google-cloud/compute');
54-
const computeProtos = compute.protos.google.cloud.compute.v1;
5554

56-
// Creates a new instance in the specified project and zone using a selected template, but overrides the disk and machine type options in the template.
55+
// Creates a new instance in the specified project and zone using a selected template,
56+
// but overrides the disk and machine type options in the template.
5757
async function createInstanceFromTemplateWithOverrides() {
5858
const instancesClient = new compute.InstancesClient();
5959
const instanceTemplatesClient = new compute.InstanceTemplatesClient();
@@ -96,7 +96,7 @@ function main(
9696
},
9797
autoDelete: true,
9898
boot: false,
99-
type: computeProtos.AttachedDisk.Type.PERSISTENT,
99+
type: 'PERSISTENT',
100100
},
101101
],
102102
},

compute/custom-hostname-instance/createInstanceWithCustomHostname.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ function main(
5656
// const networkName = 'global/networks/default';
5757

5858
const compute = require('@google-cloud/compute');
59-
const computeProtos = compute.protos.google.cloud.compute.v1;
6059

6160
// Create a new instance with the values provided above in the specified project and zone.
6261
async function createInstanceWithCustomHostname() {
@@ -82,7 +81,7 @@ function main(
8281
},
8382
autoDelete: true,
8483
boot: true,
85-
type: computeProtos.AttachedDisk.Type.PERSISTENT,
84+
type: 'PERSISTENT',
8685
},
8786
],
8887
machineType: `zones/${zone}/machineTypes/${machineType}`,

compute/firewall/createFirewallRule.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,15 @@ function main(
3636
// const networkName = 'global/networks/default'
3737

3838
const compute = require('@google-cloud/compute');
39-
const compute_protos = compute.protos.google.cloud.compute.v1;
39+
const computeProtos = compute.protos.google.cloud.compute.v1;
4040

4141
async function createFirewallRule() {
4242
const firewallsClient = new compute.FirewallsClient();
4343
const operationsClient = new compute.GlobalOperationsClient();
4444

45-
const firewallRule = new compute_protos.Firewall();
45+
const firewallRule = new computeProtos.Firewall();
4646
firewallRule.name = firewallRuleName;
47-
firewallRule.direction = compute_protos.Firewall.Direction.INGRESS;
47+
firewallRule.direction = 'INGRESS';
4848
firewallRule.allowed = [
4949
{
5050
IPProtocol: 'tcp',

compute/firewall/patchFirewallPriority.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ function main(projectId, firewallRuleName, priority = 10) {
2929
// const priority = 10;
3030

3131
const compute = require('@google-cloud/compute');
32-
const compute_protos = compute.protos.google.cloud.compute.v1;
32+
const computeProtos = compute.protos.google.cloud.compute.v1;
3333

3434
async function patchFirewallPriority() {
3535
const firewallsClient = new compute.FirewallsClient();
3636
const operationsClient = new compute.GlobalOperationsClient();
3737

38-
const firewallRule = new compute_protos.Firewall();
38+
const firewallRule = new computeProtos.Firewall();
3939
firewallRule.priority = priority;
4040

4141
// The patch operation doesn't require the full definition of a Firewall object. It will only update

compute/getUsageExportBucket.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
// limitations under the License.
1414

1515
/**
16-
* Retrieve Compute Engine usage export bucket for the Cloud project. Replaces the empty value returned by the API with the default value used to generate report file names.
16+
* Retrieve Compute Engine usage export bucket for the Cloud project.
17+
* Replaces the empty value returned by the API with the default value used to generate report file names.
1718
*
1819
* @param {string} projectId - ID or number of the project you want to use.
1920
*/
@@ -41,7 +42,9 @@ function main(projectId) {
4142
}
4243

4344
if (!usageExportLocation.reportNamePrefix) {
44-
// Although the server explicitly sent the empty string value, the next usage report generated with these settings still has the default prefix value `usage_gce`. (see https://cloud.google.com/compute/docs/reference/rest/v1/projects/get)
45+
// Although the server explicitly sent the empty string value,
46+
// the next usage report generated with these settings still has the default prefix value `usage_gce`.
47+
// (see https://cloud.google.com/compute/docs/reference/rest/v1/projects/get)
4548
console.log(
4649
'Report name prefix not set, replacing with default value of `usage_gce`.'
4750
);

compute/setUsageExportBucket.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
// limitations under the License.
1414

1515
/**
16-
* Set Compute Engine usage export bucket for the Cloud project. This sample presents how to interpret the default value for the report name prefix parameter.
16+
* Set Compute Engine usage export bucket for the Cloud project.
17+
* This sample presents how to interpret the default value for the report name prefix parameter.
1718
*
1819
* @param {string} projectId - ID or number of the project you want to use.
1920
* @param {string} bucketName - Google Cloud Storage Bucket used to store Compute Engine usage reports. An existing Google Cloud Storage bucket is required.
@@ -28,16 +29,16 @@ function main(projectId, bucketName, reportNamePrefix = '') {
2829
// const bucketName = 'YOUR_BUCKET_NAME';
2930

3031
const compute = require('@google-cloud/compute');
31-
const compute_protos = compute.protos.google.cloud.compute.v1;
32+
const computeProtos = compute.protos.google.cloud.compute.v1;
3233

3334
async function setUsageExportBucket() {
34-
const usageExportLocationResource =
35-
new compute_protos.UsageExportLocation();
35+
const usageExportLocationResource = new computeProtos.UsageExportLocation();
3636
usageExportLocationResource.bucketName = bucketName;
3737
usageExportLocationResource.reportNamePrefix = reportNamePrefix;
3838

3939
if (!reportNamePrefix) {
40-
// Sending an empty value for reportNamePrefix results in the next usage report being generated with the default prefix value "usage_gce". (see: https://cloud.google.com/compute/docs/reference/rest/v1/projects/get)
40+
// Sending an empty value for reportNamePrefix results in the next usage report being generated with the default prefix value "usage_gce".
41+
// (see: https://cloud.google.com/compute/docs/reference/rest/v1/projects/get)
4142
console.log(
4243
'Setting reportNamePrefix to empty value causes the report to have the default prefix value `usage_gce`.'
4344
);

0 commit comments

Comments
 (0)