use of com.google.privacy.dlp.v2.StoredInfoType in project java-dlp by googleapis.
the class DlpServiceClientTest method listStoredInfoTypesTest4.
@Test
public void listStoredInfoTypesTest4() throws Exception {
StoredInfoType responsesElement = StoredInfoType.newBuilder().build();
ListStoredInfoTypesResponse expectedResponse = ListStoredInfoTypesResponse.newBuilder().setNextPageToken("").addAllStoredInfoTypes(Arrays.asList(responsesElement)).build();
mockDlpService.addResponse(expectedResponse);
ProjectName parent = ProjectName.of("[PROJECT]");
ListStoredInfoTypesPagedResponse pagedListResponse = client.listStoredInfoTypes(parent);
List<StoredInfoType> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getStoredInfoTypesList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockDlpService.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListStoredInfoTypesRequest actualRequest = ((ListStoredInfoTypesRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.privacy.dlp.v2.StoredInfoType in project java-dlp by googleapis.
the class DlpServiceClientTest method createStoredInfoTypeTest.
@Test
public void createStoredInfoTypeTest() throws Exception {
StoredInfoType expectedResponse = StoredInfoType.newBuilder().setName(StoredInfoTypeName.ofOrganizationStoredInfoTypeName("[ORGANIZATION]", "[STORED_INFO_TYPE]").toString()).setCurrentVersion(StoredInfoTypeVersion.newBuilder().build()).addAllPendingVersions(new ArrayList<StoredInfoTypeVersion>()).build();
mockDlpService.addResponse(expectedResponse);
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
StoredInfoTypeConfig config = StoredInfoTypeConfig.newBuilder().build();
StoredInfoType actualResponse = client.createStoredInfoType(parent, config);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockDlpService.getRequests();
Assert.assertEquals(1, actualRequests.size());
CreateStoredInfoTypeRequest actualRequest = ((CreateStoredInfoTypeRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertEquals(config, actualRequest.getConfig());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.privacy.dlp.v2.StoredInfoType in project java-dlp by googleapis.
the class DlpServiceClientTest method createStoredInfoTypeTest3.
@Test
public void createStoredInfoTypeTest3() throws Exception {
StoredInfoType expectedResponse = StoredInfoType.newBuilder().setName(StoredInfoTypeName.ofOrganizationStoredInfoTypeName("[ORGANIZATION]", "[STORED_INFO_TYPE]").toString()).setCurrentVersion(StoredInfoTypeVersion.newBuilder().build()).addAllPendingVersions(new ArrayList<StoredInfoTypeVersion>()).build();
mockDlpService.addResponse(expectedResponse);
OrganizationName parent = OrganizationName.of("[ORGANIZATION]");
StoredInfoTypeConfig config = StoredInfoTypeConfig.newBuilder().build();
StoredInfoType actualResponse = client.createStoredInfoType(parent, config);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockDlpService.getRequests();
Assert.assertEquals(1, actualRequests.size());
CreateStoredInfoTypeRequest actualRequest = ((CreateStoredInfoTypeRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertEquals(config, actualRequest.getConfig());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.privacy.dlp.v2.StoredInfoType in project java-dlp by googleapis.
the class DlpServiceClientTest method listStoredInfoTypesTest.
@Test
public void listStoredInfoTypesTest() throws Exception {
StoredInfoType responsesElement = StoredInfoType.newBuilder().build();
ListStoredInfoTypesResponse expectedResponse = ListStoredInfoTypesResponse.newBuilder().setNextPageToken("").addAllStoredInfoTypes(Arrays.asList(responsesElement)).build();
mockDlpService.addResponse(expectedResponse);
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
ListStoredInfoTypesPagedResponse pagedListResponse = client.listStoredInfoTypes(parent);
List<StoredInfoType> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getStoredInfoTypesList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockDlpService.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListStoredInfoTypesRequest actualRequest = ((ListStoredInfoTypesRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.privacy.dlp.v2.StoredInfoType in project java-dlp by googleapis.
the class DlpServiceClient method deleteStoredInfoType.
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Deletes a stored infoType. See https://cloud.google.com/dlp/docs/creating-stored-infotypes to
* learn more.
*
* <p>Sample code:
*
* <pre>{@code
* try (DlpServiceClient dlpServiceClient = DlpServiceClient.create()) {
* StoredInfoTypeName name =
* StoredInfoTypeName.ofOrganizationStoredInfoTypeName(
* "[ORGANIZATION]", "[STORED_INFO_TYPE]");
* dlpServiceClient.deleteStoredInfoType(name);
* }
* }</pre>
*
* @param name Required. Resource name of the organization and storedInfoType to be deleted, for
* example `organizations/433245324/storedInfoTypes/432452342` or
* projects/project-id/storedInfoTypes/432452342.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final void deleteStoredInfoType(StoredInfoTypeName name) {
DeleteStoredInfoTypeRequest request = DeleteStoredInfoTypeRequest.newBuilder().setName(name == null ? null : name.toString()).build();
deleteStoredInfoType(request);
}
Aggregations