Search in sources :

Example 1 with StoredInfoType

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()));
}
Also used : ListStoredInfoTypesPagedResponse(com.google.cloud.dlp.v2.DlpServiceClient.ListStoredInfoTypesPagedResponse) AbstractMessage(com.google.protobuf.AbstractMessage) ProjectName(com.google.privacy.dlp.v2.ProjectName) ListStoredInfoTypesRequest(com.google.privacy.dlp.v2.ListStoredInfoTypesRequest) ListStoredInfoTypesResponse(com.google.privacy.dlp.v2.ListStoredInfoTypesResponse) StoredInfoType(com.google.privacy.dlp.v2.StoredInfoType) Test(org.junit.Test)

Example 2 with StoredInfoType

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()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) CreateStoredInfoTypeRequest(com.google.privacy.dlp.v2.CreateStoredInfoTypeRequest) ArrayList(java.util.ArrayList) StoredInfoType(com.google.privacy.dlp.v2.StoredInfoType) StoredInfoTypeConfig(com.google.privacy.dlp.v2.StoredInfoTypeConfig) OrganizationLocationName(com.google.privacy.dlp.v2.OrganizationLocationName) LocationName(com.google.privacy.dlp.v2.LocationName) Test(org.junit.Test)

Example 3 with StoredInfoType

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()));
}
Also used : OrganizationName(com.google.privacy.dlp.v2.OrganizationName) AbstractMessage(com.google.protobuf.AbstractMessage) CreateStoredInfoTypeRequest(com.google.privacy.dlp.v2.CreateStoredInfoTypeRequest) ArrayList(java.util.ArrayList) StoredInfoType(com.google.privacy.dlp.v2.StoredInfoType) StoredInfoTypeConfig(com.google.privacy.dlp.v2.StoredInfoTypeConfig) Test(org.junit.Test)

Example 4 with StoredInfoType

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()));
}
Also used : ListStoredInfoTypesPagedResponse(com.google.cloud.dlp.v2.DlpServiceClient.ListStoredInfoTypesPagedResponse) AbstractMessage(com.google.protobuf.AbstractMessage) ListStoredInfoTypesRequest(com.google.privacy.dlp.v2.ListStoredInfoTypesRequest) ListStoredInfoTypesResponse(com.google.privacy.dlp.v2.ListStoredInfoTypesResponse) StoredInfoType(com.google.privacy.dlp.v2.StoredInfoType) OrganizationLocationName(com.google.privacy.dlp.v2.OrganizationLocationName) LocationName(com.google.privacy.dlp.v2.LocationName) Test(org.junit.Test)

Example 5 with StoredInfoType

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);
}
Also used : DeleteStoredInfoTypeRequest(com.google.privacy.dlp.v2.DeleteStoredInfoTypeRequest)

Aggregations

StoredInfoType (com.google.privacy.dlp.v2.StoredInfoType)14 AbstractMessage (com.google.protobuf.AbstractMessage)14 Test (org.junit.Test)14 ArrayList (java.util.ArrayList)9 StoredInfoTypeConfig (com.google.privacy.dlp.v2.StoredInfoTypeConfig)7 ListStoredInfoTypesPagedResponse (com.google.cloud.dlp.v2.DlpServiceClient.ListStoredInfoTypesPagedResponse)5 CreateStoredInfoTypeRequest (com.google.privacy.dlp.v2.CreateStoredInfoTypeRequest)5 ListStoredInfoTypesRequest (com.google.privacy.dlp.v2.ListStoredInfoTypesRequest)5 ListStoredInfoTypesResponse (com.google.privacy.dlp.v2.ListStoredInfoTypesResponse)5 OrganizationLocationName (com.google.privacy.dlp.v2.OrganizationLocationName)4 ByteString (com.google.protobuf.ByteString)4 DeleteStoredInfoTypeRequest (com.google.privacy.dlp.v2.DeleteStoredInfoTypeRequest)2 GetStoredInfoTypeRequest (com.google.privacy.dlp.v2.GetStoredInfoTypeRequest)2 LocationName (com.google.privacy.dlp.v2.LocationName)2 OrganizationName (com.google.privacy.dlp.v2.OrganizationName)2 ProjectName (com.google.privacy.dlp.v2.ProjectName)2 StoredInfoTypeName (com.google.privacy.dlp.v2.StoredInfoTypeName)2 UpdateStoredInfoTypeRequest (com.google.privacy.dlp.v2.UpdateStoredInfoTypeRequest)2 FieldMask (com.google.protobuf.FieldMask)2