Listing supported predefined infoType detectors

InfoTypes are types of sensitive data. In the Cloud Data Loss Prevention (DLP), there are both predefined and custom infoTypes. You can view all predefined infoTypes in the InfoTypes reference, or you can use the Cloud DLP API to list all predefined infoTypes programmatically.

The infoTypes.list method lists all built-in infoTypes that are currently supported in Cloud DLP. Each infoType includes the following information:

  • Internal name of the infoType.
  • Human readable infoType name.
  • Whether the infoType is supported by inspection or risk analysis operations.

Code examples


 * List the types of sensitive information the DLP API supports.
 * @param filter The filter to use, e.g. "supported_by=INSPECT"
 * @param languageCode The BCP-47 language code to use, e.g. 'en-US'
private static void listInfoTypes(String filter, String languageCode) throws Exception {

  // Instantiate a DLP client
  try (DlpServiceClient dlpClient = DlpServiceClient.create()) {
    ListInfoTypesRequest listInfoTypesRequest =
    ListInfoTypesResponse infoTypesResponse = dlpClient.listInfoTypes(listInfoTypesRequest);
    List<InfoTypeDescription> infoTypeDescriptions = infoTypesResponse.getInfoTypesList();
    for (InfoTypeDescription infoTypeDescription : infoTypeDescriptions) {
      System.out.println("Name : " + infoTypeDescription.getName());
      System.out.println("Display name : " + infoTypeDescription.getDisplayName());


// Imports the Google Cloud Data Loss Prevention library
const DLP = require('@google-cloud/dlp');

// Instantiates a client
const dlp = new DLP.DlpServiceClient();

// The BCP-47 language code to use, e.g. 'en-US'
// const languageCode = 'en-US';

// The filter to use
// const filter = 'supported_by=INSPECT'

const [response] = await dlp.listInfoTypes({
  languageCode: languageCode,
  filter: filter,
const infoTypes = response.infoTypes;
console.log(`Info types:`);
infoTypes.forEach(infoType => {
  console.log(`\t${} (${infoType.displayName})`);


def list_info_types(language_code=None, result_filter=None):
    """List types of sensitive information within a category.
        language_code: The BCP-47 language code to use, e.g. 'en-US'.
        filter: An optional filter to only return info types supported by
                certain parts of the API. Defaults to "supported_by=INSPECT".
        None; the response from the API is printed to the terminal.
    # Import the client library

    # Instantiate a client.
    dlp =

    # Make the API call.
    response = dlp.list_info_types(language_code, result_filter)

    # Print the results to the console.
    print('Info types:')
    for info_type in response.info_types:
        print('{name}: {display_name}'.format(
  , display_name=info_type.display_name))


// infoTypes returns the info types in the given language and matching the given filter.
func infoTypes(w io.Writer, client *dlp.Client, languageCode, filter string) {
	req := &dlppb.ListInfoTypesRequest{
		LanguageCode: languageCode,
		Filter:       filter,
	resp, err := client.ListInfoTypes(context.Background(), req)
	if err != nil {
	for _, it := range resp.GetInfoTypes() {
		fmt.Fprintln(w, it.GetName())


 * Lists all Info Types for the Data Loss Prevention (DLP) API.
use Google\Cloud\Dlp\V2\DlpServiceClient;

/** Uncomment and populate these variables in your code */
// $filter = ''; // (Optional) filter to use, empty for ''.
// $languageCode = ''; // (Optional) language code, empty for 'en-US'.

// Instantiate a client.
$dlp = new DlpServiceClient();

// Run request
$response = $dlp->listInfoTypes([
    'languageCode' => $languageCode,
    'filter' => $filter

// Print the results
print('Info Types:' . PHP_EOL);
foreach ($response->getInfoTypes() as $infoType) {
        '  %s (%s)' . PHP_EOL,


public static object ListInfoTypes(
    string languageCode,
    string filter)
    DlpServiceClient dlp = DlpServiceClient.Create();
    var response = dlp.ListInfoTypes(
        new ListInfoTypesRequest
            LanguageCode = languageCode,
            Filter = filter

    Console.WriteLine("Info Types:");
    foreach (var InfoType in response.InfoTypes)
        Console.WriteLine($"\t{InfoType.Name} ({InfoType.DisplayName})");

    return 0;

หน้านี้มีประโยชน์ไหม โปรดแสดงความคิดเห็น