diff --git a/parametermanager/pom.xml b/parametermanager/pom.xml
index 33cd5ffdc52..d3405e9ee95 100644
--- a/parametermanager/pom.xml
+++ b/parametermanager/pom.xml
@@ -43,7 +43,7 @@
com.google.cloud
libraries-bom
- 26.60.0
+ 26.90.0
pom
import
@@ -56,6 +56,11 @@
google-cloud-parametermanager
+
+ com.google.cloud
+ google-cloud-resourcemanager
+
+
com.google.protobuf
protobuf-java-util
diff --git a/parametermanager/src/main/java/parametermanager/BindTagsToParam.java b/parametermanager/src/main/java/parametermanager/BindTagsToParam.java
new file mode 100644
index 00000000000..10ee6ec4180
--- /dev/null
+++ b/parametermanager/src/main/java/parametermanager/BindTagsToParam.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright 2026 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 parametermanager;
+
+// [START parametermanager_bind_tags_to_param]
+
+import com.google.cloud.parametermanager.v1.LocationName;
+import com.google.cloud.parametermanager.v1.Parameter;
+import com.google.cloud.parametermanager.v1.ParameterManagerClient;
+import com.google.cloud.resourcemanager.v3.TagBinding;
+import com.google.cloud.resourcemanager.v3.TagBindingsClient;
+import java.io.IOException;
+import java.util.concurrent.ExecutionException;
+
+/**
+ * This class demonstrates how to create a parameter and bind a tag to it using the Parameter
+ * Manager SDK for GCP.
+ */
+public class BindTagsToParam {
+
+ public static void main(String[] args)
+ throws IOException, ExecutionException, InterruptedException {
+ // TODO(developer): Replace these variables before running the sample.
+ String projectId = "your-project-id";
+ String parameterId = "your-parameter-id";
+ String tagValue = "tagValues/1234567890";
+
+ // Call the method to create a parameter and bind a tag to it.
+ bindTagsToParam(projectId, parameterId, tagValue);
+ }
+
+ // This is an example snippet for creating a parameter and binding a tag to it.
+ public static TagBinding bindTagsToParam(String projectId, String parameterId, String tagValue)
+ throws IOException, ExecutionException, InterruptedException {
+
+ // Initialize the client that will be used to send requests. This client only needs to be
+ // created once, and can be reused for multiple requests.
+ try (ParameterManagerClient client = ParameterManagerClient.create();
+ TagBindingsClient tagBindingsClient = TagBindingsClient.create()) {
+ String locationId = "global";
+
+ // Build the parent name from the project.
+ LocationName location = LocationName.of(projectId, locationId);
+
+ // Create the parameter.
+ Parameter parameter =
+ client.createParameter(location.toString(), Parameter.newBuilder().build(), parameterId);
+ System.out.printf("Created parameter: %s\n", parameter.getName());
+
+ // Build the tag binding for the new parameter.
+ TagBinding tagBinding =
+ TagBinding.newBuilder()
+ .setParent("//parametermanager.googleapis.com/" + parameter.getName())
+ .setTagValue(tagValue)
+ .build();
+
+ // Create the tag binding and wait for the operation to complete.
+ TagBinding createdTagBinding = tagBindingsClient.createTagBindingAsync(tagBinding).get();
+ System.out.printf("Created tag binding: %s\n", createdTagBinding.getName());
+
+ return createdTagBinding;
+ }
+ }
+}
+// [END parametermanager_bind_tags_to_param]
diff --git a/parametermanager/src/main/java/parametermanager/CreateParamTemplate.java b/parametermanager/src/main/java/parametermanager/CreateParamTemplate.java
new file mode 100644
index 00000000000..eb25797756f
--- /dev/null
+++ b/parametermanager/src/main/java/parametermanager/CreateParamTemplate.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2026 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 parametermanager;
+
+// [START parametermanager_create_param_template]
+
+import com.google.cloud.parametermanager.v1.LocationName;
+import com.google.cloud.parametermanager.v1.ParameterManagerClient;
+import com.google.cloud.parametermanager.v1.Template;
+import com.google.cloud.parametermanager.v1.TemplateFormat;
+import java.io.IOException;
+
+/** This class demonstrates how to create a template using the Parameter Manager SDK for GCP. */
+public class CreateParamTemplate {
+
+ public static void main(String[] args) throws IOException {
+ // TODO(developer): Replace these variables before running the sample.
+ String projectId = "your-project-id";
+ String templateId = "your-template-id";
+ TemplateFormat format = TemplateFormat.TEMPLATE_FORMAT_JSON;
+
+ // Call the method to create a template.
+ createParamTemplate(projectId, templateId, format);
+ }
+
+ // This is an example snippet for creating a template.
+ public static Template createParamTemplate(
+ String projectId, String templateId, TemplateFormat format) throws IOException {
+
+ // Initialize the client that will be used to send requests. This client only needs to be
+ // created once, and can be reused for multiple requests.
+ try (ParameterManagerClient client = ParameterManagerClient.create()) {
+ String locationId = "global";
+
+ // Build the parent name from the project.
+ LocationName location = LocationName.of(projectId, locationId);
+
+ // Build the template to create.
+ Template template = Template.newBuilder().setFormat(format).build();
+
+ // Create the template.
+ Template createdTemplate = client.createTemplate(location.toString(), template, templateId);
+ System.out.printf(
+ "Created template %s with format %s\n",
+ createdTemplate.getName(), createdTemplate.getFormat());
+
+ return createdTemplate;
+ }
+ }
+}
+// [END parametermanager_create_param_template]
diff --git a/parametermanager/src/main/java/parametermanager/CreateParamTemplateVersion.java b/parametermanager/src/main/java/parametermanager/CreateParamTemplateVersion.java
new file mode 100644
index 00000000000..799358034d4
--- /dev/null
+++ b/parametermanager/src/main/java/parametermanager/CreateParamTemplateVersion.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2026 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 parametermanager;
+
+// [START parametermanager_create_param_template_version]
+
+import com.google.cloud.parametermanager.v1.ParameterManagerClient;
+import com.google.cloud.parametermanager.v1.TemplateName;
+import com.google.cloud.parametermanager.v1.TemplateVersion;
+import com.google.cloud.parametermanager.v1.TemplateVersionPayload;
+import com.google.protobuf.ByteString;
+import java.io.IOException;
+
+/**
+ * This class demonstrates how to create a template version using the Parameter Manager SDK for GCP.
+ */
+public class CreateParamTemplateVersion {
+
+ public static void main(String[] args) throws IOException {
+ // TODO(developer): Replace these variables before running the sample.
+ String projectId = "your-project-id";
+ String templateId = "your-template-id";
+ String versionId = "your-version-id";
+
+ // Call the method to create a template version.
+ createParamTemplateVersion(projectId, templateId, versionId);
+ }
+
+ // This is an example snippet for creating a template version with placeholders in its payload.
+ public static TemplateVersion createParamTemplateVersion(
+ String projectId, String templateId, String versionId) throws IOException {
+
+ // Initialize the client that will be used to send requests. This client only needs to be
+ // created once, and can be reused for multiple requests.
+ try (ParameterManagerClient client = ParameterManagerClient.create()) {
+ String locationId = "global";
+
+ // Build the template name.
+ TemplateName templateName = TemplateName.of(projectId, locationId, templateId);
+
+ // Build the template version payload with placeholders.
+ String payload = "{\"username\": \"{{.username}}\", \"host\": \"{{.host}}\"}";
+ TemplateVersionPayload templateVersionPayload =
+ TemplateVersionPayload.newBuilder().setData(ByteString.copyFromUtf8(payload)).build();
+
+ // Build the template version to create.
+ TemplateVersion templateVersion =
+ TemplateVersion.newBuilder().setPayload(templateVersionPayload).build();
+
+ // Create the template version.
+ TemplateVersion createdTemplateVersion =
+ client.createTemplateVersion(templateName.toString(), templateVersion, versionId);
+ System.out.printf("Created template version: %s\n", createdTemplateVersion.getName());
+
+ return createdTemplateVersion;
+ }
+ }
+}
+// [END parametermanager_create_param_template_version]
diff --git a/parametermanager/src/main/java/parametermanager/CreateParamVersionWithChecksum.java b/parametermanager/src/main/java/parametermanager/CreateParamVersionWithChecksum.java
new file mode 100644
index 00000000000..a004e77ee9a
--- /dev/null
+++ b/parametermanager/src/main/java/parametermanager/CreateParamVersionWithChecksum.java
@@ -0,0 +1,82 @@
+/*
+ * Copyright 2026 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 parametermanager;
+
+// [START parametermanager_create_param_version_with_checksum]
+
+import com.google.cloud.parametermanager.v1.ParameterManagerClient;
+import com.google.cloud.parametermanager.v1.ParameterName;
+import com.google.cloud.parametermanager.v1.ParameterVersion;
+import com.google.cloud.parametermanager.v1.ParameterVersionPayload;
+import com.google.protobuf.ByteString;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.util.zip.CRC32C;
+
+/**
+ * This class demonstrates how to create a parameter version with a checksum using the Parameter
+ * Manager SDK for GCP.
+ */
+public class CreateParamVersionWithChecksum {
+
+ public static void main(String[] args) throws IOException {
+ // TODO(developer): Replace these variables before running the sample.
+ String projectId = "your-project-id";
+ String parameterId = "your-parameter-id";
+ String versionId = "your-version-id";
+
+ // Call the method to create a parameter version with a checksum.
+ createParamVersionWithChecksum(projectId, parameterId, versionId);
+ }
+
+ // This is an example snippet for creating a parameter version with a CRC32C checksum of the
+ // payload.
+ public static ParameterVersion createParamVersionWithChecksum(
+ String projectId, String parameterId, String versionId) throws IOException {
+
+ // Initialize the client that will be used to send requests. This client only needs to be
+ // created once, and can be reused for multiple requests.
+ try (ParameterManagerClient client = ParameterManagerClient.create()) {
+ String locationId = "global";
+
+ // Build the parameter name.
+ ParameterName parameterName = ParameterName.of(projectId, locationId, parameterId);
+
+ // Define the payload and compute its CRC32C checksum.
+ byte[] data = "hello world!".getBytes(StandardCharsets.UTF_8);
+ CRC32C crc32c = new CRC32C();
+ crc32c.update(data);
+
+ // Build the parameter version with the payload and checksum.
+ ParameterVersionPayload payload =
+ ParameterVersionPayload.newBuilder()
+ .setData(ByteString.copyFrom(data))
+ .setDataCrc32C(crc32c.getValue())
+ .build();
+ ParameterVersion parameterVersion = ParameterVersion.newBuilder().setPayload(payload).build();
+
+ // Create the parameter version.
+ ParameterVersion createdParameterVersion =
+ client.createParameterVersion(parameterName.toString(), parameterVersion, versionId);
+ System.out.printf("Created parameter version: %s\n", createdParameterVersion.getName());
+ System.out.printf("Checksum source: %s\n", createdParameterVersion.getChecksumSource());
+
+ return createdParameterVersion;
+ }
+ }
+}
+// [END parametermanager_create_param_version_with_checksum]
diff --git a/parametermanager/src/main/java/parametermanager/CreateParamWithTags.java b/parametermanager/src/main/java/parametermanager/CreateParamWithTags.java
new file mode 100644
index 00000000000..b5afc04f350
--- /dev/null
+++ b/parametermanager/src/main/java/parametermanager/CreateParamWithTags.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2026 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 parametermanager;
+
+// [START parametermanager_create_param_with_tags]
+
+import com.google.cloud.parametermanager.v1.LocationName;
+import com.google.cloud.parametermanager.v1.Parameter;
+import com.google.cloud.parametermanager.v1.ParameterManagerClient;
+import java.io.IOException;
+
+/**
+ * This class demonstrates how to create a parameter with a tag using the Parameter Manager SDK for
+ * GCP.
+ */
+public class CreateParamWithTags {
+
+ public static void main(String[] args) throws IOException {
+ // TODO(developer): Replace these variables before running the sample.
+ String projectId = "your-project-id";
+ String parameterId = "your-parameter-id";
+ String tagKey = "tagKeys/1234567890";
+ String tagValue = "tagValues/1234567890";
+
+ // Call the method to create a parameter with a tag.
+ createParamWithTags(projectId, parameterId, tagKey, tagValue);
+ }
+
+ // This is an example snippet for creating a parameter with a tag.
+ public static Parameter createParamWithTags(
+ String projectId, String parameterId, String tagKey, String tagValue) throws IOException {
+
+ // Initialize the client that will be used to send requests. This client only needs to be
+ // created once, and can be reused for multiple requests.
+ try (ParameterManagerClient client = ParameterManagerClient.create()) {
+ String locationId = "global";
+
+ // Build the parent name from the project.
+ LocationName location = LocationName.of(projectId, locationId);
+
+ // Build the parameter to create with the tag.
+ Parameter parameter = Parameter.newBuilder().putTags(tagKey, tagValue).build();
+
+ // Create the parameter.
+ Parameter createdParameter =
+ client.createParameter(location.toString(), parameter, parameterId);
+ System.out.printf(
+ "Created parameter %s with tag %s: %s\n", createdParameter.getName(), tagKey, tagValue);
+
+ return createdParameter;
+ }
+ }
+}
+// [END parametermanager_create_param_with_tags]
diff --git a/parametermanager/src/main/java/parametermanager/DeleteParamTemplate.java b/parametermanager/src/main/java/parametermanager/DeleteParamTemplate.java
new file mode 100644
index 00000000000..076a43a9f6c
--- /dev/null
+++ b/parametermanager/src/main/java/parametermanager/DeleteParamTemplate.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2026 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 parametermanager;
+
+// [START parametermanager_delete_param_template]
+
+import com.google.cloud.parametermanager.v1.ParameterManagerClient;
+import com.google.cloud.parametermanager.v1.TemplateName;
+import java.io.IOException;
+
+/** This class demonstrates how to delete a template using the Parameter Manager SDK for GCP. */
+public class DeleteParamTemplate {
+
+ public static void main(String[] args) throws IOException {
+ // TODO(developer): Replace these variables before running the sample.
+ String projectId = "your-project-id";
+ String templateId = "your-template-id";
+
+ // Call the method to delete a template.
+ deleteParamTemplate(projectId, templateId);
+ }
+
+ // This is an example snippet for deleting a template.
+ public static void deleteParamTemplate(String projectId, String templateId) throws IOException {
+
+ // Initialize the client that will be used to send requests. This client only needs to be
+ // created once, and can be reused for multiple requests.
+ try (ParameterManagerClient client = ParameterManagerClient.create()) {
+ String locationId = "global";
+
+ // Build the template name.
+ TemplateName templateName = TemplateName.of(projectId, locationId, templateId);
+
+ // Delete the template.
+ client.deleteTemplate(templateName);
+ System.out.printf("Deleted template: %s\n", templateName);
+ }
+ }
+}
+// [END parametermanager_delete_param_template]
diff --git a/parametermanager/src/main/java/parametermanager/DeleteParamTemplateVersion.java b/parametermanager/src/main/java/parametermanager/DeleteParamTemplateVersion.java
new file mode 100644
index 00000000000..c0db0deb5aa
--- /dev/null
+++ b/parametermanager/src/main/java/parametermanager/DeleteParamTemplateVersion.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2026 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 parametermanager;
+
+// [START parametermanager_delete_param_template_version]
+
+import com.google.cloud.parametermanager.v1.ParameterManagerClient;
+import com.google.cloud.parametermanager.v1.TemplateVersionName;
+import java.io.IOException;
+
+/**
+ * This class demonstrates how to delete a template version using the Parameter Manager SDK for GCP.
+ */
+public class DeleteParamTemplateVersion {
+
+ public static void main(String[] args) throws IOException {
+ // TODO(developer): Replace these variables before running the sample.
+ String projectId = "your-project-id";
+ String templateId = "your-template-id";
+ String versionId = "your-version-id";
+
+ // Call the method to delete a template version.
+ deleteParamTemplateVersion(projectId, templateId, versionId);
+ }
+
+ // This is an example snippet for deleting a template version.
+ public static void deleteParamTemplateVersion(
+ String projectId, String templateId, String versionId) throws IOException {
+
+ // Initialize the client that will be used to send requests. This client only needs to be
+ // created once, and can be reused for multiple requests.
+ try (ParameterManagerClient client = ParameterManagerClient.create()) {
+ String locationId = "global";
+
+ // Build the template version name.
+ TemplateVersionName templateVersionName =
+ TemplateVersionName.of(projectId, locationId, templateId, versionId);
+
+ // Delete the template version.
+ client.deleteTemplateVersion(templateVersionName);
+ System.out.printf("Deleted template version: %s\n", templateVersionName);
+ }
+ }
+}
+// [END parametermanager_delete_param_template_version]
diff --git a/parametermanager/src/main/java/parametermanager/DisableParamTemplateVersion.java b/parametermanager/src/main/java/parametermanager/DisableParamTemplateVersion.java
new file mode 100644
index 00000000000..e4148013084
--- /dev/null
+++ b/parametermanager/src/main/java/parametermanager/DisableParamTemplateVersion.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2026 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 parametermanager;
+
+// [START parametermanager_disable_param_template_version]
+
+import com.google.cloud.parametermanager.v1.ParameterManagerClient;
+import com.google.cloud.parametermanager.v1.TemplateVersion;
+import com.google.cloud.parametermanager.v1.TemplateVersionName;
+import com.google.protobuf.FieldMask;
+import com.google.protobuf.util.FieldMaskUtil;
+import java.io.IOException;
+
+/**
+ * This class demonstrates how to disable a template version using the Parameter Manager SDK for
+ * GCP.
+ */
+public class DisableParamTemplateVersion {
+
+ public static void main(String[] args) throws IOException {
+ // TODO(developer): Replace these variables before running the sample.
+ String projectId = "your-project-id";
+ String templateId = "your-template-id";
+ String versionId = "your-version-id";
+
+ // Call the method to disable a template version.
+ disableParamTemplateVersion(projectId, templateId, versionId);
+ }
+
+ // This is an example snippet for disabling a template version.
+ public static TemplateVersion disableParamTemplateVersion(
+ String projectId, String templateId, String versionId) throws IOException {
+
+ // Initialize the client that will be used to send requests. This client only needs to be
+ // created once, and can be reused for multiple requests.
+ try (ParameterManagerClient client = ParameterManagerClient.create()) {
+ String locationId = "global";
+
+ // Build the template version name.
+ TemplateVersionName templateVersionName =
+ TemplateVersionName.of(projectId, locationId, templateId, versionId);
+
+ // Set the template version to disable.
+ TemplateVersion templateVersion =
+ TemplateVersion.newBuilder()
+ .setName(templateVersionName.toString())
+ .setDisabled(true)
+ .build();
+
+ // Build the field mask for the disabled field.
+ FieldMask fieldMask = FieldMaskUtil.fromString("disabled");
+
+ // Update the template version.
+ TemplateVersion updatedTemplateVersion =
+ client.updateTemplateVersion(templateVersion, fieldMask);
+ System.out.printf("Disabled template version: %s\n", updatedTemplateVersion.getName());
+
+ return updatedTemplateVersion;
+ }
+ }
+}
+// [END parametermanager_disable_param_template_version]
diff --git a/parametermanager/src/main/java/parametermanager/EnableParamTemplateVersion.java b/parametermanager/src/main/java/parametermanager/EnableParamTemplateVersion.java
new file mode 100644
index 00000000000..f8e05eb659a
--- /dev/null
+++ b/parametermanager/src/main/java/parametermanager/EnableParamTemplateVersion.java
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2026 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 parametermanager;
+
+// [START parametermanager_enable_param_template_version]
+
+import com.google.cloud.parametermanager.v1.ParameterManagerClient;
+import com.google.cloud.parametermanager.v1.TemplateVersion;
+import com.google.cloud.parametermanager.v1.TemplateVersionName;
+import com.google.protobuf.FieldMask;
+import com.google.protobuf.util.FieldMaskUtil;
+import java.io.IOException;
+
+/**
+ * This class demonstrates how to enable a template version using the Parameter Manager SDK for GCP.
+ */
+public class EnableParamTemplateVersion {
+
+ public static void main(String[] args) throws IOException {
+ // TODO(developer): Replace these variables before running the sample.
+ String projectId = "your-project-id";
+ String templateId = "your-template-id";
+ String versionId = "your-version-id";
+
+ // Call the method to enable a template version.
+ enableParamTemplateVersion(projectId, templateId, versionId);
+ }
+
+ // This is an example snippet for enabling a template version.
+ public static TemplateVersion enableParamTemplateVersion(
+ String projectId, String templateId, String versionId) throws IOException {
+
+ // Initialize the client that will be used to send requests. This client only needs to be
+ // created once, and can be reused for multiple requests.
+ try (ParameterManagerClient client = ParameterManagerClient.create()) {
+ String locationId = "global";
+
+ // Build the template version name.
+ TemplateVersionName templateVersionName =
+ TemplateVersionName.of(projectId, locationId, templateId, versionId);
+
+ // Set the template version to enable.
+ TemplateVersion templateVersion =
+ TemplateVersion.newBuilder()
+ .setName(templateVersionName.toString())
+ .setDisabled(false)
+ .build();
+
+ // Build the field mask for the disabled field.
+ FieldMask fieldMask = FieldMaskUtil.fromString("disabled");
+
+ // Update the template version.
+ TemplateVersion updatedTemplateVersion =
+ client.updateTemplateVersion(templateVersion, fieldMask);
+ System.out.printf("Enabled template version: %s\n", updatedTemplateVersion.getName());
+
+ return updatedTemplateVersion;
+ }
+ }
+}
+// [END parametermanager_enable_param_template_version]
diff --git a/parametermanager/src/main/java/parametermanager/GetParamTags.java b/parametermanager/src/main/java/parametermanager/GetParamTags.java
new file mode 100644
index 00000000000..ccf5aa7a583
--- /dev/null
+++ b/parametermanager/src/main/java/parametermanager/GetParamTags.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2026 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 parametermanager;
+
+// [START parametermanager_get_param_tags]
+
+import com.google.cloud.parametermanager.v1.Parameter;
+import com.google.cloud.parametermanager.v1.ParameterManagerClient;
+import com.google.cloud.parametermanager.v1.ParameterName;
+import com.google.cloud.resourcemanager.v3.TagBindingsClient;
+import com.google.cloud.resourcemanager.v3.TagBindingsClient.ListTagBindingsPagedResponse;
+import java.io.IOException;
+
+/**
+ * This class demonstrates how to get the tags of a parameter using the Parameter Manager SDK for
+ * GCP.
+ */
+public class GetParamTags {
+
+ public static void main(String[] args) throws IOException {
+ // TODO(developer): Replace these variables before running the sample.
+ String projectId = "your-project-id";
+ String parameterId = "your-parameter-id";
+
+ // Call the method to get the tags of a parameter.
+ getParamTags(projectId, parameterId);
+ }
+
+ // This is an example snippet for getting the tag bindings of a parameter.
+ public static ListTagBindingsPagedResponse getParamTags(String projectId, String parameterId)
+ throws IOException {
+
+ // Initialize the client that will be used to send requests. This client only needs to be
+ // created once, and can be reused for multiple requests.
+ try (ParameterManagerClient client = ParameterManagerClient.create();
+ TagBindingsClient tagBindingsClient = TagBindingsClient.create()) {
+ String locationId = "global";
+
+ // Build the parameter name.
+ ParameterName parameterName = ParameterName.of(projectId, locationId, parameterId);
+
+ // Get the parameter.
+ Parameter parameter = client.getParameter(parameterName.toString());
+
+ // List the tag bindings of the parameter.
+ ListTagBindingsPagedResponse response =
+ tagBindingsClient.listTagBindings(
+ "//parametermanager.googleapis.com/" + parameter.getName());
+ response
+ .iterateAll()
+ .forEach(
+ binding -> System.out.printf("Found parameter tag: %s\n", binding.getTagValue()));
+
+ return response;
+ }
+ }
+}
+// [END parametermanager_get_param_tags]
diff --git a/parametermanager/src/main/java/parametermanager/GetParamTemplate.java b/parametermanager/src/main/java/parametermanager/GetParamTemplate.java
new file mode 100644
index 00000000000..141affbdfb9
--- /dev/null
+++ b/parametermanager/src/main/java/parametermanager/GetParamTemplate.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2026 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 parametermanager;
+
+// [START parametermanager_get_param_template]
+
+import com.google.cloud.parametermanager.v1.ParameterManagerClient;
+import com.google.cloud.parametermanager.v1.Template;
+import com.google.cloud.parametermanager.v1.TemplateName;
+import java.io.IOException;
+
+/** This class demonstrates how to get a template using the Parameter Manager SDK for GCP. */
+public class GetParamTemplate {
+
+ public static void main(String[] args) throws IOException {
+ // TODO(developer): Replace these variables before running the sample.
+ String projectId = "your-project-id";
+ String templateId = "your-template-id";
+
+ // Call the method to get a template.
+ getParamTemplate(projectId, templateId);
+ }
+
+ // This is an example snippet for getting a template.
+ public static Template getParamTemplate(String projectId, String templateId) throws IOException {
+
+ // Initialize the client that will be used to send requests. This client only needs to be
+ // created once, and can be reused for multiple requests.
+ try (ParameterManagerClient client = ParameterManagerClient.create()) {
+ String locationId = "global";
+
+ // Build the template name.
+ TemplateName templateName = TemplateName.of(projectId, locationId, templateId);
+
+ // Get the template.
+ Template template = client.getTemplate(templateName.toString());
+ System.out.printf(
+ "Got template %s with format %s\n", template.getName(), template.getFormat());
+
+ return template;
+ }
+ }
+}
+// [END parametermanager_get_param_template]
diff --git a/parametermanager/src/main/java/parametermanager/GetParamTemplateVersion.java b/parametermanager/src/main/java/parametermanager/GetParamTemplateVersion.java
new file mode 100644
index 00000000000..641aea28988
--- /dev/null
+++ b/parametermanager/src/main/java/parametermanager/GetParamTemplateVersion.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2026 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 parametermanager;
+
+// [START parametermanager_get_param_template_version]
+
+import com.google.cloud.parametermanager.v1.ParameterManagerClient;
+import com.google.cloud.parametermanager.v1.TemplateVersion;
+import com.google.cloud.parametermanager.v1.TemplateVersionName;
+import java.io.IOException;
+
+/**
+ * This class demonstrates how to get a template version using the Parameter Manager SDK for GCP.
+ */
+public class GetParamTemplateVersion {
+
+ public static void main(String[] args) throws IOException {
+ // TODO(developer): Replace these variables before running the sample.
+ String projectId = "your-project-id";
+ String templateId = "your-template-id";
+ String versionId = "your-version-id";
+
+ // Call the method to get a template version.
+ getParamTemplateVersion(projectId, templateId, versionId);
+ }
+
+ // This is an example snippet for getting a template version.
+ public static TemplateVersion getParamTemplateVersion(
+ String projectId, String templateId, String versionId) throws IOException {
+
+ // Initialize the client that will be used to send requests. This client only needs to be
+ // created once, and can be reused for multiple requests.
+ try (ParameterManagerClient client = ParameterManagerClient.create()) {
+ String locationId = "global";
+
+ // Build the template version name.
+ TemplateVersionName templateVersionName =
+ TemplateVersionName.of(projectId, locationId, templateId, versionId);
+
+ // Get the template version.
+ TemplateVersion templateVersion = client.getTemplateVersion(templateVersionName.toString());
+ System.out.printf("Got template version %s\n", templateVersion.getName());
+ System.out.printf("Payload: %s\n", templateVersion.getPayload().getData().toStringUtf8());
+
+ return templateVersion;
+ }
+ }
+}
+// [END parametermanager_get_param_template_version]
diff --git a/parametermanager/src/main/java/parametermanager/GetParamVersionVerifyChecksum.java b/parametermanager/src/main/java/parametermanager/GetParamVersionVerifyChecksum.java
new file mode 100644
index 00000000000..b40e9905b32
--- /dev/null
+++ b/parametermanager/src/main/java/parametermanager/GetParamVersionVerifyChecksum.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2026 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 parametermanager;
+
+// [START parametermanager_get_param_version_verify_checksum]
+
+import com.google.cloud.parametermanager.v1.GetParameterVersionRequest;
+import com.google.cloud.parametermanager.v1.ParameterManagerClient;
+import com.google.cloud.parametermanager.v1.ParameterVersion;
+import com.google.cloud.parametermanager.v1.ParameterVersionName;
+import com.google.cloud.parametermanager.v1.View;
+import java.io.IOException;
+import java.util.zip.CRC32C;
+
+/**
+ * This class demonstrates how to get a parameter version and verify its checksum using the
+ * Parameter Manager SDK for GCP.
+ */
+public class GetParamVersionVerifyChecksum {
+
+ public static void main(String[] args) throws IOException {
+ // TODO(developer): Replace these variables before running the sample.
+ String projectId = "your-project-id";
+ String parameterId = "your-parameter-id";
+ String versionId = "your-version-id";
+
+ // Call the method to get a parameter version and verify its checksum.
+ getParamVersionVerifyChecksum(projectId, parameterId, versionId);
+ }
+
+ // This is an example snippet for getting a parameter version and verifying its payload checksum.
+ public static ParameterVersion getParamVersionVerifyChecksum(
+ String projectId, String parameterId, String versionId) throws IOException {
+
+ // Initialize the client that will be used to send requests. This client only needs to be
+ // created once, and can be reused for multiple requests.
+ try (ParameterManagerClient client = ParameterManagerClient.create()) {
+ String locationId = "global";
+
+ // Build the parameter version name.
+ ParameterVersionName parameterVersionName =
+ ParameterVersionName.of(projectId, locationId, parameterId, versionId);
+
+ // Get the parameter version with the payload and checksum.
+ GetParameterVersionRequest request =
+ GetParameterVersionRequest.newBuilder()
+ .setName(parameterVersionName.toString())
+ .setView(View.FULL)
+ .build();
+ ParameterVersion parameterVersion = client.getParameterVersion(request);
+
+ // Verify the payload checksum.
+ CRC32C crc32c = new CRC32C();
+ crc32c.update(parameterVersion.getPayload().getData().toByteArray());
+ if (crc32c.getValue() != parameterVersion.getPayload().getDataCrc32C()) {
+ throw new IllegalStateException(
+ String.format("Checksum mismatch for %s: data corrupted", parameterVersion.getName()));
+ }
+ System.out.printf(
+ "Verified checksum for parameter version: %s\n", parameterVersion.getName());
+ System.out.printf("Checksum source: %s\n", parameterVersion.getChecksumSource());
+
+ return parameterVersion;
+ }
+ }
+}
+// [END parametermanager_get_param_version_verify_checksum]
diff --git a/parametermanager/src/main/java/parametermanager/ListParamTemplateVersions.java b/parametermanager/src/main/java/parametermanager/ListParamTemplateVersions.java
new file mode 100644
index 00000000000..5c07ceacc8f
--- /dev/null
+++ b/parametermanager/src/main/java/parametermanager/ListParamTemplateVersions.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2026 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 parametermanager;
+
+// [START parametermanager_list_param_template_versions]
+
+import com.google.cloud.parametermanager.v1.ParameterManagerClient;
+import com.google.cloud.parametermanager.v1.ParameterManagerClient.ListTemplateVersionsPagedResponse;
+import com.google.cloud.parametermanager.v1.TemplateName;
+import java.io.IOException;
+
+/**
+ * This class demonstrates how to list template versions using the Parameter Manager SDK for GCP.
+ */
+public class ListParamTemplateVersions {
+
+ public static void main(String[] args) throws IOException {
+ // TODO(developer): Replace these variables before running the sample.
+ String projectId = "your-project-id";
+ String templateId = "your-template-id";
+
+ // Call the method to list template versions.
+ listParamTemplateVersions(projectId, templateId);
+ }
+
+ // This is an example snippet for listing all versions of a template.
+ public static ListTemplateVersionsPagedResponse listParamTemplateVersions(
+ String projectId, String templateId) throws IOException {
+
+ // Initialize the client that will be used to send requests. This client only needs to be
+ // created once, and can be reused for multiple requests.
+ try (ParameterManagerClient client = ParameterManagerClient.create()) {
+ String locationId = "global";
+
+ // Build the template name.
+ TemplateName templateName = TemplateName.of(projectId, locationId, templateId);
+
+ // List the template versions.
+ ListTemplateVersionsPagedResponse response =
+ client.listTemplateVersions(templateName.toString());
+ response
+ .iterateAll()
+ .forEach(version -> System.out.printf("Found template version: %s\n", version.getName()));
+
+ return response;
+ }
+ }
+}
+// [END parametermanager_list_param_template_versions]
diff --git a/parametermanager/src/main/java/parametermanager/ListParamTemplates.java b/parametermanager/src/main/java/parametermanager/ListParamTemplates.java
new file mode 100644
index 00000000000..9ac72b9e4b3
--- /dev/null
+++ b/parametermanager/src/main/java/parametermanager/ListParamTemplates.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2026 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 parametermanager;
+
+// [START parametermanager_list_param_templates]
+
+import com.google.cloud.parametermanager.v1.LocationName;
+import com.google.cloud.parametermanager.v1.ParameterManagerClient;
+import com.google.cloud.parametermanager.v1.ParameterManagerClient.ListTemplatesPagedResponse;
+import java.io.IOException;
+
+/** This class demonstrates how to list templates using the Parameter Manager SDK for GCP. */
+public class ListParamTemplates {
+
+ public static void main(String[] args) throws IOException {
+ // TODO(developer): Replace these variables before running the sample.
+ String projectId = "your-project-id";
+
+ // Call the method to list templates.
+ listParamTemplates(projectId);
+ }
+
+ // This is an example snippet for listing all templates in the given project.
+ public static ListTemplatesPagedResponse listParamTemplates(String projectId) throws IOException {
+
+ // Initialize the client that will be used to send requests. This client only needs to be
+ // created once, and can be reused for multiple requests.
+ try (ParameterManagerClient client = ParameterManagerClient.create()) {
+ String locationId = "global";
+
+ // Build the parent name from the project.
+ LocationName location = LocationName.of(projectId, locationId);
+
+ // List all templates.
+ ListTemplatesPagedResponse response = client.listTemplates(location.toString());
+ response
+ .iterateAll()
+ .forEach(
+ template ->
+ System.out.printf(
+ "Found template %s with format %s\n",
+ template.getName(), template.getFormat()));
+
+ return response;
+ }
+ }
+}
+// [END parametermanager_list_param_templates]
diff --git a/parametermanager/src/main/java/parametermanager/RenderParamTemplateVersion.java b/parametermanager/src/main/java/parametermanager/RenderParamTemplateVersion.java
new file mode 100644
index 00000000000..9165d305181
--- /dev/null
+++ b/parametermanager/src/main/java/parametermanager/RenderParamTemplateVersion.java
@@ -0,0 +1,84 @@
+/*
+ * Copyright 2026 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 parametermanager;
+
+// [START parametermanager_render_param_template_version]
+
+import com.google.cloud.parametermanager.v1.ParameterManagerClient;
+import com.google.cloud.parametermanager.v1.ParameterVersionName;
+import com.google.cloud.parametermanager.v1.RenderTemplateVersionRequest;
+import com.google.cloud.parametermanager.v1.RenderTemplateVersionResponse;
+import com.google.cloud.parametermanager.v1.TemplateVersionName;
+import java.io.IOException;
+
+/**
+ * This class demonstrates how to render a template version using the Parameter Manager SDK for GCP.
+ */
+public class RenderParamTemplateVersion {
+
+ public static void main(String[] args) throws IOException {
+ // TODO(developer): Replace these variables before running the sample.
+ String projectId = "your-project-id";
+ String templateId = "your-template-id";
+ String versionId = "your-version-id";
+ String parameterId = "your-parameter-id";
+ String parameterVersionId = "your-parameter-version-id";
+
+ // Call the method to render a template version.
+ renderParamTemplateVersion(projectId, templateId, versionId, parameterId, parameterVersionId);
+ }
+
+ // This is an example snippet for rendering a template version with the values of a parameter
+ // version.
+ public static RenderTemplateVersionResponse renderParamTemplateVersion(
+ String projectId,
+ String templateId,
+ String versionId,
+ String parameterId,
+ String parameterVersionId)
+ throws IOException {
+
+ // Initialize the client that will be used to send requests. This client only needs to be
+ // created once, and can be reused for multiple requests.
+ try (ParameterManagerClient client = ParameterManagerClient.create()) {
+ String locationId = "global";
+
+ // Build the template version name.
+ TemplateVersionName templateVersionName =
+ TemplateVersionName.of(projectId, locationId, templateId, versionId);
+
+ // Build the parameter version name that supplies the values.
+ ParameterVersionName parameterVersionName =
+ ParameterVersionName.of(projectId, locationId, parameterId, parameterVersionId);
+
+ // Build the render request.
+ RenderTemplateVersionRequest request =
+ RenderTemplateVersionRequest.newBuilder()
+ .setName(templateVersionName.toString())
+ .setParameterVersion(parameterVersionName.toString())
+ .build();
+
+ // Render the template version.
+ RenderTemplateVersionResponse response = client.renderTemplateVersion(request);
+ System.out.printf("Template payload: %s\n", response.getPayload().getData().toStringUtf8());
+ System.out.printf("Rendered payload: %s\n", response.getRenderedPayload().toStringUtf8());
+
+ return response;
+ }
+ }
+}
+// [END parametermanager_render_param_template_version]
diff --git a/parametermanager/src/main/java/parametermanager/TemplateQuickstart.java b/parametermanager/src/main/java/parametermanager/TemplateQuickstart.java
new file mode 100644
index 00000000000..1e5aca97e19
--- /dev/null
+++ b/parametermanager/src/main/java/parametermanager/TemplateQuickstart.java
@@ -0,0 +1,116 @@
+/*
+ * Copyright 2026 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 parametermanager;
+
+// [START parametermanager_template_quickstart]
+
+import com.google.cloud.parametermanager.v1.LocationName;
+import com.google.cloud.parametermanager.v1.Parameter;
+import com.google.cloud.parametermanager.v1.ParameterFormat;
+import com.google.cloud.parametermanager.v1.ParameterManagerClient;
+import com.google.cloud.parametermanager.v1.ParameterVersion;
+import com.google.cloud.parametermanager.v1.ParameterVersionPayload;
+import com.google.cloud.parametermanager.v1.RenderTemplateVersionRequest;
+import com.google.cloud.parametermanager.v1.RenderTemplateVersionResponse;
+import com.google.cloud.parametermanager.v1.Template;
+import com.google.cloud.parametermanager.v1.TemplateFormat;
+import com.google.cloud.parametermanager.v1.TemplateVersion;
+import com.google.cloud.parametermanager.v1.TemplateVersionPayload;
+import com.google.protobuf.ByteString;
+
+/**
+ * This class demonstrates how to use the template capabilities of the Parameter Manager API using
+ * the Parameter Manager SDK for GCP.
+ */
+public class TemplateQuickstart {
+
+ public static void main(String[] args) throws Exception {
+ // TODO(developer): Replace these variables before running the sample.
+ String projectId = "your-project-id";
+ String templateId = "your-template-id";
+ String parameterId = "your-parameter-id";
+ String versionId = "your-version-id";
+
+ // Call the method to run the quickstart.
+ templateQuickstart(projectId, templateId, parameterId, versionId);
+ }
+
+ // This is an example snippet for how to use templates in the Parameter Manager API.
+ public static void templateQuickstart(
+ String projectId, String templateId, String parameterId, String versionId) throws Exception {
+
+ // Initialize the client that will be used to send requests. This client only needs to be
+ // created once, and can be reused for multiple requests.
+ try (ParameterManagerClient client = ParameterManagerClient.create()) {
+ String locationId = "global";
+
+ // Build the parent name from the project.
+ LocationName location = LocationName.of(projectId, locationId);
+
+ // Step 1: Create a template in JSON format.
+ Template template =
+ client.createTemplate(
+ location.toString(),
+ Template.newBuilder().setFormat(TemplateFormat.TEMPLATE_FORMAT_JSON).build(),
+ templateId);
+ System.out.printf("Created template: %s\n", template.getName());
+
+ // Step 2: Create a template version with placeholders.
+ String templatePayload = "{\"username\": \"{{.username}}\", \"host\": \"{{.host}}\"}";
+ TemplateVersion templateVersion =
+ client.createTemplateVersion(
+ template.getName(),
+ TemplateVersion.newBuilder()
+ .setPayload(
+ TemplateVersionPayload.newBuilder()
+ .setData(ByteString.copyFromUtf8(templatePayload)))
+ .build(),
+ versionId);
+ System.out.printf("Created template version: %s\n", templateVersion.getName());
+
+ // Step 3: Create a JSON parameter.
+ Parameter parameter =
+ client.createParameter(
+ location.toString(),
+ Parameter.newBuilder().setFormat(ParameterFormat.JSON).build(),
+ parameterId);
+ System.out.printf("Created parameter: %s\n", parameter.getName());
+
+ // Step 4: Create a parameter version with the values for the placeholders.
+ String values = "{\"username\": \"test-user\", \"host\": \"localhost\"}";
+ ParameterVersion parameterVersion =
+ client.createParameterVersion(
+ parameter.getName(),
+ ParameterVersion.newBuilder()
+ .setPayload(
+ ParameterVersionPayload.newBuilder().setData(ByteString.copyFromUtf8(values)))
+ .build(),
+ versionId);
+ System.out.printf("Created parameter version: %s\n", parameterVersion.getName());
+
+ // Step 5: Render the template version with the parameter version's values.
+ RenderTemplateVersionResponse response =
+ client.renderTemplateVersion(
+ RenderTemplateVersionRequest.newBuilder()
+ .setName(templateVersion.getName())
+ .setParameterVersion(parameterVersion.getName())
+ .build());
+ System.out.printf("Rendered payload: %s\n", response.getRenderedPayload().toStringUtf8());
+ }
+ }
+}
+// [END parametermanager_template_quickstart]
diff --git a/parametermanager/src/main/java/parametermanager/UpdateParamTemplateLabels.java b/parametermanager/src/main/java/parametermanager/UpdateParamTemplateLabels.java
new file mode 100644
index 00000000000..fb36835c030
--- /dev/null
+++ b/parametermanager/src/main/java/parametermanager/UpdateParamTemplateLabels.java
@@ -0,0 +1,77 @@
+/*
+ * Copyright 2026 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 parametermanager;
+
+// [START parametermanager_update_param_template_labels]
+
+import com.google.cloud.parametermanager.v1.ParameterManagerClient;
+import com.google.cloud.parametermanager.v1.Template;
+import com.google.cloud.parametermanager.v1.TemplateName;
+import com.google.protobuf.FieldMask;
+import com.google.protobuf.util.FieldMaskUtil;
+import java.io.IOException;
+
+/**
+ * This class demonstrates how to update the labels of a template using the Parameter Manager SDK
+ * for GCP.
+ */
+public class UpdateParamTemplateLabels {
+
+ public static void main(String[] args) throws IOException {
+ // TODO(developer): Replace these variables before running the sample.
+ String projectId = "your-project-id";
+ String templateId = "your-template-id";
+ String key = "your-label-key";
+ String value = "your-label-value";
+
+ // Call the method to update the labels of a template.
+ updateParamTemplateLabels(projectId, templateId, key, value);
+ }
+
+ // This is an example snippet for updating the labels of a template.
+ public static Template updateParamTemplateLabels(
+ String projectId, String templateId, String key, String value) throws IOException {
+
+ // Initialize the client that will be used to send requests. This client only needs to be
+ // created once, and can be reused for multiple requests.
+ try (ParameterManagerClient client = ParameterManagerClient.create()) {
+ String locationId = "global";
+
+ // Build the template name.
+ TemplateName templateName = TemplateName.of(projectId, locationId, templateId);
+
+ // Get the template and set the label.
+ Template template = client.getTemplate(templateName.toString());
+ Template templateWithLabel = template.toBuilder().putLabels(key, value).build();
+
+ // Build the field mask for the labels field.
+ FieldMask fieldMask = FieldMaskUtil.fromString("labels");
+
+ // Update the template.
+ client.updateTemplate(templateWithLabel, fieldMask);
+
+ // Get the updated template.
+ Template updatedTemplate = client.getTemplate(templateName.toString());
+ System.out.printf(
+ "Updated template %s with labels %s\n",
+ updatedTemplate.getName(), updatedTemplate.getLabelsMap());
+
+ return updatedTemplate;
+ }
+ }
+}
+// [END parametermanager_update_param_template_labels]
diff --git a/parametermanager/src/main/java/parametermanager/regionalsamples/BindTagsToRegionalParam.java b/parametermanager/src/main/java/parametermanager/regionalsamples/BindTagsToRegionalParam.java
new file mode 100644
index 00000000000..dd713afe389
--- /dev/null
+++ b/parametermanager/src/main/java/parametermanager/regionalsamples/BindTagsToRegionalParam.java
@@ -0,0 +1,89 @@
+/*
+ * Copyright 2026 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 parametermanager.regionalsamples;
+
+// [START parametermanager_bind_tags_to_regional_param]
+
+import com.google.cloud.parametermanager.v1.LocationName;
+import com.google.cloud.parametermanager.v1.Parameter;
+import com.google.cloud.parametermanager.v1.ParameterManagerClient;
+import com.google.cloud.parametermanager.v1.ParameterManagerSettings;
+import com.google.cloud.resourcemanager.v3.TagBinding;
+import com.google.cloud.resourcemanager.v3.TagBindingsClient;
+import com.google.cloud.resourcemanager.v3.TagBindingsSettings;
+import java.io.IOException;
+import java.util.concurrent.ExecutionException;
+
+/**
+ * This class demonstrates how to create a regional parameter and bind a tag to it using the
+ * Parameter Manager SDK for GCP.
+ */
+public class BindTagsToRegionalParam {
+
+ public static void main(String[] args)
+ throws IOException, ExecutionException, InterruptedException {
+ // TODO(developer): Replace these variables before running the sample.
+ String projectId = "your-project-id";
+ String locationId = "your-location-id";
+ String parameterId = "your-parameter-id";
+ String tagValue = "tagValues/1234567890";
+
+ // Call the method to create a parameter and bind a tag to it.
+ bindTagsToRegionalParam(projectId, locationId, parameterId, tagValue);
+ }
+
+ // This is an example snippet for creating a regional parameter and binding a tag to it.
+ public static TagBinding bindTagsToRegionalParam(
+ String projectId, String locationId, String parameterId, String tagValue)
+ throws IOException, ExecutionException, InterruptedException {
+ // Endpoint to call the regional parameter manager server.
+ String apiEndpoint = String.format("parametermanager.%s.rep.googleapis.com:443", locationId);
+ ParameterManagerSettings parameterManagerSettings =
+ ParameterManagerSettings.newBuilder().setEndpoint(apiEndpoint).build();
+
+ // Endpoint to call the regional resource manager server.
+ String tagEndpoint = String.format("%s-cloudresourcemanager.googleapis.com:443", locationId);
+ TagBindingsSettings tagBindingsSettings =
+ TagBindingsSettings.newBuilder().setEndpoint(tagEndpoint).build();
+ // Initialize the client that will be used to send requests. This client only needs to be
+ // created once, and can be reused for multiple requests.
+ try (ParameterManagerClient client = ParameterManagerClient.create(parameterManagerSettings);
+ TagBindingsClient tagBindingsClient = TagBindingsClient.create(tagBindingsSettings)) {
+ // Build the parent name from the project.
+ LocationName location = LocationName.of(projectId, locationId);
+
+ // Create the parameter.
+ Parameter parameter =
+ client.createParameter(location.toString(), Parameter.newBuilder().build(), parameterId);
+ System.out.printf("Created regional parameter: %s\n", parameter.getName());
+
+ // Build the tag binding for the new parameter.
+ TagBinding tagBinding =
+ TagBinding.newBuilder()
+ .setParent("//parametermanager.googleapis.com/" + parameter.getName())
+ .setTagValue(tagValue)
+ .build();
+
+ // Create the tag binding and wait for the operation to complete.
+ TagBinding createdTagBinding = tagBindingsClient.createTagBindingAsync(tagBinding).get();
+ System.out.printf("Created tag binding: %s\n", createdTagBinding.getName());
+
+ return createdTagBinding;
+ }
+ }
+}
+// [END parametermanager_bind_tags_to_regional_param]
diff --git a/parametermanager/src/main/java/parametermanager/regionalsamples/CreateRegionalParamTemplate.java b/parametermanager/src/main/java/parametermanager/regionalsamples/CreateRegionalParamTemplate.java
new file mode 100644
index 00000000000..a0ffdc15200
--- /dev/null
+++ b/parametermanager/src/main/java/parametermanager/regionalsamples/CreateRegionalParamTemplate.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2026 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 parametermanager.regionalsamples;
+
+// [START parametermanager_create_regional_param_template]
+
+import com.google.cloud.parametermanager.v1.LocationName;
+import com.google.cloud.parametermanager.v1.ParameterManagerClient;
+import com.google.cloud.parametermanager.v1.ParameterManagerSettings;
+import com.google.cloud.parametermanager.v1.Template;
+import com.google.cloud.parametermanager.v1.TemplateFormat;
+import java.io.IOException;
+
+/**
+ * This class demonstrates how to create a regional template using the Parameter Manager SDK for
+ * GCP.
+ */
+public class CreateRegionalParamTemplate {
+
+ public static void main(String[] args) throws IOException {
+ // TODO(developer): Replace these variables before running the sample.
+ String projectId = "your-project-id";
+ String locationId = "your-location-id";
+ String templateId = "your-template-id";
+ TemplateFormat format = TemplateFormat.TEMPLATE_FORMAT_JSON;
+
+ // Call the method to create a template.
+ createRegionalParamTemplate(projectId, locationId, templateId, format);
+ }
+
+ // This is an example snippet for creating a regional template.
+ public static Template createRegionalParamTemplate(
+ String projectId, String locationId, String templateId, TemplateFormat format)
+ throws IOException {
+ // Endpoint to call the regional parameter manager server.
+ String apiEndpoint = String.format("parametermanager.%s.rep.googleapis.com:443", locationId);
+ ParameterManagerSettings parameterManagerSettings =
+ ParameterManagerSettings.newBuilder().setEndpoint(apiEndpoint).build();
+ // Initialize the client that will be used to send requests. This client only needs to be
+ // created once, and can be reused for multiple requests.
+ try (ParameterManagerClient client = ParameterManagerClient.create(parameterManagerSettings)) {
+ // Build the parent name from the project.
+ LocationName location = LocationName.of(projectId, locationId);
+
+ // Build the template to create.
+ Template template = Template.newBuilder().setFormat(format).build();
+
+ // Create the template.
+ Template createdTemplate = client.createTemplate(location.toString(), template, templateId);
+ System.out.printf(
+ "Created regional template %s with format %s\n",
+ createdTemplate.getName(), createdTemplate.getFormat());
+
+ return createdTemplate;
+ }
+ }
+}
+// [END parametermanager_create_regional_param_template]
diff --git a/parametermanager/src/main/java/parametermanager/regionalsamples/CreateRegionalParamTemplateVersion.java b/parametermanager/src/main/java/parametermanager/regionalsamples/CreateRegionalParamTemplateVersion.java
new file mode 100644
index 00000000000..a4162f8e78f
--- /dev/null
+++ b/parametermanager/src/main/java/parametermanager/regionalsamples/CreateRegionalParamTemplateVersion.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright 2026 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 parametermanager.regionalsamples;
+
+// [START parametermanager_create_regional_param_template_version]
+
+import com.google.cloud.parametermanager.v1.ParameterManagerClient;
+import com.google.cloud.parametermanager.v1.ParameterManagerSettings;
+import com.google.cloud.parametermanager.v1.TemplateName;
+import com.google.cloud.parametermanager.v1.TemplateVersion;
+import com.google.cloud.parametermanager.v1.TemplateVersionPayload;
+import com.google.protobuf.ByteString;
+import java.io.IOException;
+
+/**
+ * This class demonstrates how to create a regional template version using the Parameter Manager SDK
+ * for GCP.
+ */
+public class CreateRegionalParamTemplateVersion {
+
+ public static void main(String[] args) throws IOException {
+ // TODO(developer): Replace these variables before running the sample.
+ String projectId = "your-project-id";
+ String locationId = "your-location-id";
+ String templateId = "your-template-id";
+ String versionId = "your-version-id";
+
+ // Call the method to create a template version.
+ createRegionalParamTemplateVersion(projectId, locationId, templateId, versionId);
+ }
+
+ // This is an example snippet for creating a regional template version with placeholders in its
+ // payload.
+ public static TemplateVersion createRegionalParamTemplateVersion(
+ String projectId, String locationId, String templateId, String versionId) throws IOException {
+ // Endpoint to call the regional parameter manager server.
+ String apiEndpoint = String.format("parametermanager.%s.rep.googleapis.com:443", locationId);
+ ParameterManagerSettings parameterManagerSettings =
+ ParameterManagerSettings.newBuilder().setEndpoint(apiEndpoint).build();
+ // Initialize the client that will be used to send requests. This client only needs to be
+ // created once, and can be reused for multiple requests.
+ try (ParameterManagerClient client = ParameterManagerClient.create(parameterManagerSettings)) {
+ // Build the template name.
+ TemplateName templateName = TemplateName.of(projectId, locationId, templateId);
+
+ // Build the template version payload with placeholders.
+ String payload = "{\"username\": \"{{.username}}\", \"host\": \"{{.host}}\"}";
+ TemplateVersionPayload templateVersionPayload =
+ TemplateVersionPayload.newBuilder().setData(ByteString.copyFromUtf8(payload)).build();
+
+ // Build the template version to create.
+ TemplateVersion templateVersion =
+ TemplateVersion.newBuilder().setPayload(templateVersionPayload).build();
+
+ // Create the template version.
+ TemplateVersion createdTemplateVersion =
+ client.createTemplateVersion(templateName.toString(), templateVersion, versionId);
+ System.out.printf(
+ "Created regional template version: %s\n", createdTemplateVersion.getName());
+
+ return createdTemplateVersion;
+ }
+ }
+}
+// [END parametermanager_create_regional_param_template_version]
diff --git a/parametermanager/src/main/java/parametermanager/regionalsamples/CreateRegionalParamVersionWithChecksum.java b/parametermanager/src/main/java/parametermanager/regionalsamples/CreateRegionalParamVersionWithChecksum.java
new file mode 100644
index 00000000000..673bf8dfbb1
--- /dev/null
+++ b/parametermanager/src/main/java/parametermanager/regionalsamples/CreateRegionalParamVersionWithChecksum.java
@@ -0,0 +1,87 @@
+/*
+ * Copyright 2026 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 parametermanager.regionalsamples;
+
+// [START parametermanager_create_regional_param_version_with_checksum]
+
+import com.google.cloud.parametermanager.v1.ParameterManagerClient;
+import com.google.cloud.parametermanager.v1.ParameterManagerSettings;
+import com.google.cloud.parametermanager.v1.ParameterName;
+import com.google.cloud.parametermanager.v1.ParameterVersion;
+import com.google.cloud.parametermanager.v1.ParameterVersionPayload;
+import com.google.protobuf.ByteString;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.util.zip.CRC32C;
+
+/**
+ * This class demonstrates how to create a regional parameter version with a checksum using the
+ * Parameter Manager SDK for GCP.
+ */
+public class CreateRegionalParamVersionWithChecksum {
+
+ public static void main(String[] args) throws IOException {
+ // TODO(developer): Replace these variables before running the sample.
+ String projectId = "your-project-id";
+ String locationId = "your-location-id";
+ String parameterId = "your-parameter-id";
+ String versionId = "your-version-id";
+
+ // Call the method to create a parameter version with a checksum.
+ createRegionalParamVersionWithChecksum(projectId, locationId, parameterId, versionId);
+ }
+
+ // This is an example snippet for creating a regional parameter version with a CRC32C checksum of
+ // the payload.
+ public static ParameterVersion createRegionalParamVersionWithChecksum(
+ String projectId, String locationId, String parameterId, String versionId)
+ throws IOException {
+ // Endpoint to call the regional parameter manager server.
+ String apiEndpoint = String.format("parametermanager.%s.rep.googleapis.com:443", locationId);
+ ParameterManagerSettings parameterManagerSettings =
+ ParameterManagerSettings.newBuilder().setEndpoint(apiEndpoint).build();
+ // Initialize the client that will be used to send requests. This client only needs to be
+ // created once, and can be reused for multiple requests.
+ try (ParameterManagerClient client = ParameterManagerClient.create(parameterManagerSettings)) {
+ // Build the parameter name.
+ ParameterName parameterName = ParameterName.of(projectId, locationId, parameterId);
+
+ // Define the payload and compute its CRC32C checksum.
+ byte[] data = "hello world!".getBytes(StandardCharsets.UTF_8);
+ CRC32C crc32c = new CRC32C();
+ crc32c.update(data);
+
+ // Build the parameter version with the payload and checksum.
+ ParameterVersionPayload payload =
+ ParameterVersionPayload.newBuilder()
+ .setData(ByteString.copyFrom(data))
+ .setDataCrc32C(crc32c.getValue())
+ .build();
+ ParameterVersion parameterVersion = ParameterVersion.newBuilder().setPayload(payload).build();
+
+ // Create the parameter version.
+ ParameterVersion createdParameterVersion =
+ client.createParameterVersion(parameterName.toString(), parameterVersion, versionId);
+ System.out.printf(
+ "Created regional parameter version: %s\n", createdParameterVersion.getName());
+ System.out.printf("Checksum source: %s\n", createdParameterVersion.getChecksumSource());
+
+ return createdParameterVersion;
+ }
+ }
+}
+// [END parametermanager_create_regional_param_version_with_checksum]
diff --git a/parametermanager/src/main/java/parametermanager/regionalsamples/CreateRegionalParamWithTags.java b/parametermanager/src/main/java/parametermanager/regionalsamples/CreateRegionalParamWithTags.java
new file mode 100644
index 00000000000..aadae070a6e
--- /dev/null
+++ b/parametermanager/src/main/java/parametermanager/regionalsamples/CreateRegionalParamWithTags.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2026 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 parametermanager.regionalsamples;
+
+// [START parametermanager_create_regional_param_with_tags]
+
+import com.google.cloud.parametermanager.v1.LocationName;
+import com.google.cloud.parametermanager.v1.Parameter;
+import com.google.cloud.parametermanager.v1.ParameterManagerClient;
+import com.google.cloud.parametermanager.v1.ParameterManagerSettings;
+import java.io.IOException;
+
+/**
+ * This class demonstrates how to create a regional parameter with a tag using the Parameter Manager
+ * SDK for GCP.
+ */
+public class CreateRegionalParamWithTags {
+
+ public static void main(String[] args) throws IOException {
+ // TODO(developer): Replace these variables before running the sample.
+ String projectId = "your-project-id";
+ String locationId = "your-location-id";
+ String parameterId = "your-parameter-id";
+ String tagKey = "tagKeys/1234567890";
+ String tagValue = "tagValues/1234567890";
+
+ // Call the method to create a parameter with a tag.
+ createRegionalParamWithTags(projectId, locationId, parameterId, tagKey, tagValue);
+ }
+
+ // This is an example snippet for creating a regional parameter with a tag.
+ public static Parameter createRegionalParamWithTags(
+ String projectId, String locationId, String parameterId, String tagKey, String tagValue)
+ throws IOException {
+ // Endpoint to call the regional parameter manager server.
+ String apiEndpoint = String.format("parametermanager.%s.rep.googleapis.com:443", locationId);
+ ParameterManagerSettings parameterManagerSettings =
+ ParameterManagerSettings.newBuilder().setEndpoint(apiEndpoint).build();
+ // Initialize the client that will be used to send requests. This client only needs to be
+ // created once, and can be reused for multiple requests.
+ try (ParameterManagerClient client = ParameterManagerClient.create(parameterManagerSettings)) {
+ // Build the parent name from the project.
+ LocationName location = LocationName.of(projectId, locationId);
+
+ // Build the parameter to create with the tag.
+ Parameter parameter = Parameter.newBuilder().putTags(tagKey, tagValue).build();
+
+ // Create the parameter.
+ Parameter createdParameter =
+ client.createParameter(location.toString(), parameter, parameterId);
+ System.out.printf(
+ "Created regional parameter %s with tag %s: %s\n",
+ createdParameter.getName(), tagKey, tagValue);
+
+ return createdParameter;
+ }
+ }
+}
+// [END parametermanager_create_regional_param_with_tags]
diff --git a/parametermanager/src/main/java/parametermanager/regionalsamples/DeleteRegionalParamTemplate.java b/parametermanager/src/main/java/parametermanager/regionalsamples/DeleteRegionalParamTemplate.java
new file mode 100644
index 00000000000..cad9fe60a3d
--- /dev/null
+++ b/parametermanager/src/main/java/parametermanager/regionalsamples/DeleteRegionalParamTemplate.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2026 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 parametermanager.regionalsamples;
+
+// [START parametermanager_delete_regional_param_template]
+
+import com.google.cloud.parametermanager.v1.ParameterManagerClient;
+import com.google.cloud.parametermanager.v1.ParameterManagerSettings;
+import com.google.cloud.parametermanager.v1.TemplateName;
+import java.io.IOException;
+
+/**
+ * This class demonstrates how to delete a regional template using the Parameter Manager SDK for
+ * GCP.
+ */
+public class DeleteRegionalParamTemplate {
+
+ public static void main(String[] args) throws IOException {
+ // TODO(developer): Replace these variables before running the sample.
+ String projectId = "your-project-id";
+ String locationId = "your-location-id";
+ String templateId = "your-template-id";
+
+ // Call the method to delete a template.
+ deleteRegionalParamTemplate(projectId, locationId, templateId);
+ }
+
+ // This is an example snippet for deleting a regional template.
+ public static void deleteRegionalParamTemplate(
+ String projectId, String locationId, String templateId) throws IOException {
+ // Endpoint to call the regional parameter manager server.
+ String apiEndpoint = String.format("parametermanager.%s.rep.googleapis.com:443", locationId);
+ ParameterManagerSettings parameterManagerSettings =
+ ParameterManagerSettings.newBuilder().setEndpoint(apiEndpoint).build();
+ // Initialize the client that will be used to send requests. This client only needs to be
+ // created once, and can be reused for multiple requests.
+ try (ParameterManagerClient client = ParameterManagerClient.create(parameterManagerSettings)) {
+ // Build the template name.
+ TemplateName templateName = TemplateName.of(projectId, locationId, templateId);
+
+ // Delete the template.
+ client.deleteTemplate(templateName);
+ System.out.printf("Deleted regional template: %s\n", templateName);
+ }
+ }
+}
+// [END parametermanager_delete_regional_param_template]
diff --git a/parametermanager/src/main/java/parametermanager/regionalsamples/DeleteRegionalParamTemplateVersion.java b/parametermanager/src/main/java/parametermanager/regionalsamples/DeleteRegionalParamTemplateVersion.java
new file mode 100644
index 00000000000..d6280f7b856
--- /dev/null
+++ b/parametermanager/src/main/java/parametermanager/regionalsamples/DeleteRegionalParamTemplateVersion.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2026 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 parametermanager.regionalsamples;
+
+// [START parametermanager_delete_regional_param_template_version]
+
+import com.google.cloud.parametermanager.v1.ParameterManagerClient;
+import com.google.cloud.parametermanager.v1.ParameterManagerSettings;
+import com.google.cloud.parametermanager.v1.TemplateVersionName;
+import java.io.IOException;
+
+/**
+ * This class demonstrates how to delete a regional template version using the Parameter Manager SDK
+ * for GCP.
+ */
+public class DeleteRegionalParamTemplateVersion {
+
+ public static void main(String[] args) throws IOException {
+ // TODO(developer): Replace these variables before running the sample.
+ String projectId = "your-project-id";
+ String locationId = "your-location-id";
+ String templateId = "your-template-id";
+ String versionId = "your-version-id";
+
+ // Call the method to delete a template version.
+ deleteRegionalParamTemplateVersion(projectId, locationId, templateId, versionId);
+ }
+
+ // This is an example snippet for deleting a regional template version.
+ public static void deleteRegionalParamTemplateVersion(
+ String projectId, String locationId, String templateId, String versionId) throws IOException {
+ // Endpoint to call the regional parameter manager server.
+ String apiEndpoint = String.format("parametermanager.%s.rep.googleapis.com:443", locationId);
+ ParameterManagerSettings parameterManagerSettings =
+ ParameterManagerSettings.newBuilder().setEndpoint(apiEndpoint).build();
+ // Initialize the client that will be used to send requests. This client only needs to be
+ // created once, and can be reused for multiple requests.
+ try (ParameterManagerClient client = ParameterManagerClient.create(parameterManagerSettings)) {
+ // Build the template version name.
+ TemplateVersionName templateVersionName =
+ TemplateVersionName.of(projectId, locationId, templateId, versionId);
+
+ // Delete the template version.
+ client.deleteTemplateVersion(templateVersionName);
+ System.out.printf("Deleted regional template version: %s\n", templateVersionName);
+ }
+ }
+}
+// [END parametermanager_delete_regional_param_template_version]
diff --git a/parametermanager/src/main/java/parametermanager/regionalsamples/DisableRegionalParamTemplateVersion.java b/parametermanager/src/main/java/parametermanager/regionalsamples/DisableRegionalParamTemplateVersion.java
new file mode 100644
index 00000000000..0c93612b1ab
--- /dev/null
+++ b/parametermanager/src/main/java/parametermanager/regionalsamples/DisableRegionalParamTemplateVersion.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright 2026 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 parametermanager.regionalsamples;
+
+// [START parametermanager_disable_regional_param_template_version]
+
+import com.google.cloud.parametermanager.v1.ParameterManagerClient;
+import com.google.cloud.parametermanager.v1.ParameterManagerSettings;
+import com.google.cloud.parametermanager.v1.TemplateVersion;
+import com.google.cloud.parametermanager.v1.TemplateVersionName;
+import com.google.protobuf.FieldMask;
+import com.google.protobuf.util.FieldMaskUtil;
+import java.io.IOException;
+
+/**
+ * This class demonstrates how to disable a regional template version using the Parameter Manager
+ * SDK for GCP.
+ */
+public class DisableRegionalParamTemplateVersion {
+
+ public static void main(String[] args) throws IOException {
+ // TODO(developer): Replace these variables before running the sample.
+ String projectId = "your-project-id";
+ String locationId = "your-location-id";
+ String templateId = "your-template-id";
+ String versionId = "your-version-id";
+
+ // Call the method to disable a template version.
+ disableRegionalParamTemplateVersion(projectId, locationId, templateId, versionId);
+ }
+
+ // This is an example snippet for disabling a regional template version.
+ public static TemplateVersion disableRegionalParamTemplateVersion(
+ String projectId, String locationId, String templateId, String versionId) throws IOException {
+ // Endpoint to call the regional parameter manager server.
+ String apiEndpoint = String.format("parametermanager.%s.rep.googleapis.com:443", locationId);
+ ParameterManagerSettings parameterManagerSettings =
+ ParameterManagerSettings.newBuilder().setEndpoint(apiEndpoint).build();
+ // Initialize the client that will be used to send requests. This client only needs to be
+ // created once, and can be reused for multiple requests.
+ try (ParameterManagerClient client = ParameterManagerClient.create(parameterManagerSettings)) {
+ // Build the template version name.
+ TemplateVersionName templateVersionName =
+ TemplateVersionName.of(projectId, locationId, templateId, versionId);
+
+ // Set the template version to disable.
+ TemplateVersion templateVersion =
+ TemplateVersion.newBuilder()
+ .setName(templateVersionName.toString())
+ .setDisabled(true)
+ .build();
+
+ // Build the field mask for the disabled field.
+ FieldMask fieldMask = FieldMaskUtil.fromString("disabled");
+
+ // Update the template version.
+ TemplateVersion updatedTemplateVersion =
+ client.updateTemplateVersion(templateVersion, fieldMask);
+ System.out.printf(
+ "Disabled regional template version: %s\n", updatedTemplateVersion.getName());
+
+ return updatedTemplateVersion;
+ }
+ }
+}
+// [END parametermanager_disable_regional_param_template_version]
diff --git a/parametermanager/src/main/java/parametermanager/regionalsamples/EnableRegionalParamTemplateVersion.java b/parametermanager/src/main/java/parametermanager/regionalsamples/EnableRegionalParamTemplateVersion.java
new file mode 100644
index 00000000000..d23e3055c62
--- /dev/null
+++ b/parametermanager/src/main/java/parametermanager/regionalsamples/EnableRegionalParamTemplateVersion.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright 2026 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 parametermanager.regionalsamples;
+
+// [START parametermanager_enable_regional_param_template_version]
+
+import com.google.cloud.parametermanager.v1.ParameterManagerClient;
+import com.google.cloud.parametermanager.v1.ParameterManagerSettings;
+import com.google.cloud.parametermanager.v1.TemplateVersion;
+import com.google.cloud.parametermanager.v1.TemplateVersionName;
+import com.google.protobuf.FieldMask;
+import com.google.protobuf.util.FieldMaskUtil;
+import java.io.IOException;
+
+/**
+ * This class demonstrates how to enable a regional template version using the Parameter Manager SDK
+ * for GCP.
+ */
+public class EnableRegionalParamTemplateVersion {
+
+ public static void main(String[] args) throws IOException {
+ // TODO(developer): Replace these variables before running the sample.
+ String projectId = "your-project-id";
+ String locationId = "your-location-id";
+ String templateId = "your-template-id";
+ String versionId = "your-version-id";
+
+ // Call the method to enable a template version.
+ enableRegionalParamTemplateVersion(projectId, locationId, templateId, versionId);
+ }
+
+ // This is an example snippet for enabling a regional template version.
+ public static TemplateVersion enableRegionalParamTemplateVersion(
+ String projectId, String locationId, String templateId, String versionId) throws IOException {
+ // Endpoint to call the regional parameter manager server.
+ String apiEndpoint = String.format("parametermanager.%s.rep.googleapis.com:443", locationId);
+ ParameterManagerSettings parameterManagerSettings =
+ ParameterManagerSettings.newBuilder().setEndpoint(apiEndpoint).build();
+ // Initialize the client that will be used to send requests. This client only needs to be
+ // created once, and can be reused for multiple requests.
+ try (ParameterManagerClient client = ParameterManagerClient.create(parameterManagerSettings)) {
+ // Build the template version name.
+ TemplateVersionName templateVersionName =
+ TemplateVersionName.of(projectId, locationId, templateId, versionId);
+
+ // Set the template version to enable.
+ TemplateVersion templateVersion =
+ TemplateVersion.newBuilder()
+ .setName(templateVersionName.toString())
+ .setDisabled(false)
+ .build();
+
+ // Build the field mask for the disabled field.
+ FieldMask fieldMask = FieldMaskUtil.fromString("disabled");
+
+ // Update the template version.
+ TemplateVersion updatedTemplateVersion =
+ client.updateTemplateVersion(templateVersion, fieldMask);
+ System.out.printf(
+ "Enabled regional template version: %s\n", updatedTemplateVersion.getName());
+
+ return updatedTemplateVersion;
+ }
+ }
+}
+// [END parametermanager_enable_regional_param_template_version]
diff --git a/parametermanager/src/main/java/parametermanager/regionalsamples/GetRegionalParamTags.java b/parametermanager/src/main/java/parametermanager/regionalsamples/GetRegionalParamTags.java
new file mode 100644
index 00000000000..260dbd10221
--- /dev/null
+++ b/parametermanager/src/main/java/parametermanager/regionalsamples/GetRegionalParamTags.java
@@ -0,0 +1,82 @@
+/*
+ * Copyright 2026 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 parametermanager.regionalsamples;
+
+// [START parametermanager_get_regional_param_tags]
+
+import com.google.cloud.parametermanager.v1.Parameter;
+import com.google.cloud.parametermanager.v1.ParameterManagerClient;
+import com.google.cloud.parametermanager.v1.ParameterManagerSettings;
+import com.google.cloud.parametermanager.v1.ParameterName;
+import com.google.cloud.resourcemanager.v3.TagBindingsClient;
+import com.google.cloud.resourcemanager.v3.TagBindingsClient.ListTagBindingsPagedResponse;
+import com.google.cloud.resourcemanager.v3.TagBindingsSettings;
+import java.io.IOException;
+
+/**
+ * This class demonstrates how to get the tags of a regional parameter using the Parameter Manager
+ * SDK for GCP.
+ */
+public class GetRegionalParamTags {
+
+ public static void main(String[] args) throws IOException {
+ // TODO(developer): Replace these variables before running the sample.
+ String projectId = "your-project-id";
+ String locationId = "your-location-id";
+ String parameterId = "your-parameter-id";
+
+ // Call the method to get the tags of a parameter.
+ getRegionalParamTags(projectId, locationId, parameterId);
+ }
+
+ // This is an example snippet for getting the tag bindings of a regional parameter.
+ public static ListTagBindingsPagedResponse getRegionalParamTags(
+ String projectId, String locationId, String parameterId) throws IOException {
+ // Endpoint to call the regional parameter manager server.
+ String apiEndpoint = String.format("parametermanager.%s.rep.googleapis.com:443", locationId);
+ ParameterManagerSettings parameterManagerSettings =
+ ParameterManagerSettings.newBuilder().setEndpoint(apiEndpoint).build();
+
+ // Endpoint to call the regional resource manager server.
+ String tagEndpoint = String.format("%s-cloudresourcemanager.googleapis.com:443", locationId);
+ TagBindingsSettings tagBindingsSettings =
+ TagBindingsSettings.newBuilder().setEndpoint(tagEndpoint).build();
+ // Initialize the client that will be used to send requests. This client only needs to be
+ // created once, and can be reused for multiple requests.
+ try (ParameterManagerClient client = ParameterManagerClient.create(parameterManagerSettings);
+ TagBindingsClient tagBindingsClient = TagBindingsClient.create(tagBindingsSettings)) {
+ // Build the parameter name.
+ ParameterName parameterName = ParameterName.of(projectId, locationId, parameterId);
+
+ // Get the parameter.
+ Parameter parameter = client.getParameter(parameterName.toString());
+
+ // List the tag bindings of the parameter.
+ ListTagBindingsPagedResponse response =
+ tagBindingsClient.listTagBindings(
+ "//parametermanager.googleapis.com/" + parameter.getName());
+ response
+ .iterateAll()
+ .forEach(
+ binding ->
+ System.out.printf("Found regional parameter tag: %s\n", binding.getTagValue()));
+
+ return response;
+ }
+ }
+}
+// [END parametermanager_get_regional_param_tags]
diff --git a/parametermanager/src/main/java/parametermanager/regionalsamples/GetRegionalParamTemplate.java b/parametermanager/src/main/java/parametermanager/regionalsamples/GetRegionalParamTemplate.java
new file mode 100644
index 00000000000..2cf064a74de
--- /dev/null
+++ b/parametermanager/src/main/java/parametermanager/regionalsamples/GetRegionalParamTemplate.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2026 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 parametermanager.regionalsamples;
+
+// [START parametermanager_get_regional_param_template]
+
+import com.google.cloud.parametermanager.v1.ParameterManagerClient;
+import com.google.cloud.parametermanager.v1.ParameterManagerSettings;
+import com.google.cloud.parametermanager.v1.Template;
+import com.google.cloud.parametermanager.v1.TemplateName;
+import java.io.IOException;
+
+/**
+ * This class demonstrates how to get a regional template using the Parameter Manager SDK for GCP.
+ */
+public class GetRegionalParamTemplate {
+
+ public static void main(String[] args) throws IOException {
+ // TODO(developer): Replace these variables before running the sample.
+ String projectId = "your-project-id";
+ String locationId = "your-location-id";
+ String templateId = "your-template-id";
+
+ // Call the method to get a template.
+ getRegionalParamTemplate(projectId, locationId, templateId);
+ }
+
+ // This is an example snippet for getting a regional template.
+ public static Template getRegionalParamTemplate(
+ String projectId, String locationId, String templateId) throws IOException {
+ // Endpoint to call the regional parameter manager server.
+ String apiEndpoint = String.format("parametermanager.%s.rep.googleapis.com:443", locationId);
+ ParameterManagerSettings parameterManagerSettings =
+ ParameterManagerSettings.newBuilder().setEndpoint(apiEndpoint).build();
+ // Initialize the client that will be used to send requests. This client only needs to be
+ // created once, and can be reused for multiple requests.
+ try (ParameterManagerClient client = ParameterManagerClient.create(parameterManagerSettings)) {
+ // Build the template name.
+ TemplateName templateName = TemplateName.of(projectId, locationId, templateId);
+
+ // Get the template.
+ Template template = client.getTemplate(templateName.toString());
+ System.out.printf(
+ "Got regional template %s with format %s\n", template.getName(), template.getFormat());
+
+ return template;
+ }
+ }
+}
+// [END parametermanager_get_regional_param_template]
diff --git a/parametermanager/src/main/java/parametermanager/regionalsamples/GetRegionalParamTemplateVersion.java b/parametermanager/src/main/java/parametermanager/regionalsamples/GetRegionalParamTemplateVersion.java
new file mode 100644
index 00000000000..7b559dca2e4
--- /dev/null
+++ b/parametermanager/src/main/java/parametermanager/regionalsamples/GetRegionalParamTemplateVersion.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2026 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 parametermanager.regionalsamples;
+
+// [START parametermanager_get_regional_param_template_version]
+
+import com.google.cloud.parametermanager.v1.ParameterManagerClient;
+import com.google.cloud.parametermanager.v1.ParameterManagerSettings;
+import com.google.cloud.parametermanager.v1.TemplateVersion;
+import com.google.cloud.parametermanager.v1.TemplateVersionName;
+import java.io.IOException;
+
+/**
+ * This class demonstrates how to get a regional template version using the Parameter Manager SDK
+ * for GCP.
+ */
+public class GetRegionalParamTemplateVersion {
+
+ public static void main(String[] args) throws IOException {
+ // TODO(developer): Replace these variables before running the sample.
+ String projectId = "your-project-id";
+ String locationId = "your-location-id";
+ String templateId = "your-template-id";
+ String versionId = "your-version-id";
+
+ // Call the method to get a template version.
+ getRegionalParamTemplateVersion(projectId, locationId, templateId, versionId);
+ }
+
+ // This is an example snippet for getting a regional template version.
+ public static TemplateVersion getRegionalParamTemplateVersion(
+ String projectId, String locationId, String templateId, String versionId) throws IOException {
+ // Endpoint to call the regional parameter manager server.
+ String apiEndpoint = String.format("parametermanager.%s.rep.googleapis.com:443", locationId);
+ ParameterManagerSettings parameterManagerSettings =
+ ParameterManagerSettings.newBuilder().setEndpoint(apiEndpoint).build();
+ // Initialize the client that will be used to send requests. This client only needs to be
+ // created once, and can be reused for multiple requests.
+ try (ParameterManagerClient client = ParameterManagerClient.create(parameterManagerSettings)) {
+ // Build the template version name.
+ TemplateVersionName templateVersionName =
+ TemplateVersionName.of(projectId, locationId, templateId, versionId);
+
+ // Get the template version.
+ TemplateVersion templateVersion = client.getTemplateVersion(templateVersionName.toString());
+ System.out.printf("Got regional template version %s\n", templateVersion.getName());
+ System.out.printf("Payload: %s\n", templateVersion.getPayload().getData().toStringUtf8());
+
+ return templateVersion;
+ }
+ }
+}
+// [END parametermanager_get_regional_param_template_version]
diff --git a/parametermanager/src/main/java/parametermanager/regionalsamples/GetRegionalParamVersionVerifyChecksum.java b/parametermanager/src/main/java/parametermanager/regionalsamples/GetRegionalParamVersionVerifyChecksum.java
new file mode 100644
index 00000000000..f57efbb08c4
--- /dev/null
+++ b/parametermanager/src/main/java/parametermanager/regionalsamples/GetRegionalParamVersionVerifyChecksum.java
@@ -0,0 +1,86 @@
+/*
+ * Copyright 2026 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 parametermanager.regionalsamples;
+
+// [START parametermanager_get_regional_param_version_verify_checksum]
+
+import com.google.cloud.parametermanager.v1.GetParameterVersionRequest;
+import com.google.cloud.parametermanager.v1.ParameterManagerClient;
+import com.google.cloud.parametermanager.v1.ParameterManagerSettings;
+import com.google.cloud.parametermanager.v1.ParameterVersion;
+import com.google.cloud.parametermanager.v1.ParameterVersionName;
+import com.google.cloud.parametermanager.v1.View;
+import java.io.IOException;
+import java.util.zip.CRC32C;
+
+/**
+ * This class demonstrates how to get a regional parameter version and verify its checksum using the
+ * Parameter Manager SDK for GCP.
+ */
+public class GetRegionalParamVersionVerifyChecksum {
+
+ public static void main(String[] args) throws IOException {
+ // TODO(developer): Replace these variables before running the sample.
+ String projectId = "your-project-id";
+ String locationId = "your-location-id";
+ String parameterId = "your-parameter-id";
+ String versionId = "your-version-id";
+
+ // Call the method to get a parameter version and verify its checksum.
+ getRegionalParamVersionVerifyChecksum(projectId, locationId, parameterId, versionId);
+ }
+
+ // This is an example snippet for getting a regional parameter version and verifying its payload
+ // checksum.
+ public static ParameterVersion getRegionalParamVersionVerifyChecksum(
+ String projectId, String locationId, String parameterId, String versionId)
+ throws IOException {
+ // Endpoint to call the regional parameter manager server.
+ String apiEndpoint = String.format("parametermanager.%s.rep.googleapis.com:443", locationId);
+ ParameterManagerSettings parameterManagerSettings =
+ ParameterManagerSettings.newBuilder().setEndpoint(apiEndpoint).build();
+ // Initialize the client that will be used to send requests. This client only needs to be
+ // created once, and can be reused for multiple requests.
+ try (ParameterManagerClient client = ParameterManagerClient.create(parameterManagerSettings)) {
+ // Build the parameter version name.
+ ParameterVersionName parameterVersionName =
+ ParameterVersionName.of(projectId, locationId, parameterId, versionId);
+
+ // Get the parameter version with the payload and checksum.
+ GetParameterVersionRequest request =
+ GetParameterVersionRequest.newBuilder()
+ .setName(parameterVersionName.toString())
+ .setView(View.FULL)
+ .build();
+ ParameterVersion parameterVersion = client.getParameterVersion(request);
+
+ // Verify the payload checksum.
+ CRC32C crc32c = new CRC32C();
+ crc32c.update(parameterVersion.getPayload().getData().toByteArray());
+ if (crc32c.getValue() != parameterVersion.getPayload().getDataCrc32C()) {
+ throw new IllegalStateException(
+ String.format("Checksum mismatch for %s: data corrupted", parameterVersion.getName()));
+ }
+ System.out.printf(
+ "Verified checksum for regional parameter version: %s\n", parameterVersion.getName());
+ System.out.printf("Checksum source: %s\n", parameterVersion.getChecksumSource());
+
+ return parameterVersion;
+ }
+ }
+}
+// [END parametermanager_get_regional_param_version_verify_checksum]
diff --git a/parametermanager/src/main/java/parametermanager/regionalsamples/ListRegionalParamTemplateVersions.java b/parametermanager/src/main/java/parametermanager/regionalsamples/ListRegionalParamTemplateVersions.java
new file mode 100644
index 00000000000..baaabb11873
--- /dev/null
+++ b/parametermanager/src/main/java/parametermanager/regionalsamples/ListRegionalParamTemplateVersions.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2026 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 parametermanager.regionalsamples;
+
+// [START parametermanager_list_regional_param_template_versions]
+
+import com.google.cloud.parametermanager.v1.ParameterManagerClient;
+import com.google.cloud.parametermanager.v1.ParameterManagerClient.ListTemplateVersionsPagedResponse;
+import com.google.cloud.parametermanager.v1.ParameterManagerSettings;
+import com.google.cloud.parametermanager.v1.TemplateName;
+import java.io.IOException;
+
+/**
+ * This class demonstrates how to list regional template versions using the Parameter Manager SDK
+ * for GCP.
+ */
+public class ListRegionalParamTemplateVersions {
+
+ public static void main(String[] args) throws IOException {
+ // TODO(developer): Replace these variables before running the sample.
+ String projectId = "your-project-id";
+ String locationId = "your-location-id";
+ String templateId = "your-template-id";
+
+ // Call the method to list template versions.
+ listRegionalParamTemplateVersions(projectId, locationId, templateId);
+ }
+
+ // This is an example snippet for listing all versions of a regional template.
+ public static ListTemplateVersionsPagedResponse listRegionalParamTemplateVersions(
+ String projectId, String locationId, String templateId) throws IOException {
+ // Endpoint to call the regional parameter manager server.
+ String apiEndpoint = String.format("parametermanager.%s.rep.googleapis.com:443", locationId);
+ ParameterManagerSettings parameterManagerSettings =
+ ParameterManagerSettings.newBuilder().setEndpoint(apiEndpoint).build();
+ // Initialize the client that will be used to send requests. This client only needs to be
+ // created once, and can be reused for multiple requests.
+ try (ParameterManagerClient client = ParameterManagerClient.create(parameterManagerSettings)) {
+ // Build the template name.
+ TemplateName templateName = TemplateName.of(projectId, locationId, templateId);
+
+ // List the template versions.
+ ListTemplateVersionsPagedResponse response =
+ client.listTemplateVersions(templateName.toString());
+ response
+ .iterateAll()
+ .forEach(
+ version ->
+ System.out.printf("Found regional template version: %s\n", version.getName()));
+
+ return response;
+ }
+ }
+}
+// [END parametermanager_list_regional_param_template_versions]
diff --git a/parametermanager/src/main/java/parametermanager/regionalsamples/ListRegionalParamTemplates.java b/parametermanager/src/main/java/parametermanager/regionalsamples/ListRegionalParamTemplates.java
new file mode 100644
index 00000000000..b82cb5d9028
--- /dev/null
+++ b/parametermanager/src/main/java/parametermanager/regionalsamples/ListRegionalParamTemplates.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2026 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 parametermanager.regionalsamples;
+
+// [START parametermanager_list_regional_param_templates]
+
+import com.google.cloud.parametermanager.v1.LocationName;
+import com.google.cloud.parametermanager.v1.ParameterManagerClient;
+import com.google.cloud.parametermanager.v1.ParameterManagerClient.ListTemplatesPagedResponse;
+import com.google.cloud.parametermanager.v1.ParameterManagerSettings;
+import java.io.IOException;
+
+/**
+ * This class demonstrates how to list regional templates using the Parameter Manager SDK for GCP.
+ */
+public class ListRegionalParamTemplates {
+
+ public static void main(String[] args) throws IOException {
+ // TODO(developer): Replace these variables before running the sample.
+ String projectId = "your-project-id";
+ String locationId = "your-location-id";
+
+ // Call the method to list templates.
+ listRegionalParamTemplates(projectId, locationId);
+ }
+
+ // This is an example snippet for listing all regional templates in the given project.
+ public static ListTemplatesPagedResponse listRegionalParamTemplates(
+ String projectId, String locationId) throws IOException {
+ // Endpoint to call the regional parameter manager server.
+ String apiEndpoint = String.format("parametermanager.%s.rep.googleapis.com:443", locationId);
+ ParameterManagerSettings parameterManagerSettings =
+ ParameterManagerSettings.newBuilder().setEndpoint(apiEndpoint).build();
+ // Initialize the client that will be used to send requests. This client only needs to be
+ // created once, and can be reused for multiple requests.
+ try (ParameterManagerClient client = ParameterManagerClient.create(parameterManagerSettings)) {
+ // Build the parent name from the project.
+ LocationName location = LocationName.of(projectId, locationId);
+
+ // List all templates.
+ ListTemplatesPagedResponse response = client.listTemplates(location.toString());
+ response
+ .iterateAll()
+ .forEach(
+ template ->
+ System.out.printf(
+ "Found regional template %s with format %s\n",
+ template.getName(), template.getFormat()));
+
+ return response;
+ }
+ }
+}
+// [END parametermanager_list_regional_param_templates]
diff --git a/parametermanager/src/main/java/parametermanager/regionalsamples/RegionalTemplateQuickstart.java b/parametermanager/src/main/java/parametermanager/regionalsamples/RegionalTemplateQuickstart.java
new file mode 100644
index 00000000000..736eee50f54
--- /dev/null
+++ b/parametermanager/src/main/java/parametermanager/regionalsamples/RegionalTemplateQuickstart.java
@@ -0,0 +1,121 @@
+/*
+ * Copyright 2026 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 parametermanager.regionalsamples;
+
+// [START parametermanager_regional_template_quickstart]
+
+import com.google.cloud.parametermanager.v1.LocationName;
+import com.google.cloud.parametermanager.v1.Parameter;
+import com.google.cloud.parametermanager.v1.ParameterFormat;
+import com.google.cloud.parametermanager.v1.ParameterManagerClient;
+import com.google.cloud.parametermanager.v1.ParameterManagerSettings;
+import com.google.cloud.parametermanager.v1.ParameterVersion;
+import com.google.cloud.parametermanager.v1.ParameterVersionPayload;
+import com.google.cloud.parametermanager.v1.RenderTemplateVersionRequest;
+import com.google.cloud.parametermanager.v1.RenderTemplateVersionResponse;
+import com.google.cloud.parametermanager.v1.Template;
+import com.google.cloud.parametermanager.v1.TemplateFormat;
+import com.google.cloud.parametermanager.v1.TemplateVersion;
+import com.google.cloud.parametermanager.v1.TemplateVersionPayload;
+import com.google.protobuf.ByteString;
+
+/**
+ * This class demonstrates how to use the regional template capabilities of the Parameter Manager
+ * API using the Parameter Manager SDK for GCP.
+ */
+public class RegionalTemplateQuickstart {
+
+ public static void main(String[] args) throws Exception {
+ // TODO(developer): Replace these variables before running the sample.
+ String projectId = "your-project-id";
+ String locationId = "your-location-id";
+ String templateId = "your-template-id";
+ String parameterId = "your-parameter-id";
+ String versionId = "your-version-id";
+
+ // Call the method to run the quickstart.
+ regionalTemplateQuickstart(projectId, locationId, templateId, parameterId, versionId);
+ }
+
+ // This is an example snippet for how to use regional templates in the Parameter Manager API.
+ public static void regionalTemplateQuickstart(
+ String projectId, String locationId, String templateId, String parameterId, String versionId)
+ throws Exception {
+ // Endpoint to call the regional parameter manager server.
+ String apiEndpoint = String.format("parametermanager.%s.rep.googleapis.com:443", locationId);
+ ParameterManagerSettings parameterManagerSettings =
+ ParameterManagerSettings.newBuilder().setEndpoint(apiEndpoint).build();
+ // Initialize the client that will be used to send requests. This client only needs to be
+ // created once, and can be reused for multiple requests.
+ try (ParameterManagerClient client = ParameterManagerClient.create(parameterManagerSettings)) {
+ // Build the parent name from the project.
+ LocationName location = LocationName.of(projectId, locationId);
+
+ // Step 1: Create a template in JSON format.
+ Template template =
+ client.createTemplate(
+ location.toString(),
+ Template.newBuilder().setFormat(TemplateFormat.TEMPLATE_FORMAT_JSON).build(),
+ templateId);
+ System.out.printf("Created regional template: %s\n", template.getName());
+
+ // Step 2: Create a template version with placeholders.
+ String templatePayload = "{\"username\": \"{{.username}}\", \"host\": \"{{.host}}\"}";
+ TemplateVersion templateVersion =
+ client.createTemplateVersion(
+ template.getName(),
+ TemplateVersion.newBuilder()
+ .setPayload(
+ TemplateVersionPayload.newBuilder()
+ .setData(ByteString.copyFromUtf8(templatePayload)))
+ .build(),
+ versionId);
+ System.out.printf("Created regional template version: %s\n", templateVersion.getName());
+
+ // Step 3: Create a JSON parameter.
+ Parameter parameter =
+ client.createParameter(
+ location.toString(),
+ Parameter.newBuilder().setFormat(ParameterFormat.JSON).build(),
+ parameterId);
+ System.out.printf("Created regional parameter: %s\n", parameter.getName());
+
+ // Step 4: Create a parameter version with the values for the placeholders.
+ String values = "{\"username\": \"test-user\", \"host\": \"localhost\"}";
+ ParameterVersion parameterVersion =
+ client.createParameterVersion(
+ parameter.getName(),
+ ParameterVersion.newBuilder()
+ .setPayload(
+ ParameterVersionPayload.newBuilder().setData(ByteString.copyFromUtf8(values)))
+ .build(),
+ versionId);
+ System.out.printf("Created regional parameter version: %s\n", parameterVersion.getName());
+
+ // Step 5: Render the template version with the parameter version's values.
+ RenderTemplateVersionResponse response =
+ client.renderTemplateVersion(
+ RenderTemplateVersionRequest.newBuilder()
+ .setName(templateVersion.getName())
+ .setParameterVersion(parameterVersion.getName())
+ .build());
+ System.out.printf(
+ "Rendered regional payload: %s\n", response.getRenderedPayload().toStringUtf8());
+ }
+ }
+}
+// [END parametermanager_regional_template_quickstart]
diff --git a/parametermanager/src/main/java/parametermanager/regionalsamples/RenderRegionalParamTemplateVersion.java b/parametermanager/src/main/java/parametermanager/regionalsamples/RenderRegionalParamTemplateVersion.java
new file mode 100644
index 00000000000..18e37983811
--- /dev/null
+++ b/parametermanager/src/main/java/parametermanager/regionalsamples/RenderRegionalParamTemplateVersion.java
@@ -0,0 +1,91 @@
+/*
+ * Copyright 2026 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 parametermanager.regionalsamples;
+
+// [START parametermanager_render_regional_param_template_version]
+
+import com.google.cloud.parametermanager.v1.ParameterManagerClient;
+import com.google.cloud.parametermanager.v1.ParameterManagerSettings;
+import com.google.cloud.parametermanager.v1.ParameterVersionName;
+import com.google.cloud.parametermanager.v1.RenderTemplateVersionRequest;
+import com.google.cloud.parametermanager.v1.RenderTemplateVersionResponse;
+import com.google.cloud.parametermanager.v1.TemplateVersionName;
+import java.io.IOException;
+
+/**
+ * This class demonstrates how to render a regional template version using the Parameter Manager SDK
+ * for GCP.
+ */
+public class RenderRegionalParamTemplateVersion {
+
+ public static void main(String[] args) throws IOException {
+ // TODO(developer): Replace these variables before running the sample.
+ String projectId = "your-project-id";
+ String locationId = "your-location-id";
+ String templateId = "your-template-id";
+ String versionId = "your-version-id";
+ String parameterId = "your-parameter-id";
+ String parameterVersionId = "your-parameter-version-id";
+
+ // Call the method to render a template version.
+ renderRegionalParamTemplateVersion(
+ projectId, locationId, templateId, versionId, parameterId, parameterVersionId);
+ }
+
+ // This is an example snippet for rendering a regional template version with the values of a
+ // parameter version.
+ public static RenderTemplateVersionResponse renderRegionalParamTemplateVersion(
+ String projectId,
+ String locationId,
+ String templateId,
+ String versionId,
+ String parameterId,
+ String parameterVersionId)
+ throws IOException {
+ // Endpoint to call the regional parameter manager server.
+ String apiEndpoint = String.format("parametermanager.%s.rep.googleapis.com:443", locationId);
+ ParameterManagerSettings parameterManagerSettings =
+ ParameterManagerSettings.newBuilder().setEndpoint(apiEndpoint).build();
+ // Initialize the client that will be used to send requests. This client only needs to be
+ // created once, and can be reused for multiple requests.
+ try (ParameterManagerClient client = ParameterManagerClient.create(parameterManagerSettings)) {
+ // Build the template version name.
+ TemplateVersionName templateVersionName =
+ TemplateVersionName.of(projectId, locationId, templateId, versionId);
+
+ // Build the parameter version name that supplies the values.
+ ParameterVersionName parameterVersionName =
+ ParameterVersionName.of(projectId, locationId, parameterId, parameterVersionId);
+
+ // Build the render request.
+ RenderTemplateVersionRequest request =
+ RenderTemplateVersionRequest.newBuilder()
+ .setName(templateVersionName.toString())
+ .setParameterVersion(parameterVersionName.toString())
+ .build();
+
+ // Render the template version.
+ RenderTemplateVersionResponse response = client.renderTemplateVersion(request);
+ System.out.printf("Template payload: %s\n", response.getPayload().getData().toStringUtf8());
+ System.out.printf(
+ "Rendered regional payload: %s\n", response.getRenderedPayload().toStringUtf8());
+
+ return response;
+ }
+ }
+}
+// [END parametermanager_render_regional_param_template_version]
diff --git a/parametermanager/src/main/java/parametermanager/regionalsamples/UpdateRegionalParamTemplateLabels.java b/parametermanager/src/main/java/parametermanager/regionalsamples/UpdateRegionalParamTemplateLabels.java
new file mode 100644
index 00000000000..682f2baa365
--- /dev/null
+++ b/parametermanager/src/main/java/parametermanager/regionalsamples/UpdateRegionalParamTemplateLabels.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2026 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 parametermanager.regionalsamples;
+
+// [START parametermanager_update_regional_param_template_labels]
+
+import com.google.cloud.parametermanager.v1.ParameterManagerClient;
+import com.google.cloud.parametermanager.v1.ParameterManagerSettings;
+import com.google.cloud.parametermanager.v1.Template;
+import com.google.cloud.parametermanager.v1.TemplateName;
+import com.google.protobuf.FieldMask;
+import com.google.protobuf.util.FieldMaskUtil;
+import java.io.IOException;
+
+/**
+ * This class demonstrates how to update the labels of a regional template using the Parameter
+ * Manager SDK for GCP.
+ */
+public class UpdateRegionalParamTemplateLabels {
+
+ public static void main(String[] args) throws IOException {
+ // TODO(developer): Replace these variables before running the sample.
+ String projectId = "your-project-id";
+ String locationId = "your-location-id";
+ String templateId = "your-template-id";
+ String key = "your-label-key";
+ String value = "your-label-value";
+
+ // Call the method to update the labels of a template.
+ updateRegionalParamTemplateLabels(projectId, locationId, templateId, key, value);
+ }
+
+ // This is an example snippet for updating the labels of a regional template.
+ public static Template updateRegionalParamTemplateLabels(
+ String projectId, String locationId, String templateId, String key, String value)
+ throws IOException {
+ // Endpoint to call the regional parameter manager server.
+ String apiEndpoint = String.format("parametermanager.%s.rep.googleapis.com:443", locationId);
+ ParameterManagerSettings parameterManagerSettings =
+ ParameterManagerSettings.newBuilder().setEndpoint(apiEndpoint).build();
+ // Initialize the client that will be used to send requests. This client only needs to be
+ // created once, and can be reused for multiple requests.
+ try (ParameterManagerClient client = ParameterManagerClient.create(parameterManagerSettings)) {
+ // Build the template name.
+ TemplateName templateName = TemplateName.of(projectId, locationId, templateId);
+
+ // Get the template and set the label.
+ Template template = client.getTemplate(templateName.toString());
+ Template templateWithLabel = template.toBuilder().putLabels(key, value).build();
+
+ // Build the field mask for the labels field.
+ FieldMask fieldMask = FieldMaskUtil.fromString("labels");
+
+ // Update the template.
+ client.updateTemplate(templateWithLabel, fieldMask);
+
+ // Get the updated template.
+ Template updatedTemplate = client.getTemplate(templateName.toString());
+ System.out.printf(
+ "Updated regional template %s with labels %s\n",
+ updatedTemplate.getName(), updatedTemplate.getLabelsMap());
+
+ return updatedTemplate;
+ }
+ }
+}
+// [END parametermanager_update_regional_param_template_labels]
diff --git a/parametermanager/src/test/java/parametermanager/TemplatesTagsChecksumIT.java b/parametermanager/src/test/java/parametermanager/TemplatesTagsChecksumIT.java
new file mode 100644
index 00000000000..7bc01e22c77
--- /dev/null
+++ b/parametermanager/src/test/java/parametermanager/TemplatesTagsChecksumIT.java
@@ -0,0 +1,440 @@
+/*
+ * Copyright 2026 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 parametermanager;
+
+import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertThrows;
+
+import com.google.api.client.util.Strings;
+import com.google.api.gax.rpc.InvalidArgumentException;
+import com.google.api.gax.rpc.NotFoundException;
+import com.google.cloud.parametermanager.v1.LocationName;
+import com.google.cloud.parametermanager.v1.Parameter;
+import com.google.cloud.parametermanager.v1.ParameterFormat;
+import com.google.cloud.parametermanager.v1.ParameterManagerClient;
+import com.google.cloud.parametermanager.v1.ParameterName;
+import com.google.cloud.parametermanager.v1.ParameterVersion;
+import com.google.cloud.parametermanager.v1.ParameterVersionName;
+import com.google.cloud.parametermanager.v1.ParameterVersionPayload;
+import com.google.cloud.parametermanager.v1.RenderTemplateVersionResponse;
+import com.google.cloud.parametermanager.v1.Template;
+import com.google.cloud.parametermanager.v1.TemplateFormat;
+import com.google.cloud.parametermanager.v1.TemplateName;
+import com.google.cloud.parametermanager.v1.TemplateVersion;
+import com.google.cloud.parametermanager.v1.TemplateVersionName;
+import com.google.cloud.parametermanager.v1.TemplateVersionPayload;
+import com.google.cloud.resourcemanager.v3.TagBinding;
+import com.google.cloud.resourcemanager.v3.TagBindingsClient;
+import com.google.protobuf.ByteString;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
+import java.util.zip.CRC32C;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.Assume;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+@RunWith(JUnit4.class)
+public class TemplatesTagsChecksumIT {
+ private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT");
+ private static final String TAG_KEY = System.getenv("PARAMETER_MANAGER_TAG_KEY");
+ private static final String TAG_VALUE = System.getenv("PARAMETER_MANAGER_TAG_VALUE");
+ private static final String TEMPLATE_PAYLOAD =
+ "{\"username\": \"{{.username}}\", \"host\": \"{{.host}}\"}";
+ private static final String VALUES_PAYLOAD =
+ "{\"username\": \"test-user\", \"host\": \"localhost\"}";
+ private static final String VERSION_ID = "v1";
+
+ private static final List TEMPLATE_VERSIONS = new ArrayList<>();
+ private static final List TEMPLATES = new ArrayList<>();
+ private static final List PARAMETER_VERSIONS = new ArrayList<>();
+ private static final List PARAMETERS = new ArrayList<>();
+
+ @BeforeClass
+ public static void beforeAll() {
+ Assert.assertFalse("missing GOOGLE_CLOUD_PROJECT", Strings.isNullOrEmpty(PROJECT_ID));
+ }
+
+ @AfterClass
+ public static void afterAll() throws IOException {
+ try (ParameterManagerClient client = client()) {
+ for (String name : TEMPLATE_VERSIONS) {
+ try {
+ client.deleteTemplateVersion(name);
+ } catch (NotFoundException e) {
+ // Already deleted by the test.
+ }
+ }
+ for (String name : TEMPLATES) {
+ try {
+ client.deleteTemplate(name);
+ } catch (NotFoundException e) {
+ // Already deleted by the test.
+ }
+ }
+ for (String name : PARAMETER_VERSIONS) {
+ try {
+ client.deleteParameterVersion(name);
+ } catch (NotFoundException e) {
+ // Already deleted by the test.
+ }
+ }
+ for (String name : PARAMETERS) {
+ try {
+ client.deleteParameter(name);
+ } catch (NotFoundException e) {
+ // Already deleted by the test.
+ }
+ }
+ }
+ }
+
+ private static ParameterManagerClient client() throws IOException {
+ return ParameterManagerClient.create();
+ }
+
+ private static TagBindingsClient tagBindingsClient() throws IOException {
+ return TagBindingsClient.create();
+ }
+
+ private static void assumeTagsConfigured() {
+ Assume.assumeFalse(
+ "missing PARAMETER_MANAGER_TAG_KEY or PARAMETER_MANAGER_TAG_VALUE",
+ Strings.isNullOrEmpty(TAG_KEY) || Strings.isNullOrEmpty(TAG_VALUE));
+ }
+
+ private static String randomId(String prefix) {
+ return prefix + "-" + UUID.randomUUID().toString().substring(0, 8);
+ }
+
+ private static String createTemplate() throws IOException {
+ String templateId = randomId("java-template");
+ try (ParameterManagerClient client = client()) {
+ Template template =
+ client.createTemplate(
+ LocationName.of(PROJECT_ID, "global").toString(),
+ Template.newBuilder().setFormat(TemplateFormat.TEMPLATE_FORMAT_JSON).build(),
+ templateId);
+ TEMPLATES.add(template.getName());
+ }
+ return templateId;
+ }
+
+ private static void createTemplateVersion(String templateId, String versionId)
+ throws IOException {
+ try (ParameterManagerClient client = client()) {
+ TemplateVersion version =
+ client.createTemplateVersion(
+ TemplateName.of(PROJECT_ID, "global", templateId).toString(),
+ TemplateVersion.newBuilder()
+ .setPayload(
+ TemplateVersionPayload.newBuilder()
+ .setData(ByteString.copyFromUtf8(TEMPLATE_PAYLOAD)))
+ .build(),
+ versionId);
+ TEMPLATE_VERSIONS.add(version.getName());
+ }
+ }
+
+ private static String createParameter() throws IOException {
+ return createParameter(ParameterFormat.JSON);
+ }
+
+ private static String createParameter(ParameterFormat format) throws IOException {
+ String parameterId = randomId("java-param");
+ try (ParameterManagerClient client = client()) {
+ Parameter parameter =
+ client.createParameter(
+ LocationName.of(PROJECT_ID, "global").toString(),
+ Parameter.newBuilder().setFormat(format).build(),
+ parameterId);
+ PARAMETERS.add(parameter.getName());
+ }
+ return parameterId;
+ }
+
+ private static void createParameterVersion(String parameterId, String versionId, byte[] data)
+ throws IOException {
+ try (ParameterManagerClient client = client()) {
+ CRC32C crc32c = new CRC32C();
+ crc32c.update(data);
+ ParameterVersion version =
+ client.createParameterVersion(
+ ParameterName.of(PROJECT_ID, "global", parameterId).toString(),
+ ParameterVersion.newBuilder()
+ .setPayload(
+ ParameterVersionPayload.newBuilder()
+ .setData(ByteString.copyFrom(data))
+ .setDataCrc32C(crc32c.getValue()))
+ .build(),
+ versionId);
+ PARAMETER_VERSIONS.add(version.getName());
+ }
+ }
+
+ private static List tagValuesOf(String parameterId) throws IOException {
+ List tagValues = new ArrayList<>();
+ try (ParameterManagerClient client = client();
+ TagBindingsClient tagBindingsClient = tagBindingsClient()) {
+ Parameter parameter =
+ client.getParameter(ParameterName.of(PROJECT_ID, "global", parameterId).toString());
+ tagBindingsClient
+ .listTagBindings("//parametermanager.googleapis.com/" + parameter.getName())
+ .iterateAll()
+ .forEach(binding -> tagValues.add(binding.getTagValue()));
+ }
+ return tagValues;
+ }
+
+ @Test
+ public void createParamTemplate() throws IOException {
+ String templateId = randomId("java-template");
+ Template template =
+ CreateParamTemplate.createParamTemplate(
+ PROJECT_ID, templateId, TemplateFormat.TEMPLATE_FORMAT_JSON);
+ TEMPLATES.add(template.getName());
+ assertThat(template.getName()).contains(templateId);
+ assertThat(template.getFormat()).isEqualTo(TemplateFormat.TEMPLATE_FORMAT_JSON);
+ }
+
+ @Test
+ public void createParamTemplateVersion() throws IOException {
+ String templateId = createTemplate();
+ TemplateVersion version =
+ CreateParamTemplateVersion.createParamTemplateVersion(PROJECT_ID, templateId, VERSION_ID);
+ TEMPLATE_VERSIONS.add(version.getName());
+ assertThat(version.getName()).contains(VERSION_ID);
+ }
+
+ @Test
+ public void listParamTemplates() throws IOException {
+ String templateId = createTemplate();
+ boolean found = false;
+ for (Template template : ListParamTemplates.listParamTemplates(PROJECT_ID).iterateAll()) {
+ found |= template.getName().contains(templateId);
+ }
+ assertThat(found).isTrue();
+ }
+
+ @Test
+ public void getParamTemplate() throws IOException {
+ String templateId = createTemplate();
+ Template template = GetParamTemplate.getParamTemplate(PROJECT_ID, templateId);
+ assertThat(template.getName()).contains(templateId);
+ }
+
+ @Test
+ public void listParamTemplateVersions() throws IOException {
+ String templateId = createTemplate();
+ createTemplateVersion(templateId, VERSION_ID);
+ boolean found = false;
+ for (TemplateVersion version :
+ ListParamTemplateVersions.listParamTemplateVersions(PROJECT_ID, templateId).iterateAll()) {
+ found |= version.getName().contains(VERSION_ID);
+ }
+ assertThat(found).isTrue();
+ }
+
+ @Test
+ public void getParamTemplateVersion() throws IOException {
+ String templateId = createTemplate();
+ createTemplateVersion(templateId, VERSION_ID);
+ TemplateVersion version =
+ GetParamTemplateVersion.getParamTemplateVersion(PROJECT_ID, templateId, VERSION_ID);
+ assertThat(version.getPayload().getData().toStringUtf8()).isEqualTo(TEMPLATE_PAYLOAD);
+ }
+
+ @Test
+ public void updateParamTemplateLabels() throws IOException {
+ String templateId = createTemplate();
+ Template template =
+ UpdateParamTemplateLabels.updateParamTemplateLabels(
+ PROJECT_ID, templateId, "environment", "test");
+ assertThat(template.getLabelsMap()).containsEntry("environment", "test");
+ }
+
+ @Test
+ public void deleteParamTemplate() throws IOException {
+ String templateId = createTemplate();
+ DeleteParamTemplate.deleteParamTemplate(PROJECT_ID, templateId);
+ try (ParameterManagerClient client = client()) {
+ assertThrows(
+ NotFoundException.class,
+ () -> client.getTemplate(TemplateName.of(PROJECT_ID, "global", templateId).toString()));
+ }
+ }
+
+ @Test
+ public void disableParamTemplateVersion() throws IOException {
+ String templateId = createTemplate();
+ createTemplateVersion(templateId, VERSION_ID);
+ TemplateVersion version =
+ DisableParamTemplateVersion.disableParamTemplateVersion(PROJECT_ID, templateId, VERSION_ID);
+ assertThat(version.getDisabled()).isTrue();
+ }
+
+ @Test
+ public void enableParamTemplateVersion() throws IOException {
+ String templateId = createTemplate();
+ createTemplateVersion(templateId, VERSION_ID);
+ DisableParamTemplateVersion.disableParamTemplateVersion(PROJECT_ID, templateId, VERSION_ID);
+ TemplateVersion version =
+ EnableParamTemplateVersion.enableParamTemplateVersion(PROJECT_ID, templateId, VERSION_ID);
+ assertThat(version.getDisabled()).isFalse();
+ }
+
+ @Test
+ public void deleteParamTemplateVersion() throws IOException {
+ String templateId = createTemplate();
+ createTemplateVersion(templateId, VERSION_ID);
+ DeleteParamTemplateVersion.deleteParamTemplateVersion(PROJECT_ID, templateId, VERSION_ID);
+ try (ParameterManagerClient client = client()) {
+ assertThrows(
+ NotFoundException.class,
+ () ->
+ client.getTemplateVersion(
+ TemplateVersionName.of(PROJECT_ID, "global", templateId, VERSION_ID).toString()));
+ }
+ }
+
+ @Test
+ public void renderParamTemplateVersion() throws IOException {
+ String templateId = createTemplate();
+ createTemplateVersion(templateId, VERSION_ID);
+ String parameterId = createParameter();
+ createParameterVersion(
+ parameterId, VERSION_ID, VALUES_PAYLOAD.getBytes(StandardCharsets.UTF_8));
+ RenderTemplateVersionResponse response =
+ RenderParamTemplateVersion.renderParamTemplateVersion(
+ PROJECT_ID, templateId, VERSION_ID, parameterId, VERSION_ID);
+ assertThat(response.getPayload().getData().toStringUtf8()).isEqualTo(TEMPLATE_PAYLOAD);
+ assertThat(response.getRenderedPayload().toStringUtf8()).isEqualTo(VALUES_PAYLOAD);
+ }
+
+ @Test
+ public void templateQuickstart() throws Exception {
+ String templateId = randomId("java-template");
+ String parameterId = randomId("java-param");
+ TEMPLATES.add(TemplateName.of(PROJECT_ID, "global", templateId).toString());
+ TEMPLATE_VERSIONS.add(
+ TemplateVersionName.of(PROJECT_ID, "global", templateId, VERSION_ID).toString());
+ PARAMETERS.add(ParameterName.of(PROJECT_ID, "global", parameterId).toString());
+ PARAMETER_VERSIONS.add(
+ ParameterVersionName.of(PROJECT_ID, "global", parameterId, VERSION_ID).toString());
+
+ PrintStream originalOut = System.out;
+ ByteArrayOutputStream redirected = new ByteArrayOutputStream();
+ System.setOut(new PrintStream(redirected));
+ try {
+ TemplateQuickstart.templateQuickstart(PROJECT_ID, templateId, parameterId, VERSION_ID);
+ assertThat(redirected.toString()).contains(VALUES_PAYLOAD);
+ } finally {
+ System.setOut(originalOut);
+ }
+ }
+
+ @Test
+ public void createParamWithTags() throws IOException {
+ assumeTagsConfigured();
+ String parameterId = randomId("java-param");
+ Parameter parameter =
+ CreateParamWithTags.createParamWithTags(PROJECT_ID, parameterId, TAG_KEY, TAG_VALUE);
+ PARAMETERS.add(parameter.getName());
+ assertThat(tagValuesOf(parameterId)).contains(TAG_VALUE);
+ }
+
+ @Test
+ public void bindTagsToParam() throws Exception {
+ assumeTagsConfigured();
+ String parameterId = randomId("java-param");
+ PARAMETERS.add(ParameterName.of(PROJECT_ID, "global", parameterId).toString());
+ TagBinding binding = BindTagsToParam.bindTagsToParam(PROJECT_ID, parameterId, TAG_VALUE);
+ assertThat(binding.getTagValue()).isEqualTo(TAG_VALUE);
+ assertThat(tagValuesOf(parameterId)).contains(TAG_VALUE);
+ }
+
+ @Test
+ public void getParamTags() throws Exception {
+ assumeTagsConfigured();
+ String parameterId = randomId("java-param");
+ PARAMETERS.add(ParameterName.of(PROJECT_ID, "global", parameterId).toString());
+ BindTagsToParam.bindTagsToParam(PROJECT_ID, parameterId, TAG_VALUE);
+ List tagValues = new ArrayList<>();
+ GetParamTags.getParamTags(PROJECT_ID, parameterId)
+ .iterateAll()
+ .forEach(binding -> tagValues.add(binding.getTagValue()));
+ assertThat(tagValues).contains(TAG_VALUE);
+ }
+
+ @Test
+ public void createParamVersionWithChecksum() throws IOException {
+ String parameterId = createParameter(ParameterFormat.UNFORMATTED);
+ ParameterVersion version =
+ CreateParamVersionWithChecksum.createParamVersionWithChecksum(
+ PROJECT_ID, parameterId, VERSION_ID);
+ PARAMETER_VERSIONS.add(version.getName());
+ CRC32C crc32c = new CRC32C();
+ crc32c.update("hello world!".getBytes(StandardCharsets.UTF_8));
+ assertThat(version.getChecksumSource())
+ .isEqualTo(ParameterVersion.ChecksumSource.USER_SPECIFIED);
+ assertThat(version.getPayload().getDataCrc32C()).isEqualTo(crc32c.getValue());
+ }
+
+ @Test
+ public void getParamVersionVerifyChecksum() throws IOException {
+ String parameterId = createParameter(ParameterFormat.UNFORMATTED);
+ createParameterVersion(
+ parameterId, VERSION_ID, "hello world!".getBytes(StandardCharsets.UTF_8));
+ ParameterVersion version =
+ GetParamVersionVerifyChecksum.getParamVersionVerifyChecksum(
+ PROJECT_ID, parameterId, VERSION_ID);
+ assertThat(version.getChecksumSource())
+ .isEqualTo(ParameterVersion.ChecksumSource.USER_SPECIFIED);
+ assertThat(version.getPayload().getData().toStringUtf8()).isEqualTo("hello world!");
+ }
+
+ @Test
+ public void createParamVersionWithChecksum_mismatch() throws IOException {
+ String parameterId = createParameter(ParameterFormat.UNFORMATTED);
+ try (ParameterManagerClient client = client()) {
+ ParameterVersion version =
+ ParameterVersion.newBuilder()
+ .setPayload(
+ ParameterVersionPayload.newBuilder()
+ .setData(ByteString.copyFromUtf8("hello world!"))
+ .setDataCrc32C(1L))
+ .build();
+ InvalidArgumentException e =
+ assertThrows(
+ InvalidArgumentException.class,
+ () ->
+ client.createParameterVersion(
+ ParameterName.of(PROJECT_ID, "global", parameterId).toString(),
+ version,
+ VERSION_ID));
+ assertThat(e.getReason()).isEqualTo("CHECKSUM_MISMATCH");
+ }
+ }
+}
diff --git a/parametermanager/src/test/java/parametermanager/regionalsamples/TemplatesTagsChecksumIT.java b/parametermanager/src/test/java/parametermanager/regionalsamples/TemplatesTagsChecksumIT.java
new file mode 100644
index 00000000000..85b8482da80
--- /dev/null
+++ b/parametermanager/src/test/java/parametermanager/regionalsamples/TemplatesTagsChecksumIT.java
@@ -0,0 +1,465 @@
+/*
+ * Copyright 2026 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 parametermanager.regionalsamples;
+
+import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertThrows;
+
+import com.google.api.client.util.Strings;
+import com.google.api.gax.rpc.InvalidArgumentException;
+import com.google.api.gax.rpc.NotFoundException;
+import com.google.cloud.parametermanager.v1.LocationName;
+import com.google.cloud.parametermanager.v1.Parameter;
+import com.google.cloud.parametermanager.v1.ParameterFormat;
+import com.google.cloud.parametermanager.v1.ParameterManagerClient;
+import com.google.cloud.parametermanager.v1.ParameterManagerSettings;
+import com.google.cloud.parametermanager.v1.ParameterName;
+import com.google.cloud.parametermanager.v1.ParameterVersion;
+import com.google.cloud.parametermanager.v1.ParameterVersionName;
+import com.google.cloud.parametermanager.v1.ParameterVersionPayload;
+import com.google.cloud.parametermanager.v1.RenderTemplateVersionResponse;
+import com.google.cloud.parametermanager.v1.Template;
+import com.google.cloud.parametermanager.v1.TemplateFormat;
+import com.google.cloud.parametermanager.v1.TemplateName;
+import com.google.cloud.parametermanager.v1.TemplateVersion;
+import com.google.cloud.parametermanager.v1.TemplateVersionName;
+import com.google.cloud.parametermanager.v1.TemplateVersionPayload;
+import com.google.cloud.resourcemanager.v3.TagBinding;
+import com.google.cloud.resourcemanager.v3.TagBindingsClient;
+import com.google.cloud.resourcemanager.v3.TagBindingsSettings;
+import com.google.protobuf.ByteString;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
+import java.util.zip.CRC32C;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.Assume;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+@RunWith(JUnit4.class)
+public class TemplatesTagsChecksumIT {
+ private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT");
+ private static final String LOCATION_ID =
+ System.getenv().getOrDefault("GOOGLE_CLOUD_PROJECT_LOCATION", "us-central1");
+ private static final String TAG_KEY = System.getenv("PARAMETER_MANAGER_TAG_KEY");
+ private static final String TAG_VALUE = System.getenv("PARAMETER_MANAGER_TAG_VALUE");
+ private static final String TEMPLATE_PAYLOAD =
+ "{\"username\": \"{{.username}}\", \"host\": \"{{.host}}\"}";
+ private static final String VALUES_PAYLOAD =
+ "{\"username\": \"test-user\", \"host\": \"localhost\"}";
+ private static final String VERSION_ID = "v1";
+
+ private static final List TEMPLATE_VERSIONS = new ArrayList<>();
+ private static final List TEMPLATES = new ArrayList<>();
+ private static final List PARAMETER_VERSIONS = new ArrayList<>();
+ private static final List PARAMETERS = new ArrayList<>();
+
+ @BeforeClass
+ public static void beforeAll() {
+ Assert.assertFalse("missing GOOGLE_CLOUD_PROJECT", Strings.isNullOrEmpty(PROJECT_ID));
+ }
+
+ @AfterClass
+ public static void afterAll() throws IOException {
+ try (ParameterManagerClient client = client()) {
+ for (String name : TEMPLATE_VERSIONS) {
+ try {
+ client.deleteTemplateVersion(name);
+ } catch (NotFoundException e) {
+ // Already deleted by the test.
+ }
+ }
+ for (String name : TEMPLATES) {
+ try {
+ client.deleteTemplate(name);
+ } catch (NotFoundException e) {
+ // Already deleted by the test.
+ }
+ }
+ for (String name : PARAMETER_VERSIONS) {
+ try {
+ client.deleteParameterVersion(name);
+ } catch (NotFoundException e) {
+ // Already deleted by the test.
+ }
+ }
+ for (String name : PARAMETERS) {
+ try {
+ client.deleteParameter(name);
+ } catch (NotFoundException e) {
+ // Already deleted by the test.
+ }
+ }
+ }
+ }
+
+ private static ParameterManagerClient client() throws IOException {
+ String apiEndpoint = String.format("parametermanager.%s.rep.googleapis.com:443", LOCATION_ID);
+ return ParameterManagerClient.create(
+ ParameterManagerSettings.newBuilder().setEndpoint(apiEndpoint).build());
+ }
+
+ private static TagBindingsClient tagBindingsClient() throws IOException {
+ String endpoint = String.format("%s-cloudresourcemanager.googleapis.com:443", LOCATION_ID);
+ return TagBindingsClient.create(TagBindingsSettings.newBuilder().setEndpoint(endpoint).build());
+ }
+
+ private static void assumeTagsConfigured() {
+ Assume.assumeFalse(
+ "missing PARAMETER_MANAGER_TAG_KEY or PARAMETER_MANAGER_TAG_VALUE",
+ Strings.isNullOrEmpty(TAG_KEY) || Strings.isNullOrEmpty(TAG_VALUE));
+ }
+
+ private static String randomId(String prefix) {
+ return prefix + "-" + UUID.randomUUID().toString().substring(0, 8);
+ }
+
+ private static String createTemplate() throws IOException {
+ String templateId = randomId("java-template");
+ try (ParameterManagerClient client = client()) {
+ Template template =
+ client.createTemplate(
+ LocationName.of(PROJECT_ID, LOCATION_ID).toString(),
+ Template.newBuilder().setFormat(TemplateFormat.TEMPLATE_FORMAT_JSON).build(),
+ templateId);
+ TEMPLATES.add(template.getName());
+ }
+ return templateId;
+ }
+
+ private static void createTemplateVersion(String templateId, String versionId)
+ throws IOException {
+ try (ParameterManagerClient client = client()) {
+ TemplateVersion version =
+ client.createTemplateVersion(
+ TemplateName.of(PROJECT_ID, LOCATION_ID, templateId).toString(),
+ TemplateVersion.newBuilder()
+ .setPayload(
+ TemplateVersionPayload.newBuilder()
+ .setData(ByteString.copyFromUtf8(TEMPLATE_PAYLOAD)))
+ .build(),
+ versionId);
+ TEMPLATE_VERSIONS.add(version.getName());
+ }
+ }
+
+ private static String createParameter() throws IOException {
+ return createParameter(ParameterFormat.JSON);
+ }
+
+ private static String createParameter(ParameterFormat format) throws IOException {
+ String parameterId = randomId("java-param");
+ try (ParameterManagerClient client = client()) {
+ Parameter parameter =
+ client.createParameter(
+ LocationName.of(PROJECT_ID, LOCATION_ID).toString(),
+ Parameter.newBuilder().setFormat(format).build(),
+ parameterId);
+ PARAMETERS.add(parameter.getName());
+ }
+ return parameterId;
+ }
+
+ private static void createParameterVersion(String parameterId, String versionId, byte[] data)
+ throws IOException {
+ try (ParameterManagerClient client = client()) {
+ CRC32C crc32c = new CRC32C();
+ crc32c.update(data);
+ ParameterVersion version =
+ client.createParameterVersion(
+ ParameterName.of(PROJECT_ID, LOCATION_ID, parameterId).toString(),
+ ParameterVersion.newBuilder()
+ .setPayload(
+ ParameterVersionPayload.newBuilder()
+ .setData(ByteString.copyFrom(data))
+ .setDataCrc32C(crc32c.getValue()))
+ .build(),
+ versionId);
+ PARAMETER_VERSIONS.add(version.getName());
+ }
+ }
+
+ private static List tagValuesOf(String parameterId) throws IOException {
+ List tagValues = new ArrayList<>();
+ try (ParameterManagerClient client = client();
+ TagBindingsClient tagBindingsClient = tagBindingsClient()) {
+ Parameter parameter =
+ client.getParameter(ParameterName.of(PROJECT_ID, LOCATION_ID, parameterId).toString());
+ tagBindingsClient
+ .listTagBindings("//parametermanager.googleapis.com/" + parameter.getName())
+ .iterateAll()
+ .forEach(binding -> tagValues.add(binding.getTagValue()));
+ }
+ return tagValues;
+ }
+
+ @Test
+ public void createParamTemplate() throws IOException {
+ String templateId = randomId("java-template");
+ Template template =
+ CreateRegionalParamTemplate.createRegionalParamTemplate(
+ PROJECT_ID, LOCATION_ID, templateId, TemplateFormat.TEMPLATE_FORMAT_JSON);
+ TEMPLATES.add(template.getName());
+ assertThat(template.getName()).contains(templateId);
+ assertThat(template.getFormat()).isEqualTo(TemplateFormat.TEMPLATE_FORMAT_JSON);
+ }
+
+ @Test
+ public void createParamTemplateVersion() throws IOException {
+ String templateId = createTemplate();
+ TemplateVersion version =
+ CreateRegionalParamTemplateVersion.createRegionalParamTemplateVersion(
+ PROJECT_ID, LOCATION_ID, templateId, VERSION_ID);
+ TEMPLATE_VERSIONS.add(version.getName());
+ assertThat(version.getName()).contains(VERSION_ID);
+ }
+
+ @Test
+ public void listParamTemplates() throws IOException {
+ String templateId = createTemplate();
+ boolean found = false;
+ for (Template template :
+ ListRegionalParamTemplates.listRegionalParamTemplates(PROJECT_ID, LOCATION_ID)
+ .iterateAll()) {
+ found |= template.getName().contains(templateId);
+ }
+ assertThat(found).isTrue();
+ }
+
+ @Test
+ public void getParamTemplate() throws IOException {
+ String templateId = createTemplate();
+ Template template =
+ GetRegionalParamTemplate.getRegionalParamTemplate(PROJECT_ID, LOCATION_ID, templateId);
+ assertThat(template.getName()).contains(templateId);
+ }
+
+ @Test
+ public void listParamTemplateVersions() throws IOException {
+ String templateId = createTemplate();
+ createTemplateVersion(templateId, VERSION_ID);
+ boolean found = false;
+ for (TemplateVersion version :
+ ListRegionalParamTemplateVersions.listRegionalParamTemplateVersions(
+ PROJECT_ID, LOCATION_ID, templateId)
+ .iterateAll()) {
+ found |= version.getName().contains(VERSION_ID);
+ }
+ assertThat(found).isTrue();
+ }
+
+ @Test
+ public void getParamTemplateVersion() throws IOException {
+ String templateId = createTemplate();
+ createTemplateVersion(templateId, VERSION_ID);
+ TemplateVersion version =
+ GetRegionalParamTemplateVersion.getRegionalParamTemplateVersion(
+ PROJECT_ID, LOCATION_ID, templateId, VERSION_ID);
+ assertThat(version.getPayload().getData().toStringUtf8()).isEqualTo(TEMPLATE_PAYLOAD);
+ }
+
+ @Test
+ public void updateParamTemplateLabels() throws IOException {
+ String templateId = createTemplate();
+ Template template =
+ UpdateRegionalParamTemplateLabels.updateRegionalParamTemplateLabels(
+ PROJECT_ID, LOCATION_ID, templateId, "environment", "test");
+ assertThat(template.getLabelsMap()).containsEntry("environment", "test");
+ }
+
+ @Test
+ public void deleteParamTemplate() throws IOException {
+ String templateId = createTemplate();
+ DeleteRegionalParamTemplate.deleteRegionalParamTemplate(PROJECT_ID, LOCATION_ID, templateId);
+ try (ParameterManagerClient client = client()) {
+ assertThrows(
+ NotFoundException.class,
+ () ->
+ client.getTemplate(TemplateName.of(PROJECT_ID, LOCATION_ID, templateId).toString()));
+ }
+ }
+
+ @Test
+ public void disableParamTemplateVersion() throws IOException {
+ String templateId = createTemplate();
+ createTemplateVersion(templateId, VERSION_ID);
+ TemplateVersion version =
+ DisableRegionalParamTemplateVersion.disableRegionalParamTemplateVersion(
+ PROJECT_ID, LOCATION_ID, templateId, VERSION_ID);
+ assertThat(version.getDisabled()).isTrue();
+ }
+
+ @Test
+ public void enableParamTemplateVersion() throws IOException {
+ String templateId = createTemplate();
+ createTemplateVersion(templateId, VERSION_ID);
+ DisableRegionalParamTemplateVersion.disableRegionalParamTemplateVersion(
+ PROJECT_ID, LOCATION_ID, templateId, VERSION_ID);
+ TemplateVersion version =
+ EnableRegionalParamTemplateVersion.enableRegionalParamTemplateVersion(
+ PROJECT_ID, LOCATION_ID, templateId, VERSION_ID);
+ assertThat(version.getDisabled()).isFalse();
+ }
+
+ @Test
+ public void deleteParamTemplateVersion() throws IOException {
+ String templateId = createTemplate();
+ createTemplateVersion(templateId, VERSION_ID);
+ DeleteRegionalParamTemplateVersion.deleteRegionalParamTemplateVersion(
+ PROJECT_ID, LOCATION_ID, templateId, VERSION_ID);
+ try (ParameterManagerClient client = client()) {
+ assertThrows(
+ NotFoundException.class,
+ () ->
+ client.getTemplateVersion(
+ TemplateVersionName.of(PROJECT_ID, LOCATION_ID, templateId, VERSION_ID)
+ .toString()));
+ }
+ }
+
+ @Test
+ public void renderParamTemplateVersion() throws IOException {
+ String templateId = createTemplate();
+ createTemplateVersion(templateId, VERSION_ID);
+ String parameterId = createParameter();
+ createParameterVersion(
+ parameterId, VERSION_ID, VALUES_PAYLOAD.getBytes(StandardCharsets.UTF_8));
+ RenderTemplateVersionResponse response =
+ RenderRegionalParamTemplateVersion.renderRegionalParamTemplateVersion(
+ PROJECT_ID, LOCATION_ID, templateId, VERSION_ID, parameterId, VERSION_ID);
+ assertThat(response.getPayload().getData().toStringUtf8()).isEqualTo(TEMPLATE_PAYLOAD);
+ assertThat(response.getRenderedPayload().toStringUtf8()).isEqualTo(VALUES_PAYLOAD);
+ }
+
+ @Test
+ public void templateQuickstart() throws Exception {
+ String templateId = randomId("java-template");
+ String parameterId = randomId("java-param");
+ TEMPLATES.add(TemplateName.of(PROJECT_ID, LOCATION_ID, templateId).toString());
+ TEMPLATE_VERSIONS.add(
+ TemplateVersionName.of(PROJECT_ID, LOCATION_ID, templateId, VERSION_ID).toString());
+ PARAMETERS.add(ParameterName.of(PROJECT_ID, LOCATION_ID, parameterId).toString());
+ PARAMETER_VERSIONS.add(
+ ParameterVersionName.of(PROJECT_ID, LOCATION_ID, parameterId, VERSION_ID).toString());
+
+ PrintStream originalOut = System.out;
+ ByteArrayOutputStream redirected = new ByteArrayOutputStream();
+ System.setOut(new PrintStream(redirected));
+ try {
+ RegionalTemplateQuickstart.regionalTemplateQuickstart(
+ PROJECT_ID, LOCATION_ID, templateId, parameterId, VERSION_ID);
+ assertThat(redirected.toString()).contains(VALUES_PAYLOAD);
+ } finally {
+ System.setOut(originalOut);
+ }
+ }
+
+ @Test
+ public void createParamWithTags() throws IOException {
+ assumeTagsConfigured();
+ String parameterId = randomId("java-param");
+ Parameter parameter =
+ CreateRegionalParamWithTags.createRegionalParamWithTags(
+ PROJECT_ID, LOCATION_ID, parameterId, TAG_KEY, TAG_VALUE);
+ PARAMETERS.add(parameter.getName());
+ assertThat(tagValuesOf(parameterId)).contains(TAG_VALUE);
+ }
+
+ @Test
+ public void bindTagsToParam() throws Exception {
+ assumeTagsConfigured();
+ String parameterId = randomId("java-param");
+ PARAMETERS.add(ParameterName.of(PROJECT_ID, LOCATION_ID, parameterId).toString());
+ TagBinding binding =
+ BindTagsToRegionalParam.bindTagsToRegionalParam(
+ PROJECT_ID, LOCATION_ID, parameterId, TAG_VALUE);
+ assertThat(binding.getTagValue()).isEqualTo(TAG_VALUE);
+ assertThat(tagValuesOf(parameterId)).contains(TAG_VALUE);
+ }
+
+ @Test
+ public void getParamTags() throws Exception {
+ assumeTagsConfigured();
+ String parameterId = randomId("java-param");
+ PARAMETERS.add(ParameterName.of(PROJECT_ID, LOCATION_ID, parameterId).toString());
+ BindTagsToRegionalParam.bindTagsToRegionalParam(
+ PROJECT_ID, LOCATION_ID, parameterId, TAG_VALUE);
+ List tagValues = new ArrayList<>();
+ GetRegionalParamTags.getRegionalParamTags(PROJECT_ID, LOCATION_ID, parameterId)
+ .iterateAll()
+ .forEach(binding -> tagValues.add(binding.getTagValue()));
+ assertThat(tagValues).contains(TAG_VALUE);
+ }
+
+ @Test
+ public void createParamVersionWithChecksum() throws IOException {
+ String parameterId = createParameter(ParameterFormat.UNFORMATTED);
+ ParameterVersion version =
+ CreateRegionalParamVersionWithChecksum.createRegionalParamVersionWithChecksum(
+ PROJECT_ID, LOCATION_ID, parameterId, VERSION_ID);
+ PARAMETER_VERSIONS.add(version.getName());
+ CRC32C crc32c = new CRC32C();
+ crc32c.update("hello world!".getBytes(StandardCharsets.UTF_8));
+ assertThat(version.getChecksumSource())
+ .isEqualTo(ParameterVersion.ChecksumSource.USER_SPECIFIED);
+ assertThat(version.getPayload().getDataCrc32C()).isEqualTo(crc32c.getValue());
+ }
+
+ @Test
+ public void getParamVersionVerifyChecksum() throws IOException {
+ String parameterId = createParameter(ParameterFormat.UNFORMATTED);
+ createParameterVersion(
+ parameterId, VERSION_ID, "hello world!".getBytes(StandardCharsets.UTF_8));
+ ParameterVersion version =
+ GetRegionalParamVersionVerifyChecksum.getRegionalParamVersionVerifyChecksum(
+ PROJECT_ID, LOCATION_ID, parameterId, VERSION_ID);
+ assertThat(version.getChecksumSource())
+ .isEqualTo(ParameterVersion.ChecksumSource.USER_SPECIFIED);
+ assertThat(version.getPayload().getData().toStringUtf8()).isEqualTo("hello world!");
+ }
+
+ @Test
+ public void createParamVersionWithChecksum_mismatch() throws IOException {
+ String parameterId = createParameter(ParameterFormat.UNFORMATTED);
+ try (ParameterManagerClient client = client()) {
+ ParameterVersion version =
+ ParameterVersion.newBuilder()
+ .setPayload(
+ ParameterVersionPayload.newBuilder()
+ .setData(ByteString.copyFromUtf8("hello world!"))
+ .setDataCrc32C(1L))
+ .build();
+ InvalidArgumentException e =
+ assertThrows(
+ InvalidArgumentException.class,
+ () ->
+ client.createParameterVersion(
+ ParameterName.of(PROJECT_ID, LOCATION_ID, parameterId).toString(),
+ version,
+ VERSION_ID));
+ assertThat(e.getReason()).isEqualTo("CHECKSUM_MISMATCH");
+ }
+ }
+}