Search in sources :

Example 1 with ListBigQueryExportsPagedResponse

use of com.google.cloud.securitycenter.v1.SecurityCenterClient.ListBigQueryExportsPagedResponse in project java-securitycenter by googleapis.

the class SecurityCenterClientTest method listBigQueryExportsTest4.

@Test
public void listBigQueryExportsTest4() throws Exception {
    BigQueryExport responsesElement = BigQueryExport.newBuilder().build();
    ListBigQueryExportsResponse expectedResponse = ListBigQueryExportsResponse.newBuilder().setNextPageToken("").addAllBigQueryExports(Arrays.asList(responsesElement)).build();
    mockSecurityCenter.addResponse(expectedResponse);
    String parent = "parent-995424086";
    ListBigQueryExportsPagedResponse pagedListResponse = client.listBigQueryExports(parent);
    List<BigQueryExport> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getBigQueryExportsList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockSecurityCenter.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListBigQueryExportsRequest actualRequest = ((ListBigQueryExportsRequest) actualRequests.get(0));
    Assert.assertEquals(parent, actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListBigQueryExportsPagedResponse(com.google.cloud.securitycenter.v1.SecurityCenterClient.ListBigQueryExportsPagedResponse) ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Example 2 with ListBigQueryExportsPagedResponse

use of com.google.cloud.securitycenter.v1.SecurityCenterClient.ListBigQueryExportsPagedResponse in project java-securitycenter by googleapis.

the class SecurityCenterClientTest method listBigQueryExportsTest3.

@Test
public void listBigQueryExportsTest3() throws Exception {
    BigQueryExport responsesElement = BigQueryExport.newBuilder().build();
    ListBigQueryExportsResponse expectedResponse = ListBigQueryExportsResponse.newBuilder().setNextPageToken("").addAllBigQueryExports(Arrays.asList(responsesElement)).build();
    mockSecurityCenter.addResponse(expectedResponse);
    ProjectName parent = ProjectName.of("[PROJECT]");
    ListBigQueryExportsPagedResponse pagedListResponse = client.listBigQueryExports(parent);
    List<BigQueryExport> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getBigQueryExportsList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockSecurityCenter.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListBigQueryExportsRequest actualRequest = ((ListBigQueryExportsRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListBigQueryExportsPagedResponse(com.google.cloud.securitycenter.v1.SecurityCenterClient.ListBigQueryExportsPagedResponse) Test(org.junit.Test)

Example 3 with ListBigQueryExportsPagedResponse

use of com.google.cloud.securitycenter.v1.SecurityCenterClient.ListBigQueryExportsPagedResponse in project java-securitycenter by googleapis.

the class SecurityCenterClientTest method listBigQueryExportsTest2.

@Test
public void listBigQueryExportsTest2() throws Exception {
    BigQueryExport responsesElement = BigQueryExport.newBuilder().build();
    ListBigQueryExportsResponse expectedResponse = ListBigQueryExportsResponse.newBuilder().setNextPageToken("").addAllBigQueryExports(Arrays.asList(responsesElement)).build();
    mockSecurityCenter.addResponse(expectedResponse);
    OrganizationName parent = OrganizationName.of("[ORGANIZATION]");
    ListBigQueryExportsPagedResponse pagedListResponse = client.listBigQueryExports(parent);
    List<BigQueryExport> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getBigQueryExportsList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockSecurityCenter.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListBigQueryExportsRequest actualRequest = ((ListBigQueryExportsRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListBigQueryExportsPagedResponse(com.google.cloud.securitycenter.v1.SecurityCenterClient.ListBigQueryExportsPagedResponse) Test(org.junit.Test)

Example 4 with ListBigQueryExportsPagedResponse

use of com.google.cloud.securitycenter.v1.SecurityCenterClient.ListBigQueryExportsPagedResponse in project java-securitycenter by googleapis.

the class ListBigQueryExports method listBigQueryExports.

// List BigQuery exports in the given parent.
public static void listBigQueryExports(String parent) throws IOException {
    // the "close" method on the client to safely clean up any remaining background resources.
    try (SecurityCenterClient client = SecurityCenterClient.create()) {
        ListBigQueryExportsRequest request = ListBigQueryExportsRequest.newBuilder().setParent(parent).build();
        ListBigQueryExportsPagedResponse response = client.listBigQueryExports(request);
        System.out.println("Listing BigQuery exports:");
        for (BigQueryExport bigQueryExport : response.iterateAll()) {
            System.out.println(bigQueryExport.getName());
        }
    }
}
Also used : ListBigQueryExportsRequest(com.google.cloud.securitycenter.v1.ListBigQueryExportsRequest) BigQueryExport(com.google.cloud.securitycenter.v1.BigQueryExport) ListBigQueryExportsPagedResponse(com.google.cloud.securitycenter.v1.SecurityCenterClient.ListBigQueryExportsPagedResponse) SecurityCenterClient(com.google.cloud.securitycenter.v1.SecurityCenterClient)

Example 5 with ListBigQueryExportsPagedResponse

use of com.google.cloud.securitycenter.v1.SecurityCenterClient.ListBigQueryExportsPagedResponse in project java-securitycenter by googleapis.

the class SecurityCenterClientTest method listBigQueryExportsTest.

@Test
public void listBigQueryExportsTest() throws Exception {
    BigQueryExport responsesElement = BigQueryExport.newBuilder().build();
    ListBigQueryExportsResponse expectedResponse = ListBigQueryExportsResponse.newBuilder().setNextPageToken("").addAllBigQueryExports(Arrays.asList(responsesElement)).build();
    mockSecurityCenter.addResponse(expectedResponse);
    FolderName parent = FolderName.of("[FOLDER]");
    ListBigQueryExportsPagedResponse pagedListResponse = client.listBigQueryExports(parent);
    List<BigQueryExport> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getBigQueryExportsList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockSecurityCenter.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListBigQueryExportsRequest actualRequest = ((ListBigQueryExportsRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListBigQueryExportsPagedResponse(com.google.cloud.securitycenter.v1.SecurityCenterClient.ListBigQueryExportsPagedResponse) Test(org.junit.Test)

Aggregations

ListBigQueryExportsPagedResponse (com.google.cloud.securitycenter.v1.SecurityCenterClient.ListBigQueryExportsPagedResponse)5 AbstractMessage (com.google.protobuf.AbstractMessage)4 Test (org.junit.Test)4 BigQueryExport (com.google.cloud.securitycenter.v1.BigQueryExport)1 ListBigQueryExportsRequest (com.google.cloud.securitycenter.v1.ListBigQueryExportsRequest)1 SecurityCenterClient (com.google.cloud.securitycenter.v1.SecurityCenterClient)1 ByteString (com.google.protobuf.ByteString)1