use of com.google.bigtable.repackaged.com.google.monitoring.v3.ProjectName in project java-containeranalysis by googleapis.
the class GrafeasV1Beta1ClientTest method listNotesTest.
@Test
@SuppressWarnings("all")
public void listNotesTest() {
String nextPageToken = "";
Note notesElement = Note.newBuilder().build();
List<Note> notes = Arrays.asList(notesElement);
ListNotesResponse expectedResponse = ListNotesResponse.newBuilder().setNextPageToken(nextPageToken).addAllNotes(notes).build();
mockGrafeasV1Beta1.addResponse(expectedResponse);
ProjectName parent = ProjectName.of("[PROJECT]");
String filter = "filter-1274492040";
ListNotesPagedResponse pagedListResponse = client.listNotes(parent, filter);
List<Note> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getNotesList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockGrafeasV1Beta1.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListNotesRequest actualRequest = (ListNotesRequest) actualRequests.get(0);
Assert.assertEquals(parent, ProjectName.parse(actualRequest.getParent()));
Assert.assertEquals(filter, actualRequest.getFilter());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.bigtable.repackaged.com.google.monitoring.v3.ProjectName in project native-image-support-java by GoogleCloudPlatform.
the class PubSubSampleApplication method listTopics.
private static void listTopics(String projectId) throws IOException {
try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) {
ProjectName projectName = ProjectName.of(projectId);
int count = 0;
for (Topic topic : topicAdminClient.listTopics(projectName).iterateAll()) {
count += 1;
}
System.out.println("Topic count under project: " + count);
}
}
use of com.google.bigtable.repackaged.com.google.monitoring.v3.ProjectName in project native-image-support-java by GoogleCloudPlatform.
the class PubSubSampleApplication method listSubscriptionInProject.
private static void listSubscriptionInProject(String projectId) throws IOException {
try (SubscriptionAdminClient subscriptionAdminClient = SubscriptionAdminClient.create()) {
ProjectName projectName = ProjectName.of(projectId);
int count = 0;
for (Subscription subscription : subscriptionAdminClient.listSubscriptions(projectName).iterateAll()) {
count += 1;
}
System.out.println("Subscriptions in project count: " + count);
}
}
use of com.google.bigtable.repackaged.com.google.monitoring.v3.ProjectName in project native-image-support-java by GoogleCloudPlatform.
the class SecretManagerSampleApplication method createSecret.
static void createSecret(SecretManagerServiceClient client, String projectId, String secretId) {
ProjectName projectName = ProjectName.of(projectId);
Secret secret = Secret.newBuilder().setReplication(Replication.newBuilder().setAutomatic(Replication.Automatic.newBuilder().build()).build()).build();
Secret createdSecret = client.createSecret(projectName, secretId, secret);
System.out.println("Created secret: " + createdSecret.getName());
}
use of com.google.bigtable.repackaged.com.google.monitoring.v3.ProjectName in project native-image-support-java by GoogleCloudPlatform.
the class SecretManagerSampleApplication method hasSecret.
static boolean hasSecret(SecretManagerServiceClient client, String projectId, String secretId) {
ProjectName projectName = ProjectName.of(projectId);
ListSecretsPagedResponse pagedResponse = client.listSecrets(projectName);
for (Secret secret : pagedResponse.iterateAll()) {
String otherSecretId = extractSecretId(secret);
if (secretId.equals(otherSecretId)) {
return true;
}
}
return false;
}
Aggregations