@Generated(value="by GAPIC") @BetaApi public class DlpServiceClient extends Object implements AutoCloseable
This class provides the ability to make remote calls to the backing service through method calls that map to API methods. Sample code to get started:
try (DlpServiceClient dlpServiceClient = DlpServiceClient.create()) {
InspectConfig inspectConfig = InspectConfig.newBuilder().build();
List<ContentItem> items = new ArrayList<>();
InspectContentResponse response = dlpServiceClient.inspectContent(inspectConfig, items);
}
Note: close() needs to be called on the dlpServiceClient object to clean up resources such as threads. In the example above, try-with-resources is used, which automatically calls close().
The surface of this class includes several types of Java methods for each of the API's methods:
See the individual methods for example code.
Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parse method to extract the individual identifiers contained within names that are returned.
This class can be customized by passing in a custom instance of DlpServiceSettings to create(). For example:
DlpServiceSettings dlpServiceSettings =
DlpServiceSettings.defaultBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
DlpServiceClient dlpServiceClient =
DlpServiceClient.create(dlpServiceSettings);
| Modifier | Constructor and Description |
|---|---|
protected |
DlpServiceClient(DlpServiceSettings settings)
Constructs an instance of DlpServiceClient, using the given settings.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Initiates an orderly shutdown in which preexisting calls continue but new calls are immediately
cancelled.
|
static DlpServiceClient |
create()
Constructs an instance of DlpServiceClient with default settings.
|
static DlpServiceClient |
create(DlpServiceSettings settings)
Constructs an instance of DlpServiceClient, using the given settings.
|
com.google.api.gax.grpc.OperationFuture<com.google.privacy.dlp.v2beta1.InspectOperationResult,com.google.privacy.dlp.v2beta1.InspectOperationMetadata> |
createInspectOperationAsync(com.google.privacy.dlp.v2beta1.CreateInspectOperationRequest request)
Schedules a job scanning content in a Google Cloud Platform data repository.
|
com.google.api.gax.grpc.OperationFuture<com.google.privacy.dlp.v2beta1.InspectOperationResult,com.google.privacy.dlp.v2beta1.InspectOperationMetadata> |
createInspectOperationAsync(com.google.privacy.dlp.v2beta1.InspectConfig inspectConfig,
com.google.privacy.dlp.v2beta1.StorageConfig storageConfig,
com.google.privacy.dlp.v2beta1.OutputStorageConfig outputConfig)
Schedules a job scanning content in a Google Cloud Platform data repository.
|
com.google.api.gax.grpc.UnaryCallable<com.google.privacy.dlp.v2beta1.CreateInspectOperationRequest,com.google.longrunning.Operation> |
createInspectOperationCallable()
Schedules a job scanning content in a Google Cloud Platform data repository.
|
com.google.api.gax.grpc.OperationCallable<com.google.privacy.dlp.v2beta1.CreateInspectOperationRequest,com.google.privacy.dlp.v2beta1.InspectOperationResult,com.google.privacy.dlp.v2beta1.InspectOperationMetadata> |
createInspectOperationOperationCallable()
Schedules a job scanning content in a Google Cloud Platform data repository.
|
com.google.longrunning.OperationsClient |
getOperationsClient()
Returns the OperationsClient that can be used to query the status of a long-running operation
returned by another API method call.
|
DlpServiceSettings |
getSettings() |
com.google.privacy.dlp.v2beta1.InspectContentResponse |
inspectContent(com.google.privacy.dlp.v2beta1.InspectConfig inspectConfig,
List<com.google.privacy.dlp.v2beta1.ContentItem> items)
Finds potentially sensitive info in a list of strings.
|
com.google.privacy.dlp.v2beta1.InspectContentResponse |
inspectContent(com.google.privacy.dlp.v2beta1.InspectContentRequest request)
Finds potentially sensitive info in a list of strings.
|
com.google.api.gax.grpc.UnaryCallable<com.google.privacy.dlp.v2beta1.InspectContentRequest,com.google.privacy.dlp.v2beta1.InspectContentResponse> |
inspectContentCallable()
Finds potentially sensitive info in a list of strings.
|
com.google.privacy.dlp.v2beta1.ListInfoTypesResponse |
listInfoTypes(com.google.privacy.dlp.v2beta1.ListInfoTypesRequest request)
Returns sensitive information types for given category.
|
com.google.privacy.dlp.v2beta1.ListInfoTypesResponse |
listInfoTypes(String category,
String languageCode)
Returns sensitive information types for given category.
|
com.google.api.gax.grpc.UnaryCallable<com.google.privacy.dlp.v2beta1.ListInfoTypesRequest,com.google.privacy.dlp.v2beta1.ListInfoTypesResponse> |
listInfoTypesCallable()
Returns sensitive information types for given category.
|
com.google.privacy.dlp.v2beta1.ListInspectFindingsResponse |
listInspectFindings(com.google.privacy.dlp.v2beta1.ListInspectFindingsRequest request)
Returns list of results for given inspect operation result set id.
|
com.google.privacy.dlp.v2beta1.ListInspectFindingsResponse |
listInspectFindings(com.google.privacy.dlp.v2beta1.ResultName name)
Returns list of results for given inspect operation result set id.
|
com.google.api.gax.grpc.UnaryCallable<com.google.privacy.dlp.v2beta1.ListInspectFindingsRequest,com.google.privacy.dlp.v2beta1.ListInspectFindingsResponse> |
listInspectFindingsCallable()
Returns list of results for given inspect operation result set id.
|
com.google.privacy.dlp.v2beta1.ListRootCategoriesResponse |
listRootCategories(String languageCode)
Returns the list of root categories of sensitive information.
|
com.google.api.gax.grpc.UnaryCallable<com.google.privacy.dlp.v2beta1.ListRootCategoriesRequest,com.google.privacy.dlp.v2beta1.ListRootCategoriesResponse> |
listRootCategoriesCallable()
Returns the list of root categories of sensitive information.
|
com.google.privacy.dlp.v2beta1.RedactContentResponse |
redactContent(com.google.privacy.dlp.v2beta1.InspectConfig inspectConfig,
List<com.google.privacy.dlp.v2beta1.ContentItem> items,
List<com.google.privacy.dlp.v2beta1.RedactContentRequest.ReplaceConfig> replaceConfigs)
Redacts potentially sensitive info from a list of strings.
|
com.google.privacy.dlp.v2beta1.RedactContentResponse |
redactContent(com.google.privacy.dlp.v2beta1.RedactContentRequest request)
Redacts potentially sensitive info from a list of strings.
|
com.google.api.gax.grpc.UnaryCallable<com.google.privacy.dlp.v2beta1.RedactContentRequest,com.google.privacy.dlp.v2beta1.RedactContentResponse> |
redactContentCallable()
Redacts potentially sensitive info from a list of strings.
|
protected DlpServiceClient(DlpServiceSettings settings) throws IOException
IOExceptionpublic static final DlpServiceClient create() throws IOException
IOExceptionpublic static final DlpServiceClient create(DlpServiceSettings settings) throws IOException
IOExceptionpublic final DlpServiceSettings getSettings()
public final com.google.longrunning.OperationsClient getOperationsClient()
public final com.google.privacy.dlp.v2beta1.InspectContentResponse inspectContent(com.google.privacy.dlp.v2beta1.InspectConfig inspectConfig,
List<com.google.privacy.dlp.v2beta1.ContentItem> items)
Sample code:
try (DlpServiceClient dlpServiceClient = DlpServiceClient.create()) {
InspectConfig inspectConfig = InspectConfig.newBuilder().build();
List<ContentItem> items = new ArrayList<>();
InspectContentResponse response = dlpServiceClient.inspectContent(inspectConfig, items);
}
inspectConfig - Configuration for the inspector.items - The list of items to inspect. Items in a single request are considered "related"
unless inspect_config.independent_inputs is true. Up to 100 are allowed per request.com.google.api.gax.grpc.ApiException - if the remote call failspublic final com.google.privacy.dlp.v2beta1.InspectContentResponse inspectContent(com.google.privacy.dlp.v2beta1.InspectContentRequest request)
Sample code:
try (DlpServiceClient dlpServiceClient = DlpServiceClient.create()) {
InspectConfig inspectConfig = InspectConfig.newBuilder().build();
List<ContentItem> items = new ArrayList<>();
InspectContentRequest request = InspectContentRequest.newBuilder()
.setInspectConfig(inspectConfig)
.addAllItems(items)
.build();
InspectContentResponse response = dlpServiceClient.inspectContent(request);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.grpc.ApiException - if the remote call failspublic final com.google.api.gax.grpc.UnaryCallable<com.google.privacy.dlp.v2beta1.InspectContentRequest,com.google.privacy.dlp.v2beta1.InspectContentResponse> inspectContentCallable()
Sample code:
try (DlpServiceClient dlpServiceClient = DlpServiceClient.create()) {
InspectConfig inspectConfig = InspectConfig.newBuilder().build();
List<ContentItem> items = new ArrayList<>();
InspectContentRequest request = InspectContentRequest.newBuilder()
.setInspectConfig(inspectConfig)
.addAllItems(items)
.build();
ApiFuture<InspectContentResponse> future = dlpServiceClient.inspectContentCallable().futureCall(request);
// Do something
InspectContentResponse response = future.get();
}
public final com.google.privacy.dlp.v2beta1.RedactContentResponse redactContent(com.google.privacy.dlp.v2beta1.InspectConfig inspectConfig,
List<com.google.privacy.dlp.v2beta1.ContentItem> items,
List<com.google.privacy.dlp.v2beta1.RedactContentRequest.ReplaceConfig> replaceConfigs)
Sample code:
try (DlpServiceClient dlpServiceClient = DlpServiceClient.create()) {
InspectConfig inspectConfig = InspectConfig.newBuilder().build();
List<ContentItem> items = new ArrayList<>();
List<RedactContentRequest.ReplaceConfig> replaceConfigs = new ArrayList<>();
RedactContentResponse response = dlpServiceClient.redactContent(inspectConfig, items, replaceConfigs);
}
inspectConfig - Configuration for the inspector.items - The list of items to inspect. Up to 100 are allowed per request.replaceConfigs - The strings to replace findings text findings with. Must specify at least
one of these or one ImageRedactionConfig if redacting images.com.google.api.gax.grpc.ApiException - if the remote call failspublic final com.google.privacy.dlp.v2beta1.RedactContentResponse redactContent(com.google.privacy.dlp.v2beta1.RedactContentRequest request)
Sample code:
try (DlpServiceClient dlpServiceClient = DlpServiceClient.create()) {
InspectConfig inspectConfig = InspectConfig.newBuilder().build();
List<ContentItem> items = new ArrayList<>();
List<RedactContentRequest.ReplaceConfig> replaceConfigs = new ArrayList<>();
RedactContentRequest request = RedactContentRequest.newBuilder()
.setInspectConfig(inspectConfig)
.addAllItems(items)
.addAllReplaceConfigs(replaceConfigs)
.build();
RedactContentResponse response = dlpServiceClient.redactContent(request);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.grpc.ApiException - if the remote call failspublic final com.google.api.gax.grpc.UnaryCallable<com.google.privacy.dlp.v2beta1.RedactContentRequest,com.google.privacy.dlp.v2beta1.RedactContentResponse> redactContentCallable()
Sample code:
try (DlpServiceClient dlpServiceClient = DlpServiceClient.create()) {
InspectConfig inspectConfig = InspectConfig.newBuilder().build();
List<ContentItem> items = new ArrayList<>();
List<RedactContentRequest.ReplaceConfig> replaceConfigs = new ArrayList<>();
RedactContentRequest request = RedactContentRequest.newBuilder()
.setInspectConfig(inspectConfig)
.addAllItems(items)
.addAllReplaceConfigs(replaceConfigs)
.build();
ApiFuture<RedactContentResponse> future = dlpServiceClient.redactContentCallable().futureCall(request);
// Do something
RedactContentResponse response = future.get();
}
public final com.google.api.gax.grpc.OperationFuture<com.google.privacy.dlp.v2beta1.InspectOperationResult,com.google.privacy.dlp.v2beta1.InspectOperationMetadata> createInspectOperationAsync(com.google.privacy.dlp.v2beta1.InspectConfig inspectConfig,
com.google.privacy.dlp.v2beta1.StorageConfig storageConfig,
com.google.privacy.dlp.v2beta1.OutputStorageConfig outputConfig)
Sample code:
try (DlpServiceClient dlpServiceClient = DlpServiceClient.create()) {
InspectConfig inspectConfig = InspectConfig.newBuilder().build();
StorageConfig storageConfig = StorageConfig.newBuilder().build();
OutputStorageConfig outputConfig = OutputStorageConfig.newBuilder().build();
InspectOperationResult response = dlpServiceClient.createInspectOperationAsync(inspectConfig, storageConfig, outputConfig).get();
}
inspectConfig - Configuration for the inspector.storageConfig - Specification of the data set to process.outputConfig - Optional location to store findings. The bucket must already exist and the
Google APIs service account for DLP must have write permission to write to the given
bucket. <p>Results are split over multiple csv files with each file name matching the
pattern "[operation_id]_[count].csv", for example `3094877188788974909_1.csv`. The
`operation_id` matches the identifier for the Operation, and the `count` is a counter used
for tracking the number of files written. <p>The CSV file(s) contain the following
columns regardless of storage type scanned: <li>id <li>info_type
<li>likelihood <li>byte size of finding <li>quote
<li>time_stamp<br/> <p>For Cloud Storage the next columns are:
<li>file_path <li>start_offset<br/> <p>For Cloud Datastore the next
columns are: <li>project_id <li>namespace_id <li>path
<li>column_name <li>offsetcom.google.api.gax.grpc.ApiException - if the remote call failspublic final com.google.api.gax.grpc.OperationFuture<com.google.privacy.dlp.v2beta1.InspectOperationResult,com.google.privacy.dlp.v2beta1.InspectOperationMetadata> createInspectOperationAsync(com.google.privacy.dlp.v2beta1.CreateInspectOperationRequest request)
Sample code:
try (DlpServiceClient dlpServiceClient = DlpServiceClient.create()) {
InspectConfig inspectConfig = InspectConfig.newBuilder().build();
StorageConfig storageConfig = StorageConfig.newBuilder().build();
OutputStorageConfig outputConfig = OutputStorageConfig.newBuilder().build();
CreateInspectOperationRequest request = CreateInspectOperationRequest.newBuilder()
.setInspectConfig(inspectConfig)
.setStorageConfig(storageConfig)
.setOutputConfig(outputConfig)
.build();
InspectOperationResult response = dlpServiceClient.createInspectOperationAsync(request).get();
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.grpc.ApiException - if the remote call failspublic final com.google.api.gax.grpc.OperationCallable<com.google.privacy.dlp.v2beta1.CreateInspectOperationRequest,com.google.privacy.dlp.v2beta1.InspectOperationResult,com.google.privacy.dlp.v2beta1.InspectOperationMetadata> createInspectOperationOperationCallable()
Sample code:
try (DlpServiceClient dlpServiceClient = DlpServiceClient.create()) {
InspectConfig inspectConfig = InspectConfig.newBuilder().build();
StorageConfig storageConfig = StorageConfig.newBuilder().build();
OutputStorageConfig outputConfig = OutputStorageConfig.newBuilder().build();
CreateInspectOperationRequest request = CreateInspectOperationRequest.newBuilder()
.setInspectConfig(inspectConfig)
.setStorageConfig(storageConfig)
.setOutputConfig(outputConfig)
.build();
OperationFuture<Operation> future = dlpServiceClient.createInspectOperationOperationCallable().futureCall(request);
// Do something
InspectOperationResult response = future.get();
}
public final com.google.api.gax.grpc.UnaryCallable<com.google.privacy.dlp.v2beta1.CreateInspectOperationRequest,com.google.longrunning.Operation> createInspectOperationCallable()
Sample code:
try (DlpServiceClient dlpServiceClient = DlpServiceClient.create()) {
InspectConfig inspectConfig = InspectConfig.newBuilder().build();
StorageConfig storageConfig = StorageConfig.newBuilder().build();
OutputStorageConfig outputConfig = OutputStorageConfig.newBuilder().build();
CreateInspectOperationRequest request = CreateInspectOperationRequest.newBuilder()
.setInspectConfig(inspectConfig)
.setStorageConfig(storageConfig)
.setOutputConfig(outputConfig)
.build();
ApiFuture<Operation> future = dlpServiceClient.createInspectOperationCallable().futureCall(request);
// Do something
Operation response = future.get();
}
public final com.google.privacy.dlp.v2beta1.ListInspectFindingsResponse listInspectFindings(com.google.privacy.dlp.v2beta1.ResultName name)
Sample code:
try (DlpServiceClient dlpServiceClient = DlpServiceClient.create()) {
ResultName name = ResultName.create("[RESULT]");
ListInspectFindingsResponse response = dlpServiceClient.listInspectFindings(name);
}
name - Identifier of the results set returned as metadata of the longrunning operation
created by a call to CreateInspectOperation. Should be in the format of
`inspect/results/{id}.com.google.api.gax.grpc.ApiException - if the remote call failspublic final com.google.privacy.dlp.v2beta1.ListInspectFindingsResponse listInspectFindings(com.google.privacy.dlp.v2beta1.ListInspectFindingsRequest request)
Sample code:
try (DlpServiceClient dlpServiceClient = DlpServiceClient.create()) {
ResultName name = ResultName.create("[RESULT]");
ListInspectFindingsRequest request = ListInspectFindingsRequest.newBuilder()
.setNameWithResultName(name)
.build();
ListInspectFindingsResponse response = dlpServiceClient.listInspectFindings(request);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.grpc.ApiException - if the remote call failspublic final com.google.api.gax.grpc.UnaryCallable<com.google.privacy.dlp.v2beta1.ListInspectFindingsRequest,com.google.privacy.dlp.v2beta1.ListInspectFindingsResponse> listInspectFindingsCallable()
Sample code:
try (DlpServiceClient dlpServiceClient = DlpServiceClient.create()) {
ResultName name = ResultName.create("[RESULT]");
ListInspectFindingsRequest request = ListInspectFindingsRequest.newBuilder()
.setNameWithResultName(name)
.build();
ApiFuture<ListInspectFindingsResponse> future = dlpServiceClient.listInspectFindingsCallable().futureCall(request);
// Do something
ListInspectFindingsResponse response = future.get();
}
public final com.google.privacy.dlp.v2beta1.ListInfoTypesResponse listInfoTypes(String category, String languageCode)
Sample code:
try (DlpServiceClient dlpServiceClient = DlpServiceClient.create()) {
String category = "";
String languageCode = "";
ListInfoTypesResponse response = dlpServiceClient.listInfoTypes(category, languageCode);
}
category - Category name as returned by ListRootCategories.languageCode - Optional BCP-47 language code for localized info type friendly names. If
omitted, or if localized strings are not available, en-US strings will be returned.com.google.api.gax.grpc.ApiException - if the remote call failspublic final com.google.privacy.dlp.v2beta1.ListInfoTypesResponse listInfoTypes(com.google.privacy.dlp.v2beta1.ListInfoTypesRequest request)
Sample code:
try (DlpServiceClient dlpServiceClient = DlpServiceClient.create()) {
String category = "";
String languageCode = "";
ListInfoTypesRequest request = ListInfoTypesRequest.newBuilder()
.setCategory(category)
.setLanguageCode(languageCode)
.build();
ListInfoTypesResponse response = dlpServiceClient.listInfoTypes(request);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.grpc.ApiException - if the remote call failspublic final com.google.api.gax.grpc.UnaryCallable<com.google.privacy.dlp.v2beta1.ListInfoTypesRequest,com.google.privacy.dlp.v2beta1.ListInfoTypesResponse> listInfoTypesCallable()
Sample code:
try (DlpServiceClient dlpServiceClient = DlpServiceClient.create()) {
String category = "";
String languageCode = "";
ListInfoTypesRequest request = ListInfoTypesRequest.newBuilder()
.setCategory(category)
.setLanguageCode(languageCode)
.build();
ApiFuture<ListInfoTypesResponse> future = dlpServiceClient.listInfoTypesCallable().futureCall(request);
// Do something
ListInfoTypesResponse response = future.get();
}
public final com.google.privacy.dlp.v2beta1.ListRootCategoriesResponse listRootCategories(String languageCode)
Sample code:
try (DlpServiceClient dlpServiceClient = DlpServiceClient.create()) {
String languageCode = "";
ListRootCategoriesResponse response = dlpServiceClient.listRootCategories(languageCode);
}
languageCode - Optional language code for localized friendly category names. If omitted or
if localized strings are not available, en-US strings will be returned.com.google.api.gax.grpc.ApiException - if the remote call failspublic final com.google.api.gax.grpc.UnaryCallable<com.google.privacy.dlp.v2beta1.ListRootCategoriesRequest,com.google.privacy.dlp.v2beta1.ListRootCategoriesResponse> listRootCategoriesCallable()
Sample code:
try (DlpServiceClient dlpServiceClient = DlpServiceClient.create()) {
String languageCode = "";
ListRootCategoriesRequest request = ListRootCategoriesRequest.newBuilder()
.setLanguageCode(languageCode)
.build();
ApiFuture<ListRootCategoriesResponse> future = dlpServiceClient.listRootCategoriesCallable().futureCall(request);
// Do something
ListRootCategoriesResponse response = future.get();
}
public final void close()
throws Exception
close in interface AutoCloseableExceptionCopyright © 2017 Google. All rights reserved.