Skip to content

Commit 797cddf

Browse files
authored
Merge branch 'main' into generativeaionvertexai_embedding_batch
2 parents 831a1d1 + 697100d commit 797cddf

30 files changed

+1843
-545
lines changed

.github/workflows/monitoring-opencensus.yaml

Lines changed: 0 additions & 52 deletions
This file was deleted.

.github/workflows/opencensus.yaml

Lines changed: 0 additions & 52 deletions
This file was deleted.

.github/workflows/utils/workflows.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,8 @@
7878
"media/transcoder",
7979
"media/video-stitcher",
8080
"mediatranslation",
81-
"monitoring/opencensus",
8281
"monitoring/prometheus",
8382
"monitoring/snippets",
84-
"opencensus",
8583
"retail",
8684
"run/filesystem",
8785
"scheduler",

CODEOWNERS

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ storagetransfer @GoogleCloudPlatform/cloud-storage-dpes @GoogleCloudPlatform/nod
3434

3535
# One-offs
3636
composer @GoogleCloudPlatform/cloud-dpes-composer @GoogleCloudPlatform/nodejs-samples-reviewers @GoogleCloudPlatform/cloud-samples-reviewers
37-
monitoring/opencensus @GoogleCloudPlatform/nodejs-samples-reviewers @GoogleCloudPlatform/cloud-samples-reviewers
3837

