use of com.google.cloud.securitycenter.v1.BigQueryExport 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());
}
}
}
use of com.google.cloud.securitycenter.v1.BigQueryExport 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()));
}
use of com.google.cloud.securitycenter.v1.BigQueryExport in project java-securitycenter by googleapis.
the class UpdateBigQueryExport method updateBigQueryExport.
// Updates an existing BigQuery export.
public static void updateBigQueryExport(String parent, String filter, String bigQueryExportId) throws IOException {
// the "close" method on the client to safely clean up any remaining background resources.
try (SecurityCenterClient client = SecurityCenterClient.create()) {
// Set the new values for export configuration.
BigQueryExport bigQueryExport = BigQueryExport.newBuilder().setName(String.format("%s/bigQueryExports/%s", parent, bigQueryExportId)).setFilter(filter).build();
UpdateBigQueryExportRequest request = UpdateBigQueryExportRequest.newBuilder().setBigQueryExport(bigQueryExport).setUpdateMask(FieldMask.newBuilder().addPaths("filter").build()).build();
BigQueryExport response = client.updateBigQueryExport(request);
if (!response.getFilter().equalsIgnoreCase(filter)) {
System.out.println("Failed to update BigQueryExport!");
return;
}
System.out.println("BigQueryExport updated successfully!");
}
}
Aggregations