public static List<String> toStringList(List<SnapshotName> values) { List<String> list = new ArrayList<String>(values.size()); for (SnapshotName value : values) { if (value == null) { list.add(""); } else { list.add(value.toString()); } } return list; }
public static SnapshotName parse(String formattedString) { if (formattedString.isEmpty()) { return null; } Map<String, String> matchMap = PATH_TEMPLATE.validatedMatch( formattedString, "SnapshotName.parse: formattedString not in valid format"); return of( matchMap.get("project"), matchMap.get("instance"), matchMap.get("cluster"), matchMap.get("snapshot")); }
public static List<SnapshotName> parseList(List<String> formattedStrings) { List<SnapshotName> list = new ArrayList<>(formattedStrings.size()); for (String formattedString : formattedStrings) { list.add(parse(formattedString)); } return list; }
public static String format(String project, String instance, String cluster, String snapshot) { return newBuilder() .setProject(project) .setInstance(instance) .setCluster(cluster) .setSnapshot(snapshot) .build() .toString(); }
@Test @SuppressWarnings("all") public void getSnapshotTest() { SnapshotName name2 = SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]"); long dataSizeBytes = 2110122398L; String description = "description-1724546052"; Snapshot expectedResponse = Snapshot.newBuilder() .setName(name2.toString()) .setDataSizeBytes(dataSizeBytes) .setDescription(description) .build(); mockBigtableTableAdmin.addResponse(expectedResponse); SnapshotName name = SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]"); Snapshot actualResponse = client.getSnapshot(name); Assert.assertEquals(expectedResponse, actualResponse); List<GeneratedMessageV3> actualRequests = mockBigtableTableAdmin.getRequests(); Assert.assertEquals(1, actualRequests.size()); GetSnapshotRequest actualRequest = (GetSnapshotRequest) actualRequests.get(0); Assert.assertEquals(name, SnapshotName.parse(actualRequest.getName())); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern())); }
@Test @SuppressWarnings("all") public void deleteSnapshotTest() { Empty expectedResponse = Empty.newBuilder().build(); mockBigtableTableAdmin.addResponse(expectedResponse); SnapshotName name = SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]"); client.deleteSnapshot(name); List<GeneratedMessageV3> actualRequests = mockBigtableTableAdmin.getRequests(); Assert.assertEquals(1, actualRequests.size()); DeleteSnapshotRequest actualRequest = (DeleteSnapshotRequest) actualRequests.get(0); Assert.assertEquals(name, SnapshotName.parse(actualRequest.getName())); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern())); }
public static SnapshotName of(String project, String instance, String cluster, String snapshot) { return newBuilder() .setProject(project) .setInstance(instance) .setCluster(cluster) .setSnapshot(snapshot) .build(); }
public String getFieldValue(String fieldName) { return getFieldValuesMap().get(fieldName); }
public SnapshotName build() { return new SnapshotName(this); } }
@Test @SuppressWarnings("all") public void snapshotTableTest() throws Exception { SnapshotName name2 = SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]"); long dataSizeBytes = 2110122398L; String description2 = "description2568623279"; Snapshot expectedResponse = Snapshot.newBuilder() .setName(name2.toString()) .setDataSizeBytes(dataSizeBytes) .setDescription(description2) SnapshotName snapshotId = SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]"); String description = "description-1724546052"; Assert.assertEquals(snapshotId, SnapshotName.parse(actualRequest.getSnapshotId())); Assert.assertEquals(description, actualRequest.getDescription()); Assert.assertTrue(
public static String format(String project, String instance, String cluster, String snapshot) { return newBuilder() .setProject(project) .setInstance(instance) .setCluster(cluster) .setSnapshot(snapshot) .build() .toString(); }
public static SnapshotName of(String project, String instance, String cluster, String snapshot) { return newBuilder() .setProject(project) .setInstance(instance) .setCluster(cluster) .setSnapshot(snapshot) .build(); }
public String getFieldValue(String fieldName) { return getFieldValuesMap().get(fieldName); }
public SnapshotName build() { return new SnapshotName(this); } }
/** * Gets metadata information about the specified snapshot. * * <p>Note: This is a private alpha release of Cloud Bigtable snapshots. This feature is not * currently available to most Cloud Bigtable customers. This feature might be changed in * backward-incompatible ways and is not recommended for production use. It is not subject to any * SLA or deprecation policy. * * <p>Sample code: * * <pre><code> * try (BaseBigtableTableAdminClient baseBigtableTableAdminClient = BaseBigtableTableAdminClient.create()) { * SnapshotName name = SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]"); * Snapshot response = baseBigtableTableAdminClient.getSnapshot(name); * } * </code></pre> * * @param name The unique name of the requested snapshot. Values are of the form * `projects/<project>/instances/<instance>/clusters/<cluster>/snapshots/<snapshot>`. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final Snapshot getSnapshot(SnapshotName name) { GetSnapshotRequest request = GetSnapshotRequest.newBuilder().setName(name == null ? null : name.toString()).build(); return getSnapshot(request); }
@Test @SuppressWarnings("all") public void deleteSnapshotExceptionTest() throws Exception { StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); mockBigtableTableAdmin.addException(exception); try { SnapshotName name = SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]"); client.deleteSnapshot(name); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { // Expected exception } } }
public static List<SnapshotName> parseList(List<String> formattedStrings) { List<SnapshotName> list = new ArrayList<>(formattedStrings.size()); for (String formattedString : formattedStrings) { list.add(parse(formattedString)); } return list; }
/** * Permanently deletes the specified snapshot. * * <p>Note: This is a private alpha release of Cloud Bigtable snapshots. This feature is not * currently available to most Cloud Bigtable customers. This feature might be changed in * backward-incompatible ways and is not recommended for production use. It is not subject to any * SLA or deprecation policy. * * <p>Sample code: * * <pre><code> * try (BaseBigtableTableAdminClient baseBigtableTableAdminClient = BaseBigtableTableAdminClient.create()) { * SnapshotName name = SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]"); * baseBigtableTableAdminClient.deleteSnapshot(name); * } * </code></pre> * * @param name The unique name of the snapshot to be deleted. Values are of the form * `projects/<project>/instances/<instance>/clusters/<cluster>/snapshots/<snapshot>`. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final void deleteSnapshot(SnapshotName name) { DeleteSnapshotRequest request = DeleteSnapshotRequest.newBuilder().setName(name == null ? null : name.toString()).build(); deleteSnapshot(request); }
@Test @SuppressWarnings("all") public void getSnapshotExceptionTest() throws Exception { StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); mockBigtableTableAdmin.addException(exception); try { SnapshotName name = SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]"); client.getSnapshot(name); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { // Expected exception } }