Search in sources :

Example 1 with ListNotificationConfigsPagedResponse

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()));
}
Also used : ListNotificationConfigsPagedResponse(com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient.ListNotificationConfigsPagedResponse) AbstractMessage(com.google.protobuf.AbstractMessage) ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Example 2 with ListNotificationConfigsPagedResponse

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()));
}
Also used : ListNotificationConfigsPagedResponse(com.google.cloud.securitycenter.v1.SecurityCenterClient.ListNotificationConfigsPagedResponse) AbstractMessage(com.google.protobuf.AbstractMessage) Test(org.junit.Test)

Example 3 with ListNotificationConfigsPagedResponse

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()));
}
Also used : ListNotificationConfigsPagedResponse(com.google.cloud.securitycenter.v1.SecurityCenterClient.ListNotificationConfigsPagedResponse) AbstractMessage(com.google.protobuf.AbstractMessage) ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Example 4 with ListNotificationConfigsPagedResponse

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()));
}
Also used : ListNotificationConfigsPagedResponse(com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient.ListNotificationConfigsPagedResponse) AbstractMessage(com.google.protobuf.AbstractMessage) Test(org.junit.Test)

Example 5 with ListNotificationConfigsPagedResponse

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;
    }
}
Also used : OrganizationName(com.google.cloud.securitycenter.v1.OrganizationName) ListNotificationConfigsPagedResponse(com.google.cloud.securitycenter.v1.SecurityCenterClient.ListNotificationConfigsPagedResponse) NotificationConfig(com.google.cloud.securitycenter.v1.NotificationConfig) SecurityCenterClient(com.google.cloud.securitycenter.v1.SecurityCenterClient)

Aggregations

AbstractMessage (com.google.protobuf.AbstractMessage)4 Test (org.junit.Test)4 ListNotificationConfigsPagedResponse (com.google.cloud.securitycenter.v1.SecurityCenterClient.ListNotificationConfigsPagedResponse)3 ListNotificationConfigsPagedResponse (com.google.cloud.securitycenter.v1p1beta1.SecurityCenterClient.ListNotificationConfigsPagedResponse)2 ByteString (com.google.protobuf.ByteString)2 NotificationConfig (com.google.cloud.securitycenter.v1.NotificationConfig)1 OrganizationName (com.google.cloud.securitycenter.v1.OrganizationName)1 SecurityCenterClient (com.google.cloud.securitycenter.v1.SecurityCenterClient)1