use of com.google.cloud.securitycenter.v1.SecurityCenterClient.ListNotificationConfigsPagedResponse in project java-securitycenter by googleapis.
the class SecurityCenterClientTest method listNotificationConfigsTest2.
@Test
public void listNotificationConfigsTest2() throws Exception {
NotificationConfig responsesElement = NotificationConfig.newBuilder().build();
ListNotificationConfigsResponse expectedResponse = ListNotificationConfigsResponse.newBuilder().setNextPageToken("").addAllNotificationConfigs(Arrays.asList(responsesElement)).build();
mockSecurityCenter.addResponse(expectedResponse);
String parent = "parent-995424086";
ListNotificationConfigsPagedResponse pagedListResponse = client.listNotificationConfigs(parent);
List<NotificationConfig> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getNotificationConfigsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockSecurityCenter.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListNotificationConfigsRequest actualRequest = ((ListNotificationConfigsRequest) actualRequests.get(0));
Assert.assertEquals(parent, actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.securitycenter.v1.SecurityCenterClient.ListNotificationConfigsPagedResponse in project java-securitycenter by googleapis.
the class SecurityCenterClientTest method listNotificationConfigsTest.
@Test
public void listNotificationConfigsTest() throws Exception {
NotificationConfig responsesElement = NotificationConfig.newBuilder().build();
ListNotificationConfigsResponse expectedResponse = ListNotificationConfigsResponse.newBuilder().setNextPageToken("").addAllNotificationConfigs(Arrays.asList(responsesElement)).build();
mockSecurityCenter.addResponse(expectedResponse);
OrganizationName parent = OrganizationName.of("[ORGANIZATION]");
ListNotificationConfigsPagedResponse pagedListResponse = client.listNotificationConfigs(parent);
List<NotificationConfig> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getNotificationConfigsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockSecurityCenter.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListNotificationConfigsRequest actualRequest = ((ListNotificationConfigsRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.securitycenter.v1.SecurityCenterClient.ListNotificationConfigsPagedResponse in project java-securitycenter by googleapis.
the class SecurityCenterClientTest method listNotificationConfigsTest2.
@Test
public void listNotificationConfigsTest2() throws Exception {
NotificationConfig responsesElement = NotificationConfig.newBuilder().build();
ListNotificationConfigsResponse expectedResponse = ListNotificationConfigsResponse.newBuilder().setNextPageToken("").addAllNotificationConfigs(Arrays.asList(responsesElement)).build();
mockSecurityCenter.addResponse(expectedResponse);
String parent = "parent-995424086";
ListNotificationConfigsPagedResponse pagedListResponse = client.listNotificationConfigs(parent);
List<NotificationConfig> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getNotificationConfigsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockSecurityCenter.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListNotificationConfigsRequest actualRequest = ((ListNotificationConfigsRequest) actualRequests.get(0));
Assert.assertEquals(parent, actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.securitycenter.v1.SecurityCenterClient.ListNotificationConfigsPagedResponse in project java-securitycenter by googleapis.
the class SecurityCenterClientTest method listNotificationConfigsTest.
@Test
public void listNotificationConfigsTest() throws Exception {
NotificationConfig responsesElement = NotificationConfig.newBuilder().build();
ListNotificationConfigsResponse expectedResponse = ListNotificationConfigsResponse.newBuilder().setNextPageToken("").addAllNotificationConfigs(Arrays.asList(responsesElement)).build();
mockSecurityCenter.addResponse(expectedResponse);
OrganizationName parent = OrganizationName.of("[ORGANIZATION]");
ListNotificationConfigsPagedResponse pagedListResponse = client.listNotificationConfigs(parent);
List<NotificationConfig> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getNotificationConfigsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockSecurityCenter.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListNotificationConfigsRequest actualRequest = ((ListNotificationConfigsRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.securitycenter.v1.SecurityCenterClient.ListNotificationConfigsPagedResponse in project java-securitycenter by googleapis.
the class ListNotificationConfigSnippets method listNotificationConfigs.
// [START securitycenter_list_notification_configs]
public static ImmutableList<NotificationConfig> listNotificationConfigs(String organizationId) throws IOException {
// String organizationId = "{your-org-id}";
OrganizationName orgName = OrganizationName.newBuilder().setOrganization(organizationId).build();
try (SecurityCenterClient client = SecurityCenterClient.create()) {
ListNotificationConfigsPagedResponse response = client.listNotificationConfigs(orgName);
ImmutableList<NotificationConfig> notificationConfigs = ImmutableList.copyOf(response.iterateAll());
System.out.println(String.format("List notifications response: %s", response.getPage().getValues()));
return notificationConfigs;
}
}
Aggregations