Skip to content
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

Merge from main #9978

Merged
merged 44 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from 37 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
499d530
chore(job): migrate regions by associating them with an official prod…
OremGLG Dec 18, 2024
f94b9df
chore(endpoints): delete region 'swagger' in endpoints/multiple-versi…
eapl-gemugami Dec 18, 2024
8d282b8
chore(job): delete sample jobs_java_dependencies_beta (#9810)
eapl-gemugami Dec 18, 2024
0e52e74
feat(compute): add compute disk regional replicated sample (#9697)
TetyanaYahodska Dec 18, 2024
d8d6253
feat(compute): add compute disk start/stop replication samples (#9650)
TetyanaYahodska Dec 19, 2024
e6a4c3f
feat(tpu): add tpu vm create spot sample. (#9610)
TetyanaYahodska Dec 19, 2024
05b16a2
feat(tpu): add tpu vm create startup script sample. (#9612)
TetyanaYahodska Dec 19, 2024
772c39c
feat(tpu): add tpu queued resources create/get/delete samples (#9613)
TetyanaYahodska Dec 20, 2024
38eb8d3
feat(tpu): add tpu queued resources create spot (#9615)
TetyanaYahodska Dec 20, 2024
3270e36
chore: add translate dev team for translate samples (#9888)
iennae Dec 21, 2024
230665f
feat(securitycenter): Add Resource SCC Management API Org ETD Custom …
lovenishs04 Dec 23, 2024
3b9ac56
fix(compute): fixed compute_reservation_create_shared sample and test…
TetyanaYahodska Dec 23, 2024
07416aa
feat(compute): add compute instance create replicated boot disk sampl…
TetyanaYahodska Dec 23, 2024
7afa0d2
feat(compute): add compute consistency group stop replication (#9694)
TetyanaYahodska Dec 23, 2024
cfd36a0
feat(secretmanager): add optional ttl to create secret sample (#9889)
alarconesparza Dec 23, 2024
29ccf1c
feat(tpu): add tpu queued resources list sample (#9614)
TetyanaYahodska Dec 27, 2024
0795de2
feat(compute): add compute disk create secondary regional sample (#9641)
TetyanaYahodska Dec 27, 2024
8e31c56
feat(compute): add compute disk create secondary sample. (#9643)
TetyanaYahodska Dec 27, 2024
ee8e513
fix(storage): migrate old region all to storagetransfer_transfer_all …
OremGLG Dec 29, 2024
c917ab6
fix(job): remove old region create_job (#9914)
OremGLG Dec 29, 2024
db76fdc
feat(compute): attach/ remove snapshot schedule to disk (#9791)
TetyanaYahodska Dec 30, 2024
1e9647e
feat(compute): add compute consistency group clone sample (#9885)
TetyanaYahodska Dec 30, 2024
206512e
feat(compute): add compute instance attach regional disk force sample…
TetyanaYahodska Dec 30, 2024
673b387
feat(compute): add compute disk create secondary custom sample (#9644)
TetyanaYahodska Dec 30, 2024
f328675
feat(compute): add compute snapshot schedule create/get/edit/list/del…
TetyanaYahodska Dec 30, 2024
c16bb4c
feat(compute): add compute disk create with snapshot schedule (#9788)
TetyanaYahodska Dec 31, 2024
fe97842
feat(tpu): add tpu queued resources time bound sample. (#9617)
TetyanaYahodska Dec 31, 2024
74b655e
fix(job): delete old region tag update_job_with_field_mask (#9940)
OremGLG Jan 6, 2025
a143eb6
feat(job): migrate region tags to include product prefix (#9966)
alarconesparza Jan 7, 2025
adcbc9a
fix(endpoints): migrate all regions (#9943)
OremGLG Jan 7, 2025
b53181b
fix: disable flakybot reporting (#9968)
briandorsey Jan 7, 2025
66ab30f
chore(job): remove unused region tags (#9969)
alarconesparza Jan 8, 2025
be1a4af
feat(securitycenter): Add Resource SCC Management API Org ETD Custom …
lovenishs04 Jan 9, 2025
42c928e
chore(job): migrate region tag to include product prefix (#9974)
alarconesparza Jan 15, 2025
57fc720
fix(securitycenter) issue related to cleanup logic in testclass of ET…
lovenishs04 Jan 15, 2025
75245b9
chore(job): migrate region tag (#9976)
alarconesparza Jan 15, 2025
4f6d504
fix(endpoints): update new regions adding _yaml_ (#9971)
OremGLG Jan 15, 2025
1c7aa0b
fix(storagetransfer): deleted old region tags (all) (#9939)
OremGLG Jan 16, 2025
8dfdef3
fix(compute): migrate region 'example' to 'compute_sendgrid' (#9942)
OremGLG Jan 16, 2025
00ced5c
fix(compute): migrate old region "dependecies" to "compute_sendgrid_d…
OremGLG Jan 16, 2025
cf29f4a
fix(endpoints): remove old region tags (#9979)
OremGLG Jan 16, 2025
7e4b30b
fix(compute): delete old region tag (#9980)
OremGLG Jan 18, 2025
8aa1a97
chore(job): delete old region tags from LocationSearchSample.java (#9…
OremGLG Jan 20, 2025
8622af1
chore(job): delete unused region tag after migration (#9975)
alarconesparza Jan 20, 2025
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
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
/speech @GoogleCloudPlatform/java-samples-reviewers @yoshi-approver @GoogleCloudPlatform/cloud-samples-reviewers
/talent @GoogleCloudPlatform/java-samples-reviewers @yoshi-approver @GoogleCloudPlatform/cloud-samples-reviewers
/texttospeech @GoogleCloudPlatform/java-samples-reviewers @yoshi-approver @GoogleCloudPlatform/cloud-samples-reviewers
/translate @GoogleCloudPlatform/java-samples-reviewers @yoshi-approver @GoogleCloudPlatform/cloud-samples-reviewers
/translate @GoogleCloudPlatform/java-samples-reviewers @yoshi-approver @GoogleCloudPlatform/cloud-samples-reviewers @GoogleCloudPlatform/cloud-ml-translate-dev
/video @GoogleCloudPlatform/java-samples-reviewers @yoshi-approver @GoogleCloudPlatform/cloud-samples-reviewers
/vision @GoogleCloudPlatform/java-samples-reviewers @yoshi-approver @GoogleCloudPlatform/cloud-samples-reviewers

Expand Down
7 changes: 0 additions & 7 deletions .kokoro/tests/run_prptst_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,4 @@ else
echo -e "\n Testing completed.\n"
fi

# If this is a periodic build, send the test log to the FlakyBot except for Java 8
# See https://github.com/googleapis/repo-automation-bots/tree/main/packages/flakybot.
if [[ $JAVA_VERSION != "1.8" && $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"periodic"* ]]; then
chmod +x $KOKORO_GFILE_DIR/linux_amd64/flakybot
$KOKORO_GFILE_DIR/linux_amd64/flakybot
fi

exit $RTN
7 changes: 0 additions & 7 deletions .kokoro/tests/run_test_java.sh
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,4 @@ if [[ "$file" == *"run/"* && ("$file" != *"run/filesystem"* && "$file" != *"run/
fi
fi

# If this is a periodic build, send the test log to the FlakyBot except for Java 8
# See https://github.com/googleapis/repo-automation-bots/tree/main/packages/flakybot.
if [[ $JAVA_VERSION != "1.8" && $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"periodic"* ]]; then
chmod +x $KOKORO_GFILE_DIR/linux_amd64/flakybot
$KOKORO_GFILE_DIR/linux_amd64/flakybot
fi

exit $RTN
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
/*
* Copyright 2024 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.
*/

package compute;

// [START compute_instance_create_replicated_boot_disk]
import com.google.cloud.compute.v1.AttachedDisk;
import com.google.cloud.compute.v1.AttachedDiskInitializeParams;
import com.google.cloud.compute.v1.Instance;
import com.google.cloud.compute.v1.InstancesClient;
import com.google.cloud.compute.v1.NetworkInterface;
import com.google.cloud.compute.v1.Operation;
import com.google.cloud.compute.v1.Operation.Status;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

public class CreateInstanceWithRegionalDiskFromSnapshot {

public static void main(String[] args) throws IOException, ExecutionException,
InterruptedException, TimeoutException {
// TODO(developer): Replace these variables before running the sample
// Project ID or project number of the Cloud project you want to use.
String projectId = "YOUR_PROJECT_ID";
// Name of the zone in which you want to create the instance.
String zone = "us-central1-a";
// Name of the instance you want to create.
String instanceName = "YOUR_INSTANCE_NAME";
// Name for the replicated disk.
String diskName = "YOUR_REPLICATED_DISK_NAME";
String region = zone.substring(0, zone.length() - 2);
// Type of the disk.
String diskType = String.format(
"projects/%s/regions/%s/diskTypes/pd-standard", projectId, region);
// The full path and name of the snapshot that you want to use as the source for the new disk.
String snapshotLink = String.format("projects/%s/global/snapshots/%s", projectId,
"SNAPSHOT_NAME");
// An iterable collection of zone names in which you want to keep
// the new disks' replicas. One of the replica zones of the clone must match
// the zone of the source disk.
List<String> replicaZones = new ArrayList<>();

createInstanceWithRegionalDiskFromSnapshot(projectId, zone, instanceName, diskName, diskType,
snapshotLink, replicaZones);
}

// Creates a new VM instance with regional disk from a snapshot and specifies replica zones.
public static Status createInstanceWithRegionalDiskFromSnapshot(
String projectId, String zone, String instanceName, String diskName,
String diskType, String snapshotLink, List<String> replicaZones)
throws IOException, ExecutionException, InterruptedException, TimeoutException {
// Initialize client that will be used to send requests. This client only needs to be created
// once, and can be reused for multiple requests.
try (InstancesClient instancesClient = InstancesClient.create()) {
AttachedDiskInitializeParams initializeParams = AttachedDiskInitializeParams.newBuilder()
.setSourceSnapshot(snapshotLink)
.setDiskType(diskType)
.setDiskName(diskName)
.addAllReplicaZones(replicaZones)
.build();

// Boot disk configuration
AttachedDisk bootDisk = AttachedDisk.newBuilder()
.setBoot(true)
.setAutoDelete(true) // Optional: Delete disk when instance is deleted.
.setType(AttachedDisk.Type.PERSISTENT.toString())
.setInitializeParams(initializeParams)
.build();

// Network interface configuration (using the default network)
NetworkInterface networkInterface = NetworkInterface.newBuilder()
.setNetwork("global/networks/default")
.build();

// Create the instance resource
Instance instanceResource = Instance.newBuilder()
.setName(instanceName)
.setMachineType(String.format("zones/%s/machineTypes/n1-standard-1", zone))
.addDisks(bootDisk)
.addNetworkInterfaces(networkInterface)
.build();

Operation response = instancesClient.insertAsync(projectId, zone, instanceResource).get(3,
TimeUnit.MINUTES);

if (response.hasError()) {
throw new Error("Error creating instance! " + response.getError());
}
return response.getStatus();
}
}
}
// [END compute_instance_create_replicated_boot_disk]
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*
* Copyright 2024 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.
*/

package compute.disks;

// [START compute_instance_attach_regional_disk_force]
import com.google.cloud.compute.v1.AttachDiskInstanceRequest;
import com.google.cloud.compute.v1.AttachedDisk;
import com.google.cloud.compute.v1.InstancesClient;
import com.google.cloud.compute.v1.Operation;
import com.google.cloud.compute.v1.Operation.Status;
import java.io.IOException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

public class AttachRegionalDiskForce {
public static void main(String[] args)
throws IOException, InterruptedException, ExecutionException, TimeoutException {
// TODO(developer): Replace these variables before running the sample.
// Project ID or project number of the Cloud project you want to use.
String projectId = "YOUR_PROJECT_ID";
// Name of the zone of your compute instance.
String zone = "us-central1-a";
// The name of the compute instance where you are adding the replicated disk.
String instanceName = "YOUR_INSTANCE_NAME";
// The region where your replicated disk is located.
String region = "us-central1";
// The name of the replicated disk.
String diskName = "YOUR_DISK_NAME";

attachRegionalDiskForce(projectId, zone, instanceName, region, diskName);
}

// Attaches a regional disk to the instance,
// forcing the attachment even if other VMs are using the disk.
public static Status attachRegionalDiskForce(String projectId,
String zone, String instanceName, String region, String diskName)
throws IOException, InterruptedException, ExecutionException, TimeoutException {
String diskLink = String.format("projects/%s/regions/%s/disks/%s",
projectId, region, diskName);
// Initialize client that will be used to send requests. This client only needs to be created
// once, and can be reused for multiple requests.
try (InstancesClient instancesClient = InstancesClient.create()) {
AttachedDisk attachedDisk = AttachedDisk.newBuilder()
.setSource(diskLink)
.setMode(AttachedDisk.Mode.READ_WRITE.toString())
.build();

AttachDiskInstanceRequest attachDiskRequest = AttachDiskInstanceRequest.newBuilder()
.setProject(projectId)
.setZone(zone)
.setInstance(instanceName)
.setAttachedDiskResource(attachedDisk)
.setForceAttach(true) // Force the attachment
.build();

Operation response = instancesClient.attachDiskAsync(attachDiskRequest)
.get(3, TimeUnit.MINUTES);

if (response.hasError()) {
throw new Error("Error attaching regional disk! " + response);
}
return response.getStatus();
}
}
}
// [END compute_instance_attach_regional_disk_force]
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
/*
* Copyright 2024 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.
*/

package compute.disks;

// [START compute_disk_create_secondary_regional]
import com.google.cloud.compute.v1.Disk;
import com.google.cloud.compute.v1.DiskAsyncReplication;
import com.google.cloud.compute.v1.Operation;
import com.google.cloud.compute.v1.Operation.Status;
import com.google.cloud.compute.v1.RegionDisksClient;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

public class CreateDiskSecondaryRegional {
public static void main(String[] args)
throws IOException, ExecutionException, InterruptedException, TimeoutException {
// TODO(developer): Replace these variables before running the sample.
// The project that contains the primary disk.
String primaryProjectId = "PRIMARY_PROJECT_ID";
// The project that contains the secondary disk.
String secondaryProjectId = "SECONDARY_PROJECT_ID";
// Name of the primary disk you want to use.
String primaryDiskName = "PRIMARY_DISK_NAME";
// Name of the disk you want to create.
String secondaryDiskName = "SECONDARY_DISK_NAME";
// Name of the region in which your primary disk is located.
// Learn more about zones and regions:
// https://cloud.google.com/compute/docs/disks/async-pd/about#supported_region_pairs
String primaryDiskRegion = "us-central1";
// Name of the region in which you want to create the secondary disk.
String secondaryDiskRegion = "us-east1";
// Size of the new disk in gigabytes.
// Learn more about disk requirements:
// https://cloud.google.com/compute/docs/disks/async-pd/configure?authuser=0#disk_requirements
long diskSizeGb = 30L;
// The type of the disk you want to create. This value uses the following format:
// "projects/{projectId}/zones/{zone}/diskTypes/
// (pd-standard|pd-ssd|pd-balanced|pd-extreme)".
String diskType = String.format(
"projects/%s/regions/%s/diskTypes/pd-balanced", secondaryProjectId, secondaryDiskRegion);

createDiskSecondaryRegional(primaryProjectId, secondaryProjectId, primaryDiskName,
secondaryDiskName, primaryDiskRegion, secondaryDiskRegion, diskSizeGb, diskType);
}

// Creates a secondary disk in a specified region.
public static Status createDiskSecondaryRegional(String projectId,
String secondaryProjectId, String primaryDiskName, String secondaryDiskName,
String primaryDiskRegion, String secondaryDiskRegion, long diskSizeGb, String diskType)
throws IOException, ExecutionException, InterruptedException, TimeoutException {
List<String> replicaZones = Arrays.asList(
String.format("projects/%s/zones/%s-c", secondaryProjectId, secondaryDiskRegion),
String.format("projects/%s/zones/%s-b", secondaryProjectId, secondaryDiskRegion));

String primaryDiskSource = String.format("projects/%s/regions/%s/disks/%s",
projectId, primaryDiskRegion, primaryDiskName);

// Initialize client that will be used to send requests. This client only needs to be created
// once, and can be reused for multiple requests.
try (RegionDisksClient disksClient = RegionDisksClient.create()) {
DiskAsyncReplication asyncReplication = DiskAsyncReplication.newBuilder()
.setDisk(primaryDiskSource)
.build();

Disk disk = Disk.newBuilder()
.addAllReplicaZones(replicaZones)
.setName(secondaryDiskName)
.setSizeGb(diskSizeGb)
.setType(diskType)
.setRegion(secondaryDiskRegion)
.setAsyncPrimaryDisk(asyncReplication)
.build();

// Wait for the create disk operation to complete.
Operation response = disksClient.insertAsync(secondaryProjectId, secondaryDiskRegion, disk)
.get(3, TimeUnit.MINUTES);

if (response.hasError()) {
throw new Error("Error creating secondary disks! " + response.getError());
}
return response.getStatus();
}
}
}
// [END compute_disk_create_secondary_regional]
Loading
Loading