use of com.google.bigtable.admin.v2.ProjectName in project java-secretmanager by googleapis.
the class ListSecrets method listSecrets.
// List all secrets for a project
public void listSecrets(String projectId) throws IOException {
// the "close" method on the client to safely clean up any remaining background resources.
try (SecretManagerServiceClient client = SecretManagerServiceClient.create()) {
// Build the parent name.
ProjectName projectName = ProjectName.of(projectId);
// Get all secrets.
ListSecretsPagedResponse pagedResponse = client.listSecrets(projectName);
// List all secrets.
pagedResponse.iterateAll().forEach(secret -> {
System.out.printf("Secret %s\n", secret.getName());
});
}
}
use of com.google.bigtable.admin.v2.ProjectName in project google-cloud-java by GoogleCloudPlatform.
the class MetricServiceClientTest method listTimeSeriesTest.
@Test
@SuppressWarnings("all")
public void listTimeSeriesTest() {
String nextPageToken = "";
TimeSeries timeSeriesElement = TimeSeries.newBuilder().build();
List<TimeSeries> timeSeries = Arrays.asList(timeSeriesElement);
ListTimeSeriesResponse expectedResponse = ListTimeSeriesResponse.newBuilder().setNextPageToken(nextPageToken).addAllTimeSeries(timeSeries).build();
mockMetricService.addResponse(expectedResponse);
ProjectName name = ProjectName.create("[PROJECT]");
String filter = "filter-1274492040";
TimeInterval interval = TimeInterval.newBuilder().build();
ListTimeSeriesRequest.TimeSeriesView view = ListTimeSeriesRequest.TimeSeriesView.FULL;
ListTimeSeriesPagedResponse pagedListResponse = client.listTimeSeries(name, filter, interval, view);
List<TimeSeries> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getTimeSeriesList().get(0), resources.get(0));
List<GeneratedMessageV3> actualRequests = mockMetricService.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListTimeSeriesRequest actualRequest = (ListTimeSeriesRequest) actualRequests.get(0);
Assert.assertEquals(name, actualRequest.getNameAsProjectName());
Assert.assertEquals(filter, actualRequest.getFilter());
Assert.assertEquals(interval, actualRequest.getInterval());
Assert.assertEquals(view, actualRequest.getView());
}
use of com.google.bigtable.admin.v2.ProjectName in project google-cloud-java by GoogleCloudPlatform.
the class ErrorStatsServiceClientTest method deleteEventsExceptionTest.
@Test
@SuppressWarnings("all")
public void deleteEventsExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
mockErrorStatsService.addException(exception);
try {
ProjectName projectName = ProjectName.create("[PROJECT]");
client.deleteEvents(projectName);
Assert.fail("No exception raised");
} catch (ApiException e) {
Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode());
}
}
use of com.google.bigtable.admin.v2.ProjectName in project google-cloud-java by GoogleCloudPlatform.
the class ErrorStatsServiceClientTest method deleteEventsTest.
@Test
@SuppressWarnings("all")
public void deleteEventsTest() {
DeleteEventsResponse expectedResponse = DeleteEventsResponse.newBuilder().build();
mockErrorStatsService.addResponse(expectedResponse);
ProjectName projectName = ProjectName.create("[PROJECT]");
DeleteEventsResponse actualResponse = client.deleteEvents(projectName);
Assert.assertEquals(expectedResponse, actualResponse);
List<GeneratedMessageV3> actualRequests = mockErrorStatsService.getRequests();
Assert.assertEquals(1, actualRequests.size());
DeleteEventsRequest actualRequest = (DeleteEventsRequest) actualRequests.get(0);
Assert.assertEquals(projectName, actualRequest.getProjectNameAsProjectName());
}
use of com.google.bigtable.admin.v2.ProjectName in project google-cloud-java by GoogleCloudPlatform.
the class ErrorStatsServiceClientTest method listEventsExceptionTest.
@Test
@SuppressWarnings("all")
public void listEventsExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
mockErrorStatsService.addException(exception);
try {
ProjectName projectName = ProjectName.create("[PROJECT]");
String groupId = "groupId506361563";
client.listEvents(projectName, groupId);
Assert.fail("No exception raised");
} catch (ApiException e) {
Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode());
}
}
Aggregations