3938
# Data & AI
4039
document-ai @GoogleCloudPlatform/nodejs-samples-reviewers @GoogleCloudPlatform/document-ai-samples-contributors @GoogleCloudPlatform/cloud-samples-reviewers
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
/*
2+
* Copyright 2024 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
'use strict';
18+
19+
async function main(diskName, region, vmName, zone) {
20+
// [START compute_instance_attach_regional_disk]
21+
// Import the Compute library
22+
const computeLib = require('@google-cloud/compute');
23+
const compute = computeLib.protos.google.cloud.compute.v1;
24+
25+
// Instantiate an instancesClient
26+
const instancesClient = new computeLib.InstancesClient();
27+
// Instantiate a zoneOperationsClient
28+
const zoneOperationsClient = new computeLib.ZoneOperationsClient();
29+
30+
/**
31+
* TODO(developer): Update/uncomment these variables before running the sample.
32+
*/
33+
// Your project ID.
34+
const projectId = await instancesClient.getProjectId();
35+
36+
// The zone of your VM.
37+
// zone = 'us-central1-a';
38+
39+
// The name of the VM to which you're adding the new replicated disk.
40+
// vmName = 'vm-name';
41+
42+
// The name of the replicated disk
43+
// diskName = 'disk-name';
44+
45+
// The region where the replicated disk is located.
46+
// region = 'us-central1';
47+
48+
async function callAttachRegionalDisk() {
49+
const [response] = await instancesClient.attachDisk({
50+
instance: vmName,
51+
project: projectId,
52+
attachedDiskResource: new compute.AttachedDisk({
53+
source: `projects/${projectId}/regions/${region}/disks/${diskName}`,
54+
// If you want to force the disk to be attached, uncomment next line.
55+
// forceAttach: true,
56+
}),
57+
zone,
58+
});
59+
60+
let operation = response.latestResponse;
61+
62+
// Wait for the operation to complete.
63+
while (operation.status !== 'DONE') {
64+
[operation] = await zoneOperationsClient.wait({
65+
operation: operation.name,
66+
project: projectId,
67+
zone: operation.zone.split('/').pop(),
68+
});
69+
}
70+
71+
console.log(`Replicated disk: ${diskName} attached to VM: ${vmName}.`);
72+
}
73+
74+
await callAttachRegionalDisk();
75+
// [END compute_instance_attach_regional_disk]
76+
}
77+
78+
main(...process.argv.slice(2)).catch(err => {
79+
console.error(err);
80+
process.exitCode = 1;
81+
});
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
/*
2+
* Copyright 2024 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
'use strict';
18+
19+
async function main(
20+
secondaryDiskName,
21+
secondaryLocation,
22+
primaryDiskName,
23+
primaryLocation
24+
) {
25+
// [START compute_disk_create_secondary_custom]
26+
// Import the Compute library
27+
const computeLib = require('@google-cloud/compute');
28+
const compute = computeLib.protos.google.cloud.compute.v1;
29+
30+
// If you want to create regional disk, you should use: RegionDisksClient and RegionOperationsClient.
31+
// Instantiate a diskClient
32+
const disksClient = new computeLib.DisksClient();
33+
// Instantiate a zoneOperationsClient
34+
const zoneOperationsClient = new computeLib.ZoneOperationsClient();
35+
36+
/**
37+
* TODO(developer): Update/uncomment these variables before running the sample.
38+
*/
39+
// The project for the secondary disk.
40+
const secondaryProjectId = await disksClient.getProjectId();
41+
42+
// The zone or region for the secondary disk. The primary and secondary disks must be in different regions.
43+
// If you use RegionDisksClient- define region, if DisksClient- define zone.
44+
// secondaryLocation = 'us-central1-a';
45+
46+
// The name of the secondary disk.
47+
// secondaryDiskName = 'secondary-disk-name';
48+
49+
// The project that contains the primary disk.
50+
const primaryProjectId = await disksClient.getProjectId();
51+
52+
// The zone or region for the primary disk.
53+
// If you use RegionDisksClient- define region, if DisksClient- define zone.
54+
// primaryLocation = 'us-central1-b';
55+
56+
// The name of the primary disk that the secondary disk receives data from.
57+
// primaryDiskName = 'primary-disk-name';
58+
59+
// The disk type. Must be one of `pd-ssd` or `pd-balanced`.
60+
const diskType = `zones/${secondaryLocation}/diskTypes/pd-balanced`;
61+
62+
// The size of the secondary disk in gigabytes.
63+
const diskSizeGb = 10;
64+
65+
// Create a secondary disk identical to the primary disk.
66+
async function callCreateComputeSecondaryDisk() {
67+
// Create a secondary disk
68+
const disk = new compute.Disk({
69+
sizeGb: diskSizeGb,
70+
name: secondaryDiskName,
71+
// If you use RegionDisksClient, pass region as an argument instead of zone
72+
zone: secondaryLocation,
73+
type: diskType,
74+
asyncPrimaryDisk: new compute.DiskAsyncReplication({
75+
// Make sure that the primary disk supports asynchronous replication.
76+
// Only certain persistent disk types, like `pd-balanced` and `pd-ssd`, are eligible.
77+
disk: `projects/${primaryProjectId}/zones/${primaryLocation}/disks/${primaryDiskName}`,
78+
}),
79+
// Specify additional guest OS features.
80+
// To learn more about OS features, open: `https://cloud.google.com/compute/docs/disks/async-pd/configure?authuser=0#secondary2`.
81+
// You don't need to include the guest OS features of the primary disk.
82+
// The secondary disk automatically inherits the guest OS features of the primary disk.
83+
guestOsFeatures: [
84+
new compute.GuestOsFeature({
85+
type: 'NEW_FEATURE_ID_1',
86+
}),
87+
],
88+
// Assign additional labels to the secondary disk.
89+
// You don't need to include the labels of the primary disk.
90+
// The secondary disk automatically inherits the labels from the primary disk
91+
labels: {
92+
key: 'value',
93+
},
94+
});
95+
96+
const [response] = await disksClient.insert({
97+
project: secondaryProjectId,
98+
// If you use RegionDisksClient, pass region as an argument instead of zone
99+
zone: secondaryLocation,
100+
diskResource: disk,
101+
});
102+
103+
let operation = response.latestResponse;
104+
105+
// Wait for the create secondary disk operation to complete.
106+
while (operation.status !== 'DONE') {
107+
[operation] = await zoneOperationsClient.wait({
108+
operation: operation.name,
109+
project: secondaryProjectId,
110+
// If you use RegionOperationsClient, pass region as an argument instead of zone
111+
zone: operation.zone.split('/').pop(),
112+
});
113+
}
114+
115+
console.log(`Custom secondary disk: ${secondaryDiskName} created.`);
116+
}
117+
118+
await callCreateComputeSecondaryDisk();
119+
// [END compute_disk_create_secondary_custom]
120+
}
121+
122+
main(...process.argv.slice(2)).catch(err => {
123+
console.error(err);
124+
process.exitCode = 1;
125+
});

0 commit comments

Comments
 (0)