サポートされている事前定義の infoType 検出器のリスト

infoType は機密データのタイプです。Cloud Data Loss Prevention(DLP)には、事前定義とカスタムの両方の infoType があります。事前定義の infoType は infoType のリファレンスで確認できます。また、Cloud DLP API を使用して、事前定義の infoType のリストをプログラムで取得することもできます。

infoTypes.list メソッドは、現在 Cloud DLP でサポートされている組み込み infoType のリストを出力します。各 infoType には、次の情報が含まれます。

  • infoType の内部名。
  • 人間が読んで理解できる infoType の名前。
  • infoType が検査またはリスク分析のオペレーションでサポートされているかどうか。

コードの例

Java

/*
 * 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 =
        ListInfoTypesRequest.newBuilder().setFilter(filter).setLanguageCode(languageCode).build();
    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());
    }
  }
}

Node.js

// 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.name} (${infoType.displayName})`);
});

Python

def list_info_types(language_code=None, result_filter=None):
    """List types of sensitive information within a category.
    Args:
        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".
    Returns:
        None; the response from the API is printed to the terminal.
    """
    # Import the client library
    import google.cloud.dlp

    # Instantiate a client.
    dlp = google.cloud.dlp.DlpServiceClient()

    # 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(
            name=info_type.name, display_name=info_type.display_name))

Go

// 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 {
		log.Fatal(err)
	}
	for _, it := range resp.GetInfoTypes() {
		fmt.Fprintln(w, it.GetName())
	}
}

PHP

use Google\Cloud\Dlp\V2\DlpServiceClient;

/**
 * Lists all Info Types for the Data Loss Prevention (DLP) API.
 *
 * @param string $category Optional filter to use, empty for ''.
 * @param string $languageCode Optional language code, empty for 'en-US'.
 */
function list_info_types($filter = '', $languageCode = '')
{
    // 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) {
        printf(
            '  %s (%s)' . PHP_EOL,
            $infoType->getDisplayName(),
            $infoType->getName()
        );
    }
}

C#

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;
}

このページは役立ちましたか?評価をお願いいたします。

フィードバックを送信...

Cloud Data Loss Prevention